topologicpy 0.8.33__py3-none-any.whl → 0.8.36__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/BVH.py +4 -4
- topologicpy/CSG.py +5 -5
- topologicpy/Cell.py +17 -17
- topologicpy/CellComplex.py +3 -188
- topologicpy/Cluster.py +2 -2
- topologicpy/Dictionary.py +121 -2
- topologicpy/Edge.py +14 -14
- topologicpy/Face.py +31 -31
- topologicpy/Graph.py +105 -65
- topologicpy/Helper.py +56 -4
- topologicpy/Matrix.py +3 -3
- topologicpy/Neo4j.py +1 -1
- topologicpy/Plotly.py +29 -7
- topologicpy/ShapeGrammar.py +7 -7
- topologicpy/Shell.py +123 -96
- topologicpy/Topology.py +231 -46
- topologicpy/Vector.py +5 -5
- topologicpy/Vertex.py +6 -6
- topologicpy/Wire.py +21 -21
- topologicpy/version.py +1 -1
- {topologicpy-0.8.33.dist-info → topologicpy-0.8.36.dist-info}/METADATA +1 -1
- topologicpy-0.8.36.dist-info/RECORD +38 -0
- topologicpy-0.8.33.dist-info/RECORD +0 -38
- {topologicpy-0.8.33.dist-info → topologicpy-0.8.36.dist-info}/WHEEL +0 -0
- {topologicpy-0.8.33.dist-info → topologicpy-0.8.36.dist-info}/licenses/LICENSE +0 -0
- {topologicpy-0.8.33.dist-info → topologicpy-0.8.36.dist-info}/top_level.txt +0 -0
topologicpy/BVH.py
CHANGED
@@ -75,7 +75,7 @@ class BVH:
|
|
75
75
|
topologies : list
|
76
76
|
The list of topologies.
|
77
77
|
silent : bool , optional
|
78
|
-
If set to True,
|
78
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
79
79
|
|
80
80
|
Returns
|
81
81
|
-------
|
@@ -152,7 +152,7 @@ class BVH:
|
|
152
152
|
topologies : list
|
153
153
|
The list of topologies.
|
154
154
|
silent : bool , optional
|
155
|
-
If set to True,
|
155
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
156
156
|
|
157
157
|
Returns
|
158
158
|
-------
|
@@ -220,7 +220,7 @@ class BVH:
|
|
220
220
|
topologies : list
|
221
221
|
The list of topologies.
|
222
222
|
silent : bool , optional
|
223
|
-
If set to True,
|
223
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
224
224
|
|
225
225
|
Returns
|
226
226
|
-------
|
@@ -263,7 +263,7 @@ class BVH:
|
|
263
263
|
tolerance : float , optional
|
264
264
|
The desired tolerance. The default is 0.0001.
|
265
265
|
silent : bool , optional
|
266
|
-
If set to True,
|
266
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
267
267
|
|
268
268
|
Returns
|
269
269
|
-------
|
topologicpy/CSG.py
CHANGED
@@ -56,7 +56,7 @@ class CSG():
|
|
56
56
|
tolerance : float , optional
|
57
57
|
The desired tolerance. The default is 0.0001.
|
58
58
|
silent : bool , optional
|
59
|
-
If set to True,
|
59
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
60
60
|
|
61
61
|
Returns
|
62
62
|
-------
|
@@ -121,7 +121,7 @@ class CSG():
|
|
121
121
|
tolerance : float , optional
|
122
122
|
The desired tolerance. The default is 0.0001.
|
123
123
|
silent : bool , optional
|
124
|
-
If set to True,
|
124
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
125
125
|
|
126
126
|
Returns
|
127
127
|
-------
|
@@ -183,7 +183,7 @@ class CSG():
|
|
183
183
|
tolerance : float , optional
|
184
184
|
The desired tolerance. The default is 0.0001.
|
185
185
|
silent : bool , optional
|
186
|
-
If set to True,
|
186
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
187
187
|
|
188
188
|
Returns
|
189
189
|
-------
|
@@ -248,7 +248,7 @@ class CSG():
|
|
248
248
|
graph : topologic_core.Graph
|
249
249
|
The input graph.
|
250
250
|
silent : bool , optional
|
251
|
-
If set to True,
|
251
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
252
252
|
|
253
253
|
Returns
|
254
254
|
-------
|
@@ -358,7 +358,7 @@ class CSG():
|
|
358
358
|
scale : float , optional
|
359
359
|
A desired scale to resize the placed topologies. The default is 1.
|
360
360
|
silent : bool , optional
|
361
|
-
If set to True,
|
361
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
362
362
|
|
363
363
|
Returns
|
364
364
|
-------
|
topologicpy/Cell.py
CHANGED
@@ -99,7 +99,7 @@ class Cell():
|
|
99
99
|
tolerance : float , optional
|
100
100
|
The desired tolerance. The default is 0.0001.
|
101
101
|
silent : bool , optional
|
102
|
-
If set to True,
|
102
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
103
103
|
|
104
104
|
Returns
|
105
105
|
-------
|
@@ -268,7 +268,7 @@ class Cell():
|
|
268
268
|
tolerance : float , optional
|
269
269
|
The desired tolerance. The default is 0.0001.
|
270
270
|
silent : bool , optional
|
271
|
-
If set to True,
|
271
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
272
272
|
|
273
273
|
Returns
|
274
274
|
-------
|
@@ -320,7 +320,7 @@ class Cell():
|
|
320
320
|
tolerance : float , optional
|
321
321
|
The desired tolerance. The default is 0.0001.
|
322
322
|
silent : bool , optional
|
323
|
-
If set to True,
|
323
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
324
324
|
|
325
325
|
Returns
|
326
326
|
-------
|
@@ -377,7 +377,7 @@ class Cell():
|
|
377
377
|
tolerance : float , optional
|
378
378
|
The desired tolerance. The default is 0.0001.
|
379
379
|
silent : bool , optional
|
380
|
-
If set to True,
|
380
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
381
381
|
|
382
382
|
Returns
|
383
383
|
-------
|
@@ -435,7 +435,7 @@ class Cell():
|
|
435
435
|
tolerance : float , optional
|
436
436
|
The desired tolerance. The default is 0.0001.
|
437
437
|
silent : bool , optional
|
438
|
-
If set to True,
|
438
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
439
439
|
|
440
440
|
Raises
|
441
441
|
------
|
@@ -672,7 +672,7 @@ class Cell():
|
|
672
672
|
tolerance : float , optional
|
673
673
|
The desired tolerance. The default is 0.0001.
|
674
674
|
silent : bool , optional
|
675
|
-
If set to True,
|
675
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
676
676
|
|
677
677
|
Returns
|
678
678
|
-------
|
@@ -972,7 +972,7 @@ class Cell():
|
|
972
972
|
tolerance : float , optional
|
973
973
|
The desired tolerance. The default is 0.0001.
|
974
974
|
silent : bool , optional
|
975
|
-
If set to True,
|
975
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
976
976
|
|
977
977
|
Returns
|
978
978
|
-------
|
@@ -1157,7 +1157,7 @@ class Cell():
|
|
1157
1157
|
tolerance : float , optional
|
1158
1158
|
The desired tolerance. The default is 0.0001.
|
1159
1159
|
silent : bool , optional
|
1160
|
-
If set to True,
|
1160
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
1161
1161
|
|
1162
1162
|
Returns
|
1163
1163
|
-------
|
@@ -1949,7 +1949,7 @@ class Cell():
|
|
1949
1949
|
tolerance : float , optional
|
1950
1950
|
The desired tolerance. The default is 0.0001.
|
1951
1951
|
silent : bool , optional
|
1952
|
-
If set to True,
|
1952
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
1953
1953
|
|
1954
1954
|
Returns
|
1955
1955
|
-------
|
@@ -2008,7 +2008,7 @@ class Cell():
|
|
2008
2008
|
tolerance : float , optional
|
2009
2009
|
The desired tolerance. The default is 0.0001.
|
2010
2010
|
silent : bool , optional
|
2011
|
-
If set to True,
|
2011
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
2012
2012
|
|
2013
2013
|
Returns
|
2014
2014
|
-------
|
@@ -2188,7 +2188,7 @@ class Cell():
|
|
2188
2188
|
tolerance : float , optional
|
2189
2189
|
The desired tolerance. The default is 0.0001.
|
2190
2190
|
silent : bool , optional
|
2191
|
-
If set to True,
|
2191
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
2192
2192
|
|
2193
2193
|
Returns
|
2194
2194
|
-------
|
@@ -2398,7 +2398,7 @@ class Cell():
|
|
2398
2398
|
tolerance : float , optional
|
2399
2399
|
The desired tolerance. The default is 0.0001.
|
2400
2400
|
silent : bool , optional
|
2401
|
-
If set to True,
|
2401
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
2402
2402
|
|
2403
2403
|
Returns
|
2404
2404
|
-------
|
@@ -2783,7 +2783,7 @@ class Cell():
|
|
2783
2783
|
tolerance : float , optional
|
2784
2784
|
The desired tolerance. The default is 0.0001.
|
2785
2785
|
silent : bool , optional
|
2786
|
-
If set to True,
|
2786
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
2787
2787
|
|
2788
2788
|
Returns
|
2789
2789
|
-------
|
@@ -3002,7 +3002,7 @@ class Cell():
|
|
3002
3002
|
tolerance : float , optional
|
3003
3003
|
The desired tolerance. The default is 0.0001.
|
3004
3004
|
silent : bool , optional
|
3005
|
-
If set to True,
|
3005
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
3006
3006
|
|
3007
3007
|
Returns
|
3008
3008
|
-------
|
@@ -3358,7 +3358,7 @@ class Cell():
|
|
3358
3358
|
tolerance : float , optional
|
3359
3359
|
The desired tolerance. The default is 0.0001.
|
3360
3360
|
silent : bool , optional
|
3361
|
-
If set to True,
|
3361
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
3362
3362
|
|
3363
3363
|
Returns
|
3364
3364
|
-------
|
@@ -3490,7 +3490,7 @@ class Cell():
|
|
3490
3490
|
tolerance : float , optional
|
3491
3491
|
The desired tolerance. The default is 0.0001.
|
3492
3492
|
silent : bool , optional
|
3493
|
-
If set to True,
|
3493
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
3494
3494
|
|
3495
3495
|
Returns
|
3496
3496
|
-------
|
@@ -3605,7 +3605,7 @@ class Cell():
|
|
3605
3605
|
tolerance : float , optional
|
3606
3606
|
The desired tolerance. The default is 0.0001.
|
3607
3607
|
silent : bool , optional
|
3608
|
-
If set to True,
|
3608
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
3609
3609
|
|
3610
3610
|
Returns
|
3611
3611
|
-------
|
topologicpy/CellComplex.py
CHANGED
@@ -48,99 +48,6 @@ except:
|
|
48
48
|
warnings.warn("CellComplex - Error: Could not import scipy.")
|
49
49
|
|
50
50
|
class CellComplex():
|
51
|
-
@staticmethod
|
52
|
-
def AdjacencyDictionary(cellComplex, cellLabelKey: str = None, faceKey: str = None, includeWeights: bool = False, reverse: bool = False, mantissa: int = 6, silent: bool = False):
|
53
|
-
"""
|
54
|
-
Returns the adjacency dictionary of the input Graph.
|
55
|
-
|
56
|
-
Parameters
|
57
|
-
----------
|
58
|
-
cellComplex : topologic_core.CellComplex
|
59
|
-
The input cellComplex.
|
60
|
-
cellLabelKey : str , optional
|
61
|
-
The returned cells are labelled according to the dictionary values stored under this key.
|
62
|
-
If the cellLabelKey does not exist, it will be created and the cells are labelled numerically and stored in the vertex dictionary under this key. The default is None.
|
63
|
-
faceKey : str , optional
|
64
|
-
If set, the faces' dictionaries will be searched for this key to set their weight. If the key is set to "Area" (case insensitive), the area of the shared faces will be used as its weight. If set to None, a weight of 1 will be used. The default is None.
|
65
|
-
includeWeights : bool , optional
|
66
|
-
If set to True, edge weights are included. Otherwise, they are not. The default is False.
|
67
|
-
reverse : bool , optional
|
68
|
-
If set to True, the cells are sorted in reverse order (only if cellLabelKey is set). Otherwise, they are not. The default is False.
|
69
|
-
|
70
|
-
silent : bool , optional
|
71
|
-
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
72
|
-
|
73
|
-
Returns
|
74
|
-
-------
|
75
|
-
dict
|
76
|
-
The adjacency dictionary.
|
77
|
-
"""
|
78
|
-
from topologicpy.Face import Face
|
79
|
-
from topologicpy.Dictionary import Dictionary
|
80
|
-
from topologicpy.Topology import Topology
|
81
|
-
from topologicpy.Helper import Helper
|
82
|
-
|
83
|
-
if not Topology.IsInstance(cellComplex, "CellComplex"):
|
84
|
-
if not silent:
|
85
|
-
print("CellComplex.AdjacencyDictionary - Error: The input cellComplex input parameter is not a valid cellComplex. Returning None.")
|
86
|
-
return None
|
87
|
-
if cellLabelKey == None:
|
88
|
-
cellLabelKey = "__label__"
|
89
|
-
if not isinstance(cellLabelKey, str):
|
90
|
-
if not silent:
|
91
|
-
print("CellComplex.AdjacencyDictionary - Error: The input cellLabelKey is not a valid string. Returning None.")
|
92
|
-
return None
|
93
|
-
all_cells = Topology.Cells(cellComplex)
|
94
|
-
labels = []
|
95
|
-
n = max(len(str(len(all_cells))), 3)
|
96
|
-
for i, cell in enumerate(all_cells):
|
97
|
-
d = Topology.Dictionary(cell)
|
98
|
-
value = Dictionary.ValueAtKey(d, cellLabelKey)
|
99
|
-
if value == None:
|
100
|
-
value = str(i+1).zfill(n)
|
101
|
-
if d == None:
|
102
|
-
d = Dictionary.ByKeyValue(cellLabelKey, value)
|
103
|
-
else:
|
104
|
-
d = Dictionary.SetValueAtKey(d, cellLabelKey, value)
|
105
|
-
cell = Topology.SetDictionary(cell, d)
|
106
|
-
labels.append(value)
|
107
|
-
all_cells = Helper.Sort(all_cells, labels)
|
108
|
-
labels.sort()
|
109
|
-
order = len(all_cells)
|
110
|
-
adjDict = {}
|
111
|
-
for i in range(order):
|
112
|
-
cell = all_cells[i]
|
113
|
-
cell_label = labels[i]
|
114
|
-
adjCells = Topology.AdjacentTopologies(cell, hostTopology=cellComplex, topologyType="cell")
|
115
|
-
temp_list = []
|
116
|
-
for adjCell in adjCells:
|
117
|
-
adj_label = Dictionary.ValueAtKey(Topology.Dictionary(adjCell), cellLabelKey)
|
118
|
-
adj_index = labels.index(adj_label)
|
119
|
-
if includeWeights == True:
|
120
|
-
if faceKey == None:
|
121
|
-
weight = 1
|
122
|
-
elif "area" in faceKey.lower():
|
123
|
-
shared_topologies = Topology.SharedTopologies(cell, adjCell)
|
124
|
-
faces = shared_topologies.get("faces", [])
|
125
|
-
weight = sum([Face.Area(face, mantissa=mantissa) for face in faces])
|
126
|
-
else:
|
127
|
-
shared_topologies = Topology.SharedTopologies(cell, adjCell)
|
128
|
-
faces = shared_topologies.get("faces", [])
|
129
|
-
weight = sum([Dictionary.ValueAtKey(Topology.Dictionary(face),faceKey, 0) for face in faces])
|
130
|
-
if not adj_index == None:
|
131
|
-
temp_list.append((adj_label, weight))
|
132
|
-
else:
|
133
|
-
if not adj_index == None:
|
134
|
-
temp_list.append(adj_label)
|
135
|
-
temp_list.sort()
|
136
|
-
adjDict[cell_label] = temp_list
|
137
|
-
if cellLabelKey == "__label__": # This is label we added, so remove it
|
138
|
-
for cell in all_cells:
|
139
|
-
d = Topology.Dictionary(cell)
|
140
|
-
d = Dictionary.RemoveKey(d, cellLabelKey)
|
141
|
-
cell = Topology.SetDictionary(cell, d)
|
142
|
-
return adjDict
|
143
|
-
|
144
51
|
@staticmethod
|
145
52
|
def Box(origin= None,
|
146
53
|
width: float = 1.0, length: float = 1.0, height: float = 1.0,
|
@@ -197,7 +104,7 @@ class CellComplex():
|
|
197
104
|
tolerance : float , optional
|
198
105
|
The desired tolerance. The default is 0.0001.
|
199
106
|
silent : bool , optional
|
200
|
-
If set to True,
|
107
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
201
108
|
|
202
109
|
Returns
|
203
110
|
-------
|
@@ -298,7 +205,7 @@ class CellComplex():
|
|
298
205
|
tolerance : float , optional
|
299
206
|
The desired tolerance. The default is 0.0001.
|
300
207
|
silent : bool , optional
|
301
|
-
If set to True,
|
208
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
302
209
|
|
303
210
|
Returns
|
304
211
|
-------
|
@@ -1143,7 +1050,7 @@ class CellComplex():
|
|
1143
1050
|
shells = Topology.Shells(cellComplex)
|
1144
1051
|
return shells
|
1145
1052
|
|
1146
|
-
|
1053
|
+
@staticmethod
|
1147
1054
|
def _grow_connected_group(seed_idx, group_size, adjacency, visited_global):
|
1148
1055
|
"""
|
1149
1056
|
Attempts to grow a group of the given size starting from seed_idx using adjacency.
|
@@ -1170,98 +1077,6 @@ class CellComplex():
|
|
1170
1077
|
|
1171
1078
|
return group if len(group) == group_size else None
|
1172
1079
|
|
1173
|
-
def SubCombinations(cellComplex,
|
1174
|
-
minCells: int = 2,
|
1175
|
-
maxCells: int = None,
|
1176
|
-
maxCombinations: int = 100,
|
1177
|
-
timeLimit: int = 10,
|
1178
|
-
silent: bool = False):
|
1179
|
-
"""
|
1180
|
-
Creates sub-combination cellComplexes of the input cellComplex. Warning: This is prone to combinatorial explosion.
|
1181
|
-
|
1182
|
-
Parameters
|
1183
|
-
----------
|
1184
|
-
cellComplex : topologic_core.cellComplex
|
1185
|
-
The input cellComplex
|
1186
|
-
minCells : int , optional
|
1187
|
-
The minimum number of cells to include in a combination. The default is 2.
|
1188
|
-
maxCells : int , optional
|
1189
|
-
The maximum number of cells to include in a combinations. The default is None which means the maximum will be set to the number of cells in the cellComplex minus 1.
|
1190
|
-
maxCombinations : int , optional
|
1191
|
-
The maximum number of combinations to create. The default is 100.
|
1192
|
-
timeLimit : int , optional
|
1193
|
-
The time limit in seconds. The default is 10 seconds. Note that this time limit only applies to creating the combination indices and not the actual CellComplexes.
|
1194
|
-
tolerance : float , optional
|
1195
|
-
The tolerance for computing if the input vertex is external to the input topology. The default is 0.0001.
|
1196
|
-
silent : bool , optional
|
1197
|
-
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
1198
|
-
|
1199
|
-
Returns
|
1200
|
-
-------
|
1201
|
-
list
|
1202
|
-
The list of created CellComplex sub-combinations.
|
1203
|
-
|
1204
|
-
"""
|
1205
|
-
from topologicpy.Cluster import Cluster
|
1206
|
-
from topologicpy.Topology import Topology
|
1207
|
-
from topologicpy.Dictionary import Dictionary
|
1208
|
-
import random
|
1209
|
-
import time
|
1210
|
-
|
1211
|
-
if not Topology.IsInstance(cellComplex, "CellComplex"):
|
1212
|
-
if not silent:
|
1213
|
-
print("CellComplex.SubCombinations - Error: The cellComplex input parameter is not a valid cellComplex. Returning None.")
|
1214
|
-
return None
|
1215
|
-
|
1216
|
-
|
1217
|
-
start_time = time.time()
|
1218
|
-
all_cells = CellComplex.Cells(cellComplex)
|
1219
|
-
num_cells = len(all_cells)
|
1220
|
-
indices = list(range(num_cells))
|
1221
|
-
cell_label_key = "index"
|
1222
|
-
# 1. Assign a unique index to each cell's dictionary
|
1223
|
-
all_cells = [Topology.SetDictionary(cell, Dictionary.ByKeyValue(cell_label_key, i)) for i, cell in enumerate(all_cells)]
|
1224
|
-
if maxCells == None:
|
1225
|
-
maxCells = len(all_cells) - 1
|
1226
|
-
# 2. Allocate counts per group size
|
1227
|
-
group_sizes = list(range(minCells, maxCells + 1))
|
1228
|
-
combinations_per_size = maxCombinations // len(group_sizes)
|
1229
|
-
|
1230
|
-
# 3. Build adjacency dict
|
1231
|
-
adjacency = CellComplex.AdjacencyDictionary(cellComplex, cellLabelKey=cell_label_key, faceKey=None, includeWeights=False)
|
1232
|
-
|
1233
|
-
results = []
|
1234
|
-
seen_groups = set() # sets of sorted indices
|
1235
|
-
|
1236
|
-
# 4. Start from longest group size
|
1237
|
-
for group_size in reversed(group_sizes):
|
1238
|
-
remaining = combinations_per_size
|
1239
|
-
tries = 0
|
1240
|
-
max_tries = combinations_per_size * 10 # fallback guard
|
1241
|
-
while remaining > 0 and time.time() - start_time < timeLimit and tries < max_tries:
|
1242
|
-
random.shuffle(indices)
|
1243
|
-
for seed in indices:
|
1244
|
-
if time.time() - start_time > timeLimit:
|
1245
|
-
break
|
1246
|
-
group = CellComplex._grow_connected_group(seed, group_size, adjacency, visited_global=seen_groups)
|
1247
|
-
if group:
|
1248
|
-
key = tuple(sorted(group))
|
1249
|
-
if key not in seen_groups:
|
1250
|
-
tries += 1
|
1251
|
-
seen_groups.add(key)
|
1252
|
-
results.append(group)
|
1253
|
-
remaining -= 1
|
1254
|
-
if remaining <= 0 or tries >= max_tries:
|
1255
|
-
break
|
1256
|
-
# 5. Build CellComplex SubCombinations
|
1257
|
-
return_combinations = []
|
1258
|
-
for i, result in enumerate(reversed(results)):
|
1259
|
-
cells = [all_cells[i] for i in result]
|
1260
|
-
combination = Topology.SelfMerge(Cluster.ByTopologies(cells))
|
1261
|
-
if Topology.IsInstance(combination, "CellComplex"):
|
1262
|
-
return_combinations.append(combination)
|
1263
|
-
return return_combinations
|
1264
|
-
|
1265
1080
|
@staticmethod
|
1266
1081
|
def Tetrahedron(origin = None, length: float = 1, depth: int = 1, direction=[0,0,1], placement="center", mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False):
|
1267
1082
|
"""
|
topologicpy/Cluster.py
CHANGED
@@ -154,7 +154,7 @@ class Cluster():
|
|
154
154
|
transferDictionaries : bool , optional
|
155
155
|
If set to True, the dictionaries from the input topologies are merged and transferred to the cluster. Otherwise they are not. The default is False.
|
156
156
|
silent : bool , optional
|
157
|
-
If set to True,
|
157
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
158
158
|
|
159
159
|
Returns
|
160
160
|
-------
|
@@ -1128,7 +1128,7 @@ class Cluster():
|
|
1128
1128
|
tolerance : float , optional
|
1129
1129
|
The desired tolerance. The default is 0.0001.
|
1130
1130
|
silent : bool , optional
|
1131
|
-
If set to True,
|
1131
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
1132
1132
|
|
1133
1133
|
Returns
|
1134
1134
|
-------
|
topologicpy/Dictionary.py
CHANGED
@@ -46,6 +46,125 @@ class Dictionary():
|
|
46
46
|
dictionaries.append(Dictionary.ByKeysValues(keys, values))
|
47
47
|
return dictionaries
|
48
48
|
'''
|
49
|
+
@staticmethod
|
50
|
+
def AdjacencyDictionary(topology, subTopologyType: str = None, labelKey: str = None, weightKey: str = None, includeWeights: bool = False, mantissa: int = 6, silent: bool = False):
|
51
|
+
"""
|
52
|
+
Returns the adjacency dictionary of the input Shell.
|
53
|
+
|
54
|
+
Parameters
|
55
|
+
----------
|
56
|
+
topology : topologic_core.Topology
|
57
|
+
The input topology.
|
58
|
+
subTopologyType : str , optional
|
59
|
+
The type of subTopology on which to base the adjacency dictionary.
|
60
|
+
labelKey : str , optional
|
61
|
+
The returned subTopologies are labelled according to the dictionary values stored under this key.
|
62
|
+
If the labelKey does not exist, it will be created and the subTopologies are labelled numerically and stored in the subTopologies' dictionary under this key. The default is None.
|
63
|
+
weightKey : str , optional
|
64
|
+
If set, the sharedTopologies' dictionaries will be searched for this key to set their weight. If the key is set to "Area" or "Length" (case insensitive), the area of shared faces or the length of the shared edges will be used as its weight. If set to None, a weight of 1 will be used. The default is None.
|
65
|
+
includeWeights : bool , optional
|
66
|
+
If set to True, edge weights are included. Otherwise, they are not. The default is False.
|
67
|
+
mantissa : int , optional
|
68
|
+
The desired length of the mantissa. The default is 6.
|
69
|
+
silent : bool , optional
|
70
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
71
|
+
|
72
|
+
Returns
|
73
|
+
-------
|
74
|
+
dict
|
75
|
+
The adjacency dictionary.
|
76
|
+
"""
|
77
|
+
from topologicpy.Edge import Edge
|
78
|
+
from topologicpy.Dictionary import Dictionary
|
79
|
+
from topologicpy.Topology import Topology
|
80
|
+
from topologicpy.Graph import Graph
|
81
|
+
from topologicpy.Helper import Helper
|
82
|
+
|
83
|
+
if not Topology.IsInstance(topology, "Topology") and not Topology.IsInstance(topology, "Graph"):
|
84
|
+
if not silent:
|
85
|
+
print("Dictionary.AdjacencyDictionary - Error: The input topology input parameter is not a valid topology. Returning None.")
|
86
|
+
return None
|
87
|
+
# Special Case for Graphs
|
88
|
+
|
89
|
+
if Topology.IsInstance(topology, "Graph"):
|
90
|
+
return Graph.AdjacencyDictionary(topology, vertexLabelKey=labelKey, edgeKey=weightKey, includeWeights=includeWeights, mantissa=mantissa)
|
91
|
+
if labelKey == None:
|
92
|
+
labelKey = "__label__"
|
93
|
+
if not isinstance(labelKey, str):
|
94
|
+
if not silent:
|
95
|
+
print("Dictionary.AdjacencyDictionary - Error: The input labelKey is not a valid string. Returning None.")
|
96
|
+
return None
|
97
|
+
if Topology.IsInstance(topology, "cellcomplex"):
|
98
|
+
if subTopologyType == None:
|
99
|
+
subTopologyType = "cell"
|
100
|
+
all_subtopologies = Topology.SubTopologies(topology, subTopologyType=subTopologyType, silent=silent)
|
101
|
+
elif Topology.IsInstance(topology, "cell") or Topology.IsInstance(topology, "shell"):
|
102
|
+
if subTopologyType == None:
|
103
|
+
subTopologyType = "face"
|
104
|
+
all_subtopologies = Topology.SubTopologies(topology, subTopologyType=subTopologyType, silent=silent)
|
105
|
+
elif Topology.IsInstance(topology, "face") or Topology.IsInstance(topology, "wire"):
|
106
|
+
if subTopologyType == None:
|
107
|
+
subTopologyType = "edge"
|
108
|
+
all_subtopologies = Topology.SubTopologies(topology, subTopologyType=subTopologyType, silent=silent)
|
109
|
+
labels = []
|
110
|
+
n = max(len(str(len(all_subtopologies))), 3)
|
111
|
+
for i, subtopology in enumerate(all_subtopologies):
|
112
|
+
d = Topology.Dictionary(subtopology)
|
113
|
+
value = Dictionary.ValueAtKey(d, labelKey)
|
114
|
+
if value == None:
|
115
|
+
value = str(i+1).zfill(n)
|
116
|
+
if d == None:
|
117
|
+
d = Dictionary.ByKeyValue(labelKey, value)
|
118
|
+
else:
|
119
|
+
d = Dictionary.SetValueAtKey(d, labelKey, value)
|
120
|
+
subtopology = Topology.SetDictionary(subtopology, d)
|
121
|
+
labels.append(value)
|
122
|
+
all_subtopologies = Helper.Sort(all_subtopologies, labels)
|
123
|
+
labels.sort()
|
124
|
+
order = len(all_subtopologies)
|
125
|
+
adjDict = {}
|
126
|
+
for i in range(order):
|
127
|
+
subtopology = all_subtopologies[i]
|
128
|
+
subt_label = labels[i]
|
129
|
+
adjacent_topologies = Topology.AdjacentTopologies(subtopology, hostTopology=topology, topologyType=subTopologyType)
|
130
|
+
temp_list = []
|
131
|
+
for adj_topology in adjacent_topologies:
|
132
|
+
adj_label = Dictionary.ValueAtKey(Topology.Dictionary(adj_topology), labelKey)
|
133
|
+
adj_index = labels.index(adj_label)
|
134
|
+
if includeWeights == True:
|
135
|
+
if weightKey == None:
|
136
|
+
weight = 1
|
137
|
+
elif "length" in weightKey.lower():
|
138
|
+
shared_topologies = Topology.SharedTopologies(subtopology, adj_topology)
|
139
|
+
edges = shared_topologies.get("edges", [])
|
140
|
+
weight = sum([Edge.Length(edge, mantissa=mantissa) for edge in edges])
|
141
|
+
elif "area" in weightKey.lower():
|
142
|
+
shared_topologies = Topology.SharedTopologies(subtopology, adj_topology)
|
143
|
+
faces = shared_topologies.get("faces", [])
|
144
|
+
weight = sum([Edge.Length(edge, mantissa=mantissa) for face in faces])
|
145
|
+
else:
|
146
|
+
shared_topologies = Topology.SharedTopologies(subtopology, adj_topology)
|
147
|
+
vertices = shared_topologies.get("vertices", [])
|
148
|
+
edges = shared_topologies.get("edges", [])
|
149
|
+
wires = shared_topologies.get("wires", [])
|
150
|
+
faces = shared_topologies.get("faces", [])
|
151
|
+
everything = vertices+edges+wires+faces
|
152
|
+
weight = sum([Dictionary.ValueAtKey(Topology.Dictionary(x),weightKey, 0) for x in everything])
|
153
|
+
weight = round(weight, mantissa)
|
154
|
+
if not adj_index == None:
|
155
|
+
temp_list.append((adj_label, weight))
|
156
|
+
else:
|
157
|
+
if not adj_index == None:
|
158
|
+
temp_list.append(adj_label)
|
159
|
+
temp_list.sort()
|
160
|
+
adjDict[subt_label] = temp_list
|
161
|
+
if labelKey == "__label__": # This is label we added, so remove it
|
162
|
+
for subtopology in all_subtopologies:
|
163
|
+
d = Topology.Dictionary(subtopology)
|
164
|
+
d = Dictionary.RemoveKey(d, labelKey)
|
165
|
+
subtopology = Topology.SetDictionary(subtopology, d)
|
166
|
+
return adjDict
|
167
|
+
|
49
168
|
@staticmethod
|
50
169
|
def ByKeyValue(key, value):
|
51
170
|
"""
|
@@ -162,7 +281,7 @@ class Dictionary():
|
|
162
281
|
dictionaries : list or comma separated dictionaries
|
163
282
|
The input list of dictionaries to be merged.
|
164
283
|
silent : bool , optional
|
165
|
-
If set to True,
|
284
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
166
285
|
|
167
286
|
Returns
|
168
287
|
-------
|
@@ -786,7 +905,7 @@ class Dictionary():
|
|
786
905
|
defaultValue : any , optional
|
787
906
|
The default value to return if the key or value are not found. The default is None.
|
788
907
|
silent : bool , optional
|
789
|
-
If set to True,
|
908
|
+
If set to True, error and warning messages are suppressed. The default is False.
|
790
909
|
|
791
910
|
Returns
|
792
911
|
-------
|