topologicpy 0.5.6__py3-none-any.whl → 0.5.8__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/Dictionary.py +51 -0
- topologicpy/Face.py +21 -14
- topologicpy/Graph.py +355 -112
- topologicpy/Topology.py +60 -16
- topologicpy/__init__.py +1 -1
- {topologicpy-0.5.6.dist-info → topologicpy-0.5.8.dist-info}/METADATA +1 -1
- {topologicpy-0.5.6.dist-info → topologicpy-0.5.8.dist-info}/RECORD +10 -10
- {topologicpy-0.5.6.dist-info → topologicpy-0.5.8.dist-info}/LICENSE +0 -0
- {topologicpy-0.5.6.dist-info → topologicpy-0.5.8.dist-info}/WHEEL +0 -0
- {topologicpy-0.5.6.dist-info → topologicpy-0.5.8.dist-info}/top_level.txt +0 -0
topologicpy/Graph.py
CHANGED
@@ -173,7 +173,7 @@ class _DrawTree(object):
|
|
173
173
|
|
174
174
|
class Graph:
|
175
175
|
@staticmethod
|
176
|
-
def AdjacencyMatrix(graph, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=True, useEdgeIndex=False, useEdgeLength=False, tolerance=0.0001):
|
176
|
+
def AdjacencyMatrix(graph, vertexKey=None, reverse=False, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=True, useEdgeIndex=False, useEdgeLength=False, tolerance=0.0001):
|
177
177
|
"""
|
178
178
|
Returns the adjacency matrix of the input Graph. See https://en.wikipedia.org/wiki/Adjacency_matrix.
|
179
179
|
|
@@ -181,6 +181,10 @@ class Graph:
|
|
181
181
|
----------
|
182
182
|
graph : topologic.Graph
|
183
183
|
The input graph.
|
184
|
+
vertexKey : str , optional
|
185
|
+
If set, the returned list of vertices is sorted according to the dicitonary values stored under this key. The default is None.
|
186
|
+
reverse : bool , optional
|
187
|
+
If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. The default is False.
|
184
188
|
edgeKeyFwd : str , optional
|
185
189
|
If set, the value at this key in the connecting edge from start vertex to end verrtex (forward) will be used instead of the value 1. The default is None. useEdgeIndex and useEdgeLength override this setting.
|
186
190
|
edgeKeyBwd : str , optional
|
@@ -205,12 +209,24 @@ class Graph:
|
|
205
209
|
from topologicpy.Vertex import Vertex
|
206
210
|
from topologicpy.Edge import Edge
|
207
211
|
from topologicpy.Topology import Topology
|
212
|
+
from topologicpy.Dictionary import Dictionary
|
213
|
+
from topologicpy.Helper import Helper
|
208
214
|
|
209
215
|
if not isinstance(graph, topologic.Graph):
|
210
216
|
print("Graph.AdjacencyMatrix - Error: The input graph is not a valid graph. Returning None.")
|
211
217
|
return None
|
212
218
|
|
213
219
|
vertices = Graph.Vertices(graph)
|
220
|
+
if not vertexKey == None:
|
221
|
+
sorting_values = []
|
222
|
+
for v in vertices:
|
223
|
+
d = Topology.Dictionary(v)
|
224
|
+
value = Dictionary.ValueAtKey(d, vertexKey)
|
225
|
+
sorting_values.append(value)
|
226
|
+
vertices = Helper.Sort(vertices, sorting_values)
|
227
|
+
if reverse == True:
|
228
|
+
vertices.reverse()
|
229
|
+
|
214
230
|
edges = Graph.Edges(graph)
|
215
231
|
order = len(vertices)
|
216
232
|
matrix = []
|
@@ -256,7 +272,7 @@ class Graph:
|
|
256
272
|
return matrix
|
257
273
|
|
258
274
|
@staticmethod
|
259
|
-
def AdjacencyList(graph, tolerance=0.0001):
|
275
|
+
def AdjacencyList(graph, vertexKey=None, reverse=True, tolerance=0.0001):
|
260
276
|
"""
|
261
277
|
Returns the adjacency list of the input Graph. See https://en.wikipedia.org/wiki/Adjacency_list.
|
262
278
|
|
@@ -264,6 +280,10 @@ class Graph:
|
|
264
280
|
----------
|
265
281
|
graph : topologic.Graph
|
266
282
|
The input graph.
|
283
|
+
vertexKey : str , optional
|
284
|
+
If set, the returned list of vertices is sorted according to the dicitonary values stored under this key. The default is None.
|
285
|
+
reverse : bool , optional
|
286
|
+
If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. The default is False.
|
267
287
|
tolerance : float , optional
|
268
288
|
The desired tolerance. The default is 0.0001.
|
269
289
|
|
@@ -274,10 +294,21 @@ class Graph:
|
|
274
294
|
"""
|
275
295
|
from topologicpy.Vertex import Vertex
|
276
296
|
from topologicpy.Topology import Topology
|
297
|
+
from topologicpy.Helper import Helper
|
298
|
+
|
277
299
|
if not isinstance(graph, topologic.Graph):
|
278
300
|
print("Graph.AdjacencyList - Error: The input graph is not a valid graph. Returning None.")
|
279
301
|
return None
|
280
302
|
vertices = Graph.Vertices(graph)
|
303
|
+
if not vertexKey == None:
|
304
|
+
sorting_values = []
|
305
|
+
for v in vertices:
|
306
|
+
d = Topology.Dictionary(v)
|
307
|
+
value = Dictionary.ValueAtKey(d, vertexKey)
|
308
|
+
sorting_values.append(value)
|
309
|
+
vertices = Helper.Sort(vertices, sorting_values)
|
310
|
+
if reverse == True:
|
311
|
+
vertices.reverse()
|
281
312
|
order = len(vertices)
|
282
313
|
adjList = []
|
283
314
|
for i in range(order):
|
@@ -533,6 +564,7 @@ class Graph:
|
|
533
564
|
bidirectional=False,
|
534
565
|
includeAttributes=False,
|
535
566
|
includeLabel=False,
|
567
|
+
includeGeometry=False,
|
536
568
|
siteLabel = "Site_0001",
|
537
569
|
siteDictionary = None,
|
538
570
|
buildingLabel = "Building_0001",
|
@@ -541,6 +573,7 @@ class Graph:
|
|
541
573
|
floorLevels =[],
|
542
574
|
labelKey="label",
|
543
575
|
typeKey="type",
|
576
|
+
geometryKey="brep",
|
544
577
|
spaceType = "space",
|
545
578
|
wallType = "wall",
|
546
579
|
slabType = "slab",
|
@@ -561,6 +594,8 @@ class Graph:
|
|
561
594
|
If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
562
595
|
includeLabel : bool , optional
|
563
596
|
If set to True, a label is attached to each node. Otherwise, it is not. The default is False.
|
597
|
+
includeGeometry : bool , optional
|
598
|
+
If set to True, the geometry associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
564
599
|
siteLabel : str , optional
|
565
600
|
The desired site label. The default is "Site_0001".
|
566
601
|
siteDictionary : dict , optional
|
@@ -574,10 +609,12 @@ class Graph:
|
|
574
609
|
floorLevels : list , optional
|
575
610
|
The list of floor levels. This should be a numeric list, sorted from lowest to highest.
|
576
611
|
If not provided, floorLevels will be computed automatically based on the vertices' 'z' attribute.
|
577
|
-
typeKey : str , optional
|
578
|
-
The dictionary key to use to look up the type of the node. The default is "type".
|
579
612
|
labelKey : str , optional
|
580
613
|
The dictionary key to use to look up the label of the node. The default is "label".
|
614
|
+
typeKey : str , optional
|
615
|
+
The dictionary key to use to look up the type of the node. The default is "type".
|
616
|
+
geometryKey : str , optional
|
617
|
+
The dictionary key to use to look up the geometry of the node. The default is "brep".
|
581
618
|
spaceType : str , optional
|
582
619
|
The dictionary string value to use to look up vertices of type "space". The default is "space".
|
583
620
|
wallType : str , optional
|
@@ -628,7 +665,6 @@ class Graph:
|
|
628
665
|
|
629
666
|
# Define namespaces
|
630
667
|
rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
|
631
|
-
rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#")
|
632
668
|
bot = Namespace("https://w3id.org/bot#")
|
633
669
|
|
634
670
|
# Define a custom prefix mapping
|
@@ -714,10 +750,13 @@ class Graph:
|
|
714
750
|
|
715
751
|
if includeAttributes:
|
716
752
|
for key, value in attributes.items():
|
753
|
+
if key == geometryKey:
|
754
|
+
if includeGeometry:
|
755
|
+
bot_graph.add((node_uri, bot.hasSimpleGeometry, Literal(value)))
|
717
756
|
if key == labelKey:
|
718
757
|
if includeLabel:
|
719
758
|
bot_graph.add((node_uri, RDFS.label, Literal(value)))
|
720
|
-
elif key != typeKey:
|
759
|
+
elif key != typeKey and key != geometryKey:
|
721
760
|
bot_graph.add((node_uri, bot[key], Literal(value)))
|
722
761
|
if includeLabel:
|
723
762
|
for key, value in attributes.items():
|
@@ -754,6 +793,7 @@ class Graph:
|
|
754
793
|
bidirectional=False,
|
755
794
|
includeAttributes=False,
|
756
795
|
includeLabel=False,
|
796
|
+
includeGeometry=False,
|
757
797
|
siteLabel = "Site_0001",
|
758
798
|
siteDictionary = None,
|
759
799
|
buildingLabel = "Building_0001",
|
@@ -762,6 +802,7 @@ class Graph:
|
|
762
802
|
floorLevels =[],
|
763
803
|
labelKey="label",
|
764
804
|
typeKey="type",
|
805
|
+
geometryKey="brep",
|
765
806
|
spaceType = "space",
|
766
807
|
wallType = "wall",
|
767
808
|
slabType = "slab",
|
@@ -793,6 +834,8 @@ class Graph:
|
|
793
834
|
If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
794
835
|
includeLabel : bool , optional
|
795
836
|
If set to True, a label is attached to each node. Otherwise, it is not. The default is False.
|
837
|
+
includeGeometry : bool , optional
|
838
|
+
If set to True, the geometry associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
796
839
|
siteLabel : str , optional
|
797
840
|
The desired site label. The default is "Site_0001".
|
798
841
|
siteDictionary : dict , optional
|
@@ -834,6 +877,7 @@ class Graph:
|
|
834
877
|
bidirectional=bidirectional,
|
835
878
|
includeAttributes=includeAttributes,
|
836
879
|
includeLabel=includeLabel,
|
880
|
+
includeGeometry=includeGeometry,
|
837
881
|
siteLabel=siteLabel,
|
838
882
|
siteDictionary=siteDictionary,
|
839
883
|
buildingLabel=buildingLabel,
|
@@ -842,6 +886,7 @@ class Graph:
|
|
842
886
|
floorLevels=floorLevels,
|
843
887
|
labelKey=labelKey,
|
844
888
|
typeKey=typeKey,
|
889
|
+
geometryKey=geometryKey,
|
845
890
|
spaceType = spaceType,
|
846
891
|
wallType = wallType,
|
847
892
|
slabType = slabType,
|
@@ -1007,21 +1052,189 @@ class Graph:
|
|
1007
1052
|
x, y, z = random.uniform(xMin,xMax), random.uniform(yMin,yMax), random.uniform(zMin,zMax)
|
1008
1053
|
vertices.append(Vertex.ByCoordinates(x, y, z))
|
1009
1054
|
|
1010
|
-
# Add edges based on the adjacency matrix
|
1011
|
-
edges = []
|
1012
|
-
for i in range(len(adjacencyMatrix)):
|
1013
|
-
for j in range(i + 1, len(adjacencyMatrix[i])):
|
1014
|
-
if adjacencyMatrix[i][j] == 1:
|
1015
|
-
edges.append(Edge.ByVertices([vertices[i], vertices[j]]))
|
1016
|
-
|
1017
1055
|
# Create the graph using vertices and edges
|
1018
1056
|
if len(vertices) == 0:
|
1019
1057
|
print("Graph.ByAdjacencyMatrix - Error: The graph does not contain any vertices. Returning None.")
|
1020
1058
|
return None
|
1021
1059
|
|
1060
|
+
# Add edges based on the adjacency matrix
|
1061
|
+
edges = []
|
1062
|
+
for i in range(len(adjacencyMatrix)):
|
1063
|
+
for j in range(i+1, len(adjacencyMatrix)):
|
1064
|
+
if not adjacencyMatrix[i][j] == 0:
|
1065
|
+
edges.append(Edge.ByVertices([vertices[i], vertices[j]]))
|
1066
|
+
|
1022
1067
|
return Graph.ByVerticesEdges(vertices, edges)
|
1023
1068
|
|
1024
1069
|
@staticmethod
|
1070
|
+
def ByBOTGraph(botGraph,
|
1071
|
+
includeContext = False,
|
1072
|
+
xMin = -0.5,
|
1073
|
+
xMax = 0.5,
|
1074
|
+
yMin = -0.5,
|
1075
|
+
yMax = 0.5,
|
1076
|
+
zMin = -0.5,
|
1077
|
+
zMax = 0.5,
|
1078
|
+
tolerance = 0.0001
|
1079
|
+
):
|
1080
|
+
|
1081
|
+
def value_by_string(s):
|
1082
|
+
if s.lower() == "true":
|
1083
|
+
return True
|
1084
|
+
if s.lower() == "false":
|
1085
|
+
return False
|
1086
|
+
vt = "str"
|
1087
|
+
s2 = s.strip("-")
|
1088
|
+
if s2.isnumeric():
|
1089
|
+
vt = "int"
|
1090
|
+
else:
|
1091
|
+
try:
|
1092
|
+
s3 = s2.split(".")[0]
|
1093
|
+
s4 = s2.split(".")[1]
|
1094
|
+
if (s3.isnumeric() or s4.isnumeric()):
|
1095
|
+
vt = "float"
|
1096
|
+
except:
|
1097
|
+
vt = "str"
|
1098
|
+
if vt == "str":
|
1099
|
+
return s
|
1100
|
+
elif vt == "int":
|
1101
|
+
return int(s)
|
1102
|
+
elif vt == "float":
|
1103
|
+
return float(s)
|
1104
|
+
|
1105
|
+
def collect_nodes_by_type(rdf_graph, node_type=None):
|
1106
|
+
results = set()
|
1107
|
+
|
1108
|
+
if node_type is not None:
|
1109
|
+
for subj, pred, obj in rdf_graph.triples((None, None, None)):
|
1110
|
+
if "type" in pred.lower():
|
1111
|
+
if node_type.lower() in obj.lower():
|
1112
|
+
results.add(subj)
|
1113
|
+
return list(results)
|
1114
|
+
|
1115
|
+
def collect_attributes_for_subject(rdf_graph, subject):
|
1116
|
+
attributes = {}
|
1117
|
+
|
1118
|
+
for subj, pred, obj in rdf_graph.triples((subject, None, None)):
|
1119
|
+
predicate_str = str(pred)
|
1120
|
+
object_str = str(obj)
|
1121
|
+
attributes[predicate_str] = object_str
|
1122
|
+
|
1123
|
+
return attributes
|
1124
|
+
|
1125
|
+
def get_triples_by_predicate_type(rdf_graph, predicate_type):
|
1126
|
+
triples = []
|
1127
|
+
|
1128
|
+
for subj, pred, obj in rdf_graph:
|
1129
|
+
if pred.split('#')[-1].lower() == predicate_type.lower():
|
1130
|
+
triples.append((str(subj), str(pred), str(obj)))
|
1131
|
+
|
1132
|
+
return triples
|
1133
|
+
|
1134
|
+
from topologicpy.Vertex import Vertex
|
1135
|
+
from topologicpy.Edge import Edge
|
1136
|
+
from topologicpy.Graph import Graph
|
1137
|
+
from topologicpy.Dictionary import Dictionary
|
1138
|
+
from topologicpy.Topology import Topology
|
1139
|
+
|
1140
|
+
import rdflib
|
1141
|
+
import random
|
1142
|
+
predicates = ['adjacentto', 'interfaceof', 'containselement', 'connectsto']
|
1143
|
+
bot_types = ['Space', 'Wall', 'Slab', 'Door', 'Window', 'Element']
|
1144
|
+
|
1145
|
+
if includeContext:
|
1146
|
+
predicates += ['hasspace', 'hasbuilding', 'hasstorey']
|
1147
|
+
bot_types += ['Site', 'Building', 'Storey']
|
1148
|
+
|
1149
|
+
|
1150
|
+
namespaces = botGraph.namespaces()
|
1151
|
+
|
1152
|
+
for ns in namespaces:
|
1153
|
+
if 'bot' in ns[0].lower():
|
1154
|
+
bot_namespace = ns
|
1155
|
+
break
|
1156
|
+
|
1157
|
+
ref = bot_namespace[1]
|
1158
|
+
|
1159
|
+
nodes = []
|
1160
|
+
for bot_type in bot_types:
|
1161
|
+
node_type = rdflib.term.URIRef(ref+bot_type)
|
1162
|
+
nodes +=collect_nodes_by_type(botGraph, node_type=node_type)
|
1163
|
+
|
1164
|
+
vertices = []
|
1165
|
+
dic = {}
|
1166
|
+
for node in nodes:
|
1167
|
+
x, y, z = random.uniform(xMin,xMax), random.uniform(yMin,yMax), random.uniform(zMin,zMax)
|
1168
|
+
d_keys = ["bot_id"]
|
1169
|
+
d_values = [str(node)]
|
1170
|
+
attributes = collect_attributes_for_subject(botGraph, node)
|
1171
|
+
keys = attributes.keys()
|
1172
|
+
for key in keys:
|
1173
|
+
key_type = key.split('#')[-1]
|
1174
|
+
if key_type.lower() not in predicates:
|
1175
|
+
if 'x' == key_type.lower():
|
1176
|
+
x = value_by_string(attributes[key])
|
1177
|
+
d_keys.append('x')
|
1178
|
+
d_values.append(x)
|
1179
|
+
elif 'y' == key_type.lower():
|
1180
|
+
y = value_by_string(attributes[key])
|
1181
|
+
d_keys.append('y')
|
1182
|
+
d_values.append(y)
|
1183
|
+
elif 'z' == key_type.lower():
|
1184
|
+
z = value_by_string(attributes[key])
|
1185
|
+
d_keys.append('z')
|
1186
|
+
d_values.append(z)
|
1187
|
+
else:
|
1188
|
+
d_keys.append(key_type.lower())
|
1189
|
+
d_values.append(value_by_string(attributes[key].split("#")[-1]))
|
1190
|
+
|
1191
|
+
d = Dictionary.ByKeysValues(d_keys, d_values)
|
1192
|
+
v = Vertex.ByCoordinates(x,y,z)
|
1193
|
+
v = Topology.SetDictionary(v, d)
|
1194
|
+
dic[str(node)] = v
|
1195
|
+
vertices.append(v)
|
1196
|
+
|
1197
|
+
edges = []
|
1198
|
+
for predicate in predicates:
|
1199
|
+
triples = get_triples_by_predicate_type(botGraph, predicate)
|
1200
|
+
for triple in triples:
|
1201
|
+
subj = triple[0]
|
1202
|
+
obj = triple[2]
|
1203
|
+
sv = dic[subj]
|
1204
|
+
ev = dic[obj]
|
1205
|
+
e = Edge.ByVertices([sv,ev], tolerance=tolerance)
|
1206
|
+
d = Dictionary.ByKeyValue("type", predicate)
|
1207
|
+
e = Topology.SetDictionary(e, d)
|
1208
|
+
edges.append(e)
|
1209
|
+
|
1210
|
+
return Graph.ByVerticesEdges(vertices, edges)
|
1211
|
+
|
1212
|
+
@staticmethod
|
1213
|
+
def ByBOTPath(path,
|
1214
|
+
includeContext = False,
|
1215
|
+
xMin = -0.5,
|
1216
|
+
xMax = 0.5,
|
1217
|
+
yMin = -0.5,
|
1218
|
+
yMax = 0.5,
|
1219
|
+
zMin = -0.5,
|
1220
|
+
zMax = 0.5,
|
1221
|
+
tolerance = 0.0001
|
1222
|
+
):
|
1223
|
+
|
1224
|
+
from rdflib import Graph as RDFGraph
|
1225
|
+
bot_graph = RDFGraph()
|
1226
|
+
bot_graph.parse(path)
|
1227
|
+
return Graph.ByBOTGraph(bot_graph,
|
1228
|
+
includeContext = includeContext,
|
1229
|
+
xMin = xMin,
|
1230
|
+
xMax = xMax,
|
1231
|
+
yMin = yMin,
|
1232
|
+
yMax = yMax,
|
1233
|
+
zMin = zMin,
|
1234
|
+
zMax = zMax,
|
1235
|
+
tolerance = tolerance
|
1236
|
+
)
|
1237
|
+
@staticmethod
|
1025
1238
|
def ByCSVPath(path,
|
1026
1239
|
graphIDHeader="graph_id", graphLabelHeader="label", graphFeaturesHeader="feat", graphFeaturesKeys=[],
|
1027
1240
|
edgeSRCHeader="src_id", edgeDSTHeader="dst_id", edgeLabelHeader="label", edgeTrainMaskHeader="train_mask",
|
@@ -1747,7 +1960,7 @@ class Graph:
|
|
1747
1960
|
return Graph.ByVerticesEdges(g_vertices, g_edges)
|
1748
1961
|
|
1749
1962
|
@staticmethod
|
1750
|
-
def ByTopology(topology, direct=True, directApertures=False, viaSharedTopologies=False, viaSharedApertures=False, toExteriorTopologies=False, toExteriorApertures=False, toContents=False, toOutposts=False, idKey="TOPOLOGIC_ID", outpostsKey="outposts", useInternalVertex=True,
|
1963
|
+
def ByTopology(topology, direct=True, directApertures=False, viaSharedTopologies=False, viaSharedApertures=False, toExteriorTopologies=False, toExteriorApertures=False, toContents=False, toOutposts=False, idKey="TOPOLOGIC_ID", outpostsKey="outposts", useInternalVertex=True, storeBREP=False, tolerance=0.0001):
|
1751
1964
|
"""
|
1752
1965
|
Creates a graph.See https://en.wikipedia.org/wiki/Graph_(discrete_mathematics).
|
1753
1966
|
|
@@ -1777,7 +1990,7 @@ class Graph:
|
|
1777
1990
|
The key to use to find the list of outposts. It is case insensitive. The default is "outposts".
|
1778
1991
|
useInternalVertex : bool , optional
|
1779
1992
|
If set to True, use an internal vertex to represent the subtopology. Otherwise, use its centroid. The default is False.
|
1780
|
-
|
1993
|
+
storeBREP : bool , optional
|
1781
1994
|
If set to True, store the BRep of the subtopology in its representative vertex. The default is False.
|
1782
1995
|
tolerance : float , optional
|
1783
1996
|
The desired tolerance. The default is 0.0001.
|
@@ -1896,7 +2109,7 @@ class Graph:
|
|
1896
2109
|
return returnList
|
1897
2110
|
|
1898
2111
|
def processCellComplex(item):
|
1899
|
-
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
2112
|
+
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
1900
2113
|
edges = []
|
1901
2114
|
vertices = []
|
1902
2115
|
cellmat = []
|
@@ -1996,7 +2209,7 @@ class Graph:
|
|
1996
2209
|
vop = Topology.CenterOfMass(outpost)
|
1997
2210
|
vcc = Topology.CenterOfMass(topology)
|
1998
2211
|
d1 = Topology.Dictionary(vcc)
|
1999
|
-
if
|
2212
|
+
if storeBREP:
|
2000
2213
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2001
2214
|
d3 = mergeDictionaries2([d1, d2])
|
2002
2215
|
_ = vcc.SetDictionary(d3)
|
@@ -2018,7 +2231,7 @@ class Graph:
|
|
2018
2231
|
else:
|
2019
2232
|
vCell = aCell.CenterOfMass()
|
2020
2233
|
d1 = aCell.GetDictionary()
|
2021
|
-
if
|
2234
|
+
if storeBREP:
|
2022
2235
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aCell), Topology.Type(aCell), Topology.TypeAsString(aCell)])
|
2023
2236
|
d3 = mergeDictionaries2([d1, d2])
|
2024
2237
|
_ = vCell.SetDictionary(d3)
|
@@ -2056,7 +2269,7 @@ class Graph:
|
|
2056
2269
|
else:
|
2057
2270
|
vst = sharedTopology.CenterOfMass()
|
2058
2271
|
d1 = sharedTopology.GetDictionary()
|
2059
|
-
if
|
2272
|
+
if storeBREP:
|
2060
2273
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2061
2274
|
d3 = mergeDictionaries2([d1, d2])
|
2062
2275
|
_ = vst.SetDictionary(d3)
|
@@ -2079,7 +2292,7 @@ class Graph:
|
|
2079
2292
|
vst2 = content.CenterOfMass()
|
2080
2293
|
d1 = content.GetDictionary()
|
2081
2294
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X(), vst2.Y(), vst2.Z())
|
2082
|
-
if
|
2295
|
+
if storeBREP:
|
2083
2296
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2084
2297
|
d3 = mergeDictionaries2([d1, d2])
|
2085
2298
|
_ = vst2.SetDictionary(d3)
|
@@ -2099,8 +2312,8 @@ class Graph:
|
|
2099
2312
|
vsa = sharedAp.CenterOfMass()
|
2100
2313
|
d1 = sharedAp.GetDictionary()
|
2101
2314
|
vsa = topologic.Vertex.ByCoordinates(vsa.X()+(tolerance*100), vsa.Y()+(tolerance*100), vsa.Z()+(tolerance*100))
|
2102
|
-
if
|
2103
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
2315
|
+
if storeBREP:
|
2316
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
2104
2317
|
d3 = mergeDictionaries2([d1, d2])
|
2105
2318
|
_ = vsa.SetDictionary(d3)
|
2106
2319
|
else:
|
@@ -2118,7 +2331,7 @@ class Graph:
|
|
2118
2331
|
vet = exteriorTopology.CenterOfMass()
|
2119
2332
|
_ = vet.SetDictionary(exteriorTopology.GetDictionary())
|
2120
2333
|
d1 = exteriorTopology.GetDictionary()
|
2121
|
-
if
|
2334
|
+
if storeBREP:
|
2122
2335
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2123
2336
|
d3 = mergeDictionaries2([d1, d2])
|
2124
2337
|
_ = vet.SetDictionary(d3)
|
@@ -2141,7 +2354,7 @@ class Graph:
|
|
2141
2354
|
vst2 = content.CenterOfMass()
|
2142
2355
|
d1 = content.GetDictionary()
|
2143
2356
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2144
|
-
if
|
2357
|
+
if storeBREP:
|
2145
2358
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2146
2359
|
d3 = mergeDictionaries2([d1, d2])
|
2147
2360
|
_ = vst2.SetDictionary(d3)
|
@@ -2154,15 +2367,15 @@ class Graph:
|
|
2154
2367
|
edges.append(tempe)
|
2155
2368
|
if toExteriorApertures:
|
2156
2369
|
for exteriorAperture in exteriorApertures:
|
2157
|
-
|
2370
|
+
exTop = exteriorAperture.Topology()
|
2158
2371
|
if useInternalVertex == True:
|
2159
|
-
vea = Topology.InternalVertex(
|
2372
|
+
vea = Topology.InternalVertex(exTop, tolerance)
|
2160
2373
|
else:
|
2161
|
-
vea =
|
2162
|
-
d1 =
|
2374
|
+
vea = exTop.CenterOfMass()
|
2375
|
+
d1 = exTop.GetDictionary()
|
2163
2376
|
vea = topologic.Vertex.ByCoordinates(vea.X()+(tolerance*100), vea.Y()+(tolerance*100), vea.Z()+(tolerance*100))
|
2164
|
-
if
|
2165
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
2377
|
+
if storeBREP:
|
2378
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2166
2379
|
d3 = mergeDictionaries2([d1, d2])
|
2167
2380
|
_ = vea.SetDictionary(d3)
|
2168
2381
|
else:
|
@@ -2184,7 +2397,7 @@ class Graph:
|
|
2184
2397
|
vcn = content.CenterOfMass()
|
2185
2398
|
vcn = topologic.Vertex.ByCoordinates(vcn.X()+(tolerance*100), vcn.Y()+(tolerance*100), vcn.Z()+(tolerance*100))
|
2186
2399
|
d1 = content.GetDictionary()
|
2187
|
-
if
|
2400
|
+
if storeBREP:
|
2188
2401
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2189
2402
|
d3 = mergeDictionaries2([d1, d2])
|
2190
2403
|
_ = vcn.SetDictionary(d3)
|
@@ -2202,7 +2415,7 @@ class Graph:
|
|
2202
2415
|
else:
|
2203
2416
|
vCell = aCell.CenterOfMass()
|
2204
2417
|
d1 = aCell.GetDictionary()
|
2205
|
-
if
|
2418
|
+
if storeBREP:
|
2206
2419
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aCell), Topology.Type(aCell), Topology.TypeAsString(aCell)])
|
2207
2420
|
d3 = mergeDictionaries2([d1, d2])
|
2208
2421
|
_ = vCell.SetDictionary(d3)
|
@@ -2212,7 +2425,7 @@ class Graph:
|
|
2212
2425
|
return [vertices,edges]
|
2213
2426
|
|
2214
2427
|
def processCell(item):
|
2215
|
-
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
2428
|
+
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
2216
2429
|
vertices = []
|
2217
2430
|
edges = []
|
2218
2431
|
if useInternalVertex == True:
|
@@ -2220,7 +2433,7 @@ class Graph:
|
|
2220
2433
|
else:
|
2221
2434
|
vCell = topology.CenterOfMass()
|
2222
2435
|
d1 = topology.GetDictionary()
|
2223
|
-
if
|
2436
|
+
if storeBREP:
|
2224
2437
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2225
2438
|
d3 = mergeDictionaries2([d1, d2])
|
2226
2439
|
_ = vCell.SetDictionary(d3)
|
@@ -2267,7 +2480,7 @@ class Graph:
|
|
2267
2480
|
else:
|
2268
2481
|
vst = exteriorTopology.CenterOfMass()
|
2269
2482
|
d1 = exteriorTopology.GetDictionary()
|
2270
|
-
if
|
2483
|
+
if storeBREP:
|
2271
2484
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2272
2485
|
d3 = mergeDictionaries2([d1, d2])
|
2273
2486
|
_ = vst.SetDictionary(d3)
|
@@ -2290,7 +2503,7 @@ class Graph:
|
|
2290
2503
|
vst2 = content.CenterOfMass()
|
2291
2504
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2292
2505
|
d1 = content.GetDictionary()
|
2293
|
-
if
|
2506
|
+
if storeBREP:
|
2294
2507
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2295
2508
|
d3 = mergeDictionaries2([d1, d2])
|
2296
2509
|
_ = vst2.SetDictionary(d3)
|
@@ -2303,15 +2516,15 @@ class Graph:
|
|
2303
2516
|
edges.append(tempe)
|
2304
2517
|
if toExteriorApertures:
|
2305
2518
|
for exteriorAperture in exteriorApertures:
|
2306
|
-
|
2519
|
+
exTop = exteriorAperture.Topology()
|
2307
2520
|
if useInternalVertex == True:
|
2308
|
-
vst = Topology.InternalVertex(
|
2521
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
2309
2522
|
else:
|
2310
|
-
vst =
|
2311
|
-
d1 =
|
2523
|
+
vst = exTop.CenterOfMass()
|
2524
|
+
d1 = exTop.GetDictionary()
|
2312
2525
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2313
|
-
if
|
2314
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
2526
|
+
if storeBREP:
|
2527
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2315
2528
|
d3 = mergeDictionaries2([d1, d2])
|
2316
2529
|
_ = vst.SetDictionary(d3)
|
2317
2530
|
else:
|
@@ -2333,7 +2546,7 @@ class Graph:
|
|
2333
2546
|
vst = content.CenterOfMass()
|
2334
2547
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2335
2548
|
d1 = content.GetDictionary()
|
2336
|
-
if
|
2549
|
+
if storeBREP:
|
2337
2550
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2338
2551
|
d3 = mergeDictionaries2([d1, d2])
|
2339
2552
|
_ = vst.SetDictionary(d3)
|
@@ -2348,7 +2561,7 @@ class Graph:
|
|
2348
2561
|
|
2349
2562
|
def processShell(item):
|
2350
2563
|
from topologicpy.Face import Face
|
2351
|
-
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
2564
|
+
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
2352
2565
|
graph = None
|
2353
2566
|
edges = []
|
2354
2567
|
vertices = []
|
@@ -2465,7 +2678,7 @@ class Graph:
|
|
2465
2678
|
else:
|
2466
2679
|
vst = sharedTopology.CenterOfMass()
|
2467
2680
|
d1 = sharedTopology.GetDictionary()
|
2468
|
-
if
|
2681
|
+
if storeBREP:
|
2469
2682
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2470
2683
|
d3 = mergeDictionaries2([d1, d2])
|
2471
2684
|
_ = vst.SetDictionary(d3)
|
@@ -2488,7 +2701,7 @@ class Graph:
|
|
2488
2701
|
vst2 = content.CenterOfMass()
|
2489
2702
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2490
2703
|
d1 = content.GetDictionary()
|
2491
|
-
if
|
2704
|
+
if storeBREP:
|
2492
2705
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2493
2706
|
d3 = mergeDictionaries2([d1, d2])
|
2494
2707
|
_ = vst2.SetDictionary(d3)
|
@@ -2501,14 +2714,15 @@ class Graph:
|
|
2501
2714
|
edges.append(tempe)
|
2502
2715
|
if viaSharedApertures:
|
2503
2716
|
for sharedAperture in sharedApertures:
|
2717
|
+
sharedAp = Aperture.Topology(sharedAperture)
|
2504
2718
|
if useInternalVertex == True:
|
2505
|
-
vst = Topology.InternalVertex(
|
2719
|
+
vst = Topology.InternalVertex(sharedAp, tolerance)
|
2506
2720
|
else:
|
2507
|
-
vst =
|
2508
|
-
d1 =
|
2721
|
+
vst = sharedAp.CenterOfMass()
|
2722
|
+
d1 = sharedAp.GetDictionary()
|
2509
2723
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2510
|
-
if
|
2511
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
2724
|
+
if storeBREP:
|
2725
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
2512
2726
|
d3 = mergeDictionaries2([d1, d2])
|
2513
2727
|
_ = vst.SetDictionary(d3)
|
2514
2728
|
else:
|
@@ -2525,7 +2739,7 @@ class Graph:
|
|
2525
2739
|
else:
|
2526
2740
|
vst = exteriorTopology.CenterOfMass()
|
2527
2741
|
d1 = exteriorTopology.GetDictionary()
|
2528
|
-
if
|
2742
|
+
if storeBREP:
|
2529
2743
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2530
2744
|
d3 = mergeDictionaries2([d1, d2])
|
2531
2745
|
_ = vst.SetDictionary(d3)
|
@@ -2548,7 +2762,7 @@ class Graph:
|
|
2548
2762
|
vst2 = content.CenterOfMass()
|
2549
2763
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2550
2764
|
d1 = content.GetDictionary()
|
2551
|
-
if
|
2765
|
+
if storeBREP:
|
2552
2766
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2553
2767
|
d3 = mergeDictionaries2([d1, d2])
|
2554
2768
|
_ = vst2.SetDictionary(d3)
|
@@ -2561,15 +2775,15 @@ class Graph:
|
|
2561
2775
|
edges.append(tempe)
|
2562
2776
|
if toExteriorApertures:
|
2563
2777
|
for exteriorAperture in exteriorApertures:
|
2564
|
-
|
2778
|
+
exTop = exteriorAperture.Topology()
|
2565
2779
|
if useInternalVertex == True:
|
2566
|
-
vst = Topology.InternalVertex(
|
2780
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
2567
2781
|
else:
|
2568
|
-
vst =
|
2569
|
-
d1 =
|
2782
|
+
vst = exTop.CenterOfMass()
|
2783
|
+
d1 = exTop.GetDictionary()
|
2570
2784
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2571
|
-
if
|
2572
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
2785
|
+
if storeBREP:
|
2786
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2573
2787
|
d3 = mergeDictionaries2([d1, d2])
|
2574
2788
|
_ = vst.SetDictionary(d3)
|
2575
2789
|
else:
|
@@ -2591,7 +2805,7 @@ class Graph:
|
|
2591
2805
|
vst = content.CenterOfMass()
|
2592
2806
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2593
2807
|
d1 = content.GetDictionary()
|
2594
|
-
if
|
2808
|
+
if storeBREP:
|
2595
2809
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2596
2810
|
d3 = mergeDictionaries2([d1, d2])
|
2597
2811
|
_ = vst.SetDictionary(d3)
|
@@ -2609,7 +2823,7 @@ class Graph:
|
|
2609
2823
|
else:
|
2610
2824
|
vFace = aFace.CenterOfMass()
|
2611
2825
|
d1 = aFace.GetDictionary()
|
2612
|
-
if
|
2826
|
+
if storeBREP:
|
2613
2827
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aFace), Topology.Type(aFace), Topology.TypeAsString(aFace)])
|
2614
2828
|
d3 = mergeDictionaries2([d1, d2])
|
2615
2829
|
_ = vFace.SetDictionary(d3)
|
@@ -2639,7 +2853,7 @@ class Graph:
|
|
2639
2853
|
vop = Topology.CenterOfMass(outpost)
|
2640
2854
|
vcc = Topology.CenterOfMass(topology)
|
2641
2855
|
d1 = Topology.Dictionary(vcc)
|
2642
|
-
if
|
2856
|
+
if storeBREP:
|
2643
2857
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2644
2858
|
d3 = mergeDictionaries2([d1, d2])
|
2645
2859
|
_ = vcc.SetDictionary(d3)
|
@@ -2654,7 +2868,7 @@ class Graph:
|
|
2654
2868
|
|
2655
2869
|
def processFace(item):
|
2656
2870
|
from topologicpy.Face import Face
|
2657
|
-
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
2871
|
+
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
2658
2872
|
graph = None
|
2659
2873
|
vertices = []
|
2660
2874
|
edges = []
|
@@ -2664,7 +2878,7 @@ class Graph:
|
|
2664
2878
|
else:
|
2665
2879
|
vFace = topology.CenterOfMass()
|
2666
2880
|
d1 = topology.GetDictionary()
|
2667
|
-
if
|
2881
|
+
if storeBREP:
|
2668
2882
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2669
2883
|
d3 = mergeDictionaries2([d1, d2])
|
2670
2884
|
_ = vFace.SetDictionary(d3)
|
@@ -2714,7 +2928,7 @@ class Graph:
|
|
2714
2928
|
else:
|
2715
2929
|
vst = exteriorTopology.CenterOfMass()
|
2716
2930
|
d1 = exteriorTopology.GetDictionary()
|
2717
|
-
if
|
2931
|
+
if storeBREP:
|
2718
2932
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2719
2933
|
d3 = mergeDictionaries2([d1, d2])
|
2720
2934
|
_ = vst.SetDictionary(d3)
|
@@ -2737,7 +2951,7 @@ class Graph:
|
|
2737
2951
|
vst2 = content.CenterOfMass()
|
2738
2952
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2739
2953
|
d1 = content.GetDictionary()
|
2740
|
-
if
|
2954
|
+
if storeBREP:
|
2741
2955
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2742
2956
|
d3 = mergeDictionaries2([d1, d2])
|
2743
2957
|
_ = vst2.SetDictionary(d3)
|
@@ -2750,15 +2964,15 @@ class Graph:
|
|
2750
2964
|
edges.append(tempe)
|
2751
2965
|
if toExteriorApertures:
|
2752
2966
|
for exteriorAperture in exteriorApertures:
|
2753
|
-
|
2967
|
+
exTop = exteriorAperture.Topology()
|
2754
2968
|
if useInternalVertex == True:
|
2755
|
-
vst = Topology.InternalVertex(
|
2969
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
2756
2970
|
else:
|
2757
|
-
vst =
|
2758
|
-
d1 =
|
2971
|
+
vst = exTop.CenterOfMass()
|
2972
|
+
d1 = exTop.GetDictionary()
|
2759
2973
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2760
|
-
if
|
2761
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
2974
|
+
if storeBREP:
|
2975
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2762
2976
|
d3 = mergeDictionaries2([d1, d2])
|
2763
2977
|
_ = vst.SetDictionary(d3)
|
2764
2978
|
else:
|
@@ -2780,7 +2994,7 @@ class Graph:
|
|
2780
2994
|
vst = content.CenterOfMass()
|
2781
2995
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2782
2996
|
d1 = content.GetDictionary()
|
2783
|
-
if
|
2997
|
+
if storeBREP:
|
2784
2998
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2785
2999
|
d3 = mergeDictionaries2([d1, d2])
|
2786
3000
|
_ = vst.SetDictionary(d3)
|
@@ -2794,7 +3008,7 @@ class Graph:
|
|
2794
3008
|
return [vertices, edges]
|
2795
3009
|
|
2796
3010
|
def processWire(item):
|
2797
|
-
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
3011
|
+
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
2798
3012
|
graph = None
|
2799
3013
|
edges = []
|
2800
3014
|
vertices = []
|
@@ -2886,7 +3100,7 @@ class Graph:
|
|
2886
3100
|
except:
|
2887
3101
|
vEdge = anEdge.CenterOfMass()
|
2888
3102
|
d1 = anEdge.GetDictionary()
|
2889
|
-
if
|
3103
|
+
if storeBREP:
|
2890
3104
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(anEdge), Topology.Type(anEdge), Topology.TypeAsString(anEdge)])
|
2891
3105
|
d3 = mergeDictionaries2([d1, d2])
|
2892
3106
|
_ = vEdge.SetDictionary(d3)
|
@@ -2920,7 +3134,7 @@ class Graph:
|
|
2920
3134
|
for sharedTopology in sharedTopologies:
|
2921
3135
|
vst = sharedTopology.CenterOfMass()
|
2922
3136
|
d1 = sharedTopology.GetDictionary()
|
2923
|
-
if
|
3137
|
+
if storeBREP:
|
2924
3138
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2925
3139
|
d3 = mergeDictionaries2([d1, d2])
|
2926
3140
|
_ = vst.SetDictionary(d3)
|
@@ -2943,7 +3157,7 @@ class Graph:
|
|
2943
3157
|
vst2 = content.CenterOfMass()
|
2944
3158
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2945
3159
|
d1 = content.GetDictionary()
|
2946
|
-
if
|
3160
|
+
if storeBREP:
|
2947
3161
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2948
3162
|
d3 = mergeDictionaries2([d1, d2])
|
2949
3163
|
_ = vst2.SetDictionary(d3)
|
@@ -2956,15 +3170,15 @@ class Graph:
|
|
2956
3170
|
edges.append(tempe)
|
2957
3171
|
if viaSharedApertures:
|
2958
3172
|
for sharedAperture in sharedApertures:
|
2959
|
-
|
3173
|
+
sharedAp = sharedAperture.Topology()
|
2960
3174
|
if useInternalVertex == True:
|
2961
|
-
vst = Topology.InternalVertex(
|
3175
|
+
vst = Topology.InternalVertex(sharedAp, tolerance)
|
2962
3176
|
else:
|
2963
|
-
vst =
|
2964
|
-
d1 =
|
3177
|
+
vst = sharedAp.CenterOfMass()
|
3178
|
+
d1 = sharedAp.GetDictionary()
|
2965
3179
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2966
|
-
if
|
2967
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
3180
|
+
if storeBREP:
|
3181
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
2968
3182
|
d3 = mergeDictionaries2([d1, d2])
|
2969
3183
|
_ = vst.SetDictionary(d3)
|
2970
3184
|
else:
|
@@ -2994,7 +3208,7 @@ class Graph:
|
|
2994
3208
|
vst2 = content.CenterOfMass()
|
2995
3209
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2996
3210
|
d1 = content.GetDictionary()
|
2997
|
-
if
|
3211
|
+
if storeBREP:
|
2998
3212
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2999
3213
|
d3 = mergeDictionaries2([d1, d2])
|
3000
3214
|
_ = vst2.SetDictionary(d3)
|
@@ -3007,15 +3221,15 @@ class Graph:
|
|
3007
3221
|
edges.append(tempe)
|
3008
3222
|
if toExteriorApertures:
|
3009
3223
|
for exteriorAperture in exteriorApertures:
|
3010
|
-
|
3224
|
+
exTop = exteriorAperture.Topology()
|
3011
3225
|
if useInternalVertex == True:
|
3012
|
-
vst = Topology.InternalVertex(
|
3226
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
3013
3227
|
else:
|
3014
|
-
vst =
|
3015
|
-
d1 =
|
3228
|
+
vst = exTop.CenterOfMass()
|
3229
|
+
d1 = exTop.GetDictionary()
|
3016
3230
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3017
|
-
if
|
3018
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
3231
|
+
if storeBREP:
|
3232
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3019
3233
|
d3 = mergeDictionaries2([d1, d2])
|
3020
3234
|
_ = vst.SetDictionary(d3)
|
3021
3235
|
else:
|
@@ -3037,7 +3251,7 @@ class Graph:
|
|
3037
3251
|
vst = content.CenterOfMass()
|
3038
3252
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3039
3253
|
d1 = content.GetDictionary()
|
3040
|
-
if
|
3254
|
+
if storeBREP:
|
3041
3255
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3042
3256
|
d3 = mergeDictionaries2([d1, d2])
|
3043
3257
|
_ = vst.SetDictionary(d3)
|
@@ -3054,7 +3268,7 @@ class Graph:
|
|
3054
3268
|
except:
|
3055
3269
|
vEdge = anEdge.CenterOfMass()
|
3056
3270
|
d1 = anEdge.GetDictionary()
|
3057
|
-
if
|
3271
|
+
if storeBREP:
|
3058
3272
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(anEdge), Topology.Type(anEdge), Topology.TypeAsString(anEdge)])
|
3059
3273
|
d3 = mergeDictionaries2([d1, d2])
|
3060
3274
|
_ = vEdge.SetDictionary(d3)
|
@@ -3085,7 +3299,7 @@ class Graph:
|
|
3085
3299
|
vop = Topology.CenterOfMass(outpost)
|
3086
3300
|
vcc = Topology.CenterOfMass(topology)
|
3087
3301
|
d1 = Topology.Dictionary(vcc)
|
3088
|
-
if
|
3302
|
+
if storeBREP:
|
3089
3303
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3090
3304
|
d3 = mergeDictionaries2([d1, d2])
|
3091
3305
|
_ = vcc.SetDictionary(d3)
|
@@ -3100,7 +3314,7 @@ class Graph:
|
|
3100
3314
|
return [vertices, edges]
|
3101
3315
|
|
3102
3316
|
def processEdge(item):
|
3103
|
-
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
3317
|
+
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3104
3318
|
graph = None
|
3105
3319
|
vertices = []
|
3106
3320
|
edges = []
|
@@ -3114,7 +3328,7 @@ class Graph:
|
|
3114
3328
|
vEdge = topology.CenterOfMass()
|
3115
3329
|
|
3116
3330
|
d1 = vEdge.GetDictionary()
|
3117
|
-
if
|
3331
|
+
if storeBREP:
|
3118
3332
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3119
3333
|
d3 = mergeDictionaries2([d1, d2])
|
3120
3334
|
_ = vEdge.SetDictionary(d3)
|
@@ -3166,7 +3380,7 @@ class Graph:
|
|
3166
3380
|
else:
|
3167
3381
|
vst = exteriorTopology.CenterOfMass()
|
3168
3382
|
d1 = exteriorTopology.GetDictionary()
|
3169
|
-
if
|
3383
|
+
if storeBREP:
|
3170
3384
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
3171
3385
|
d3 = mergeDictionaries2([d1, d2])
|
3172
3386
|
_ = vst.SetDictionary(d3)
|
@@ -3189,7 +3403,7 @@ class Graph:
|
|
3189
3403
|
vst2 = content.CenterOfMass()
|
3190
3404
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
3191
3405
|
d1 = content.GetDictionary()
|
3192
|
-
if
|
3406
|
+
if storeBREP:
|
3193
3407
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3194
3408
|
d3 = mergeDictionaries2([d1, d2])
|
3195
3409
|
_ = vst2.SetDictionary(d3)
|
@@ -3202,20 +3416,20 @@ class Graph:
|
|
3202
3416
|
edges.append(tempe)
|
3203
3417
|
if toExteriorApertures:
|
3204
3418
|
for exteriorAperture in exteriorApertures:
|
3205
|
-
|
3419
|
+
exTop = exteriorAperture.Topology()
|
3206
3420
|
if useInternalVertex == True:
|
3207
|
-
vst = Topology.InternalVertex(
|
3421
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
3208
3422
|
else:
|
3209
|
-
vst =
|
3210
|
-
d1 =
|
3423
|
+
vst = exTop.CenterOfMass()
|
3424
|
+
d1 = exTop.GetDictionary()
|
3211
3425
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3212
|
-
if
|
3213
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(
|
3426
|
+
if storeBREP:
|
3427
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3214
3428
|
d3 = mergeDictionaries2([d1, d2])
|
3215
3429
|
_ = vst.SetDictionary(d3)
|
3216
3430
|
else:
|
3217
3431
|
_ = vst.SetDictionary(d1)
|
3218
|
-
_ = vst.SetDictionary(
|
3432
|
+
_ = vst.SetDictionary(exTop.GetDictionary())
|
3219
3433
|
vertices.append(vst)
|
3220
3434
|
tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3221
3435
|
tempd = Dictionary.ByKeysValues(["relationship"],["To Exterior Apertures"])
|
@@ -3225,7 +3439,7 @@ class Graph:
|
|
3225
3439
|
return [vertices, edges]
|
3226
3440
|
|
3227
3441
|
def processVertex(item):
|
3228
|
-
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
3442
|
+
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3229
3443
|
vertices = [topology]
|
3230
3444
|
edges = []
|
3231
3445
|
|
@@ -3241,7 +3455,7 @@ class Graph:
|
|
3241
3455
|
vst = content.CenterOfMass()
|
3242
3456
|
d1 = content.GetDictionary()
|
3243
3457
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3244
|
-
if
|
3458
|
+
if storeBREP:
|
3245
3459
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3246
3460
|
d3 = mergeDictionaries2([d1, d2])
|
3247
3461
|
_ = vst.SetDictionary(d3)
|
@@ -3285,7 +3499,7 @@ class Graph:
|
|
3285
3499
|
print("Graph.ByTopology - Error: The input topology is not a valid topology. Returning None.")
|
3286
3500
|
return None
|
3287
3501
|
graph = None
|
3288
|
-
item = [topology, None, None, None, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, None, useInternalVertex,
|
3502
|
+
item = [topology, None, None, None, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, None, useInternalVertex, storeBREP, tolerance]
|
3289
3503
|
vertices = []
|
3290
3504
|
edges = []
|
3291
3505
|
if isinstance(topology, topologic.CellComplex):
|
@@ -3311,7 +3525,7 @@ class Graph:
|
|
3311
3525
|
c_edges = Cluster.FreeEdges(topology, tolerance=tolerance)
|
3312
3526
|
c_vertices = Cluster.FreeVertices(topology, tolerance=tolerance)
|
3313
3527
|
others = c_cellComplexes+c_cells+c_shells+c_faces+c_wires+c_edges+c_vertices
|
3314
|
-
parameters = [others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex,
|
3528
|
+
parameters = [others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance]
|
3315
3529
|
|
3316
3530
|
for t in c_cellComplexes:
|
3317
3531
|
v, e = processCellComplex([t]+parameters)
|
@@ -4061,6 +4275,7 @@ class Graph:
|
|
4061
4275
|
bidirectional=False,
|
4062
4276
|
includeAttributes=False,
|
4063
4277
|
includeLabel=False,
|
4278
|
+
includeGeometry=False,
|
4064
4279
|
siteLabel = "Site_0001",
|
4065
4280
|
siteDictionary = None,
|
4066
4281
|
buildingLabel = "Building_0001",
|
@@ -4069,8 +4284,7 @@ class Graph:
|
|
4069
4284
|
floorLevels =[],
|
4070
4285
|
labelKey="label",
|
4071
4286
|
typeKey="type",
|
4072
|
-
|
4073
|
-
targetKey="target",
|
4287
|
+
geometryKey="brep",
|
4074
4288
|
spaceType = "space",
|
4075
4289
|
wallType = "wall",
|
4076
4290
|
slabType = "slab",
|
@@ -4106,6 +4320,8 @@ class Graph:
|
|
4106
4320
|
If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
4107
4321
|
includeLabel : bool , optional
|
4108
4322
|
If set to True, a label is attached to each node. Otherwise, it is not. The default is False.
|
4323
|
+
includeGeometry : bool , optional
|
4324
|
+
If set to True, the geometry associated with vertices in the graph are written out. Otherwise, it is not. The default is False.
|
4109
4325
|
siteLabel : str , optional
|
4110
4326
|
The desired site label. The default is "Site_0001".
|
4111
4327
|
siteDictionary : dict , optional
|
@@ -4123,6 +4339,8 @@ class Graph:
|
|
4123
4339
|
The dictionary key to use to look up the type of the node. The default is "type".
|
4124
4340
|
labelKey : str , optional
|
4125
4341
|
The dictionary key to use to look up the label of the node. The default is "label".
|
4342
|
+
geometryKey : str , optional
|
4343
|
+
The dictionary key to use to look up the label of the node. The default is "brep".
|
4126
4344
|
spaceType : str , optional
|
4127
4345
|
The dictionary string value to use to look up nodes of type "space". The default is "space".
|
4128
4346
|
wallType : str , optional
|
@@ -4156,6 +4374,7 @@ class Graph:
|
|
4156
4374
|
bidirectional=bidirectional,
|
4157
4375
|
includeAttributes=includeAttributes,
|
4158
4376
|
includeLabel=includeLabel,
|
4377
|
+
includeGeometry=includeGeometry,
|
4159
4378
|
siteLabel=siteLabel,
|
4160
4379
|
siteDictionary=siteDictionary,
|
4161
4380
|
buildingLabel=buildingLabel,
|
@@ -4164,6 +4383,7 @@ class Graph:
|
|
4164
4383
|
floorLevels=floorLevels,
|
4165
4384
|
labelKey=labelKey,
|
4166
4385
|
typeKey=typeKey,
|
4386
|
+
geometryKey=geometryKey,
|
4167
4387
|
spaceType = spaceType,
|
4168
4388
|
wallType = wallType,
|
4169
4389
|
slabType = slabType,
|
@@ -5640,6 +5860,7 @@ class Graph:
|
|
5640
5860
|
xKey="x",
|
5641
5861
|
yKey="y",
|
5642
5862
|
zKey="z",
|
5863
|
+
geometryKey="brep",
|
5643
5864
|
mantissa=6):
|
5644
5865
|
"""
|
5645
5866
|
Converts the input graph into JSON data.
|
@@ -5668,6 +5889,8 @@ class Graph:
|
|
5668
5889
|
The desired key name to use for y-coordinates. The default is "y".
|
5669
5890
|
zKey : str , optional
|
5670
5891
|
The desired key name to use for z-coordinates. The default is "z".
|
5892
|
+
geometryKey : str , optional
|
5893
|
+
The desired key name to use for geometry. The default is "brep".
|
5671
5894
|
mantissa : int , optional
|
5672
5895
|
The desired length of the mantissa. The default is 6.
|
5673
5896
|
|
@@ -5695,6 +5918,11 @@ class Graph:
|
|
5695
5918
|
d = Dictionary.SetValueAtKey(d, xKey, Vertex.X(v, mantissa=mantissa))
|
5696
5919
|
d = Dictionary.SetValueAtKey(d, yKey, Vertex.Y(v, mantissa=mantissa))
|
5697
5920
|
d = Dictionary.SetValueAtKey(d, zKey, Vertex.Z(v, mantissa=mantissa))
|
5921
|
+
if geometryKey:
|
5922
|
+
v_d = Topology.Dictionary(v)
|
5923
|
+
brep = Dictionary.ValueAtKey(v_d,"brep")
|
5924
|
+
if brep:
|
5925
|
+
d = Dictionary.SetValueAtKey(d, geometryKey, brep)
|
5698
5926
|
v_dict = Dictionary.PythonDictionary(d)
|
5699
5927
|
v_label = Dictionary.ValueAtKey(d, vertexLabelKey)
|
5700
5928
|
if isinstance(v_label, str):
|
@@ -7342,7 +7570,7 @@ class Graph:
|
|
7342
7570
|
return degree
|
7343
7571
|
|
7344
7572
|
@staticmethod
|
7345
|
-
def Vertices(graph):
|
7573
|
+
def Vertices(graph, vertexKey=None, reverse=False):
|
7346
7574
|
"""
|
7347
7575
|
Returns the list of vertices in the input graph.
|
7348
7576
|
|
@@ -7350,13 +7578,19 @@ class Graph:
|
|
7350
7578
|
----------
|
7351
7579
|
graph : topologic.Graph
|
7352
7580
|
The input graph.
|
7353
|
-
|
7581
|
+
vertexKey : str , optional
|
7582
|
+
If set, the returned list of vertices is sorted according to the dicitonary values stored under this key. The default is None.
|
7583
|
+
reverse : bool , optional
|
7584
|
+
If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. The default is False.
|
7354
7585
|
Returns
|
7355
7586
|
-------
|
7356
7587
|
list
|
7357
7588
|
The list of vertices in the input graph.
|
7358
7589
|
|
7359
7590
|
"""
|
7591
|
+
|
7592
|
+
from topologicpy.Helper import Helper
|
7593
|
+
|
7360
7594
|
if not isinstance(graph, topologic.Graph):
|
7361
7595
|
print("Graph.Vertices - Error: The input graph is not a valid graph. Returning None.")
|
7362
7596
|
return None
|
@@ -7366,6 +7600,15 @@ class Graph:
|
|
7366
7600
|
_ = graph.Vertices(vertices)
|
7367
7601
|
except:
|
7368
7602
|
vertices = []
|
7603
|
+
if not vertexKey == None:
|
7604
|
+
sorting_values = []
|
7605
|
+
for v in vertices:
|
7606
|
+
d = Topology.Dictionary(v)
|
7607
|
+
value = Dictionary.ValueAtKey(d, vertexKey)
|
7608
|
+
sorting_values.append(value)
|
7609
|
+
vertices = Helper.Sort(vertices, sorting_values)
|
7610
|
+
if reverse == True:
|
7611
|
+
vertices.reverse()
|
7369
7612
|
return vertices
|
7370
7613
|
|
7371
7614
|
@staticmethod
|