topologicpy 0.5.5__py3-none-any.whl → 0.5.7__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/Graph.py +478 -244
- topologicpy/__init__.py +1 -1
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/METADATA +2 -1
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/RECORD +8 -8
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/LICENSE +0 -0
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/WHEEL +0 -0
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.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,11 +573,7 @@ class Graph:
|
|
541
573
|
floorLevels =[],
|
542
574
|
labelKey="label",
|
543
575
|
typeKey="type",
|
544
|
-
|
545
|
-
targetKey="target",
|
546
|
-
xKey = "x",
|
547
|
-
yKey = "y",
|
548
|
-
zKey = "z",
|
576
|
+
geometryKey="brep",
|
549
577
|
spaceType = "space",
|
550
578
|
wallType = "wall",
|
551
579
|
slabType = "slab",
|
@@ -566,6 +594,8 @@ class Graph:
|
|
566
594
|
If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
567
595
|
includeLabel : bool , optional
|
568
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.
|
569
599
|
siteLabel : str , optional
|
570
600
|
The desired site label. The default is "Site_0001".
|
571
601
|
siteDictionary : dict , optional
|
@@ -578,33 +608,25 @@ class Graph:
|
|
578
608
|
The desired prefixed to use for each building storey. The default is "Storey".
|
579
609
|
floorLevels : list , optional
|
580
610
|
The list of floor levels. This should be a numeric list, sorted from lowest to highest.
|
581
|
-
If not provided, floorLevels will be computed automatically based on the
|
582
|
-
typeKey : str , optional
|
583
|
-
The dictionary key to use to look up the type of the node. The default is "type".
|
611
|
+
If not provided, floorLevels will be computed automatically based on the vertices' 'z' attribute.
|
584
612
|
labelKey : str , optional
|
585
613
|
The dictionary key to use to look up the label of the node. The default is "label".
|
586
|
-
|
587
|
-
The
|
588
|
-
|
589
|
-
The
|
590
|
-
xKey : str , optional
|
591
|
-
The dictionary key to use to look up the x-coordinate of the node. The default is "x".
|
592
|
-
yKey : str , optional
|
593
|
-
The dictionary key to use to look up the y-coordinate of the node. The default is "y".
|
594
|
-
zKey : str , optional
|
595
|
-
The dictionary key to use to look up the z-coordinate of the node. The default is "z".
|
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".
|
596
618
|
spaceType : str , optional
|
597
|
-
The dictionary string value to use to look up
|
619
|
+
The dictionary string value to use to look up vertices of type "space". The default is "space".
|
598
620
|
wallType : str , optional
|
599
|
-
The dictionary string value to use to look up
|
621
|
+
The dictionary string value to use to look up vertices of type "wall". The default is "wall".
|
600
622
|
slabType : str , optional
|
601
|
-
The dictionary string value to use to look up
|
623
|
+
The dictionary string value to use to look up vertices of type "slab". The default is "slab".
|
602
624
|
doorType : str , optional
|
603
|
-
The dictionary string value to use to look up
|
625
|
+
The dictionary string value to use to look up vertices of type "door". The default is "door".
|
604
626
|
windowType : str , optional
|
605
|
-
The dictionary string value to use to look up
|
627
|
+
The dictionary string value to use to look up vertices of type "window". The default is "window".
|
606
628
|
contentType : str , optional
|
607
|
-
The dictionary string value to use to look up
|
629
|
+
The dictionary string value to use to look up vertices of type "content". The default is "contents".
|
608
630
|
|
609
631
|
Returns
|
610
632
|
-------
|
@@ -639,135 +661,131 @@ class Graph:
|
|
639
661
|
floorLevels = []
|
640
662
|
json_data = Graph.JSONData(graph, vertexLabelKey=labelKey)
|
641
663
|
# Create an empty RDF graph
|
642
|
-
|
664
|
+
bot_graph = RDFGraph()
|
643
665
|
|
644
666
|
# Define namespaces
|
645
667
|
rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
|
646
|
-
rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#")
|
647
668
|
bot = Namespace("https://w3id.org/bot#")
|
648
669
|
|
649
670
|
# Define a custom prefix mapping
|
650
|
-
|
671
|
+
bot_graph.namespace_manager.bind("bot", bot)
|
651
672
|
|
652
673
|
# Add site
|
653
674
|
site_uri = URIRef(siteLabel)
|
654
|
-
|
675
|
+
bot_graph.add((site_uri, rdf.type, bot.Site))
|
655
676
|
if includeLabel:
|
656
|
-
|
677
|
+
bot_graph.add((site_uri, RDFS.label, Literal(siteLabel)))
|
657
678
|
if isinstance(siteDictionary, topologic.Dictionary):
|
658
679
|
keys = Dictionary.Keys(siteDictionary)
|
659
680
|
for key in keys:
|
660
681
|
value = Dictionary.ValueAtKey(siteDictionary, key)
|
661
|
-
if key == labelKey:
|
662
|
-
|
663
|
-
rdf_graph.add((site_uri, RDFS.label, Literal(value)))
|
664
|
-
elif key != typeKey:
|
665
|
-
rdf_graph.add((site_uri, bot[key], Literal(value)))
|
682
|
+
if not (key == labelKey) and not (key == typeKey):
|
683
|
+
bot_graph.add((site_uri, bot[key], Literal(value)))
|
666
684
|
# Add building
|
667
685
|
building_uri = URIRef(buildingLabel)
|
668
|
-
|
686
|
+
bot_graph.add((building_uri, rdf.type, bot.Building))
|
669
687
|
if includeLabel:
|
670
|
-
|
688
|
+
bot_graph.add((building_uri, RDFS.label, Literal(buildingLabel)))
|
671
689
|
if isinstance(buildingDictionary, topologic.Dictionary):
|
672
690
|
keys = Dictionary.Keys(buildingDictionary)
|
673
691
|
for key in keys:
|
674
692
|
value = Dictionary.ValueAtKey(buildingDictionary, key)
|
675
693
|
if key == labelKey:
|
676
694
|
if includeLabel:
|
677
|
-
|
695
|
+
bot_graph.add((building_uri, RDFS.label, Literal(value)))
|
678
696
|
elif key != typeKey:
|
679
|
-
|
697
|
+
bot_graph.add((building_uri, bot[key], Literal(value)))
|
680
698
|
# Add stories
|
681
699
|
# if floor levels are not given, then need to be computed
|
682
700
|
if len(floorLevels) == 0:
|
683
|
-
for node, attributes in json_data['
|
701
|
+
for node, attributes in json_data['vertices'].items():
|
684
702
|
if slabType.lower() in attributes[typeKey].lower():
|
685
|
-
floorLevels.append(attributes[
|
703
|
+
floorLevels.append(attributes["z"])
|
686
704
|
floorLevels = list(set(floorLevels))
|
687
705
|
floorLevels.sort()
|
706
|
+
floorLevels = floorLevels[:-1]
|
688
707
|
storey_uris = []
|
689
708
|
n = max(len(str(len(floorLevels))),4)
|
690
709
|
for i, floor_level in enumerate(floorLevels):
|
691
710
|
storey_uri = URIRef(storeyPrefix+"_"+str(i+1).zfill(n))
|
692
|
-
|
711
|
+
bot_graph.add((storey_uri, rdf.type, bot.Storey))
|
693
712
|
if includeLabel:
|
694
|
-
|
713
|
+
bot_graph.add((storey_uri, RDFS.label, Literal(storeyPrefix+"_"+str(i+1).zfill(n))))
|
695
714
|
storey_uris.append(storey_uri)
|
696
715
|
|
697
716
|
# Add triples to relate building to site and stories to building
|
698
|
-
|
717
|
+
bot_graph.add((site_uri, bot.hasBuilding, building_uri))
|
699
718
|
if bidirectional:
|
700
|
-
|
719
|
+
bot_graph.add((building_uri, bot.isPartOf, site_uri)) # might not be needed
|
701
720
|
|
702
721
|
for storey_uri in storey_uris:
|
703
|
-
|
722
|
+
bot_graph.add((building_uri, bot.hasStorey, storey_uri))
|
704
723
|
if bidirectional:
|
705
|
-
|
724
|
+
bot_graph.add((storey_uri, bot.isPartOf, building_uri)) # might not be needed
|
706
725
|
|
707
726
|
# Add vertices as RDF resources
|
708
|
-
for node, attributes in json_data['
|
727
|
+
for node, attributes in json_data['vertices'].items():
|
709
728
|
node_uri = URIRef(node)
|
710
729
|
if spaceType.lower() in attributes[typeKey].lower():
|
711
|
-
|
730
|
+
bot_graph.add((node_uri, rdf.type, bot.Space))
|
712
731
|
# Find the storey it is on
|
713
|
-
z = attributes[
|
732
|
+
z = attributes["z"]
|
714
733
|
level = Helper.Position(z, floorLevels)
|
715
734
|
if level > len(storey_uris):
|
716
735
|
level = len(storey_uris)
|
717
736
|
storey_uri = storey_uris[level-1]
|
718
|
-
|
737
|
+
bot_graph.add((storey_uri, bot.hasSpace, node_uri))
|
719
738
|
if bidirectional:
|
720
|
-
|
739
|
+
bot_graph.add((node_uri, bot.isPartOf, storey_uri)) # might not be needed
|
721
740
|
elif windowType.lower() in attributes[typeKey].lower():
|
722
|
-
|
741
|
+
bot_graph.add((node_uri, rdf.type, bot.Window))
|
723
742
|
elif doorType.lower() in attributes[typeKey].lower():
|
724
|
-
|
743
|
+
bot_graph.add((node_uri, rdf.type, bot.Door))
|
725
744
|
elif wallType.lower() in attributes[typeKey].lower():
|
726
|
-
|
745
|
+
bot_graph.add((node_uri, rdf.type, bot.Wall))
|
727
746
|
elif slabType.lower() in attributes[typeKey].lower():
|
728
|
-
|
747
|
+
bot_graph.add((node_uri, rdf.type, bot.Slab))
|
729
748
|
else:
|
730
|
-
|
749
|
+
bot_graph.add((node_uri, rdf.type, bot.Element))
|
731
750
|
|
732
751
|
if includeAttributes:
|
733
752
|
for key, value in attributes.items():
|
753
|
+
if key == geometryKey:
|
754
|
+
if includeGeometry:
|
755
|
+
bot_graph.add((node_uri, bot.hasSimpleGeometry, Literal(value)))
|
734
756
|
if key == labelKey:
|
735
757
|
if includeLabel:
|
736
|
-
|
737
|
-
elif key != typeKey:
|
738
|
-
|
758
|
+
bot_graph.add((node_uri, RDFS.label, Literal(value)))
|
759
|
+
elif key != typeKey and key != geometryKey:
|
760
|
+
bot_graph.add((node_uri, bot[key], Literal(value)))
|
739
761
|
if includeLabel:
|
740
762
|
for key, value in attributes.items():
|
741
763
|
if key == labelKey:
|
742
|
-
|
764
|
+
bot_graph.add((node_uri, RDFS.label, Literal(value)))
|
743
765
|
|
744
766
|
# Add edges as RDF triples
|
745
767
|
for edge, attributes in json_data['edges'].items():
|
746
|
-
source = attributes[
|
747
|
-
target = attributes[
|
768
|
+
source = attributes["source"]
|
769
|
+
target = attributes["target"]
|
748
770
|
source_uri = URIRef(source)
|
749
771
|
target_uri = URIRef(target)
|
750
|
-
if spaceType.lower() in json_data['
|
751
|
-
|
772
|
+
if spaceType.lower() in json_data['vertices'][source][typeKey].lower() and spaceType.lower() in json_data['vertices'][target][typeKey].lower():
|
773
|
+
bot_graph.add((source_uri, bot.adjacentTo, target_uri))
|
752
774
|
if bidirectional:
|
753
|
-
|
754
|
-
elif spaceType.lower() in json_data['
|
755
|
-
|
756
|
-
elif spaceType.lower() in json_data['
|
757
|
-
|
758
|
-
elif spaceType.lower() in json_data['
|
759
|
-
|
775
|
+
bot_graph.add((target_uri, bot.adjacentTo, source_uri))
|
776
|
+
elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and wallType.lower() in json_data['vertices'][target][typeKey].lower():
|
777
|
+
bot_graph.add((target_uri, bot.interfaceOf, source_uri))
|
778
|
+
elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and slabType.lower() in json_data['vertices'][target][typeKey].lower():
|
779
|
+
bot_graph.add((target_uri, bot.interfaceOf, source_uri))
|
780
|
+
elif spaceType.lower() in json_data['vertices'][source][typeKey].lower() and contentType.lower() in json_data['vertices'][target][typeKey].lower():
|
781
|
+
bot_graph.add((source_uri, bot.containsElement, target_uri))
|
760
782
|
if bidirectional:
|
761
|
-
|
783
|
+
bot_graph.add((target_uri, bot.isPartOf, source_uri))
|
762
784
|
else:
|
763
|
-
|
785
|
+
bot_graph.add((source_uri, bot.connectsTo, target_uri))
|
764
786
|
if bidirectional:
|
765
|
-
|
766
|
-
|
767
|
-
#rdf_graph.add((source_uri, bot[key], Literal(value)))
|
768
|
-
# Return serialized RDF graph
|
769
|
-
#rdf_serialized = rdf_graph.serialize(format=format)
|
770
|
-
return rdf_graph
|
787
|
+
bot_graph.add((target_uri, bot.connectsTo, source_uri))
|
788
|
+
return bot_graph
|
771
789
|
|
772
790
|
@staticmethod
|
773
791
|
def BOTString(graph,
|
@@ -775,6 +793,7 @@ class Graph:
|
|
775
793
|
bidirectional=False,
|
776
794
|
includeAttributes=False,
|
777
795
|
includeLabel=False,
|
796
|
+
includeGeometry=False,
|
778
797
|
siteLabel = "Site_0001",
|
779
798
|
siteDictionary = None,
|
780
799
|
buildingLabel = "Building_0001",
|
@@ -783,11 +802,7 @@ class Graph:
|
|
783
802
|
floorLevels =[],
|
784
803
|
labelKey="label",
|
785
804
|
typeKey="type",
|
786
|
-
|
787
|
-
targetKey="target",
|
788
|
-
xKey = "x",
|
789
|
-
yKey = "y",
|
790
|
-
zKey = "z",
|
805
|
+
geometryKey="brep",
|
791
806
|
spaceType = "space",
|
792
807
|
wallType = "wall",
|
793
808
|
slabType = "slab",
|
@@ -819,6 +834,8 @@ class Graph:
|
|
819
834
|
If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
820
835
|
includeLabel : bool , optional
|
821
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.
|
822
839
|
siteLabel : str , optional
|
823
840
|
The desired site label. The default is "Site_0001".
|
824
841
|
siteDictionary : dict , optional
|
@@ -831,33 +848,23 @@ class Graph:
|
|
831
848
|
The desired prefixed to use for each building storey. The default is "Storey".
|
832
849
|
floorLevels : list , optional
|
833
850
|
The list of floor levels. This should be a numeric list, sorted from lowest to highest.
|
834
|
-
If not provided, floorLevels will be computed automatically based on the
|
851
|
+
If not provided, floorLevels will be computed automatically based on the vertices' 'z' attribute.
|
835
852
|
typeKey : str , optional
|
836
853
|
The dictionary key to use to look up the type of the node. The default is "type".
|
837
854
|
labelKey : str , optional
|
838
855
|
The dictionary key to use to look up the label of the node. The default is "label".
|
839
|
-
sourceKey : str , optional
|
840
|
-
The desired dictionary key to use to store the source vertex. The default is "source".
|
841
|
-
targetKey : str , optional
|
842
|
-
The desired dictionary key to use to store the target vertex. The default is "target".
|
843
|
-
xKey : str , optional
|
844
|
-
The dictionary key to use to look up the x-coordinate of the node. The default is "x".
|
845
|
-
yKey : str , optional
|
846
|
-
The dictionary key to use to look up the y-coordinate of the node. The default is "y".
|
847
|
-
zKey : str , optional
|
848
|
-
The dictionary key to use to look up the z-coordinate of the node. The default is "z".
|
849
856
|
spaceType : str , optional
|
850
|
-
The dictionary string value to use to look up
|
857
|
+
The dictionary string value to use to look up vertices of type "space". The default is "space".
|
851
858
|
wallType : str , optional
|
852
|
-
The dictionary string value to use to look up
|
859
|
+
The dictionary string value to use to look up vertices of type "wall". The default is "wall".
|
853
860
|
slabType : str , optional
|
854
|
-
The dictionary string value to use to look up
|
861
|
+
The dictionary string value to use to look up vertices of type "slab". The default is "slab".
|
855
862
|
doorType : str , optional
|
856
|
-
The dictionary string value to use to look up
|
863
|
+
The dictionary string value to use to look up vertices of type "door". The default is "door".
|
857
864
|
windowType : str , optional
|
858
|
-
The dictionary string value to use to look up
|
865
|
+
The dictionary string value to use to look up vertices of type "window". The default is "window".
|
859
866
|
contentType : str , optional
|
860
|
-
The dictionary string value to use to look up
|
867
|
+
The dictionary string value to use to look up vertices of type "content". The default is "contents".
|
861
868
|
|
862
869
|
|
863
870
|
Returns
|
@@ -870,6 +877,7 @@ class Graph:
|
|
870
877
|
bidirectional=bidirectional,
|
871
878
|
includeAttributes=includeAttributes,
|
872
879
|
includeLabel=includeLabel,
|
880
|
+
includeGeometry=includeGeometry,
|
873
881
|
siteLabel=siteLabel,
|
874
882
|
siteDictionary=siteDictionary,
|
875
883
|
buildingLabel=buildingLabel,
|
@@ -878,11 +886,7 @@ class Graph:
|
|
878
886
|
floorLevels=floorLevels,
|
879
887
|
labelKey=labelKey,
|
880
888
|
typeKey=typeKey,
|
881
|
-
|
882
|
-
targetKey=targetKey,
|
883
|
-
xKey=xKey,
|
884
|
-
yKey=yKey,
|
885
|
-
zKey=zKey,
|
889
|
+
geometryKey=geometryKey,
|
886
890
|
spaceType = spaceType,
|
887
891
|
wallType = wallType,
|
888
892
|
slabType = slabType,
|
@@ -1048,21 +1052,189 @@ class Graph:
|
|
1048
1052
|
x, y, z = random.uniform(xMin,xMax), random.uniform(yMin,yMax), random.uniform(zMin,zMax)
|
1049
1053
|
vertices.append(Vertex.ByCoordinates(x, y, z))
|
1050
1054
|
|
1051
|
-
# Add edges based on the adjacency matrix
|
1052
|
-
edges = []
|
1053
|
-
for i in range(len(adjacencyMatrix)):
|
1054
|
-
for j in range(i + 1, len(adjacencyMatrix[i])):
|
1055
|
-
if adjacencyMatrix[i][j] == 1:
|
1056
|
-
edges.append(Edge.ByVertices([vertices[i], vertices[j]]))
|
1057
|
-
|
1058
1055
|
# Create the graph using vertices and edges
|
1059
1056
|
if len(vertices) == 0:
|
1060
1057
|
print("Graph.ByAdjacencyMatrix - Error: The graph does not contain any vertices. Returning None.")
|
1061
1058
|
return None
|
1062
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
|
+
|
1063
1067
|
return Graph.ByVerticesEdges(vertices, edges)
|
1064
1068
|
|
1065
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
|
1066
1238
|
def ByCSVPath(path,
|
1067
1239
|
graphIDHeader="graph_id", graphLabelHeader="label", graphFeaturesHeader="feat", graphFeaturesKeys=[],
|
1068
1240
|
edgeSRCHeader="src_id", edgeDSTHeader="dst_id", edgeLabelHeader="label", edgeTrainMaskHeader="train_mask",
|
@@ -1788,7 +1960,7 @@ class Graph:
|
|
1788
1960
|
return Graph.ByVerticesEdges(g_vertices, g_edges)
|
1789
1961
|
|
1790
1962
|
@staticmethod
|
1791
|
-
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):
|
1792
1964
|
"""
|
1793
1965
|
Creates a graph.See https://en.wikipedia.org/wiki/Graph_(discrete_mathematics).
|
1794
1966
|
|
@@ -1818,7 +1990,7 @@ class Graph:
|
|
1818
1990
|
The key to use to find the list of outposts. It is case insensitive. The default is "outposts".
|
1819
1991
|
useInternalVertex : bool , optional
|
1820
1992
|
If set to True, use an internal vertex to represent the subtopology. Otherwise, use its centroid. The default is False.
|
1821
|
-
|
1993
|
+
storeBREP : bool , optional
|
1822
1994
|
If set to True, store the BRep of the subtopology in its representative vertex. The default is False.
|
1823
1995
|
tolerance : float , optional
|
1824
1996
|
The desired tolerance. The default is 0.0001.
|
@@ -1937,7 +2109,7 @@ class Graph:
|
|
1937
2109
|
return returnList
|
1938
2110
|
|
1939
2111
|
def processCellComplex(item):
|
1940
|
-
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
|
1941
2113
|
edges = []
|
1942
2114
|
vertices = []
|
1943
2115
|
cellmat = []
|
@@ -2037,7 +2209,7 @@ class Graph:
|
|
2037
2209
|
vop = Topology.CenterOfMass(outpost)
|
2038
2210
|
vcc = Topology.CenterOfMass(topology)
|
2039
2211
|
d1 = Topology.Dictionary(vcc)
|
2040
|
-
if
|
2212
|
+
if storeBREP:
|
2041
2213
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2042
2214
|
d3 = mergeDictionaries2([d1, d2])
|
2043
2215
|
_ = vcc.SetDictionary(d3)
|
@@ -2059,7 +2231,7 @@ class Graph:
|
|
2059
2231
|
else:
|
2060
2232
|
vCell = aCell.CenterOfMass()
|
2061
2233
|
d1 = aCell.GetDictionary()
|
2062
|
-
if
|
2234
|
+
if storeBREP:
|
2063
2235
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aCell), Topology.Type(aCell), Topology.TypeAsString(aCell)])
|
2064
2236
|
d3 = mergeDictionaries2([d1, d2])
|
2065
2237
|
_ = vCell.SetDictionary(d3)
|
@@ -2097,7 +2269,7 @@ class Graph:
|
|
2097
2269
|
else:
|
2098
2270
|
vst = sharedTopology.CenterOfMass()
|
2099
2271
|
d1 = sharedTopology.GetDictionary()
|
2100
|
-
if
|
2272
|
+
if storeBREP:
|
2101
2273
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2102
2274
|
d3 = mergeDictionaries2([d1, d2])
|
2103
2275
|
_ = vst.SetDictionary(d3)
|
@@ -2120,7 +2292,7 @@ class Graph:
|
|
2120
2292
|
vst2 = content.CenterOfMass()
|
2121
2293
|
d1 = content.GetDictionary()
|
2122
2294
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X(), vst2.Y(), vst2.Z())
|
2123
|
-
if
|
2295
|
+
if storeBREP:
|
2124
2296
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2125
2297
|
d3 = mergeDictionaries2([d1, d2])
|
2126
2298
|
_ = vst2.SetDictionary(d3)
|
@@ -2140,8 +2312,8 @@ class Graph:
|
|
2140
2312
|
vsa = sharedAp.CenterOfMass()
|
2141
2313
|
d1 = sharedAp.GetDictionary()
|
2142
2314
|
vsa = topologic.Vertex.ByCoordinates(vsa.X()+(tolerance*100), vsa.Y()+(tolerance*100), vsa.Z()+(tolerance*100))
|
2143
|
-
if
|
2144
|
-
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)])
|
2145
2317
|
d3 = mergeDictionaries2([d1, d2])
|
2146
2318
|
_ = vsa.SetDictionary(d3)
|
2147
2319
|
else:
|
@@ -2159,7 +2331,7 @@ class Graph:
|
|
2159
2331
|
vet = exteriorTopology.CenterOfMass()
|
2160
2332
|
_ = vet.SetDictionary(exteriorTopology.GetDictionary())
|
2161
2333
|
d1 = exteriorTopology.GetDictionary()
|
2162
|
-
if
|
2334
|
+
if storeBREP:
|
2163
2335
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2164
2336
|
d3 = mergeDictionaries2([d1, d2])
|
2165
2337
|
_ = vet.SetDictionary(d3)
|
@@ -2182,7 +2354,7 @@ class Graph:
|
|
2182
2354
|
vst2 = content.CenterOfMass()
|
2183
2355
|
d1 = content.GetDictionary()
|
2184
2356
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2185
|
-
if
|
2357
|
+
if storeBREP:
|
2186
2358
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2187
2359
|
d3 = mergeDictionaries2([d1, d2])
|
2188
2360
|
_ = vst2.SetDictionary(d3)
|
@@ -2195,15 +2367,15 @@ class Graph:
|
|
2195
2367
|
edges.append(tempe)
|
2196
2368
|
if toExteriorApertures:
|
2197
2369
|
for exteriorAperture in exteriorApertures:
|
2198
|
-
|
2370
|
+
exTop = exteriorAperture.Topology()
|
2199
2371
|
if useInternalVertex == True:
|
2200
|
-
vea = Topology.InternalVertex(
|
2372
|
+
vea = Topology.InternalVertex(exTop, tolerance)
|
2201
2373
|
else:
|
2202
|
-
vea =
|
2203
|
-
d1 =
|
2374
|
+
vea = exTop.CenterOfMass()
|
2375
|
+
d1 = exTop.GetDictionary()
|
2204
2376
|
vea = topologic.Vertex.ByCoordinates(vea.X()+(tolerance*100), vea.Y()+(tolerance*100), vea.Z()+(tolerance*100))
|
2205
|
-
if
|
2206
|
-
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)])
|
2207
2379
|
d3 = mergeDictionaries2([d1, d2])
|
2208
2380
|
_ = vea.SetDictionary(d3)
|
2209
2381
|
else:
|
@@ -2225,7 +2397,7 @@ class Graph:
|
|
2225
2397
|
vcn = content.CenterOfMass()
|
2226
2398
|
vcn = topologic.Vertex.ByCoordinates(vcn.X()+(tolerance*100), vcn.Y()+(tolerance*100), vcn.Z()+(tolerance*100))
|
2227
2399
|
d1 = content.GetDictionary()
|
2228
|
-
if
|
2400
|
+
if storeBREP:
|
2229
2401
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2230
2402
|
d3 = mergeDictionaries2([d1, d2])
|
2231
2403
|
_ = vcn.SetDictionary(d3)
|
@@ -2243,7 +2415,7 @@ class Graph:
|
|
2243
2415
|
else:
|
2244
2416
|
vCell = aCell.CenterOfMass()
|
2245
2417
|
d1 = aCell.GetDictionary()
|
2246
|
-
if
|
2418
|
+
if storeBREP:
|
2247
2419
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aCell), Topology.Type(aCell), Topology.TypeAsString(aCell)])
|
2248
2420
|
d3 = mergeDictionaries2([d1, d2])
|
2249
2421
|
_ = vCell.SetDictionary(d3)
|
@@ -2253,7 +2425,7 @@ class Graph:
|
|
2253
2425
|
return [vertices,edges]
|
2254
2426
|
|
2255
2427
|
def processCell(item):
|
2256
|
-
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
|
2257
2429
|
vertices = []
|
2258
2430
|
edges = []
|
2259
2431
|
if useInternalVertex == True:
|
@@ -2261,7 +2433,7 @@ class Graph:
|
|
2261
2433
|
else:
|
2262
2434
|
vCell = topology.CenterOfMass()
|
2263
2435
|
d1 = topology.GetDictionary()
|
2264
|
-
if
|
2436
|
+
if storeBREP:
|
2265
2437
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2266
2438
|
d3 = mergeDictionaries2([d1, d2])
|
2267
2439
|
_ = vCell.SetDictionary(d3)
|
@@ -2308,7 +2480,7 @@ class Graph:
|
|
2308
2480
|
else:
|
2309
2481
|
vst = exteriorTopology.CenterOfMass()
|
2310
2482
|
d1 = exteriorTopology.GetDictionary()
|
2311
|
-
if
|
2483
|
+
if storeBREP:
|
2312
2484
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2313
2485
|
d3 = mergeDictionaries2([d1, d2])
|
2314
2486
|
_ = vst.SetDictionary(d3)
|
@@ -2331,7 +2503,7 @@ class Graph:
|
|
2331
2503
|
vst2 = content.CenterOfMass()
|
2332
2504
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2333
2505
|
d1 = content.GetDictionary()
|
2334
|
-
if
|
2506
|
+
if storeBREP:
|
2335
2507
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2336
2508
|
d3 = mergeDictionaries2([d1, d2])
|
2337
2509
|
_ = vst2.SetDictionary(d3)
|
@@ -2344,15 +2516,15 @@ class Graph:
|
|
2344
2516
|
edges.append(tempe)
|
2345
2517
|
if toExteriorApertures:
|
2346
2518
|
for exteriorAperture in exteriorApertures:
|
2347
|
-
|
2519
|
+
exTop = exteriorAperture.Topology()
|
2348
2520
|
if useInternalVertex == True:
|
2349
|
-
vst = Topology.InternalVertex(
|
2521
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
2350
2522
|
else:
|
2351
|
-
vst =
|
2352
|
-
d1 =
|
2523
|
+
vst = exTop.CenterOfMass()
|
2524
|
+
d1 = exTop.GetDictionary()
|
2353
2525
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2354
|
-
if
|
2355
|
-
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)])
|
2356
2528
|
d3 = mergeDictionaries2([d1, d2])
|
2357
2529
|
_ = vst.SetDictionary(d3)
|
2358
2530
|
else:
|
@@ -2374,7 +2546,7 @@ class Graph:
|
|
2374
2546
|
vst = content.CenterOfMass()
|
2375
2547
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2376
2548
|
d1 = content.GetDictionary()
|
2377
|
-
if
|
2549
|
+
if storeBREP:
|
2378
2550
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2379
2551
|
d3 = mergeDictionaries2([d1, d2])
|
2380
2552
|
_ = vst.SetDictionary(d3)
|
@@ -2389,7 +2561,7 @@ class Graph:
|
|
2389
2561
|
|
2390
2562
|
def processShell(item):
|
2391
2563
|
from topologicpy.Face import Face
|
2392
|
-
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
|
2393
2565
|
graph = None
|
2394
2566
|
edges = []
|
2395
2567
|
vertices = []
|
@@ -2506,7 +2678,7 @@ class Graph:
|
|
2506
2678
|
else:
|
2507
2679
|
vst = sharedTopology.CenterOfMass()
|
2508
2680
|
d1 = sharedTopology.GetDictionary()
|
2509
|
-
if
|
2681
|
+
if storeBREP:
|
2510
2682
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2511
2683
|
d3 = mergeDictionaries2([d1, d2])
|
2512
2684
|
_ = vst.SetDictionary(d3)
|
@@ -2529,7 +2701,7 @@ class Graph:
|
|
2529
2701
|
vst2 = content.CenterOfMass()
|
2530
2702
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2531
2703
|
d1 = content.GetDictionary()
|
2532
|
-
if
|
2704
|
+
if storeBREP:
|
2533
2705
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2534
2706
|
d3 = mergeDictionaries2([d1, d2])
|
2535
2707
|
_ = vst2.SetDictionary(d3)
|
@@ -2542,14 +2714,15 @@ class Graph:
|
|
2542
2714
|
edges.append(tempe)
|
2543
2715
|
if viaSharedApertures:
|
2544
2716
|
for sharedAperture in sharedApertures:
|
2717
|
+
sharedAp = Aperture.Topology(sharedAperture)
|
2545
2718
|
if useInternalVertex == True:
|
2546
|
-
vst = Topology.InternalVertex(
|
2719
|
+
vst = Topology.InternalVertex(sharedAp, tolerance)
|
2547
2720
|
else:
|
2548
|
-
vst =
|
2549
|
-
d1 =
|
2721
|
+
vst = sharedAp.CenterOfMass()
|
2722
|
+
d1 = sharedAp.GetDictionary()
|
2550
2723
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2551
|
-
if
|
2552
|
-
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)])
|
2553
2726
|
d3 = mergeDictionaries2([d1, d2])
|
2554
2727
|
_ = vst.SetDictionary(d3)
|
2555
2728
|
else:
|
@@ -2566,7 +2739,7 @@ class Graph:
|
|
2566
2739
|
else:
|
2567
2740
|
vst = exteriorTopology.CenterOfMass()
|
2568
2741
|
d1 = exteriorTopology.GetDictionary()
|
2569
|
-
if
|
2742
|
+
if storeBREP:
|
2570
2743
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2571
2744
|
d3 = mergeDictionaries2([d1, d2])
|
2572
2745
|
_ = vst.SetDictionary(d3)
|
@@ -2589,7 +2762,7 @@ class Graph:
|
|
2589
2762
|
vst2 = content.CenterOfMass()
|
2590
2763
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2591
2764
|
d1 = content.GetDictionary()
|
2592
|
-
if
|
2765
|
+
if storeBREP:
|
2593
2766
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2594
2767
|
d3 = mergeDictionaries2([d1, d2])
|
2595
2768
|
_ = vst2.SetDictionary(d3)
|
@@ -2602,15 +2775,15 @@ class Graph:
|
|
2602
2775
|
edges.append(tempe)
|
2603
2776
|
if toExteriorApertures:
|
2604
2777
|
for exteriorAperture in exteriorApertures:
|
2605
|
-
|
2778
|
+
exTop = exteriorAperture.Topology()
|
2606
2779
|
if useInternalVertex == True:
|
2607
|
-
vst = Topology.InternalVertex(
|
2780
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
2608
2781
|
else:
|
2609
|
-
vst =
|
2610
|
-
d1 =
|
2782
|
+
vst = exTop.CenterOfMass()
|
2783
|
+
d1 = exTop.GetDictionary()
|
2611
2784
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2612
|
-
if
|
2613
|
-
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)])
|
2614
2787
|
d3 = mergeDictionaries2([d1, d2])
|
2615
2788
|
_ = vst.SetDictionary(d3)
|
2616
2789
|
else:
|
@@ -2632,7 +2805,7 @@ class Graph:
|
|
2632
2805
|
vst = content.CenterOfMass()
|
2633
2806
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2634
2807
|
d1 = content.GetDictionary()
|
2635
|
-
if
|
2808
|
+
if storeBREP:
|
2636
2809
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2637
2810
|
d3 = mergeDictionaries2([d1, d2])
|
2638
2811
|
_ = vst.SetDictionary(d3)
|
@@ -2650,7 +2823,7 @@ class Graph:
|
|
2650
2823
|
else:
|
2651
2824
|
vFace = aFace.CenterOfMass()
|
2652
2825
|
d1 = aFace.GetDictionary()
|
2653
|
-
if
|
2826
|
+
if storeBREP:
|
2654
2827
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aFace), Topology.Type(aFace), Topology.TypeAsString(aFace)])
|
2655
2828
|
d3 = mergeDictionaries2([d1, d2])
|
2656
2829
|
_ = vFace.SetDictionary(d3)
|
@@ -2680,7 +2853,7 @@ class Graph:
|
|
2680
2853
|
vop = Topology.CenterOfMass(outpost)
|
2681
2854
|
vcc = Topology.CenterOfMass(topology)
|
2682
2855
|
d1 = Topology.Dictionary(vcc)
|
2683
|
-
if
|
2856
|
+
if storeBREP:
|
2684
2857
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2685
2858
|
d3 = mergeDictionaries2([d1, d2])
|
2686
2859
|
_ = vcc.SetDictionary(d3)
|
@@ -2695,7 +2868,7 @@ class Graph:
|
|
2695
2868
|
|
2696
2869
|
def processFace(item):
|
2697
2870
|
from topologicpy.Face import Face
|
2698
|
-
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
|
2699
2872
|
graph = None
|
2700
2873
|
vertices = []
|
2701
2874
|
edges = []
|
@@ -2705,7 +2878,7 @@ class Graph:
|
|
2705
2878
|
else:
|
2706
2879
|
vFace = topology.CenterOfMass()
|
2707
2880
|
d1 = topology.GetDictionary()
|
2708
|
-
if
|
2881
|
+
if storeBREP:
|
2709
2882
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2710
2883
|
d3 = mergeDictionaries2([d1, d2])
|
2711
2884
|
_ = vFace.SetDictionary(d3)
|
@@ -2755,7 +2928,7 @@ class Graph:
|
|
2755
2928
|
else:
|
2756
2929
|
vst = exteriorTopology.CenterOfMass()
|
2757
2930
|
d1 = exteriorTopology.GetDictionary()
|
2758
|
-
if
|
2931
|
+
if storeBREP:
|
2759
2932
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2760
2933
|
d3 = mergeDictionaries2([d1, d2])
|
2761
2934
|
_ = vst.SetDictionary(d3)
|
@@ -2778,7 +2951,7 @@ class Graph:
|
|
2778
2951
|
vst2 = content.CenterOfMass()
|
2779
2952
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2780
2953
|
d1 = content.GetDictionary()
|
2781
|
-
if
|
2954
|
+
if storeBREP:
|
2782
2955
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2783
2956
|
d3 = mergeDictionaries2([d1, d2])
|
2784
2957
|
_ = vst2.SetDictionary(d3)
|
@@ -2791,15 +2964,15 @@ class Graph:
|
|
2791
2964
|
edges.append(tempe)
|
2792
2965
|
if toExteriorApertures:
|
2793
2966
|
for exteriorAperture in exteriorApertures:
|
2794
|
-
|
2967
|
+
exTop = exteriorAperture.Topology()
|
2795
2968
|
if useInternalVertex == True:
|
2796
|
-
vst = Topology.InternalVertex(
|
2969
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
2797
2970
|
else:
|
2798
|
-
vst =
|
2799
|
-
d1 =
|
2971
|
+
vst = exTop.CenterOfMass()
|
2972
|
+
d1 = exTop.GetDictionary()
|
2800
2973
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2801
|
-
if
|
2802
|
-
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)])
|
2803
2976
|
d3 = mergeDictionaries2([d1, d2])
|
2804
2977
|
_ = vst.SetDictionary(d3)
|
2805
2978
|
else:
|
@@ -2821,7 +2994,7 @@ class Graph:
|
|
2821
2994
|
vst = content.CenterOfMass()
|
2822
2995
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
2823
2996
|
d1 = content.GetDictionary()
|
2824
|
-
if
|
2997
|
+
if storeBREP:
|
2825
2998
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2826
2999
|
d3 = mergeDictionaries2([d1, d2])
|
2827
3000
|
_ = vst.SetDictionary(d3)
|
@@ -2835,7 +3008,7 @@ class Graph:
|
|
2835
3008
|
return [vertices, edges]
|
2836
3009
|
|
2837
3010
|
def processWire(item):
|
2838
|
-
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
|
2839
3012
|
graph = None
|
2840
3013
|
edges = []
|
2841
3014
|
vertices = []
|
@@ -2927,7 +3100,7 @@ class Graph:
|
|
2927
3100
|
except:
|
2928
3101
|
vEdge = anEdge.CenterOfMass()
|
2929
3102
|
d1 = anEdge.GetDictionary()
|
2930
|
-
if
|
3103
|
+
if storeBREP:
|
2931
3104
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(anEdge), Topology.Type(anEdge), Topology.TypeAsString(anEdge)])
|
2932
3105
|
d3 = mergeDictionaries2([d1, d2])
|
2933
3106
|
_ = vEdge.SetDictionary(d3)
|
@@ -2961,7 +3134,7 @@ class Graph:
|
|
2961
3134
|
for sharedTopology in sharedTopologies:
|
2962
3135
|
vst = sharedTopology.CenterOfMass()
|
2963
3136
|
d1 = sharedTopology.GetDictionary()
|
2964
|
-
if
|
3137
|
+
if storeBREP:
|
2965
3138
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2966
3139
|
d3 = mergeDictionaries2([d1, d2])
|
2967
3140
|
_ = vst.SetDictionary(d3)
|
@@ -2984,7 +3157,7 @@ class Graph:
|
|
2984
3157
|
vst2 = content.CenterOfMass()
|
2985
3158
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
2986
3159
|
d1 = content.GetDictionary()
|
2987
|
-
if
|
3160
|
+
if storeBREP:
|
2988
3161
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2989
3162
|
d3 = mergeDictionaries2([d1, d2])
|
2990
3163
|
_ = vst2.SetDictionary(d3)
|
@@ -2997,15 +3170,15 @@ class Graph:
|
|
2997
3170
|
edges.append(tempe)
|
2998
3171
|
if viaSharedApertures:
|
2999
3172
|
for sharedAperture in sharedApertures:
|
3000
|
-
|
3173
|
+
sharedAp = sharedAperture.Topology()
|
3001
3174
|
if useInternalVertex == True:
|
3002
|
-
vst = Topology.InternalVertex(
|
3175
|
+
vst = Topology.InternalVertex(sharedAp, tolerance)
|
3003
3176
|
else:
|
3004
|
-
vst =
|
3005
|
-
d1 =
|
3177
|
+
vst = sharedAp.CenterOfMass()
|
3178
|
+
d1 = sharedAp.GetDictionary()
|
3006
3179
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3007
|
-
if
|
3008
|
-
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)])
|
3009
3182
|
d3 = mergeDictionaries2([d1, d2])
|
3010
3183
|
_ = vst.SetDictionary(d3)
|
3011
3184
|
else:
|
@@ -3035,7 +3208,7 @@ class Graph:
|
|
3035
3208
|
vst2 = content.CenterOfMass()
|
3036
3209
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
3037
3210
|
d1 = content.GetDictionary()
|
3038
|
-
if
|
3211
|
+
if storeBREP:
|
3039
3212
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3040
3213
|
d3 = mergeDictionaries2([d1, d2])
|
3041
3214
|
_ = vst2.SetDictionary(d3)
|
@@ -3048,15 +3221,15 @@ class Graph:
|
|
3048
3221
|
edges.append(tempe)
|
3049
3222
|
if toExteriorApertures:
|
3050
3223
|
for exteriorAperture in exteriorApertures:
|
3051
|
-
|
3224
|
+
exTop = exteriorAperture.Topology()
|
3052
3225
|
if useInternalVertex == True:
|
3053
|
-
vst = Topology.InternalVertex(
|
3226
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
3054
3227
|
else:
|
3055
|
-
vst =
|
3056
|
-
d1 =
|
3228
|
+
vst = exTop.CenterOfMass()
|
3229
|
+
d1 = exTop.GetDictionary()
|
3057
3230
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3058
|
-
if
|
3059
|
-
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)])
|
3060
3233
|
d3 = mergeDictionaries2([d1, d2])
|
3061
3234
|
_ = vst.SetDictionary(d3)
|
3062
3235
|
else:
|
@@ -3078,7 +3251,7 @@ class Graph:
|
|
3078
3251
|
vst = content.CenterOfMass()
|
3079
3252
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3080
3253
|
d1 = content.GetDictionary()
|
3081
|
-
if
|
3254
|
+
if storeBREP:
|
3082
3255
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3083
3256
|
d3 = mergeDictionaries2([d1, d2])
|
3084
3257
|
_ = vst.SetDictionary(d3)
|
@@ -3095,7 +3268,7 @@ class Graph:
|
|
3095
3268
|
except:
|
3096
3269
|
vEdge = anEdge.CenterOfMass()
|
3097
3270
|
d1 = anEdge.GetDictionary()
|
3098
|
-
if
|
3271
|
+
if storeBREP:
|
3099
3272
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(anEdge), Topology.Type(anEdge), Topology.TypeAsString(anEdge)])
|
3100
3273
|
d3 = mergeDictionaries2([d1, d2])
|
3101
3274
|
_ = vEdge.SetDictionary(d3)
|
@@ -3126,7 +3299,7 @@ class Graph:
|
|
3126
3299
|
vop = Topology.CenterOfMass(outpost)
|
3127
3300
|
vcc = Topology.CenterOfMass(topology)
|
3128
3301
|
d1 = Topology.Dictionary(vcc)
|
3129
|
-
if
|
3302
|
+
if storeBREP:
|
3130
3303
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3131
3304
|
d3 = mergeDictionaries2([d1, d2])
|
3132
3305
|
_ = vcc.SetDictionary(d3)
|
@@ -3141,7 +3314,7 @@ class Graph:
|
|
3141
3314
|
return [vertices, edges]
|
3142
3315
|
|
3143
3316
|
def processEdge(item):
|
3144
|
-
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
|
3145
3318
|
graph = None
|
3146
3319
|
vertices = []
|
3147
3320
|
edges = []
|
@@ -3155,7 +3328,7 @@ class Graph:
|
|
3155
3328
|
vEdge = topology.CenterOfMass()
|
3156
3329
|
|
3157
3330
|
d1 = vEdge.GetDictionary()
|
3158
|
-
if
|
3331
|
+
if storeBREP:
|
3159
3332
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3160
3333
|
d3 = mergeDictionaries2([d1, d2])
|
3161
3334
|
_ = vEdge.SetDictionary(d3)
|
@@ -3207,7 +3380,7 @@ class Graph:
|
|
3207
3380
|
else:
|
3208
3381
|
vst = exteriorTopology.CenterOfMass()
|
3209
3382
|
d1 = exteriorTopology.GetDictionary()
|
3210
|
-
if
|
3383
|
+
if storeBREP:
|
3211
3384
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
3212
3385
|
d3 = mergeDictionaries2([d1, d2])
|
3213
3386
|
_ = vst.SetDictionary(d3)
|
@@ -3230,7 +3403,7 @@ class Graph:
|
|
3230
3403
|
vst2 = content.CenterOfMass()
|
3231
3404
|
vst2 = topologic.Vertex.ByCoordinates(vst2.X()+(tolerance*100), vst2.Y()+(tolerance*100), vst2.Z()+(tolerance*100))
|
3232
3405
|
d1 = content.GetDictionary()
|
3233
|
-
if
|
3406
|
+
if storeBREP:
|
3234
3407
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3235
3408
|
d3 = mergeDictionaries2([d1, d2])
|
3236
3409
|
_ = vst2.SetDictionary(d3)
|
@@ -3243,20 +3416,20 @@ class Graph:
|
|
3243
3416
|
edges.append(tempe)
|
3244
3417
|
if toExteriorApertures:
|
3245
3418
|
for exteriorAperture in exteriorApertures:
|
3246
|
-
|
3419
|
+
exTop = exteriorAperture.Topology()
|
3247
3420
|
if useInternalVertex == True:
|
3248
|
-
vst = Topology.InternalVertex(
|
3421
|
+
vst = Topology.InternalVertex(exTop, tolerance)
|
3249
3422
|
else:
|
3250
|
-
vst =
|
3251
|
-
d1 =
|
3423
|
+
vst = exTop.CenterOfMass()
|
3424
|
+
d1 = exTop.GetDictionary()
|
3252
3425
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3253
|
-
if
|
3254
|
-
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)])
|
3255
3428
|
d3 = mergeDictionaries2([d1, d2])
|
3256
3429
|
_ = vst.SetDictionary(d3)
|
3257
3430
|
else:
|
3258
3431
|
_ = vst.SetDictionary(d1)
|
3259
|
-
_ = vst.SetDictionary(
|
3432
|
+
_ = vst.SetDictionary(exTop.GetDictionary())
|
3260
3433
|
vertices.append(vst)
|
3261
3434
|
tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3262
3435
|
tempd = Dictionary.ByKeysValues(["relationship"],["To Exterior Apertures"])
|
@@ -3266,7 +3439,7 @@ class Graph:
|
|
3266
3439
|
return [vertices, edges]
|
3267
3440
|
|
3268
3441
|
def processVertex(item):
|
3269
|
-
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
|
3270
3443
|
vertices = [topology]
|
3271
3444
|
edges = []
|
3272
3445
|
|
@@ -3282,7 +3455,7 @@ class Graph:
|
|
3282
3455
|
vst = content.CenterOfMass()
|
3283
3456
|
d1 = content.GetDictionary()
|
3284
3457
|
vst = topologic.Vertex.ByCoordinates(vst.X()+(tolerance*100), vst.Y()+(tolerance*100), vst.Z()+(tolerance*100))
|
3285
|
-
if
|
3458
|
+
if storeBREP:
|
3286
3459
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3287
3460
|
d3 = mergeDictionaries2([d1, d2])
|
3288
3461
|
_ = vst.SetDictionary(d3)
|
@@ -3326,7 +3499,7 @@ class Graph:
|
|
3326
3499
|
print("Graph.ByTopology - Error: The input topology is not a valid topology. Returning None.")
|
3327
3500
|
return None
|
3328
3501
|
graph = None
|
3329
|
-
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]
|
3330
3503
|
vertices = []
|
3331
3504
|
edges = []
|
3332
3505
|
if isinstance(topology, topologic.CellComplex):
|
@@ -3352,7 +3525,7 @@ class Graph:
|
|
3352
3525
|
c_edges = Cluster.FreeEdges(topology, tolerance=tolerance)
|
3353
3526
|
c_vertices = Cluster.FreeVertices(topology, tolerance=tolerance)
|
3354
3527
|
others = c_cellComplexes+c_cells+c_shells+c_faces+c_wires+c_edges+c_vertices
|
3355
|
-
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]
|
3356
3529
|
|
3357
3530
|
for t in c_cellComplexes:
|
3358
3531
|
v, e = processCellComplex([t]+parameters)
|
@@ -4102,6 +4275,7 @@ class Graph:
|
|
4102
4275
|
bidirectional=False,
|
4103
4276
|
includeAttributes=False,
|
4104
4277
|
includeLabel=False,
|
4278
|
+
includeGeometry=False,
|
4105
4279
|
siteLabel = "Site_0001",
|
4106
4280
|
siteDictionary = None,
|
4107
4281
|
buildingLabel = "Building_0001",
|
@@ -4110,11 +4284,7 @@ class Graph:
|
|
4110
4284
|
floorLevels =[],
|
4111
4285
|
labelKey="label",
|
4112
4286
|
typeKey="type",
|
4113
|
-
|
4114
|
-
targetKey="target",
|
4115
|
-
xKey = "x",
|
4116
|
-
yKey = "y",
|
4117
|
-
zKey = "z",
|
4287
|
+
geometryKey="brep",
|
4118
4288
|
spaceType = "space",
|
4119
4289
|
wallType = "wall",
|
4120
4290
|
slabType = "slab",
|
@@ -4150,6 +4320,8 @@ class Graph:
|
|
4150
4320
|
If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
4151
4321
|
includeLabel : bool , optional
|
4152
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.
|
4153
4325
|
siteLabel : str , optional
|
4154
4326
|
The desired site label. The default is "Site_0001".
|
4155
4327
|
siteDictionary : dict , optional
|
@@ -4167,16 +4339,8 @@ class Graph:
|
|
4167
4339
|
The dictionary key to use to look up the type of the node. The default is "type".
|
4168
4340
|
labelKey : str , optional
|
4169
4341
|
The dictionary key to use to look up the label of the node. The default is "label".
|
4170
|
-
|
4171
|
-
The
|
4172
|
-
targetKey : str , optional
|
4173
|
-
The desired dictionary key to use to store the target vertex. The default is "target".
|
4174
|
-
xKey : str , optional
|
4175
|
-
The dictionary key to use to look up the x-coordinate of the node. The default is "x".
|
4176
|
-
yKey : str , optional
|
4177
|
-
The dictionary key to use to look up the y-coordinate of the node. The default is "y".
|
4178
|
-
zKey : str , optional
|
4179
|
-
The dictionary key to use to look up the z-coordinate of the node. The default is "z".
|
4342
|
+
geometryKey : str , optional
|
4343
|
+
The dictionary key to use to look up the label of the node. The default is "brep".
|
4180
4344
|
spaceType : str , optional
|
4181
4345
|
The dictionary string value to use to look up nodes of type "space". The default is "space".
|
4182
4346
|
wallType : str , optional
|
@@ -4210,6 +4374,7 @@ class Graph:
|
|
4210
4374
|
bidirectional=bidirectional,
|
4211
4375
|
includeAttributes=includeAttributes,
|
4212
4376
|
includeLabel=includeLabel,
|
4377
|
+
includeGeometry=includeGeometry,
|
4213
4378
|
siteLabel=siteLabel,
|
4214
4379
|
siteDictionary=siteDictionary,
|
4215
4380
|
buildingLabel=buildingLabel,
|
@@ -4218,11 +4383,7 @@ class Graph:
|
|
4218
4383
|
floorLevels=floorLevels,
|
4219
4384
|
labelKey=labelKey,
|
4220
4385
|
typeKey=typeKey,
|
4221
|
-
|
4222
|
-
targetKey=targetKey,
|
4223
|
-
xKey=xKey,
|
4224
|
-
yKey=yKey,
|
4225
|
-
zKey=zKey,
|
4386
|
+
geometryKey=geometryKey,
|
4226
4387
|
spaceType = spaceType,
|
4227
4388
|
wallType = wallType,
|
4228
4389
|
slabType = slabType,
|
@@ -4975,7 +5136,7 @@ class Graph:
|
|
4975
5136
|
return True
|
4976
5137
|
|
4977
5138
|
@staticmethod
|
4978
|
-
def ExportToJSON(graph, path, vertexLabelKey="", edgeLabelKey="", indent=4, sortKeys=False, mantissa=6, overwrite=False):
|
5139
|
+
def ExportToJSON(graph, path, verticesKey="vertices", edgesKey="edges", vertexLabelKey="", edgeLabelKey="", xKey="x", yKey="y", zKey="z", indent=4, sortKeys=False, mantissa=6, overwrite=False):
|
4979
5140
|
"""
|
4980
5141
|
Exports the input graph to a JSON file.
|
4981
5142
|
|
@@ -4985,12 +5146,22 @@ class Graph:
|
|
4985
5146
|
The input graph.
|
4986
5147
|
path : str
|
4987
5148
|
The path to the JSON file.
|
5149
|
+
verticesKey : str , optional
|
5150
|
+
The desired key name to call vertices. The default is "vertices".
|
5151
|
+
edgesKey : str , optional
|
5152
|
+
The desired key name to call edges. The default is "edges".
|
4988
5153
|
vertexLabelKey : str , optional
|
4989
5154
|
If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number.
|
4990
5155
|
Note: If vertex labels are not unique, they will be forced to be unique.
|
4991
5156
|
edgeLabelKey : str , optional
|
4992
5157
|
If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number.
|
4993
5158
|
Note: If edge labels are not unique, they will be forced to be unique.
|
5159
|
+
xKey : str , optional
|
5160
|
+
The desired key name to use for x-coordinates. The default is "x".
|
5161
|
+
yKey : str , optional
|
5162
|
+
The desired key name to use for y-coordinates. The default is "y".
|
5163
|
+
zKey : str , optional
|
5164
|
+
The desired key name to use for z-coordinates. The default is "z".
|
4994
5165
|
indent : int , optional
|
4995
5166
|
The desired amount of indent spaces to use. The default is 4.
|
4996
5167
|
sortKeys : bool , optional
|
@@ -5024,7 +5195,7 @@ class Graph:
|
|
5024
5195
|
except:
|
5025
5196
|
raise Exception("Graph.ExportToJSON - Error: Could not create a new file at the following location: "+path)
|
5026
5197
|
if (f):
|
5027
|
-
jsondata = Graph.JSONData(graph, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, mantissa=mantissa)
|
5198
|
+
jsondata = Graph.JSONData(graph, verticesKey=verticesKey, edgesKey=edgesKey, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, xKey=xKey, yKey=yKey, zKey=zKey, mantissa=mantissa)
|
5028
5199
|
if jsondata != None:
|
5029
5200
|
json.dump(jsondata, f, indent=indent, sort_keys=sortKeys)
|
5030
5201
|
f.close()
|
@@ -5679,7 +5850,18 @@ class Graph:
|
|
5679
5850
|
return vertices
|
5680
5851
|
|
5681
5852
|
@staticmethod
|
5682
|
-
def JSONData(graph,
|
5853
|
+
def JSONData(graph,
|
5854
|
+
verticesKey="vertices",
|
5855
|
+
edgesKey="edges",
|
5856
|
+
vertexLabelKey="",
|
5857
|
+
edgeLabelKey="",
|
5858
|
+
sourceKey="source",
|
5859
|
+
targetKey="target",
|
5860
|
+
xKey="x",
|
5861
|
+
yKey="y",
|
5862
|
+
zKey="z",
|
5863
|
+
geometryKey="brep",
|
5864
|
+
mantissa=6):
|
5683
5865
|
"""
|
5684
5866
|
Converts the input graph into JSON data.
|
5685
5867
|
|
@@ -5687,6 +5869,10 @@ class Graph:
|
|
5687
5869
|
----------
|
5688
5870
|
graph : topologic.Graph
|
5689
5871
|
The input graph.
|
5872
|
+
verticesKey : str , optional
|
5873
|
+
The desired key name to call vertices. The default is "vertices".
|
5874
|
+
edgesKey : str , optional
|
5875
|
+
The desired key name to call edges. The default is "edges".
|
5690
5876
|
vertexLabelKey : str , optional
|
5691
5877
|
If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number.
|
5692
5878
|
Note: If vertex labels are not unique, they will be forced to be unique.
|
@@ -5697,6 +5883,14 @@ class Graph:
|
|
5697
5883
|
The dictionary key used to store the source vertex. The default is "source".
|
5698
5884
|
targetKey : str , optional
|
5699
5885
|
The dictionary key used to store the target vertex. The default is "source".
|
5886
|
+
xKey : str , optional
|
5887
|
+
The desired key name to use for x-coordinates. The default is "x".
|
5888
|
+
yKey : str , optional
|
5889
|
+
The desired key name to use for y-coordinates. The default is "y".
|
5890
|
+
zKey : str , optional
|
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".
|
5700
5894
|
mantissa : int , optional
|
5701
5895
|
The desired length of the mantissa. The default is 6.
|
5702
5896
|
|
@@ -5714,16 +5908,21 @@ class Graph:
|
|
5714
5908
|
|
5715
5909
|
vertices = Graph.Vertices(graph)
|
5716
5910
|
j_data = {}
|
5717
|
-
j_data[
|
5718
|
-
j_data[
|
5911
|
+
j_data[verticesKey] = {}
|
5912
|
+
j_data[edgesKey] = {}
|
5719
5913
|
n = max(len(str(len(vertices))), 4)
|
5720
5914
|
v_labels = []
|
5721
5915
|
v_dicts = []
|
5722
5916
|
for i, v in enumerate(vertices):
|
5723
5917
|
d = Topology.Dictionary(v)
|
5724
|
-
d = Dictionary.SetValueAtKey(d,
|
5725
|
-
d = Dictionary.SetValueAtKey(d,
|
5726
|
-
d = Dictionary.SetValueAtKey(d,
|
5918
|
+
d = Dictionary.SetValueAtKey(d, xKey, Vertex.X(v, mantissa=mantissa))
|
5919
|
+
d = Dictionary.SetValueAtKey(d, yKey, Vertex.Y(v, mantissa=mantissa))
|
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)
|
5727
5926
|
v_dict = Dictionary.PythonDictionary(d)
|
5728
5927
|
v_label = Dictionary.ValueAtKey(d, vertexLabelKey)
|
5729
5928
|
if isinstance(v_label, str):
|
@@ -5734,7 +5933,7 @@ class Graph:
|
|
5734
5933
|
v_dicts.append(v_dict)
|
5735
5934
|
v_labels = Helper.MakeUnique(v_labels)
|
5736
5935
|
for i, v_label in enumerate(v_labels):
|
5737
|
-
j_data[
|
5936
|
+
j_data[verticesKey][v_label] = v_dicts[i]
|
5738
5937
|
|
5739
5938
|
edges = Graph.Edges(graph)
|
5740
5939
|
n = len(str(len(edges)))
|
@@ -5761,12 +5960,22 @@ class Graph:
|
|
5761
5960
|
e_dicts.append(e_dict)
|
5762
5961
|
e_labels = Helper.MakeUnique(e_labels)
|
5763
5962
|
for i, e_label in enumerate(e_labels):
|
5764
|
-
j_data[
|
5963
|
+
j_data[edgesKey][e_label] = e_dicts[i]
|
5765
5964
|
|
5766
5965
|
return j_data
|
5767
5966
|
|
5768
5967
|
@staticmethod
|
5769
|
-
def JSONString(graph,
|
5968
|
+
def JSONString(graph,
|
5969
|
+
verticesKey="vertices",
|
5970
|
+
edgesKey="edges",
|
5971
|
+
vertexLabelKey="",
|
5972
|
+
edgeLabelKey="",
|
5973
|
+
xKey = "x",
|
5974
|
+
yKey = "y",
|
5975
|
+
zKey = "z",
|
5976
|
+
indent=4,
|
5977
|
+
sortKeys=False,
|
5978
|
+
mantissa=6):
|
5770
5979
|
"""
|
5771
5980
|
Converts the input graph into JSON data.
|
5772
5981
|
|
@@ -5774,12 +5983,22 @@ class Graph:
|
|
5774
5983
|
----------
|
5775
5984
|
graph : topologic.Graph
|
5776
5985
|
The input graph.
|
5986
|
+
verticesKey : str , optional
|
5987
|
+
The desired key name to call vertices. The default is "vertices".
|
5988
|
+
edgesKey : str , optional
|
5989
|
+
The desired key name to call edges. The default is "edges".
|
5777
5990
|
vertexLabelKey : str , optional
|
5778
5991
|
If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number.
|
5779
5992
|
Note: If vertex labels are not unique, they will be forced to be unique.
|
5780
5993
|
edgeLabelKey : str , optional
|
5781
5994
|
If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number.
|
5782
5995
|
Note: If edge labels are not unique, they will be forced to be unique.
|
5996
|
+
xKey : str , optional
|
5997
|
+
The desired key name to use for x-coordinates. The default is "x".
|
5998
|
+
yKey : str , optional
|
5999
|
+
The desired key name to use for y-coordinates. The default is "y".
|
6000
|
+
zKey : str , optional
|
6001
|
+
The desired key name to use for z-coordinates. The default is "z".
|
5783
6002
|
indent : int , optional
|
5784
6003
|
The desired amount of indent spaces to use. The default is 4.
|
5785
6004
|
sortKeys : bool , optional
|
@@ -5794,7 +6013,7 @@ class Graph:
|
|
5794
6013
|
|
5795
6014
|
"""
|
5796
6015
|
import json
|
5797
|
-
json_data = Graph.JSONData(graph, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, mantissa=mantissa)
|
6016
|
+
json_data = Graph.JSONData(graph, verticesKey=verticesKey, edgesKey=edgesKey, vertexLabelKey=vertexLabelKey, edgeLabelKey=edgeLabelKey, xKey=xKey, yKey=yKey, zKey=zKey, mantissa=mantissa)
|
5798
6017
|
json_string = json.dumps(json_data, indent=indent, sort_keys=sortKeys)
|
5799
6018
|
return json_string
|
5800
6019
|
|
@@ -7351,7 +7570,7 @@ class Graph:
|
|
7351
7570
|
return degree
|
7352
7571
|
|
7353
7572
|
@staticmethod
|
7354
|
-
def Vertices(graph):
|
7573
|
+
def Vertices(graph, vertexKey=None, reverse=False):
|
7355
7574
|
"""
|
7356
7575
|
Returns the list of vertices in the input graph.
|
7357
7576
|
|
@@ -7359,13 +7578,19 @@ class Graph:
|
|
7359
7578
|
----------
|
7360
7579
|
graph : topologic.Graph
|
7361
7580
|
The input graph.
|
7362
|
-
|
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.
|
7363
7585
|
Returns
|
7364
7586
|
-------
|
7365
7587
|
list
|
7366
7588
|
The list of vertices in the input graph.
|
7367
7589
|
|
7368
7590
|
"""
|
7591
|
+
|
7592
|
+
from topologicpy.Helper import Helper
|
7593
|
+
|
7369
7594
|
if not isinstance(graph, topologic.Graph):
|
7370
7595
|
print("Graph.Vertices - Error: The input graph is not a valid graph. Returning None.")
|
7371
7596
|
return None
|
@@ -7375,6 +7600,15 @@ class Graph:
|
|
7375
7600
|
_ = graph.Vertices(vertices)
|
7376
7601
|
except:
|
7377
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()
|
7378
7612
|
return vertices
|
7379
7613
|
|
7380
7614
|
@staticmethod
|