topologicpy 0.4.8__py3-none-any.whl → 0.4.9__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/Aperture.py +46 -0
- topologicpy/Cell.py +1780 -0
- topologicpy/CellComplex.py +791 -0
- topologicpy/Cluster.py +591 -0
- topologicpy/Color.py +157 -0
- topologicpy/Context.py +56 -0
- topologicpy/DGL.py +2661 -0
- topologicpy/Dictionary.py +470 -0
- topologicpy/Edge.py +855 -0
- topologicpy/EnergyModel.py +1052 -0
- topologicpy/Face.py +1810 -0
- topologicpy/Graph.py +3526 -0
- topologicpy/Graph_Export.py +858 -0
- topologicpy/Grid.py +338 -0
- topologicpy/Helper.py +182 -0
- topologicpy/Honeybee.py +424 -0
- topologicpy/Matrix.py +255 -0
- topologicpy/Neo4jGraph.py +311 -0
- topologicpy/Plotly.py +1396 -0
- topologicpy/Polyskel.py +524 -0
- topologicpy/Process.py +1368 -0
- topologicpy/SQL.py +48 -0
- topologicpy/Shell.py +1418 -0
- topologicpy/Speckle.py +433 -0
- topologicpy/Topology.py +5854 -0
- topologicpy/UnitTest.py +29 -0
- topologicpy/Vector.py +555 -0
- topologicpy/Vertex.py +714 -0
- topologicpy/Wire.py +2346 -0
- topologicpy/__init__.py +20 -0
- topologicpy/bin/linux/topologic/__init__.py +2 -0
- topologicpy/bin/linux/topologic/topologic.cpython-310-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-311-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-38-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-39-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBO-6bdf205d.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBRep-2960a069.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBool-c44b74bd.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKFillet-9a670ba0.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG2d-8f31849e.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG3d-4c6bce57.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomAlgo-26066fd9.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomBase-2116cabe.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMath-72572fa8.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMesh-2a060427.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKOffset-6cab68ff.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKPrim-eb1262b3.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKShHealing-e67e5cc7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKTopAlgo-e4c96c33.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKernel-fb7fe3b7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libgcc_s-32c1665e.so.1 +0 -0
- topologicpy/bin/linux/topologic.libs/libstdc++-672d7b41.so.6.0.30 +0 -0
- topologicpy/bin/windows/topologic/TKBO-f6b191de.dll +0 -0
- topologicpy/bin/windows/topologic/TKBRep-e56a600e.dll +0 -0
- topologicpy/bin/windows/topologic/TKBool-7b8d47ae.dll +0 -0
- topologicpy/bin/windows/topologic/TKFillet-0ddbf0a8.dll +0 -0
- topologicpy/bin/windows/topologic/TKG2d-2e2dee3d.dll +0 -0
- topologicpy/bin/windows/topologic/TKG3d-6674513d.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomAlgo-d240e370.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomBase-df87aba5.dll +0 -0
- topologicpy/bin/windows/topologic/TKMath-45bd625a.dll +0 -0
- topologicpy/bin/windows/topologic/TKMesh-d6e826b1.dll +0 -0
- topologicpy/bin/windows/topologic/TKOffset-79b9cc94.dll +0 -0
- topologicpy/bin/windows/topologic/TKPrim-aa430a86.dll +0 -0
- topologicpy/bin/windows/topologic/TKShHealing-bb48be89.dll +0 -0
- topologicpy/bin/windows/topologic/TKTopAlgo-7d0d1e22.dll +0 -0
- topologicpy/bin/windows/topologic/TKernel-08c8cfbb.dll +0 -0
- topologicpy/bin/windows/topologic/__init__.py +2 -0
- topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd +0 -0
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/METADATA +1 -1
- topologicpy-0.4.9.dist-info/RECORD +77 -0
- topologicpy-0.4.9.dist-info/top_level.txt +1 -0
- topologicpy-0.4.8.dist-info/RECORD +0 -5
- topologicpy-0.4.8.dist-info/top_level.txt +0 -1
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/LICENSE +0 -0
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/WHEEL +0 -0
topologicpy/Cluster.py
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import topologicpy
|
|
2
|
+
import topologic
|
|
3
|
+
class Cluster(topologic.Cluster):
|
|
4
|
+
@staticmethod
|
|
5
|
+
def ByTopologies(topologies: list) -> topologic.Cluster:
|
|
6
|
+
"""
|
|
7
|
+
Creates a topologic Cluster from the input list of topologies.
|
|
8
|
+
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
topologies : list
|
|
12
|
+
The list of topologies.
|
|
13
|
+
|
|
14
|
+
Returns
|
|
15
|
+
-------
|
|
16
|
+
topologic.Cluster
|
|
17
|
+
The created topologic Cluster.
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
assert isinstance(topologies, list), "Cluster.ByTopologies - Error: Input is not a list"
|
|
21
|
+
topologyList = [x for x in topologies if isinstance(x, topologic.Topology)]
|
|
22
|
+
return topologic.Cluster.ByTopologies(topologyList, False)
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def CellComplexes(cluster: topologic.Cluster) -> list:
|
|
26
|
+
"""
|
|
27
|
+
Returns the cellComplexes of the input cluster.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
cluster : topologic.Cluster
|
|
32
|
+
The input cluster.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
list
|
|
37
|
+
The list of cellComplexes.
|
|
38
|
+
|
|
39
|
+
"""
|
|
40
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
41
|
+
return None
|
|
42
|
+
cellComplexes = []
|
|
43
|
+
_ = cluster.CellComplexes(None, cellComplexes)
|
|
44
|
+
return cellComplexes
|
|
45
|
+
|
|
46
|
+
@staticmethod
|
|
47
|
+
def Cells(cluster: topologic.Cluster) -> list:
|
|
48
|
+
"""
|
|
49
|
+
Returns the cells of the input cluster.
|
|
50
|
+
|
|
51
|
+
Parameters
|
|
52
|
+
----------
|
|
53
|
+
cluster : topologic.Cluster
|
|
54
|
+
The input cluster.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
list
|
|
59
|
+
The list of cells.
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
63
|
+
return None
|
|
64
|
+
cells = []
|
|
65
|
+
_ = cluster.Cells(None, cells)
|
|
66
|
+
return cells
|
|
67
|
+
|
|
68
|
+
@staticmethod
|
|
69
|
+
def Edges(cluster: topologic.Cluster) -> list:
|
|
70
|
+
"""
|
|
71
|
+
Returns the edges of the input cluster.
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
cluster : topologic.Cluster
|
|
76
|
+
The input cluster.
|
|
77
|
+
|
|
78
|
+
Returns
|
|
79
|
+
-------
|
|
80
|
+
list
|
|
81
|
+
The list of edges.
|
|
82
|
+
|
|
83
|
+
"""
|
|
84
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
85
|
+
return None
|
|
86
|
+
edges = []
|
|
87
|
+
_ = cluster.Edges(None, edges)
|
|
88
|
+
return edges
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def Faces(cluster: topologic.Cluster) -> list:
|
|
92
|
+
"""
|
|
93
|
+
Returns the faces of the input cluster.
|
|
94
|
+
|
|
95
|
+
Parameters
|
|
96
|
+
----------
|
|
97
|
+
cluster : topologic.Cluster
|
|
98
|
+
The input cluster.
|
|
99
|
+
|
|
100
|
+
Returns
|
|
101
|
+
-------
|
|
102
|
+
list
|
|
103
|
+
The list of faces.
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
107
|
+
return None
|
|
108
|
+
faces = []
|
|
109
|
+
_ = cluster.Faces(None, faces)
|
|
110
|
+
return faces
|
|
111
|
+
|
|
112
|
+
@staticmethod
|
|
113
|
+
def FreeCells(cluster: topologic.Cluster) -> list:
|
|
114
|
+
"""
|
|
115
|
+
Returns the free cells of the input cluster that are not part of a higher topology.
|
|
116
|
+
|
|
117
|
+
Parameters
|
|
118
|
+
----------
|
|
119
|
+
cluster : topologic.Cluster
|
|
120
|
+
The input cluster.
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
list
|
|
125
|
+
The list of free cells.
|
|
126
|
+
|
|
127
|
+
"""
|
|
128
|
+
from topologicpy.CellComplex import CellComplex
|
|
129
|
+
from topologicpy.Topology import Topology
|
|
130
|
+
|
|
131
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
132
|
+
return None
|
|
133
|
+
allCells = []
|
|
134
|
+
_ = cluster.Cells(None, allCells)
|
|
135
|
+
allCellsCluster = Cluster.ByTopologies(allCells)
|
|
136
|
+
freeCells = []
|
|
137
|
+
cellComplexes = []
|
|
138
|
+
_ = cluster.CellComplexes(None, cellComplexes)
|
|
139
|
+
cellComplexesCells = []
|
|
140
|
+
for cellComplex in cellComplexes:
|
|
141
|
+
tempCells = CellComplex.Cells(cellComplex)
|
|
142
|
+
cellComplexesCells += tempCells
|
|
143
|
+
if len(cellComplexesCells) == 0:
|
|
144
|
+
return allCells
|
|
145
|
+
cellComplexesCluster = Cluster.ByTopologies(cellComplexesCells)
|
|
146
|
+
resultingCluster = Topology.Boolean(allCellsCluster, cellComplexesCluster, operation="Difference")
|
|
147
|
+
if isinstance(resultingCluster, topologic.Cell):
|
|
148
|
+
return [resultingCluster]
|
|
149
|
+
result = Topology.SubTopologies(resultingCluster, subTopologyType="cell")
|
|
150
|
+
if not result:
|
|
151
|
+
return [] #Make sure you return an empty list instead of None
|
|
152
|
+
return result
|
|
153
|
+
|
|
154
|
+
@staticmethod
|
|
155
|
+
def FreeShells(cluster: topologic.Cluster) -> list:
|
|
156
|
+
"""
|
|
157
|
+
Returns the free shells of the input cluster that are not part of a higher topology.
|
|
158
|
+
|
|
159
|
+
Parameters
|
|
160
|
+
----------
|
|
161
|
+
cluster : topologic.Cluster
|
|
162
|
+
The input cluster.
|
|
163
|
+
|
|
164
|
+
Returns
|
|
165
|
+
-------
|
|
166
|
+
list
|
|
167
|
+
The list of free shells.
|
|
168
|
+
|
|
169
|
+
"""
|
|
170
|
+
from topologicpy.Cell import Cell
|
|
171
|
+
from topologicpy.Topology import Topology
|
|
172
|
+
|
|
173
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
174
|
+
return None
|
|
175
|
+
allShells = []
|
|
176
|
+
_ = cluster.Shells(None, allShells)
|
|
177
|
+
allShellsCluster = Cluster.ByTopologies(allShells)
|
|
178
|
+
cells = []
|
|
179
|
+
_ = cluster.Cells(None, cells)
|
|
180
|
+
cellsShells = []
|
|
181
|
+
for cell in cells:
|
|
182
|
+
tempShells = Cell.Shells(cell)
|
|
183
|
+
cellsShells += tempShells
|
|
184
|
+
if len(cellsShells) == 0:
|
|
185
|
+
return allShells
|
|
186
|
+
cellsCluster = Cluster.ByTopologies(cellsShells)
|
|
187
|
+
resultingCluster = Topology.Boolean(allShellsCluster, cellsCluster, operation="Difference")
|
|
188
|
+
if isinstance(resultingCluster, topologic.Shell):
|
|
189
|
+
return [resultingCluster]
|
|
190
|
+
result = Topology.SubTopologies(resultingCluster, subTopologyType="shell")
|
|
191
|
+
if not result:
|
|
192
|
+
return [] #Make sure you return an empty list instead of None
|
|
193
|
+
return result
|
|
194
|
+
|
|
195
|
+
@staticmethod
|
|
196
|
+
def FreeFaces(cluster: topologic.Cluster) -> list:
|
|
197
|
+
"""
|
|
198
|
+
Returns the free faces of the input cluster that are not part of a higher topology.
|
|
199
|
+
|
|
200
|
+
Parameters
|
|
201
|
+
----------
|
|
202
|
+
cluster : topologic.Cluster
|
|
203
|
+
The input cluster.
|
|
204
|
+
|
|
205
|
+
Returns
|
|
206
|
+
-------
|
|
207
|
+
list
|
|
208
|
+
The list of free faces.
|
|
209
|
+
|
|
210
|
+
"""
|
|
211
|
+
from topologicpy.Shell import Shell
|
|
212
|
+
from topologicpy.Topology import Topology
|
|
213
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
214
|
+
return None
|
|
215
|
+
allFaces = []
|
|
216
|
+
_ = cluster.Faces(None, allFaces)
|
|
217
|
+
allFacesCluster = Cluster.ByTopologies(allFaces)
|
|
218
|
+
shells = []
|
|
219
|
+
_ = cluster.Shells(None, shells)
|
|
220
|
+
shellFaces = []
|
|
221
|
+
for shell in shells:
|
|
222
|
+
tempFaces = Shell.Faces(shell)
|
|
223
|
+
shellFaces += tempFaces
|
|
224
|
+
if len(shellFaces) == 0:
|
|
225
|
+
return allFaces
|
|
226
|
+
shellCluster = Cluster.ByTopologies(shellFaces)
|
|
227
|
+
resultingCluster = Topology.Boolean(allFacesCluster, shellCluster, operation="Difference")
|
|
228
|
+
if isinstance(resultingCluster, topologic.Face):
|
|
229
|
+
return [resultingCluster]
|
|
230
|
+
result = Topology.SubTopologies(resultingCluster, subTopologyType="face")
|
|
231
|
+
if not result:
|
|
232
|
+
return [] #Make sure you return an empty list instead of None
|
|
233
|
+
return result
|
|
234
|
+
|
|
235
|
+
@staticmethod
|
|
236
|
+
def FreeWires(cluster: topologic.Cluster) -> list:
|
|
237
|
+
"""
|
|
238
|
+
Returns the free wires of the input cluster that are not part of a higher topology.
|
|
239
|
+
|
|
240
|
+
Parameters
|
|
241
|
+
----------
|
|
242
|
+
cluster : topologic.Cluster
|
|
243
|
+
The input cluster.
|
|
244
|
+
|
|
245
|
+
Returns
|
|
246
|
+
-------
|
|
247
|
+
list
|
|
248
|
+
The list of free wires.
|
|
249
|
+
|
|
250
|
+
"""
|
|
251
|
+
from topologicpy.Face import Face
|
|
252
|
+
from topologicpy.Topology import Topology
|
|
253
|
+
|
|
254
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
255
|
+
return None
|
|
256
|
+
allWires = []
|
|
257
|
+
_ = cluster.Wires(None, allWires)
|
|
258
|
+
allWiresCluster = Cluster.ByTopologies(allWires)
|
|
259
|
+
faces = []
|
|
260
|
+
_ = cluster.Faces(None, faces)
|
|
261
|
+
facesWires = []
|
|
262
|
+
for face in faces:
|
|
263
|
+
tempWires = Face.Wires(face)
|
|
264
|
+
facesWires += tempWires
|
|
265
|
+
if len(facesWires) == 0:
|
|
266
|
+
return allWires
|
|
267
|
+
facesCluster = Cluster.ByTopologies(facesWires)
|
|
268
|
+
resultingCluster = Topology.Boolean(allWiresCluster, facesCluster, operation="Difference")
|
|
269
|
+
if isinstance(resultingCluster, topologic.Wire):
|
|
270
|
+
return [resultingCluster]
|
|
271
|
+
result = Topology.SubTopologies(resultingCluster, subTopologyType="wire")
|
|
272
|
+
if not result:
|
|
273
|
+
return [] #Make sure you return an empty list instead of None
|
|
274
|
+
return result
|
|
275
|
+
|
|
276
|
+
@staticmethod
|
|
277
|
+
def FreeEdges(cluster: topologic.Cluster) -> list:
|
|
278
|
+
"""
|
|
279
|
+
Returns the free edges of the input cluster that are not part of a higher topology.
|
|
280
|
+
|
|
281
|
+
Parameters
|
|
282
|
+
----------
|
|
283
|
+
cluster : topologic.Cluster
|
|
284
|
+
The input cluster.
|
|
285
|
+
|
|
286
|
+
Returns
|
|
287
|
+
-------
|
|
288
|
+
list
|
|
289
|
+
The list of free edges.
|
|
290
|
+
|
|
291
|
+
"""
|
|
292
|
+
from topologicpy.Wire import Wire
|
|
293
|
+
from topologicpy.Topology import Topology
|
|
294
|
+
|
|
295
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
296
|
+
return None
|
|
297
|
+
allEdges = []
|
|
298
|
+
_ = cluster.Edges(None, allEdges)
|
|
299
|
+
allEdgesCluster = Cluster.ByTopologies(allEdges)
|
|
300
|
+
wires = []
|
|
301
|
+
_ = cluster.Wires(None, wires)
|
|
302
|
+
wireEdges = []
|
|
303
|
+
for wire in wires:
|
|
304
|
+
tempEdges = Wire.Edges(wire)
|
|
305
|
+
wireEdges += tempEdges
|
|
306
|
+
if len(wireEdges) == 0:
|
|
307
|
+
return allEdges
|
|
308
|
+
wireCluster = Cluster.ByTopologies(wireEdges)
|
|
309
|
+
resultingCluster = Topology.Boolean(allEdgesCluster, wireCluster, operation="Difference")
|
|
310
|
+
if isinstance(resultingCluster, topologic.Edge):
|
|
311
|
+
return [resultingCluster]
|
|
312
|
+
result = Topology.SubTopologies(resultingCluster, subTopologyType="edge")
|
|
313
|
+
if not result:
|
|
314
|
+
return [] #Make sure you return an empty list instead of None
|
|
315
|
+
return result
|
|
316
|
+
|
|
317
|
+
@staticmethod
|
|
318
|
+
def FreeVertices(cluster: topologic.Cluster) -> list:
|
|
319
|
+
"""
|
|
320
|
+
Returns the free vertices of the input cluster that are not part of a higher topology.
|
|
321
|
+
|
|
322
|
+
Parameters
|
|
323
|
+
----------
|
|
324
|
+
cluster : topologic.Cluster
|
|
325
|
+
The input cluster.
|
|
326
|
+
|
|
327
|
+
Returns
|
|
328
|
+
-------
|
|
329
|
+
list
|
|
330
|
+
The list of free vertices.
|
|
331
|
+
|
|
332
|
+
"""
|
|
333
|
+
from topologicpy.Edge import Edge
|
|
334
|
+
from topologicpy.Topology import Topology
|
|
335
|
+
|
|
336
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
337
|
+
return None
|
|
338
|
+
allVertices = []
|
|
339
|
+
_ = cluster.Vertices(None, allVertices)
|
|
340
|
+
allVerticesCluster = Cluster.ByTopologies(allVertices)
|
|
341
|
+
edges = []
|
|
342
|
+
_ = cluster.Edges(None, edges)
|
|
343
|
+
edgesVertices = []
|
|
344
|
+
for edge in edges:
|
|
345
|
+
tempVertices = Edge.Vertices(edge)
|
|
346
|
+
edgesVertices += tempVertices
|
|
347
|
+
if len(edgesVertices) == 0:
|
|
348
|
+
return allVertices
|
|
349
|
+
edgesCluster = Cluster.ByTopologies(edgesVertices)
|
|
350
|
+
resultingCluster = Topology.Boolean(allVerticesCluster, edgesCluster, operation="Difference")
|
|
351
|
+
if isinstance(resultingCluster, topologic.Vertex):
|
|
352
|
+
return [resultingCluster]
|
|
353
|
+
result = Topology.SubTopologies(resultingCluster, subTopologyType="vertex")
|
|
354
|
+
if not result:
|
|
355
|
+
return [] #Make sure you return an empty list instead of None
|
|
356
|
+
return result
|
|
357
|
+
|
|
358
|
+
@staticmethod
|
|
359
|
+
def HighestType(cluster: topologic.Cluster) -> int:
|
|
360
|
+
"""
|
|
361
|
+
Returns the type of the highest dimension subtopology found in the input cluster.
|
|
362
|
+
|
|
363
|
+
Parameters
|
|
364
|
+
----------
|
|
365
|
+
cluster : topologic.Cluster
|
|
366
|
+
The input cluster.
|
|
367
|
+
|
|
368
|
+
Returns
|
|
369
|
+
-------
|
|
370
|
+
int
|
|
371
|
+
The type of the highest dimension subtopology found in the input cluster.
|
|
372
|
+
|
|
373
|
+
"""
|
|
374
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
375
|
+
return None
|
|
376
|
+
cellComplexes = Cluster.CellComplexes(cluster)
|
|
377
|
+
if len(cellComplexes) > 0:
|
|
378
|
+
return topologic.CellComplex.Type()
|
|
379
|
+
cells = Cluster.Cells(cluster)
|
|
380
|
+
if len(cells) > 0:
|
|
381
|
+
return topologic.Cell.Type()
|
|
382
|
+
shells = Cluster.Shells(cluster)
|
|
383
|
+
if len(shells) > 0:
|
|
384
|
+
return topologic.Shell.Type()
|
|
385
|
+
faces = Cluster.Faces(cluster)
|
|
386
|
+
if len(faces) > 0:
|
|
387
|
+
return topologic.Face.Type()
|
|
388
|
+
wires = Cluster.Wires(cluster)
|
|
389
|
+
if len(wires) > 0:
|
|
390
|
+
return topologic.Wire.Type()
|
|
391
|
+
edges = Cluster.Edges(cluster)
|
|
392
|
+
if len(edges) > 0:
|
|
393
|
+
return topologic.Edge.Type()
|
|
394
|
+
vertices = Cluster.Vertices(cluster)
|
|
395
|
+
if len(vertices) > 0:
|
|
396
|
+
return topologic.Vertex.Type()
|
|
397
|
+
|
|
398
|
+
@staticmethod
|
|
399
|
+
def MysticRose(wire: topologic.Wire = None, origin: topologic.Vertex = None, radius: float = 1.0, sides: int = 16, perimeter: bool = True, direction: list = [0,0,1], placement:str = "center", tolerance: float = 0.0001) -> topologic.Cluster:
|
|
400
|
+
"""
|
|
401
|
+
Creates a mystic rose.
|
|
402
|
+
|
|
403
|
+
Parameters
|
|
404
|
+
----------
|
|
405
|
+
wire : topologic.Wire , optional
|
|
406
|
+
The input Wire. if set to None, a circle with the input parameters is created. Otherwise, the input parameters are ignored.
|
|
407
|
+
origin : topologic.Vertex , optional
|
|
408
|
+
The location of the origin of the circle. The default is None which results in the circle being placed at (0,0,0).
|
|
409
|
+
radius : float , optional
|
|
410
|
+
The radius of the mystic rose. The default is 1.
|
|
411
|
+
sides : int, optional
|
|
412
|
+
The number of sides of the mystic rose. The default is 16.
|
|
413
|
+
perimeter : bool, optional
|
|
414
|
+
If True, the perimeter edges are included in the output. The default is True.
|
|
415
|
+
direction : list , optional
|
|
416
|
+
The vector representing the up direction of the mystic rose. The default is [0,0,1].
|
|
417
|
+
placement : str , optional
|
|
418
|
+
The description of the placement of the origin of the mystic rose. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
419
|
+
tolerance : float , optional
|
|
420
|
+
The desired tolerance. The default is 0.0001.
|
|
421
|
+
|
|
422
|
+
Returns
|
|
423
|
+
-------
|
|
424
|
+
topologic.cluster
|
|
425
|
+
The created mystic rose (cluster of edges).
|
|
426
|
+
|
|
427
|
+
"""
|
|
428
|
+
import topologicpy
|
|
429
|
+
from topologicpy.Vertex import Vertex
|
|
430
|
+
from topologicpy.Edge import Edge
|
|
431
|
+
from topologicpy.Wire import Wire
|
|
432
|
+
from topologicpy.Cluster import Cluster
|
|
433
|
+
from itertools import combinations
|
|
434
|
+
|
|
435
|
+
if not wire:
|
|
436
|
+
wire = Wire.Circle(origin=origin, radius=radius, sides=sides, fromAngle=0, toAngle=360, close=True, direction=direction, placement=placement, tolerance=tolerance)
|
|
437
|
+
if not Wire.IsClosed(wire):
|
|
438
|
+
return None
|
|
439
|
+
vertices = Wire.Vertices(wire)
|
|
440
|
+
indices = list(range(len(vertices)))
|
|
441
|
+
combs = [[comb[0],comb[1]] for comb in combinations(indices, 2) if not (abs(comb[0]-comb[1]) == 1) and not (abs(comb[0]-comb[1]) == len(indices)-1)]
|
|
442
|
+
edges = []
|
|
443
|
+
if perimeter:
|
|
444
|
+
edges = Wire.Edges(wire)
|
|
445
|
+
for comb in combs:
|
|
446
|
+
edges.append(Edge.ByVertices([vertices[comb[0]], vertices[comb[1]]]))
|
|
447
|
+
return Cluster.ByTopologies(edges)
|
|
448
|
+
|
|
449
|
+
@staticmethod
|
|
450
|
+
def Shells(cluster: topologic.Cluster) -> list:
|
|
451
|
+
"""
|
|
452
|
+
Returns the shells of the input cluster.
|
|
453
|
+
|
|
454
|
+
Parameters
|
|
455
|
+
----------
|
|
456
|
+
cluster : topologic.Cluster
|
|
457
|
+
The input cluster.
|
|
458
|
+
|
|
459
|
+
Returns
|
|
460
|
+
-------
|
|
461
|
+
list
|
|
462
|
+
The list of shells.
|
|
463
|
+
|
|
464
|
+
"""
|
|
465
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
466
|
+
return None
|
|
467
|
+
shells = []
|
|
468
|
+
_ = cluster.Shells(None, shells)
|
|
469
|
+
return shells
|
|
470
|
+
|
|
471
|
+
@staticmethod
|
|
472
|
+
def Simplify(cluster: topologic.Cluster):
|
|
473
|
+
"""
|
|
474
|
+
Simplifies the input cluster if possible. For example, if the cluster contains only one cell, that cell is returned.
|
|
475
|
+
|
|
476
|
+
Parameters
|
|
477
|
+
----------
|
|
478
|
+
cluster : topologic.Cluster
|
|
479
|
+
The input cluster.
|
|
480
|
+
|
|
481
|
+
Returns
|
|
482
|
+
-------
|
|
483
|
+
topologic.Topology or list
|
|
484
|
+
The simplification of the cluster.
|
|
485
|
+
|
|
486
|
+
"""
|
|
487
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
488
|
+
return None
|
|
489
|
+
resultingTopologies = []
|
|
490
|
+
topCC = []
|
|
491
|
+
_ = cluster.CellComplexes(None, topCC)
|
|
492
|
+
topCells = []
|
|
493
|
+
_ = cluster.Cells(None, topCells)
|
|
494
|
+
topShells = []
|
|
495
|
+
_ = cluster.Shells(None, topShells)
|
|
496
|
+
topFaces = []
|
|
497
|
+
_ = cluster.Faces(None, topFaces)
|
|
498
|
+
topWires = []
|
|
499
|
+
_ = cluster.Wires(None, topWires)
|
|
500
|
+
topEdges = []
|
|
501
|
+
_ = cluster.Edges(None, topEdges)
|
|
502
|
+
topVertices = []
|
|
503
|
+
_ = cluster.Vertices(None, topVertices)
|
|
504
|
+
if len(topCC) == 1:
|
|
505
|
+
cc = topCC[0]
|
|
506
|
+
ccVertices = []
|
|
507
|
+
_ = cc.Vertices(None, ccVertices)
|
|
508
|
+
if len(topVertices) == len(ccVertices):
|
|
509
|
+
resultingTopologies.append(cc)
|
|
510
|
+
if len(topCC) == 0 and len(topCells) == 1:
|
|
511
|
+
cell = topCells[0]
|
|
512
|
+
ccVertices = []
|
|
513
|
+
_ = cell.Vertices(None, ccVertices)
|
|
514
|
+
if len(topVertices) == len(ccVertices):
|
|
515
|
+
resultingTopologies.append(cell)
|
|
516
|
+
if len(topCC) == 0 and len(topCells) == 0 and len(topShells) == 1:
|
|
517
|
+
shell = topShells[0]
|
|
518
|
+
ccVertices = []
|
|
519
|
+
_ = shell.Vertices(None, ccVertices)
|
|
520
|
+
if len(topVertices) == len(ccVertices):
|
|
521
|
+
resultingTopologies.append(shell)
|
|
522
|
+
if len(topCC) == 0 and len(topCells) == 0 and len(topShells) == 0 and len(topFaces) == 1:
|
|
523
|
+
face = topFaces[0]
|
|
524
|
+
ccVertices = []
|
|
525
|
+
_ = face.Vertices(None, ccVertices)
|
|
526
|
+
if len(topVertices) == len(ccVertices):
|
|
527
|
+
resultingTopologies.append(face)
|
|
528
|
+
if len(topCC) == 0 and len(topCells) == 0 and len(topShells) == 0 and len(topFaces) == 0 and len(topWires) == 1:
|
|
529
|
+
wire = topWires[0]
|
|
530
|
+
ccVertices = []
|
|
531
|
+
_ = wire.Vertices(None, ccVertices)
|
|
532
|
+
if len(topVertices) == len(ccVertices):
|
|
533
|
+
resultingTopologies.append(wire)
|
|
534
|
+
if len(topCC) == 0 and len(topCells) == 0 and len(topShells) == 0 and len(topFaces) == 0 and len(topWires) == 0 and len(topEdges) == 1:
|
|
535
|
+
edge = topEdges[0]
|
|
536
|
+
ccVertices = []
|
|
537
|
+
_ = wire.Vertices(None, ccVertices)
|
|
538
|
+
if len(topVertices) == len(ccVertices):
|
|
539
|
+
resultingTopologies.append(edge)
|
|
540
|
+
if len(topCC) == 0 and len(topCells) == 0 and len(topShells) == 0 and len(topFaces) == 0 and len(topWires) == 0 and len(topEdges) == 0 and len(topVertices) == 1:
|
|
541
|
+
vertex = topVertices[0]
|
|
542
|
+
resultingTopologies.append(vertex)
|
|
543
|
+
if len(resultingTopologies) == 1:
|
|
544
|
+
return resultingTopologies[0]
|
|
545
|
+
return cluster
|
|
546
|
+
|
|
547
|
+
@staticmethod
|
|
548
|
+
def Vertices(cluster: topologic.Cluster) -> list:
|
|
549
|
+
"""
|
|
550
|
+
Returns the vertices of the input cluster.
|
|
551
|
+
|
|
552
|
+
Parameters
|
|
553
|
+
----------
|
|
554
|
+
cluster : topologic.Cluster
|
|
555
|
+
The input cluster.
|
|
556
|
+
|
|
557
|
+
Returns
|
|
558
|
+
-------
|
|
559
|
+
list
|
|
560
|
+
The list of vertices.
|
|
561
|
+
|
|
562
|
+
"""
|
|
563
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
564
|
+
return None
|
|
565
|
+
vertices = []
|
|
566
|
+
_ = cluster.Vertices(None, vertices)
|
|
567
|
+
return vertices
|
|
568
|
+
|
|
569
|
+
@staticmethod
|
|
570
|
+
def Wires(cluster: topologic.Cluster) -> list:
|
|
571
|
+
"""
|
|
572
|
+
Returns the wires of the input cluster.
|
|
573
|
+
|
|
574
|
+
Parameters
|
|
575
|
+
----------
|
|
576
|
+
cluster : topologic.Cluster
|
|
577
|
+
The input cluster.
|
|
578
|
+
|
|
579
|
+
Returns
|
|
580
|
+
-------
|
|
581
|
+
list
|
|
582
|
+
The list of wires.
|
|
583
|
+
|
|
584
|
+
"""
|
|
585
|
+
if not isinstance(cluster, topologic.Cluster):
|
|
586
|
+
return None
|
|
587
|
+
wires = []
|
|
588
|
+
_ = cluster.Wires(None, wires)
|
|
589
|
+
return wires
|
|
590
|
+
|
|
591
|
+
|