topologicpy 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topologicpy/Cell.py +129 -127
- topologicpy/CellComplex.py +21 -23
- topologicpy/Cluster.py +7 -11
- topologicpy/DGL.py +10 -5
- topologicpy/Face.py +124 -38
- topologicpy/Honeybee.py +158 -334
- topologicpy/Plotly.py +51 -33
- topologicpy/Shell.py +30 -50
- topologicpy/Topology.py +231 -79
- topologicpy/UnitTest.py +2 -2
- topologicpy/Vector.py +242 -17
- topologicpy/Wire.py +38 -66
- topologicpy/__init__.py +1 -1
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/METADATA +3 -1
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/RECORD +18 -18
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/LICENSE +0 -0
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/WHEEL +0 -0
- {topologicpy-0.2.1.dist-info → topologicpy-0.2.3.dist-info}/top_level.txt +0 -0
topologicpy/Cell.py
CHANGED
|
@@ -6,7 +6,7 @@ import math
|
|
|
6
6
|
|
|
7
7
|
class Cell(Topology):
|
|
8
8
|
@staticmethod
|
|
9
|
-
def Area(cell, mantissa=4):
|
|
9
|
+
def Area(cell: topologic.Cell, mantissa: int = 4) -> float:
|
|
10
10
|
"""
|
|
11
11
|
Returns the surface area of the input cell.
|
|
12
12
|
|
|
@@ -31,8 +31,7 @@ class Cell(Topology):
|
|
|
31
31
|
return round(area, mantissa)
|
|
32
32
|
|
|
33
33
|
@staticmethod
|
|
34
|
-
def Box(origin=None, width=1, length=1, height=1, uSides=1, vSides=1, wSides=1,
|
|
35
|
-
dirY=0, dirZ=1, placement="center"):
|
|
34
|
+
def Box(origin: topologic.Vertex = None, width: float = 1, length: float = 1, height: float = 1, uSides: int = 1, vSides:int = 1, wSides:int = 1, direction: list = [0,0,1], placement: str ="center") -> topologic.Cell:
|
|
36
35
|
"""
|
|
37
36
|
Creates a box.
|
|
38
37
|
|
|
@@ -52,12 +51,8 @@ class Cell(Topology):
|
|
|
52
51
|
The number of sides along the length. The default is 1.
|
|
53
52
|
wSides : int , optional
|
|
54
53
|
The number of sides along the height. The default is 1.
|
|
55
|
-
|
|
56
|
-
The
|
|
57
|
-
dirY : float , optional
|
|
58
|
-
The Y component of the vector representing the up direction of the box. The default is 0.
|
|
59
|
-
dirZ : float , optional
|
|
60
|
-
The Z component of the vector representing the up direction of the box. The default is 1.
|
|
54
|
+
direction : list , optional
|
|
55
|
+
The vector representing the up direction of the box. The default is [0,0,1].
|
|
61
56
|
placement : str , optional
|
|
62
57
|
The description of the placement of the origin of the box. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
63
58
|
|
|
@@ -67,11 +62,10 @@ class Cell(Topology):
|
|
|
67
62
|
The created box.
|
|
68
63
|
|
|
69
64
|
"""
|
|
70
|
-
return Cell.Prism(origin=origin, width=width, length=length, height=height, uSides=uSides, vSides=vSides, wSides=wSides,
|
|
71
|
-
dirY=dirY, dirZ=dirZ, placement=placement)
|
|
65
|
+
return Cell.Prism(origin=origin, width=width, length=length, height=height, uSides=uSides, vSides=vSides, wSides=wSides, direction=direction, placement=placement)
|
|
72
66
|
|
|
73
67
|
@staticmethod
|
|
74
|
-
def ByFaces(faces, tolerance=0.0001):
|
|
68
|
+
def ByFaces(faces: list, planarize: bool = False, tolerance: float = 0.0001) -> topologic.Cell:
|
|
75
69
|
"""
|
|
76
70
|
Creates a cell from the input list of faces.
|
|
77
71
|
|
|
@@ -79,6 +73,8 @@ class Cell(Topology):
|
|
|
79
73
|
----------
|
|
80
74
|
faces : list
|
|
81
75
|
The input list of faces.
|
|
76
|
+
planarize : bool, optional
|
|
77
|
+
If set to True, the input faces are planarized before building the cell. Otherwise, they are not. The default is False.
|
|
82
78
|
tolerance : float , optional
|
|
83
79
|
The desired tolerance. The default is 0.0001.
|
|
84
80
|
|
|
@@ -88,18 +84,40 @@ class Cell(Topology):
|
|
|
88
84
|
The created cell.
|
|
89
85
|
|
|
90
86
|
"""
|
|
87
|
+
from topologicpy.Wire import Wire
|
|
88
|
+
from topologicpy.Face import Face
|
|
89
|
+
from topologicpy.Topology import Topology
|
|
91
90
|
from topologicpy.Cluster import Cluster
|
|
92
91
|
if not isinstance(faces, list):
|
|
93
92
|
return None
|
|
94
93
|
faceList = [x for x in faces if isinstance(x, topologic.Face)]
|
|
95
|
-
|
|
96
|
-
if cell:
|
|
97
|
-
return cell
|
|
98
|
-
else:
|
|
94
|
+
if len(faceList) < 1:
|
|
99
95
|
return None
|
|
96
|
+
planarizedList = []
|
|
97
|
+
enlargedList = []
|
|
98
|
+
if planarize:
|
|
99
|
+
planarizedList = [Face.Planarize(f) for f in faceList]
|
|
100
|
+
enlargedList = [Face.ByOffset(f, offset=-tolerance*10) for f in planarizedList]
|
|
101
|
+
cell = topologic.Cell.ByFaces(enlargedList, tolerance)
|
|
102
|
+
faces = Topology.SubTopologies(cell, subTopologyType="face")
|
|
103
|
+
finalFaces = []
|
|
104
|
+
for f in faces:
|
|
105
|
+
centroid = Topology.Centroid(f)
|
|
106
|
+
n = Face.Normal(f)
|
|
107
|
+
v = Topology.Translate(centroid, n[0]*0.01,n[1]*0.01,n[2]*0.01)
|
|
108
|
+
if not Cell.IsInside(cell, v):
|
|
109
|
+
finalFaces.append(f)
|
|
110
|
+
finalFinalFaces = []
|
|
111
|
+
for f in finalFaces:
|
|
112
|
+
vertices = Face.Vertices(f)
|
|
113
|
+
w = Wire.Cycles(Face.ExternalBoundary(f), maxVertices=len(vertices))[0]
|
|
114
|
+
finalFinalFaces.append(Face.ByWire(w))
|
|
115
|
+
return topologic.Cell.ByFaces(finalFinalFaces)
|
|
116
|
+
else:
|
|
117
|
+
return topologic.Cell.ByFaces(faces, tolerance)
|
|
100
118
|
|
|
101
119
|
@staticmethod
|
|
102
|
-
def ByShell(shell):
|
|
120
|
+
def ByShell(shell: topologic.Shell, planarize: bool = False, tolerance: float = 0.0001) -> topologic.Cell:
|
|
103
121
|
"""
|
|
104
122
|
Creates a cell from the input shell.
|
|
105
123
|
|
|
@@ -107,6 +125,10 @@ class Cell(Topology):
|
|
|
107
125
|
----------
|
|
108
126
|
shell : topologic.Shell
|
|
109
127
|
The input shell. The shell must be closed for this method to succeed.
|
|
128
|
+
planarize : bool, optional
|
|
129
|
+
If set to True, the input faces of the input shell are planarized before building the cell. Otherwise, they are not. The default is False.
|
|
130
|
+
tolerance : float , optional
|
|
131
|
+
The desired tolerance. The default is 0.0001.
|
|
110
132
|
|
|
111
133
|
Returns
|
|
112
134
|
-------
|
|
@@ -114,15 +136,15 @@ class Cell(Topology):
|
|
|
114
136
|
The created cell.
|
|
115
137
|
|
|
116
138
|
"""
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return topologic.Cell.ByShell(shell)
|
|
120
|
-
except:
|
|
139
|
+
from topologicpy.Topology import Topology
|
|
140
|
+
if not isinstance(shell, topologic.Shell):
|
|
121
141
|
return None
|
|
142
|
+
faces = Topology.SubTopologies(shell, subTopologyType="face")
|
|
143
|
+
return Cell.ByFaces(faces, planarize=planarize, tolerance=tolerance)
|
|
122
144
|
|
|
123
145
|
@staticmethod
|
|
124
|
-
def ByThickenedFace(face, thickness=1.0, bothSides=True, reverse=False,
|
|
125
|
-
tolerance=0.0001):
|
|
146
|
+
def ByThickenedFace(face: topologic.Face, thickness: float = 1.0, bothSides: bool = True, reverse: bool = False,
|
|
147
|
+
tolerance: float = 0.0001) -> topologic.Cell:
|
|
126
148
|
"""
|
|
127
149
|
Creates a cell by thickening the input face.
|
|
128
150
|
|
|
@@ -145,34 +167,37 @@ class Cell(Topology):
|
|
|
145
167
|
The created cell.
|
|
146
168
|
|
|
147
169
|
"""
|
|
170
|
+
from topologicpy.Edge import Edge
|
|
171
|
+
from topologicpy.Face import Face
|
|
148
172
|
from topologicpy.Cluster import Cluster
|
|
173
|
+
from topologicpy.Topology import Topology
|
|
149
174
|
|
|
150
175
|
if not isinstance(face, topologic.Face):
|
|
151
176
|
return None
|
|
152
177
|
if reverse == True and bothSides == False:
|
|
153
178
|
thickness = -thickness
|
|
154
|
-
faceNormal =
|
|
179
|
+
faceNormal = Face.Normal(face)
|
|
155
180
|
if bothSides:
|
|
156
|
-
bottomFace =
|
|
157
|
-
topFace =
|
|
181
|
+
bottomFace = Topology.Translate(face, -faceNormal[0]*0.5*thickness, -faceNormal[1]*0.5*thickness, -faceNormal[2]*0.5*thickness)
|
|
182
|
+
topFace = Topology.Translate(face, faceNormal[0]*0.5*thickness, faceNormal[1]*0.5*thickness, faceNormal[2]*0.5*thickness)
|
|
158
183
|
else:
|
|
159
184
|
bottomFace = face
|
|
160
|
-
topFace =
|
|
185
|
+
topFace = Topology.Translate(face, faceNormal[0]*thickness, faceNormal[1]*thickness, faceNormal[2]*thickness)
|
|
161
186
|
|
|
162
187
|
cellFaces = [bottomFace, topFace]
|
|
163
188
|
bottomEdges = []
|
|
164
189
|
_ = bottomFace.Edges(None, bottomEdges)
|
|
165
190
|
for bottomEdge in bottomEdges:
|
|
166
|
-
topEdge =
|
|
167
|
-
sideEdge1 =
|
|
168
|
-
sideEdge2 =
|
|
191
|
+
topEdge = Topology.Translate(bottomEdge, faceNormal[0]*thickness, faceNormal[1]*thickness, faceNormal[2]*thickness)
|
|
192
|
+
sideEdge1 = Edge.ByVertices([bottomEdge.StartVertex(), topEdge.StartVertex()])
|
|
193
|
+
sideEdge2 = Edge.ByVertices([bottomEdge.EndVertex(), topEdge.EndVertex()])
|
|
169
194
|
cellWire = Cluster.SelfMerge(Cluster.ByTopologies([bottomEdge, sideEdge1, topEdge, sideEdge2]))
|
|
170
|
-
cellFaces.append(
|
|
171
|
-
return
|
|
195
|
+
cellFaces.append(Face.ByWire(cellWire))
|
|
196
|
+
return Cell.ByFaces(cellFaces, planarize=False, tolerance=tolerance)
|
|
172
197
|
|
|
173
198
|
@staticmethod
|
|
174
|
-
def ByThickenedShell(shell, direction=[0,0,1], thickness=1.0, bothSides=True, reverse=False,
|
|
175
|
-
tolerance=0.0001):
|
|
199
|
+
def ByThickenedShell(shell: topologic.Shell, direction: list = [0,0,1], thickness: float = 1.0, bothSides: bool = True, reverse: bool = False,
|
|
200
|
+
tolerance: float = 0.0001) -> topologic.Cell:
|
|
176
201
|
"""
|
|
177
202
|
Creates a cell by thickening the input shell. The shell must be open.
|
|
178
203
|
|
|
@@ -221,10 +246,10 @@ class Cell(Topology):
|
|
|
221
246
|
cellWire = Cluster.SelfMerge(Cluster.ByTopologies([bottomEdge, sideEdge1, topEdge, sideEdge2]))
|
|
222
247
|
cellFace = Face.ByWire(cellWire)
|
|
223
248
|
cellFaces.append(cellFace)
|
|
224
|
-
return Cell.ByFaces(cellFaces, tolerance=tolerance)
|
|
249
|
+
return Cell.ByFaces(cellFaces, palanarize=False, tolerance=tolerance)
|
|
225
250
|
|
|
226
251
|
@staticmethod
|
|
227
|
-
def ByWires(wires, close=False, triangulate=True, tolerance=0.0001):
|
|
252
|
+
def ByWires(wires: list, close: bool = False, triangulate: bool = True, tolerance: float = 0.0001) -> topologic.Cell:
|
|
228
253
|
"""
|
|
229
254
|
Creates a cell by lofting through the input list of wires.
|
|
230
255
|
|
|
@@ -330,7 +355,7 @@ class Cell(Topology):
|
|
|
330
355
|
return Cell.ByFaces(faces, tolerance)
|
|
331
356
|
|
|
332
357
|
@staticmethod
|
|
333
|
-
def ByWiresCluster(cluster, close=False, triangulate=True, tolerance=0.0001):
|
|
358
|
+
def ByWiresCluster(cluster: topologic.Cluster, close: bool = False, triangulate: bool = True, tolerance: float = 0.0001) -> topologic.Cell:
|
|
334
359
|
"""
|
|
335
360
|
Creates a cell by lofting through the input cluster of wires.
|
|
336
361
|
|
|
@@ -363,7 +388,7 @@ class Cell(Topology):
|
|
|
363
388
|
return Cell.ByWires(wires, close=close, tolerance=tolerance)
|
|
364
389
|
|
|
365
390
|
@staticmethod
|
|
366
|
-
def Compactness(cell, mantissa=4):
|
|
391
|
+
def Compactness(cell: topologic.Cell, mantissa: int = 4) -> float:
|
|
367
392
|
"""
|
|
368
393
|
Returns the compactness measure of the input cell. This is also known as 'sphericity' (https://en.wikipedia.org/wiki/Sphericity).
|
|
369
394
|
|
|
@@ -400,8 +425,8 @@ class Cell(Topology):
|
|
|
400
425
|
return round(compactness, mantissa)
|
|
401
426
|
|
|
402
427
|
@staticmethod
|
|
403
|
-
def Cone(origin=None, baseRadius=0.5, topRadius=0, height=1, uSides=16, vSides=1,
|
|
404
|
-
dirZ=1, placement="center", tolerance=0.0001):
|
|
428
|
+
def Cone(origin: topologic.Vertex = None, baseRadius: float = 0.5, topRadius: float = 0, height: float = 1, uSides: int = 16, vSides: int = 1, direction: list = [0,0,1],
|
|
429
|
+
dirZ: float = 1, placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
|
405
430
|
"""
|
|
406
431
|
Creates a cone.
|
|
407
432
|
|
|
@@ -417,12 +442,8 @@ class Cell(Topology):
|
|
|
417
442
|
The height of the cone. The default is 1.
|
|
418
443
|
sides : int , optional
|
|
419
444
|
The number of sides of the cone. The default is 16.
|
|
420
|
-
|
|
421
|
-
The
|
|
422
|
-
dirY : float , optional
|
|
423
|
-
The Y component of the vector representing the up direction of the cone. The default is 0.
|
|
424
|
-
dirZ : float , optional
|
|
425
|
-
The Z component of the vector representing the up direction of the cone. The default is 1.
|
|
445
|
+
direction : list , optional
|
|
446
|
+
The vector representing the up direction of the cone. The default is [0,0,1].
|
|
426
447
|
placement : str , optional
|
|
427
448
|
The description of the placement of the origin of the cone. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
428
449
|
tolerance : float , optional
|
|
@@ -523,9 +544,9 @@ class Cell(Topology):
|
|
|
523
544
|
x1 = origin.X()
|
|
524
545
|
y1 = origin.Y()
|
|
525
546
|
z1 = origin.Z()
|
|
526
|
-
x2 = origin.X() +
|
|
527
|
-
y2 = origin.Y() +
|
|
528
|
-
z2 = origin.Z() +
|
|
547
|
+
x2 = origin.X() + direction[0]
|
|
548
|
+
y2 = origin.Y() + direction[1]
|
|
549
|
+
z2 = origin.Z() + direction[2]
|
|
529
550
|
dx = x2 - x1
|
|
530
551
|
dy = y2 - y1
|
|
531
552
|
dz = z2 - z1
|
|
@@ -540,8 +561,8 @@ class Cell(Topology):
|
|
|
540
561
|
return cone
|
|
541
562
|
|
|
542
563
|
@staticmethod
|
|
543
|
-
def Cylinder(origin=None, radius=0.5, height=1, uSides=16, vSides=1,
|
|
544
|
-
placement="center", tolerance=0.0001):
|
|
564
|
+
def Cylinder(origin: topologic.Vertex = None, radius: float = 0.5, height: float = 1, uSides: int = 16, vSides:int = 1, direction: list = [0,0,1],
|
|
565
|
+
placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
|
545
566
|
"""
|
|
546
567
|
Creates a cylinder.
|
|
547
568
|
|
|
@@ -557,12 +578,8 @@ class Cell(Topology):
|
|
|
557
578
|
The number of circle segments of the cylinder. The default is 16.
|
|
558
579
|
vSides : int , optional
|
|
559
580
|
The number of vertical segments of the cylinder. The default is 1.
|
|
560
|
-
|
|
561
|
-
The
|
|
562
|
-
dirY : float , optional
|
|
563
|
-
The Y component of the vector representing the up direction of the cylinder. The default is 0.
|
|
564
|
-
dirZ : float , optional
|
|
565
|
-
The Z component of the vector representing the up direction of the cylinder. The default is 1.
|
|
581
|
+
direction : list , optional
|
|
582
|
+
The vector representing the up direction of the cylinder. The default is [0,0,1].
|
|
566
583
|
placement : str , optional
|
|
567
584
|
The description of the placement of the origin of the cylinder. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "bottom".
|
|
568
585
|
tolerance : float , optional
|
|
@@ -593,8 +610,7 @@ class Cell(Topology):
|
|
|
593
610
|
yOffset = radius
|
|
594
611
|
circle_origin = Vertex.ByCoordinates(origin.X() + xOffset, origin.Y() + yOffset, origin.Z() + zOffset)
|
|
595
612
|
|
|
596
|
-
baseWire = Wire.Circle(origin=circle_origin, radius=radius, sides=uSides, fromAngle=0, toAngle=360, close=True,
|
|
597
|
-
dirY=0, dirZ=1, placement="center", tolerance=tolerance)
|
|
613
|
+
baseWire = Wire.Circle(origin=circle_origin, radius=radius, sides=uSides, fromAngle=0, toAngle=360, close=True, direction=[0,0,1], placement="center", tolerance=tolerance)
|
|
598
614
|
baseFace = Face.ByWire(baseWire)
|
|
599
615
|
cylinder = Cell.ByThickenedFace(face=baseFace, thickness=height, bothSides=False, reverse=False,
|
|
600
616
|
tolerance=tolerance)
|
|
@@ -613,9 +629,9 @@ class Cell(Topology):
|
|
|
613
629
|
x1 = origin.X()
|
|
614
630
|
y1 = origin.Y()
|
|
615
631
|
z1 = origin.Z()
|
|
616
|
-
x2 = origin.X() +
|
|
617
|
-
y2 = origin.Y() +
|
|
618
|
-
z2 = origin.Z() +
|
|
632
|
+
x2 = origin.X() + direction[0]
|
|
633
|
+
y2 = origin.Y() + direction[1]
|
|
634
|
+
z2 = origin.Z() + direction[2]
|
|
619
635
|
dx = x2 - x1
|
|
620
636
|
dy = y2 - y1
|
|
621
637
|
dz = z2 - z1
|
|
@@ -630,7 +646,7 @@ class Cell(Topology):
|
|
|
630
646
|
return cylinder
|
|
631
647
|
|
|
632
648
|
@staticmethod
|
|
633
|
-
def Decompose(cell, tiltAngle=10, tolerance=0.0001):
|
|
649
|
+
def Decompose(cell: topologic.Cell, tiltAngle: float = 10, tolerance: float = 0.0001) -> dict:
|
|
634
650
|
"""
|
|
635
651
|
Decomposes the input cell into its logical components. This method assumes that the positive Z direction is UP.
|
|
636
652
|
|
|
@@ -738,7 +754,7 @@ class Cell(Topology):
|
|
|
738
754
|
return d
|
|
739
755
|
|
|
740
756
|
@staticmethod
|
|
741
|
-
def Edges(cell):
|
|
757
|
+
def Edges(cell: topologic.Cell) -> list:
|
|
742
758
|
"""
|
|
743
759
|
Returns the edges of the input cell.
|
|
744
760
|
|
|
@@ -760,7 +776,7 @@ class Cell(Topology):
|
|
|
760
776
|
return edges
|
|
761
777
|
|
|
762
778
|
@staticmethod
|
|
763
|
-
def ExternalBoundary(cell):
|
|
779
|
+
def ExternalBoundary(cell: topologic.Cell) -> topologic.Shell:
|
|
764
780
|
"""
|
|
765
781
|
Returns the external boundary of the input cell.
|
|
766
782
|
|
|
@@ -785,7 +801,7 @@ class Cell(Topology):
|
|
|
785
801
|
return None
|
|
786
802
|
|
|
787
803
|
@staticmethod
|
|
788
|
-
def Faces(cell):
|
|
804
|
+
def Faces(cell: topologic.Cell) -> list:
|
|
789
805
|
"""
|
|
790
806
|
Returns the faces of the input cell.
|
|
791
807
|
|
|
@@ -807,8 +823,8 @@ class Cell(Topology):
|
|
|
807
823
|
return faces
|
|
808
824
|
|
|
809
825
|
@staticmethod
|
|
810
|
-
def Hyperboloid(origin=None, baseRadius=0.5, topRadius=0.5, height=1, sides=16,
|
|
811
|
-
|
|
826
|
+
def Hyperboloid(origin: topologic.Cell = None, baseRadius: float = 0.5, topRadius: float = 0.5, height: float = 1, sides: int = 16, direction: list = [0,0,1],
|
|
827
|
+
twist: float = 360, placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
|
812
828
|
"""
|
|
813
829
|
Creates a hyperboloid.
|
|
814
830
|
|
|
@@ -824,12 +840,8 @@ class Cell(Topology):
|
|
|
824
840
|
The height of the cone. The default is 1.
|
|
825
841
|
sides : int , optional
|
|
826
842
|
The number of sides of the cone. The default is 16.
|
|
827
|
-
|
|
828
|
-
The
|
|
829
|
-
dirY : float , optional
|
|
830
|
-
The Y component of the vector representing the up direction of the hyperboloid. The default is 0.
|
|
831
|
-
dirZ : float , optional
|
|
832
|
-
The Z component of the vector representing the up direction of the hyperboloid. The default is 1.
|
|
843
|
+
direction : list , optional
|
|
844
|
+
The vector representing the up direction of the hyperboloid. The default is [0,0,1].
|
|
833
845
|
twist : float , optional
|
|
834
846
|
The angle to twist the base cylinder. The default is 360.
|
|
835
847
|
placement : str , optional
|
|
@@ -904,9 +916,9 @@ class Cell(Topology):
|
|
|
904
916
|
x1 = origin.X()
|
|
905
917
|
y1 = origin.Y()
|
|
906
918
|
z1 = origin.Z()
|
|
907
|
-
x2 = origin.X() +
|
|
908
|
-
y2 = origin.Y() +
|
|
909
|
-
z2 = origin.Z() +
|
|
919
|
+
x2 = origin.X() + direction[0]
|
|
920
|
+
y2 = origin.Y() + direction[1]
|
|
921
|
+
z2 = origin.Z() + direction[2]
|
|
910
922
|
dx = x2 - x1
|
|
911
923
|
dy = y2 - y1
|
|
912
924
|
dz = z2 - z1
|
|
@@ -921,7 +933,7 @@ class Cell(Topology):
|
|
|
921
933
|
return hyperboloid
|
|
922
934
|
|
|
923
935
|
@staticmethod
|
|
924
|
-
def InternalBoundaries(cell):
|
|
936
|
+
def InternalBoundaries(cell: topologic.Cell) -> list:
|
|
925
937
|
"""
|
|
926
938
|
Returns the internal boundaries of the input cell.
|
|
927
939
|
|
|
@@ -941,7 +953,7 @@ class Cell(Topology):
|
|
|
941
953
|
return shells
|
|
942
954
|
|
|
943
955
|
@staticmethod
|
|
944
|
-
def InternalVertex(cell, tolerance=0.0001):
|
|
956
|
+
def InternalVertex(cell: topologic.Cell, tolerance: float = 0.0001):
|
|
945
957
|
"""
|
|
946
958
|
Creates a vertex that is guaranteed to be inside the input cell.
|
|
947
959
|
|
|
@@ -968,7 +980,7 @@ class Cell(Topology):
|
|
|
968
980
|
return None
|
|
969
981
|
|
|
970
982
|
@staticmethod
|
|
971
|
-
def IsInside(cell, vertex, tolerance=0.0001):
|
|
983
|
+
def IsInside(cell: topologic.Cell, vertex: topologic.Vertex, tolerance: float = 0.0001) -> bool:
|
|
972
984
|
"""
|
|
973
985
|
Returns True if the input vertex is inside the input cell. Returns False otherwise.
|
|
974
986
|
|
|
@@ -997,7 +1009,7 @@ class Cell(Topology):
|
|
|
997
1009
|
return None
|
|
998
1010
|
|
|
999
1011
|
@staticmethod
|
|
1000
|
-
def Pipe(edge, profile=None, radius=0.5, sides=16, startOffset=0, endOffset=0, endcapA=None, endcapB=None):
|
|
1012
|
+
def Pipe(edge: topologic.Edge, profile: topologic.Wire = None, radius: float = 0.5, sides: int = 16, startOffset: float = 0, endOffset: float = 0, endcapA: topologic.Topology = None, endcapB: topologic.Topology = None) -> dict:
|
|
1001
1013
|
"""
|
|
1002
1014
|
Description
|
|
1003
1015
|
----------
|
|
@@ -1024,8 +1036,11 @@ class Cell(Topology):
|
|
|
1024
1036
|
|
|
1025
1037
|
Returns
|
|
1026
1038
|
-------
|
|
1027
|
-
|
|
1028
|
-
A
|
|
1039
|
+
dict
|
|
1040
|
+
A dictionary containing the pipe, the start endcap, and the end endcap if they have been specified. The dictionary has the following keys:
|
|
1041
|
+
'pipe'
|
|
1042
|
+
'endcapA'
|
|
1043
|
+
'endcapB'
|
|
1029
1044
|
|
|
1030
1045
|
"""
|
|
1031
1046
|
from topologicpy.Topology import Topology
|
|
@@ -1123,11 +1138,11 @@ class Cell(Topology):
|
|
|
1123
1138
|
endcapB = topologic.TopologyUtility.Rotate(endcapB, zzz, 0, 0, 1, phi + 180)
|
|
1124
1139
|
endcapB = topologic.TopologyUtility.Translate(endcapB, origin.X(), origin.Y(), origin.Z())
|
|
1125
1140
|
returnList.append(endcapB)
|
|
1126
|
-
return returnList
|
|
1141
|
+
return {'pipe': returnList[0], 'endcapA': returnList[1], 'endcapB': returnList[2]}
|
|
1127
1142
|
|
|
1128
1143
|
@staticmethod
|
|
1129
|
-
def Prism(origin=None, width=1, length=1, height=1, uSides=1, vSides=1, wSides=1,
|
|
1130
|
-
|
|
1144
|
+
def Prism(origin: topologic.Vertex = None, width: float = 1, length: float = 1, height: float = 1, uSides: int = 1, vSides: int = 1, wSides: int = 1,
|
|
1145
|
+
direction: list = [0,0,1], placement: str ="center") -> topologic.Cell:
|
|
1131
1146
|
"""
|
|
1132
1147
|
Description
|
|
1133
1148
|
----------
|
|
@@ -1149,12 +1164,8 @@ class Cell(Topology):
|
|
|
1149
1164
|
The number of sides along the length. The default is 1.
|
|
1150
1165
|
wSides : int , optional
|
|
1151
1166
|
The number of sides along the height. The default is 1.
|
|
1152
|
-
|
|
1153
|
-
The
|
|
1154
|
-
dirY : float , optional
|
|
1155
|
-
The Y component of the vector representing the up direction of the prism. The default is 0.
|
|
1156
|
-
dirZ : float , optional
|
|
1157
|
-
The Z component of the vector representing the up direction of the prism. The default is 1.
|
|
1167
|
+
direction : list , optional
|
|
1168
|
+
The vector representing the up direction of the prism. The default is [0,0,1].
|
|
1158
1169
|
placement : str , optional
|
|
1159
1170
|
The description of the placement of the origin of the prism. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
1160
1171
|
|
|
@@ -1215,9 +1226,9 @@ class Cell(Topology):
|
|
|
1215
1226
|
x1 = origin.X()
|
|
1216
1227
|
y1 = origin.Y()
|
|
1217
1228
|
z1 = origin.Z()
|
|
1218
|
-
x2 = origin.X() +
|
|
1219
|
-
y2 = origin.Y() +
|
|
1220
|
-
z2 = origin.Z() +
|
|
1229
|
+
x2 = origin.X() + direction[0]
|
|
1230
|
+
y2 = origin.Y() + direction[1]
|
|
1231
|
+
z2 = origin.Z() + direction[2]
|
|
1221
1232
|
dx = x2 - x1
|
|
1222
1233
|
dy = y2 - y1
|
|
1223
1234
|
dz = z2 - z1
|
|
@@ -1232,7 +1243,7 @@ class Cell(Topology):
|
|
|
1232
1243
|
return prism
|
|
1233
1244
|
|
|
1234
1245
|
@staticmethod
|
|
1235
|
-
def Sets(inputCells, superCells, tolerance=0.0001):
|
|
1246
|
+
def Sets(inputCells: list, superCells: list, tolerance: float = 0.0001) -> list:
|
|
1236
1247
|
"""
|
|
1237
1248
|
Classifies the input cells into sets based on their enclosure within the input list of super cells. The order of the sets follows the order of the input list of super cells.
|
|
1238
1249
|
|
|
@@ -1275,7 +1286,7 @@ class Cell(Topology):
|
|
|
1275
1286
|
return sets
|
|
1276
1287
|
|
|
1277
1288
|
@staticmethod
|
|
1278
|
-
def Shells(cell):
|
|
1289
|
+
def Shells(cell: topologic.Cell) -> list:
|
|
1279
1290
|
"""
|
|
1280
1291
|
Returns the shells of the input cell.
|
|
1281
1292
|
|
|
@@ -1297,8 +1308,8 @@ class Cell(Topology):
|
|
|
1297
1308
|
return shells
|
|
1298
1309
|
|
|
1299
1310
|
@staticmethod
|
|
1300
|
-
def Sphere(origin=None, radius=0.5, uSides=16, vSides=8,
|
|
1301
|
-
placement="center", tolerance=0.0001):
|
|
1311
|
+
def Sphere(origin: topologic.Vertex = None, radius: float = 0.5, uSides: int = 16, vSides: int = 8, direction: list = [0,0,1],
|
|
1312
|
+
placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
|
1302
1313
|
"""
|
|
1303
1314
|
Creates a sphere.
|
|
1304
1315
|
|
|
@@ -1312,12 +1323,8 @@ class Cell(Topology):
|
|
|
1312
1323
|
The number of sides along the longitude of the sphere. The default is 16.
|
|
1313
1324
|
vSides : int , optional
|
|
1314
1325
|
The number of sides along the latitude of the sphere. The default is 8.
|
|
1315
|
-
|
|
1316
|
-
The
|
|
1317
|
-
dirY : float , optional
|
|
1318
|
-
The Y component of the vector representing the up direction of the sphere. The default is 0.
|
|
1319
|
-
dirZ : float , optional
|
|
1320
|
-
The Z component of the vector representing the up direction of the sphere. The default is 1.
|
|
1326
|
+
direction : list , optional
|
|
1327
|
+
The vector representing the up direction of the sphere. The default is [0,0,1].
|
|
1321
1328
|
placement : str , optional
|
|
1322
1329
|
The description of the placement of the origin of the sphere. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
1323
1330
|
tolerance : float , optional
|
|
@@ -1336,7 +1343,7 @@ class Cell(Topology):
|
|
|
1336
1343
|
if not isinstance(origin, topologic.Vertex):
|
|
1337
1344
|
return None
|
|
1338
1345
|
c = Wire.Circle(origin, radius, vSides, 90, 270, False, 0, 1, 0, "center")
|
|
1339
|
-
s = Topology.Spin(c, origin=origin, triangulate=False,
|
|
1346
|
+
s = Topology.Spin(c, origin=origin, triangulate=False, direction=[0,0,1], degree=360, sides=uSides, tolerance=tolerance)
|
|
1340
1347
|
if s.Type() == topologic.CellComplex.Type():
|
|
1341
1348
|
s = s.ExternalBoundary()
|
|
1342
1349
|
if s.Type() == topologic.Shell.Type():
|
|
@@ -1348,9 +1355,9 @@ class Cell(Topology):
|
|
|
1348
1355
|
x1 = origin.X()
|
|
1349
1356
|
y1 = origin.Y()
|
|
1350
1357
|
z1 = origin.Z()
|
|
1351
|
-
x2 = origin.X() +
|
|
1352
|
-
y2 = origin.Y() +
|
|
1353
|
-
z2 = origin.Z() +
|
|
1358
|
+
x2 = origin.X() + direction[0]
|
|
1359
|
+
y2 = origin.Y() + direction[1]
|
|
1360
|
+
z2 = origin.Z() + direction[2]
|
|
1354
1361
|
dx = x2 - x1
|
|
1355
1362
|
dy = y2 - y1
|
|
1356
1363
|
dz = z2 - z1
|
|
@@ -1365,7 +1372,7 @@ class Cell(Topology):
|
|
|
1365
1372
|
return s
|
|
1366
1373
|
|
|
1367
1374
|
@staticmethod
|
|
1368
|
-
def SurfaceArea(cell, mantissa=4):
|
|
1375
|
+
def SurfaceArea(cell: topologic.Cell, mantissa: int = 4) -> float:
|
|
1369
1376
|
"""
|
|
1370
1377
|
Returns the surface area of the input cell.
|
|
1371
1378
|
|
|
@@ -1382,11 +1389,10 @@ class Cell(Topology):
|
|
|
1382
1389
|
The surface area of the input cell.
|
|
1383
1390
|
|
|
1384
1391
|
"""
|
|
1385
|
-
return Cell.Area(cell, mantissa)
|
|
1392
|
+
return Cell.Area(cell=cell, mantissa=mantissa)
|
|
1386
1393
|
|
|
1387
1394
|
@staticmethod
|
|
1388
|
-
def Torus(origin=None, majorRadius=0.5, minorRadius=0.125, uSides=16, vSides=8,
|
|
1389
|
-
dirZ=1, placement="center", tolerance=0.0001):
|
|
1395
|
+
def Torus(origin: topologic.Vertex = None, majorRadius: float = 0.5, minorRadius: float = 0.125, uSides: int = 16, vSides: int = 8, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
|
1390
1396
|
"""
|
|
1391
1397
|
Creates a torus.
|
|
1392
1398
|
|
|
@@ -1402,14 +1408,10 @@ class Cell(Topology):
|
|
|
1402
1408
|
The number of sides along the longitude of the torus. The default is 16.
|
|
1403
1409
|
vSides : int , optional
|
|
1404
1410
|
The number of sides along the latitude of the torus. The default is 8.
|
|
1405
|
-
|
|
1406
|
-
The
|
|
1407
|
-
dirY : float , optional
|
|
1408
|
-
The Y component of the vector representing the up direction of the sphere. The default is 0.
|
|
1409
|
-
dirZ : float , optional
|
|
1410
|
-
The Z component of the vector representing the up direction of the sphere. The default is 1.
|
|
1411
|
+
direction : list , optional
|
|
1412
|
+
The vector representing the up direction of the torus. The default is [0,0,1].
|
|
1411
1413
|
placement : str , optional
|
|
1412
|
-
The description of the placement of the origin of the
|
|
1414
|
+
The description of the placement of the origin of the torus. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
1413
1415
|
tolerance : float , optional
|
|
1414
1416
|
The desired tolerance. The default is 0.0001.
|
|
1415
1417
|
|
|
@@ -1428,7 +1430,7 @@ class Cell(Topology):
|
|
|
1428
1430
|
return None
|
|
1429
1431
|
c = Wire.Circle(origin, minorRadius, vSides, 0, 360, False, 0, 1, 0, "center")
|
|
1430
1432
|
c = topologic.TopologyUtility.Translate(c, abs(majorRadius-minorRadius), 0, 0)
|
|
1431
|
-
s = Topology.Spin(c, origin=origin, triangulate=False,
|
|
1433
|
+
s = Topology.Spin(c, origin=origin, triangulate=False, direction=[0,0,1], degree=360, sides=uSides, tolerance=tolerance)
|
|
1432
1434
|
if s.Type() == topologic.Shell.Type():
|
|
1433
1435
|
s = topologic.Cell.ByShell(s)
|
|
1434
1436
|
#s = Topology.RemoveCoplanarFaces(s, angTol=0.1, tolerance=tolerance)
|
|
@@ -1439,9 +1441,9 @@ class Cell(Topology):
|
|
|
1439
1441
|
x1 = origin.X()
|
|
1440
1442
|
y1 = origin.Y()
|
|
1441
1443
|
z1 = origin.Z()
|
|
1442
|
-
x2 = origin.X() +
|
|
1443
|
-
y2 = origin.Y() +
|
|
1444
|
-
z2 = origin.Z() +
|
|
1444
|
+
x2 = origin.X() + direction[0]
|
|
1445
|
+
y2 = origin.Y() + direction[1]
|
|
1446
|
+
z2 = origin.Z() + direction[2]
|
|
1445
1447
|
dx = x2 - x1
|
|
1446
1448
|
dy = y2 - y1
|
|
1447
1449
|
dz = z2 - z1
|
|
@@ -1456,7 +1458,7 @@ class Cell(Topology):
|
|
|
1456
1458
|
return s
|
|
1457
1459
|
|
|
1458
1460
|
@staticmethod
|
|
1459
|
-
def Vertices(cell):
|
|
1461
|
+
def Vertices(cell: topologic.Cell) -> list:
|
|
1460
1462
|
"""
|
|
1461
1463
|
Returns the vertices of the input cell.
|
|
1462
1464
|
|
|
@@ -1478,7 +1480,7 @@ class Cell(Topology):
|
|
|
1478
1480
|
return vertices
|
|
1479
1481
|
|
|
1480
1482
|
@staticmethod
|
|
1481
|
-
def Volume(cell, mantissa=4):
|
|
1483
|
+
def Volume(cell: topologic.Cell, mantissa: int = 4) -> float:
|
|
1482
1484
|
"""
|
|
1483
1485
|
Returns the volume of the input cell.
|
|
1484
1486
|
|
|
@@ -1500,7 +1502,7 @@ class Cell(Topology):
|
|
|
1500
1502
|
return round(topologic.CellUtility.Volume(cell), mantissa)
|
|
1501
1503
|
|
|
1502
1504
|
@staticmethod
|
|
1503
|
-
def Wires(cell):
|
|
1505
|
+
def Wires(cell: topologic.Cell) -> list:
|
|
1504
1506
|
"""
|
|
1505
1507
|
Returns the wires of the input cell.
|
|
1506
1508
|
|