topologicpy 0.7.6__py3-none-any.whl → 0.7.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topologicpy/Graph.py +497 -223
- topologicpy/Grid.py +13 -4
- topologicpy/Topology.py +1 -1
- topologicpy/version.py +1 -1
- topologicpy-0.7.9.dist-info/LICENSE +21 -0
- topologicpy-0.7.9.dist-info/METADATA +112 -0
- {topologicpy-0.7.6.dist-info → topologicpy-0.7.9.dist-info}/RECORD +9 -9
- topologicpy-0.7.6.dist-info/LICENSE +0 -661
- topologicpy-0.7.6.dist-info/METADATA +0 -751
- {topologicpy-0.7.6.dist-info → topologicpy-0.7.9.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.6.dist-info → topologicpy-0.7.9.dist-info}/top_level.txt +0 -0
topologicpy/Graph.py
CHANGED
@@ -20,6 +20,9 @@ import time
|
|
20
20
|
import os
|
21
21
|
import warnings
|
22
22
|
|
23
|
+
from collections import namedtuple
|
24
|
+
from multiprocessing import Process, Queue
|
25
|
+
|
23
26
|
try:
|
24
27
|
import numpy as np
|
25
28
|
except:
|
@@ -62,6 +65,133 @@ except:
|
|
62
65
|
except:
|
63
66
|
warnings.warn("Graph - Error: Could not import tqdm.")
|
64
67
|
|
68
|
+
|
69
|
+
GraphQueueItem = namedtuple('GraphQueueItem', ['edges'])
|
70
|
+
|
71
|
+
class WorkerProcessPool(object):
|
72
|
+
"""
|
73
|
+
Create and manage a list of Worker processes. Each worker process
|
74
|
+
creates a 2D navigation graph.
|
75
|
+
"""
|
76
|
+
def __init__(self,
|
77
|
+
num_workers,
|
78
|
+
message_queue,
|
79
|
+
used,
|
80
|
+
face,
|
81
|
+
sources,
|
82
|
+
destinations,
|
83
|
+
tolerance=0.0001):
|
84
|
+
self.num_workers = num_workers
|
85
|
+
self.message_queue = message_queue
|
86
|
+
self.used = used
|
87
|
+
self.face = face
|
88
|
+
self.sources = sources
|
89
|
+
self.destinations = destinations
|
90
|
+
self.tolerance = tolerance
|
91
|
+
self.process_list = []
|
92
|
+
|
93
|
+
def startProcesses(self):
|
94
|
+
num_item_per_worker = len(self.sources) // self.num_workers
|
95
|
+
for i in range(self.num_workers):
|
96
|
+
if i == self.num_workers - 1:
|
97
|
+
begin = i * num_item_per_worker
|
98
|
+
sub_sources = self.sources[begin:]
|
99
|
+
else:
|
100
|
+
begin = i * num_item_per_worker
|
101
|
+
end = begin + num_item_per_worker
|
102
|
+
sub_sources = self.sources[begin : end]
|
103
|
+
wp = WorkerProcess(begin,
|
104
|
+
self.message_queue,
|
105
|
+
self.used,
|
106
|
+
self.face,
|
107
|
+
sub_sources,
|
108
|
+
self.destinations,
|
109
|
+
self.tolerance)
|
110
|
+
wp.start()
|
111
|
+
self.process_list.append(wp)
|
112
|
+
|
113
|
+
def stopProcesses(self):
|
114
|
+
for p in self.process_list:
|
115
|
+
p.join()
|
116
|
+
self.process_list = []
|
117
|
+
|
118
|
+
def join(self):
|
119
|
+
for p in self.process_list:
|
120
|
+
p.join()
|
121
|
+
|
122
|
+
|
123
|
+
class WorkerProcess(Process):
|
124
|
+
"""
|
125
|
+
Creates a 2D navigation graph from a subset of sources and the list of destinations.
|
126
|
+
"""
|
127
|
+
def __init__(self,
|
128
|
+
start_index,
|
129
|
+
message_queue,
|
130
|
+
used,
|
131
|
+
face,
|
132
|
+
sources,
|
133
|
+
destinations,
|
134
|
+
tolerance=0.0001):
|
135
|
+
Process.__init__(self, target=self.run)
|
136
|
+
self.start_index = start_index
|
137
|
+
self.message_queue = message_queue
|
138
|
+
self.used = used
|
139
|
+
self.face = face
|
140
|
+
self.sources = sources
|
141
|
+
self.destinations = destinations
|
142
|
+
self.tolerance = tolerance
|
143
|
+
|
144
|
+
def run(self):
|
145
|
+
from topologicpy.Topology import Topology
|
146
|
+
from topologicpy.Vertex import Vertex
|
147
|
+
from topologicpy.Edge import Edge
|
148
|
+
|
149
|
+
edges = []
|
150
|
+
face = Topology.ByBREPString(self.face)
|
151
|
+
sources = [Topology.ByBREPString(s) for s in self.sources]
|
152
|
+
destinations = [Topology.ByBREPString(s) for s in self.destinations]
|
153
|
+
for i in range(len(sources)):
|
154
|
+
source = sources[i]
|
155
|
+
index_b = Vertex.Index(source, destinations)
|
156
|
+
for j in range(len(destinations)):
|
157
|
+
destination = destinations[j]
|
158
|
+
index_a = Vertex.Index(destination, sources)
|
159
|
+
if self.used[i + self.start_index][j] == 1 or self.used[j][i + self.start_index]:
|
160
|
+
continue
|
161
|
+
if Vertex.Distance(source, destination) > self.tolerance:
|
162
|
+
edge = Edge.ByVertices([source, destination])
|
163
|
+
e = Topology.Boolean(edge, face, operation="intersect")
|
164
|
+
if Topology.IsInstance(e, "Edge"):
|
165
|
+
edges.append(edge)
|
166
|
+
self.used[i + self.start_index][j] = 1
|
167
|
+
if not index_a == None and not index_b == None:
|
168
|
+
self.used[j][i + self.start_index] = 1
|
169
|
+
if len(edges) > 0:
|
170
|
+
edges_str = [Topology.BREPString(s) for s in edges]
|
171
|
+
self.message_queue.put(GraphQueueItem(edges_str))
|
172
|
+
|
173
|
+
|
174
|
+
class MergingProcess(Process):
|
175
|
+
"""
|
176
|
+
Receive message from other processes and merging the result
|
177
|
+
"""
|
178
|
+
def __init__(self, message_queue):
|
179
|
+
Process.__init__(self, target=self.wait_message)
|
180
|
+
self.message_queue = message_queue
|
181
|
+
self.final_edges = []
|
182
|
+
|
183
|
+
def wait_message(self):
|
184
|
+
while True:
|
185
|
+
try:
|
186
|
+
item = self.message_queue.get()
|
187
|
+
if item is None:
|
188
|
+
self.message_queue.put(GraphQueueItem(self.final_edges))
|
189
|
+
break
|
190
|
+
self.final_edges.extend(item.edges)
|
191
|
+
except Exception as e:
|
192
|
+
print(str(e))
|
193
|
+
|
194
|
+
|
65
195
|
class _Tree:
|
66
196
|
def __init__(self, node="", *children):
|
67
197
|
self.node = node
|
@@ -536,26 +666,35 @@ class Graph:
|
|
536
666
|
|
537
667
|
@staticmethod
|
538
668
|
def BOTGraph(graph,
|
539
|
-
bidirectional=False,
|
540
|
-
includeAttributes=False,
|
541
|
-
includeLabel=False,
|
542
|
-
includeGeometry=False,
|
543
|
-
siteLabel = "Site_0001",
|
544
|
-
siteDictionary = None,
|
545
|
-
buildingLabel = "Building_0001",
|
546
|
-
buildingDictionary = None ,
|
547
|
-
storeyPrefix = "Storey",
|
548
|
-
floorLevels =[],
|
549
|
-
|
550
|
-
typeKey="type",
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
669
|
+
bidirectional: bool = False,
|
670
|
+
includeAttributes: bool = False,
|
671
|
+
includeLabel: bool = False,
|
672
|
+
includeGeometry: bool = False,
|
673
|
+
siteLabel: str = "Site_0001",
|
674
|
+
siteDictionary: dict = None,
|
675
|
+
buildingLabel: str = "Building_0001",
|
676
|
+
buildingDictionary: dict = None ,
|
677
|
+
storeyPrefix: str = "Storey",
|
678
|
+
floorLevels: list = [],
|
679
|
+
vertexLabelKey: str = "label",
|
680
|
+
typeKey: str = "type",
|
681
|
+
verticesKey: str = "vertices",
|
682
|
+
edgesKey: str = "edges",
|
683
|
+
edgeLabelKey: str = "",
|
684
|
+
sourceKey: str = "source",
|
685
|
+
targetKey: str = "target",
|
686
|
+
xKey: str = "hasX",
|
687
|
+
yKey: str = "hasY",
|
688
|
+
zKey: str = "hasZ",
|
689
|
+
geometryKey: str = "brep",
|
690
|
+
spaceType: str = "space",
|
691
|
+
wallType: str = "wall",
|
692
|
+
slabType: str = "slab",
|
693
|
+
doorType: str = "door",
|
694
|
+
windowType: str = "window",
|
695
|
+
contentType: str = "content",
|
696
|
+
namespace: str = "http://github.com/wassimj/topologicpy/resources",
|
697
|
+
mantissa: int = 6
|
559
698
|
):
|
560
699
|
"""
|
561
700
|
Creates an RDF graph according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.
|
@@ -584,9 +723,29 @@ class Graph:
|
|
584
723
|
The desired prefixed to use for each building storey. The default is "Storey".
|
585
724
|
floorLevels : list , optional
|
586
725
|
The list of floor levels. This should be a numeric list, sorted from lowest to highest.
|
587
|
-
If not provided, floorLevels will be computed automatically based on the vertices'
|
588
|
-
|
589
|
-
The
|
726
|
+
If not provided, floorLevels will be computed automatically based on the vertices' (zKey)) attribute. See below.
|
727
|
+
verticesKey : str , optional
|
728
|
+
The desired key name to call vertices. The default is "vertices".
|
729
|
+
edgesKey : str , optional
|
730
|
+
The desired key name to call edges. The default is "edges".
|
731
|
+
vertexLabelKey : str , optional
|
732
|
+
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.
|
733
|
+
Note: If vertex labels are not unique, they will be forced to be unique.
|
734
|
+
edgeLabelKey : str , optional
|
735
|
+
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.
|
736
|
+
Note: If edge labels are not unique, they will be forced to be unique.
|
737
|
+
sourceKey : str , optional
|
738
|
+
The dictionary key used to store the source vertex. The default is "source".
|
739
|
+
targetKey : str , optional
|
740
|
+
The dictionary key used to store the target vertex. The default is "target".
|
741
|
+
xKey : str , optional
|
742
|
+
The desired key name to use for x-coordinates. The default is "hasX".
|
743
|
+
yKey : str , optional
|
744
|
+
The desired key name to use for y-coordinates. The default is "hasY".
|
745
|
+
zKey : str , optional
|
746
|
+
The desired key name to use for z-coordinates. The default is "hasZ".
|
747
|
+
geometryKey : str , optional
|
748
|
+
The desired key name to use for geometry. The default is "brep".
|
590
749
|
typeKey : str , optional
|
591
750
|
The dictionary key to use to look up the type of the node. The default is "type".
|
592
751
|
geometryKey : str , optional
|
@@ -603,7 +762,12 @@ class Graph:
|
|
603
762
|
The dictionary string value to use to look up vertices of type "window". The default is "window".
|
604
763
|
contentType : str , optional
|
605
764
|
The dictionary string value to use to look up vertices of type "content". The default is "contents".
|
765
|
+
namespace : str , optional
|
766
|
+
The desired namespace to use in the BOT graph. The default is "http://github.com/wassimj/topologicpy/resources".
|
767
|
+
mantissa : int , optional
|
768
|
+
The desired length of the mantissa. The default is 6.
|
606
769
|
|
770
|
+
|
607
771
|
Returns
|
608
772
|
-------
|
609
773
|
rdflib.graph.Graph
|
@@ -637,7 +801,20 @@ class Graph:
|
|
637
801
|
|
638
802
|
if floorLevels == None:
|
639
803
|
floorLevels = []
|
640
|
-
|
804
|
+
|
805
|
+
json_data = Graph.JSONData(graph,
|
806
|
+
verticesKey=verticesKey,
|
807
|
+
edgesKey=edgesKey,
|
808
|
+
vertexLabelKey=vertexLabelKey,
|
809
|
+
edgeLabelKey=edgeLabelKey,
|
810
|
+
sourceKey=sourceKey,
|
811
|
+
targetKey=targetKey,
|
812
|
+
xKey=xKey,
|
813
|
+
yKey=yKey,
|
814
|
+
zKey=zKey,
|
815
|
+
geometryKey=geometryKey,
|
816
|
+
mantissa=mantissa)
|
817
|
+
|
641
818
|
# Create an empty RDF graph
|
642
819
|
bot_graph = RDFGraph()
|
643
820
|
|
@@ -660,28 +837,41 @@ class Graph:
|
|
660
837
|
keys = Dictionary.Keys(siteDictionary)
|
661
838
|
for key in keys:
|
662
839
|
value = Dictionary.ValueAtKey(siteDictionary, key)
|
663
|
-
if not (key ==
|
664
|
-
|
840
|
+
if not (key == vertexLabelKey) and not (key == typeKey):
|
841
|
+
if isinstance(value, float):
|
842
|
+
datatype = XSD.float
|
843
|
+
elif isinstance(value, bool):
|
844
|
+
datatype = XSD.boolean
|
845
|
+
elif isinstance(value, int):
|
846
|
+
datatype = XSD.integer
|
847
|
+
elif isinstance(value, str):
|
848
|
+
datatype = XSD.string
|
849
|
+
bot_graph.add((site_uri, top[key], Literal(value, datatype=datatype)))
|
665
850
|
# Add building
|
666
851
|
building_uri = URIRef(buildingLabel)
|
667
852
|
bot_graph.add((building_uri, rdf.type, bot.Building))
|
668
853
|
if includeLabel:
|
669
854
|
bot_graph.add((building_uri, RDFS.label, Literal(buildingLabel)))
|
670
855
|
if Topology.IsInstance(buildingDictionary, "Dictionary"):
|
671
|
-
keys = Dictionary.Keys(
|
856
|
+
keys = Dictionary.Keys(siteDictionary)
|
672
857
|
for key in keys:
|
673
|
-
value = Dictionary.ValueAtKey(
|
674
|
-
if key ==
|
675
|
-
if
|
676
|
-
|
677
|
-
elif
|
678
|
-
|
858
|
+
value = Dictionary.ValueAtKey(siteDictionary, key)
|
859
|
+
if not (key == vertexLabelKey) and not (key == typeKey):
|
860
|
+
if isinstance(value, float):
|
861
|
+
datatype = XSD.float
|
862
|
+
elif isinstance(value, bool):
|
863
|
+
datatype = XSD.boolean
|
864
|
+
elif isinstance(value, int):
|
865
|
+
datatype = XSD.integer
|
866
|
+
elif isinstance(value, str):
|
867
|
+
datatype = XSD.string
|
868
|
+
bot_graph.add((building_uri, top[key], Literal(value, datatype=datatype)))
|
679
869
|
# Add stories
|
680
870
|
# if floor levels are not given, then need to be computed
|
681
871
|
if len(floorLevels) == 0:
|
682
|
-
for node, attributes in json_data[
|
872
|
+
for node, attributes in json_data[verticesKey].items():
|
683
873
|
if slabType.lower() in attributes[typeKey].lower():
|
684
|
-
floorLevels.append(attributes[
|
874
|
+
floorLevels.append(attributes[zKey])
|
685
875
|
floorLevels = list(set(floorLevels))
|
686
876
|
floorLevels.sort()
|
687
877
|
floorLevels = floorLevels[:-1]
|
@@ -705,12 +895,12 @@ class Graph:
|
|
705
895
|
bot_graph.add((storey_uri, bot.isPartOf, building_uri)) # might not be needed
|
706
896
|
|
707
897
|
# Add vertices as RDF resources
|
708
|
-
for node, attributes in json_data[
|
898
|
+
for node, attributes in json_data[verticesKey].items():
|
709
899
|
node_uri = URIRef(top[node])
|
710
900
|
if spaceType.lower() in attributes[typeKey].lower():
|
711
901
|
bot_graph.add((node_uri, rdf.type, bot.Space))
|
712
902
|
# Find the storey it is on
|
713
|
-
z = attributes[
|
903
|
+
z = attributes[zKey]
|
714
904
|
level = Helper.Position(z, floorLevels)
|
715
905
|
if level > len(storey_uris):
|
716
906
|
level = len(storey_uris)
|
@@ -731,46 +921,42 @@ class Graph:
|
|
731
921
|
|
732
922
|
if includeAttributes:
|
733
923
|
for key, value in attributes.items():
|
734
|
-
if key == "brepType":
|
735
|
-
print("Key = brepType, Value =", value, value.__class__)
|
736
924
|
if key == geometryKey:
|
737
925
|
if includeGeometry:
|
738
926
|
bot_graph.add((node_uri, bot.hasSimpleGeometry, Literal(value)))
|
739
|
-
if key ==
|
927
|
+
if key == vertexLabelKey:
|
740
928
|
if includeLabel:
|
741
929
|
bot_graph.add((node_uri, RDFS.label, Literal(value)))
|
742
930
|
elif key != typeKey and key != geometryKey:
|
743
931
|
if isinstance(value, float):
|
744
932
|
datatype = XSD.float
|
745
933
|
elif isinstance(value, bool):
|
746
|
-
print("got boolean")
|
747
934
|
datatype = XSD.boolean
|
748
935
|
elif isinstance(value, int):
|
749
|
-
print("got integer")
|
750
936
|
datatype = XSD.integer
|
751
937
|
elif isinstance(value, str):
|
752
938
|
datatype = XSD.string
|
753
939
|
bot_graph.add((node_uri, top[key], Literal(value, datatype=datatype)))
|
754
940
|
if includeLabel:
|
755
941
|
for key, value in attributes.items():
|
756
|
-
if key ==
|
942
|
+
if key == vertexLabelKey:
|
757
943
|
bot_graph.add((node_uri, RDFS.label, Literal(value)))
|
758
944
|
|
759
945
|
# Add edges as RDF triples
|
760
|
-
for edge, attributes in json_data[
|
761
|
-
source = attributes[
|
762
|
-
target = attributes[
|
946
|
+
for edge, attributes in json_data[edgesKey].items():
|
947
|
+
source = attributes[sourceKey]
|
948
|
+
target = attributes[targetKey]
|
763
949
|
source_uri = URIRef(top[source])
|
764
950
|
target_uri = URIRef(top[target])
|
765
|
-
if spaceType.lower() in json_data[
|
951
|
+
if spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and spaceType.lower() in json_data[verticesKey][target][typeKey].lower():
|
766
952
|
bot_graph.add((source_uri, bot.adjacentTo, target_uri))
|
767
953
|
if bidirectional:
|
768
954
|
bot_graph.add((target_uri, bot.adjacentTo, source_uri))
|
769
|
-
elif spaceType.lower() in json_data[
|
955
|
+
elif spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and wallType.lower() in json_data[verticesKey][target][typeKey].lower():
|
770
956
|
bot_graph.add((target_uri, bot.interfaceOf, source_uri))
|
771
|
-
elif spaceType.lower() in json_data[
|
957
|
+
elif spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and slabType.lower() in json_data['vertices'][target][typeKey].lower():
|
772
958
|
bot_graph.add((target_uri, bot.interfaceOf, source_uri))
|
773
|
-
elif spaceType.lower() in json_data[
|
959
|
+
elif spaceType.lower() in json_data[verticesKey][source][typeKey].lower() and contentType.lower() in json_data[verticesKey][target][typeKey].lower():
|
774
960
|
bot_graph.add((source_uri, bot.containsElement, target_uri))
|
775
961
|
if bidirectional:
|
776
962
|
bot_graph.add((target_uri, bot.isPartOf, source_uri))
|
@@ -782,26 +968,36 @@ class Graph:
|
|
782
968
|
|
783
969
|
@staticmethod
|
784
970
|
def BOTString(graph,
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
971
|
+
format="turtle",
|
972
|
+
bidirectional: bool = False,
|
973
|
+
includeAttributes: bool = False,
|
974
|
+
includeLabel: bool = False,
|
975
|
+
includeGeometry: bool = False,
|
976
|
+
siteLabel: str = "Site_0001",
|
977
|
+
siteDictionary: dict = None,
|
978
|
+
buildingLabel: str = "Building_0001",
|
979
|
+
buildingDictionary: dict = None ,
|
980
|
+
storeyPrefix: str = "Storey",
|
981
|
+
floorLevels: list = [],
|
982
|
+
vertexLabelKey: str = "label",
|
983
|
+
typeKey: str = "type",
|
984
|
+
verticesKey: str = "vertices",
|
985
|
+
edgesKey: str = "edges",
|
986
|
+
edgeLabelKey: str = "",
|
987
|
+
sourceKey: str = "source",
|
988
|
+
targetKey: str = "target",
|
989
|
+
xKey: str = "hasX",
|
990
|
+
yKey: str = "hasY",
|
991
|
+
zKey: str = "hasZ",
|
992
|
+
geometryKey: str = "brep",
|
993
|
+
spaceType: str = "space",
|
994
|
+
wallType: str = "wall",
|
995
|
+
slabType: str = "slab",
|
996
|
+
doorType: str = "door",
|
997
|
+
windowType: str = "window",
|
998
|
+
contentType: str = "content",
|
999
|
+
namespace: str = "http://github.com/wassimj/topologicpy/resources",
|
1000
|
+
mantissa: int = 6
|
805
1001
|
):
|
806
1002
|
|
807
1003
|
"""
|
@@ -841,11 +1037,33 @@ class Graph:
|
|
841
1037
|
The desired prefixed to use for each building storey. The default is "Storey".
|
842
1038
|
floorLevels : list , optional
|
843
1039
|
The list of floor levels. This should be a numeric list, sorted from lowest to highest.
|
844
|
-
If not provided, floorLevels will be computed automatically based on the vertices'
|
1040
|
+
If not provided, floorLevels will be computed automatically based on the vertices' (zKey)) attribute. See below.
|
1041
|
+
verticesKey : str , optional
|
1042
|
+
The desired key name to call vertices. The default is "vertices".
|
1043
|
+
edgesKey : str , optional
|
1044
|
+
The desired key name to call edges. The default is "edges".
|
1045
|
+
vertexLabelKey : str , optional
|
1046
|
+
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.
|
1047
|
+
Note: If vertex labels are not unique, they will be forced to be unique.
|
1048
|
+
edgeLabelKey : str , optional
|
1049
|
+
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.
|
1050
|
+
Note: If edge labels are not unique, they will be forced to be unique.
|
1051
|
+
sourceKey : str , optional
|
1052
|
+
The dictionary key used to store the source vertex. The default is "source".
|
1053
|
+
targetKey : str , optional
|
1054
|
+
The dictionary key used to store the target vertex. The default is "target".
|
1055
|
+
xKey : str , optional
|
1056
|
+
The desired key name to use for x-coordinates. The default is "hasX".
|
1057
|
+
yKey : str , optional
|
1058
|
+
The desired key name to use for y-coordinates. The default is "hasY".
|
1059
|
+
zKey : str , optional
|
1060
|
+
The desired key name to use for z-coordinates. The default is "hasZ".
|
1061
|
+
geometryKey : str , optional
|
1062
|
+
The desired key name to use for geometry. The default is "brep".
|
845
1063
|
typeKey : str , optional
|
846
1064
|
The dictionary key to use to look up the type of the node. The default is "type".
|
847
|
-
|
848
|
-
The dictionary key to use to look up the
|
1065
|
+
geometryKey : str , optional
|
1066
|
+
The dictionary key to use to look up the geometry of the node. The default is "brep".
|
849
1067
|
spaceType : str , optional
|
850
1068
|
The dictionary string value to use to look up vertices of type "space". The default is "space".
|
851
1069
|
wallType : str , optional
|
@@ -858,6 +1076,10 @@ class Graph:
|
|
858
1076
|
The dictionary string value to use to look up vertices of type "window". The default is "window".
|
859
1077
|
contentType : str , optional
|
860
1078
|
The dictionary string value to use to look up vertices of type "content". The default is "contents".
|
1079
|
+
namespace : str , optional
|
1080
|
+
The desired namespace to use in the BOT graph. The default is "http://github.com/wassimj/topologicpy/resources".
|
1081
|
+
mantissa : int , optional
|
1082
|
+
The desired length of the mantissa. The default is 6.
|
861
1083
|
|
862
1084
|
|
863
1085
|
Returns
|
@@ -866,27 +1088,36 @@ class Graph:
|
|
866
1088
|
The rdf graph serialized string using the BOT ontology.
|
867
1089
|
"""
|
868
1090
|
|
869
|
-
bot_graph = Graph.BOTGraph(graph,
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
1091
|
+
bot_graph = Graph.BOTGraph(graph= graph,
|
1092
|
+
bidirectional= bidirectional,
|
1093
|
+
includeAttributes= includeAttributes,
|
1094
|
+
includeLabel= includeLabel,
|
1095
|
+
includeGeometry= includeGeometry,
|
1096
|
+
siteLabel= siteLabel,
|
1097
|
+
siteDictionary= siteDictionary,
|
1098
|
+
buildingLabel= buildingLabel,
|
1099
|
+
buildingDictionary= buildingDictionary,
|
1100
|
+
storeyPrefix= storeyPrefix,
|
1101
|
+
floorLevels= floorLevels,
|
1102
|
+
vertexLabelKey= vertexLabelKey,
|
1103
|
+
typeKey= typeKey,
|
1104
|
+
verticesKey= verticesKey,
|
1105
|
+
edgesKey= edgesKey,
|
1106
|
+
edgeLabelKey= edgeLabelKey,
|
1107
|
+
sourceKey= sourceKey,
|
1108
|
+
targetKey= targetKey,
|
1109
|
+
xKey= xKey,
|
1110
|
+
yKey= yKey,
|
1111
|
+
zKey= zKey,
|
1112
|
+
geometryKey= geometryKey,
|
1113
|
+
spaceType= spaceType,
|
1114
|
+
wallType= wallType,
|
1115
|
+
slabType= slabType,
|
1116
|
+
doorType= doorType,
|
1117
|
+
windowType= windowType,
|
1118
|
+
contentType= contentType,
|
1119
|
+
namespace= namespace,
|
1120
|
+
mantissa= mantissa)
|
890
1121
|
return bot_graph.serialize(format=format)
|
891
1122
|
|
892
1123
|
@staticmethod
|
@@ -2020,7 +2251,21 @@ class Graph:
|
|
2020
2251
|
return Graph.ByVerticesEdges(g_vertices, g_edges)
|
2021
2252
|
|
2022
2253
|
@staticmethod
|
2023
|
-
def ByTopology(topology,
|
2254
|
+
def ByTopology(topology,
|
2255
|
+
direct: bool = True,
|
2256
|
+
directApertures: bool = False,
|
2257
|
+
viaSharedTopologies: bool = False,
|
2258
|
+
viaSharedApertures: bool = False,
|
2259
|
+
toExteriorTopologies: bool = False,
|
2260
|
+
toExteriorApertures: bool = False,
|
2261
|
+
toContents: bool = False,
|
2262
|
+
toOutposts: bool = False,
|
2263
|
+
idKey: str = "TOPOLOGIC_ID",
|
2264
|
+
outpostsKey: str = "outposts",
|
2265
|
+
useInternalVertex: bool =True,
|
2266
|
+
storeBREP: bool =False,
|
2267
|
+
mantissa: int = 6,
|
2268
|
+
tolerance: float = 0.0001):
|
2024
2269
|
"""
|
2025
2270
|
Creates a graph.See https://en.wikipedia.org/wiki/Graph_(discrete_mathematics).
|
2026
2271
|
|
@@ -2352,7 +2597,7 @@ class Graph:
|
|
2352
2597
|
else:
|
2353
2598
|
vst2 = content.CenterOfMass()
|
2354
2599
|
d1 = content.GetDictionary()
|
2355
|
-
vst2 = Vertex.ByCoordinates(
|
2600
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa), Vertex.Y(vst2, mantissa=mantissa), Vertex.Z(vst2, mantissa=mantissa))
|
2356
2601
|
if storeBREP:
|
2357
2602
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2358
2603
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -2372,7 +2617,7 @@ class Graph:
|
|
2372
2617
|
else:
|
2373
2618
|
vsa = sharedAp.CenterOfMass()
|
2374
2619
|
d1 = sharedAp.GetDictionary()
|
2375
|
-
vsa = Vertex.ByCoordinates(
|
2620
|
+
vsa = Vertex.ByCoordinates(Vertex.X(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Y(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Z(vsa, mantissa=mantissa)+(tolerance*100))
|
2376
2621
|
if storeBREP:
|
2377
2622
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
2378
2623
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -2414,7 +2659,7 @@ class Graph:
|
|
2414
2659
|
else:
|
2415
2660
|
vst2 = content.CenterOfMass()
|
2416
2661
|
d1 = content.GetDictionary()
|
2417
|
-
vst2 = Vertex.ByCoordinates(
|
2662
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
2418
2663
|
if storeBREP:
|
2419
2664
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2420
2665
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -2434,7 +2679,7 @@ class Graph:
|
|
2434
2679
|
else:
|
2435
2680
|
vea = exTop.CenterOfMass()
|
2436
2681
|
d1 = exTop.GetDictionary()
|
2437
|
-
vea = Vertex.ByCoordinates(
|
2682
|
+
vea = Vertex.ByCoordinates(Vertex.X(vea, mantissa=mantissa)+(tolerance*100), Vertex.Y(vea, mantissa=mantissa)+(tolerance*100), Vertex.Z(vea, mantissa=mantissa)+(tolerance*100))
|
2438
2683
|
if storeBREP:
|
2439
2684
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2440
2685
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -2456,7 +2701,7 @@ class Graph:
|
|
2456
2701
|
vcn = Topology.InternalVertex(content, tolerance)
|
2457
2702
|
else:
|
2458
2703
|
vcn = content.CenterOfMass()
|
2459
|
-
vcn = Vertex.ByCoordinates(
|
2704
|
+
vcn = Vertex.ByCoordinates(Vertex.X(vcn, mantissa=mantissa)+(tolerance*100), Vertex.Y(vcn, mantissa=mantissa)+(tolerance*100), Vertex.Z(vcn, mantissa=mantissa)+(tolerance*100))
|
2460
2705
|
d1 = content.GetDictionary()
|
2461
2706
|
if storeBREP:
|
2462
2707
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -2562,7 +2807,7 @@ class Graph:
|
|
2562
2807
|
vst2 = Topology.InternalVertex(content, tolerance)
|
2563
2808
|
else:
|
2564
2809
|
vst2 = content.CenterOfMass()
|
2565
|
-
vst2 = Vertex.ByCoordinates(
|
2810
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
2566
2811
|
d1 = content.GetDictionary()
|
2567
2812
|
if storeBREP:
|
2568
2813
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -2583,7 +2828,7 @@ class Graph:
|
|
2583
2828
|
else:
|
2584
2829
|
vst = exTop.CenterOfMass()
|
2585
2830
|
d1 = exTop.GetDictionary()
|
2586
|
-
vst = Vertex.ByCoordinates(
|
2831
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
2587
2832
|
if storeBREP:
|
2588
2833
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2589
2834
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -2605,7 +2850,7 @@ class Graph:
|
|
2605
2850
|
vst = Topology.InternalVertex(content, tolerance)
|
2606
2851
|
else:
|
2607
2852
|
vst = content.CenterOfMass()
|
2608
|
-
vst = Vertex.ByCoordinates(
|
2853
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
2609
2854
|
d1 = content.GetDictionary()
|
2610
2855
|
if storeBREP:
|
2611
2856
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -2760,7 +3005,7 @@ class Graph:
|
|
2760
3005
|
vst2 = Topology.InternalVertex(content, tolerance)
|
2761
3006
|
else:
|
2762
3007
|
vst2 = content.CenterOfMass()
|
2763
|
-
vst2 = Vertex.ByCoordinates(
|
3008
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
2764
3009
|
d1 = content.GetDictionary()
|
2765
3010
|
if storeBREP:
|
2766
3011
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -2781,7 +3026,7 @@ class Graph:
|
|
2781
3026
|
else:
|
2782
3027
|
vst = sharedAp.CenterOfMass()
|
2783
3028
|
d1 = sharedAp.GetDictionary()
|
2784
|
-
vst = Vertex.ByCoordinates(
|
3029
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
2785
3030
|
if storeBREP:
|
2786
3031
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
2787
3032
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -2821,7 +3066,7 @@ class Graph:
|
|
2821
3066
|
vst2 = Topology.InternalVertex(content, tolerance)
|
2822
3067
|
else:
|
2823
3068
|
vst2 = content.CenterOfMass()
|
2824
|
-
vst2 = Vertex.ByCoordinates(
|
3069
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
2825
3070
|
d1 = content.GetDictionary()
|
2826
3071
|
if storeBREP:
|
2827
3072
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -2842,7 +3087,7 @@ class Graph:
|
|
2842
3087
|
else:
|
2843
3088
|
vst = exTop.CenterOfMass()
|
2844
3089
|
d1 = exTop.GetDictionary()
|
2845
|
-
vst = Vertex.ByCoordinates(
|
3090
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
2846
3091
|
if storeBREP:
|
2847
3092
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2848
3093
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -2864,7 +3109,7 @@ class Graph:
|
|
2864
3109
|
vst = Topology.InternalVertex(content, tolerance)
|
2865
3110
|
else:
|
2866
3111
|
vst = content.CenterOfMass()
|
2867
|
-
vst = Vertex.ByCoordinates(
|
3112
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
2868
3113
|
d1 = content.GetDictionary()
|
2869
3114
|
if storeBREP:
|
2870
3115
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -3010,7 +3255,7 @@ class Graph:
|
|
3010
3255
|
vst2 = Topology.InternalVertex(content, tolerance)
|
3011
3256
|
else:
|
3012
3257
|
vst2 = content.CenterOfMass()
|
3013
|
-
vst2 = Vertex.ByCoordinates(
|
3258
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3014
3259
|
d1 = content.GetDictionary()
|
3015
3260
|
if storeBREP:
|
3016
3261
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -3031,7 +3276,7 @@ class Graph:
|
|
3031
3276
|
else:
|
3032
3277
|
vst = exTop.CenterOfMass()
|
3033
3278
|
d1 = exTop.GetDictionary()
|
3034
|
-
vst = Vertex.ByCoordinates(
|
3279
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3035
3280
|
if storeBREP:
|
3036
3281
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3037
3282
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -3053,7 +3298,7 @@ class Graph:
|
|
3053
3298
|
vst = Topology.InternalVertex(content, tolerance)
|
3054
3299
|
else:
|
3055
3300
|
vst = content.CenterOfMass()
|
3056
|
-
vst = Vertex.ByCoordinates(
|
3301
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3057
3302
|
d1 = content.GetDictionary()
|
3058
3303
|
if storeBREP:
|
3059
3304
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -3216,7 +3461,7 @@ class Graph:
|
|
3216
3461
|
vst2 = Topology.InternalVertex(content, tolerance)
|
3217
3462
|
else:
|
3218
3463
|
vst2 = content.CenterOfMass()
|
3219
|
-
vst2 = Vertex.ByCoordinates(
|
3464
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3220
3465
|
d1 = content.GetDictionary()
|
3221
3466
|
if storeBREP:
|
3222
3467
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -3237,7 +3482,7 @@ class Graph:
|
|
3237
3482
|
else:
|
3238
3483
|
vst = sharedAp.CenterOfMass()
|
3239
3484
|
d1 = sharedAp.GetDictionary()
|
3240
|
-
vst = Vertex.ByCoordinates(
|
3485
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3241
3486
|
if storeBREP:
|
3242
3487
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
3243
3488
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -3267,7 +3512,7 @@ class Graph:
|
|
3267
3512
|
vst2 = Topology.InternalVertex(content, tolerance)
|
3268
3513
|
else:
|
3269
3514
|
vst2 = content.CenterOfMass()
|
3270
|
-
vst2 = Vertex.ByCoordinates(
|
3515
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3271
3516
|
d1 = content.GetDictionary()
|
3272
3517
|
if storeBREP:
|
3273
3518
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -3288,7 +3533,7 @@ class Graph:
|
|
3288
3533
|
else:
|
3289
3534
|
vst = exTop.CenterOfMass()
|
3290
3535
|
d1 = exTop.GetDictionary()
|
3291
|
-
vst = Vertex.ByCoordinates(
|
3536
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3292
3537
|
if storeBREP:
|
3293
3538
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3294
3539
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -3310,7 +3555,7 @@ class Graph:
|
|
3310
3555
|
vst = Topology.InternalVertex(content, tolerance)
|
3311
3556
|
else:
|
3312
3557
|
vst = content.CenterOfMass()
|
3313
|
-
vst = Vertex.ByCoordinates(
|
3558
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3314
3559
|
d1 = content.GetDictionary()
|
3315
3560
|
if storeBREP:
|
3316
3561
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -3462,7 +3707,7 @@ class Graph:
|
|
3462
3707
|
vst2 = Topology.InternalVertex(content, tolerance)
|
3463
3708
|
else:
|
3464
3709
|
vst2 = content.CenterOfMass()
|
3465
|
-
vst2 = Vertex.ByCoordinates(
|
3710
|
+
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3466
3711
|
d1 = content.GetDictionary()
|
3467
3712
|
if storeBREP:
|
3468
3713
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
@@ -3483,7 +3728,7 @@ class Graph:
|
|
3483
3728
|
else:
|
3484
3729
|
vst = exTop.CenterOfMass()
|
3485
3730
|
d1 = exTop.GetDictionary()
|
3486
|
-
vst = Vertex.ByCoordinates(
|
3731
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3487
3732
|
if storeBREP:
|
3488
3733
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3489
3734
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -3515,7 +3760,7 @@ class Graph:
|
|
3515
3760
|
else:
|
3516
3761
|
vst = content.CenterOfMass()
|
3517
3762
|
d1 = content.GetDictionary()
|
3518
|
-
vst = Vertex.ByCoordinates(
|
3763
|
+
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3519
3764
|
if storeBREP:
|
3520
3765
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3521
3766
|
d3 = mergeDictionaries2([d1, d2])
|
@@ -4358,38 +4603,49 @@ class Graph:
|
|
4358
4603
|
|
4359
4604
|
@staticmethod
|
4360
4605
|
def ExportToBOT(graph,
|
4361
|
-
path,
|
4362
|
-
format="turtle",
|
4363
|
-
|
4364
|
-
|
4365
|
-
|
4366
|
-
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
4370
|
-
|
4371
|
-
|
4372
|
-
|
4373
|
-
|
4374
|
-
|
4375
|
-
|
4376
|
-
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4382
|
-
|
4383
|
-
|
4606
|
+
path: str,
|
4607
|
+
format: str = "turtle",
|
4608
|
+
overwrite: bool = False,
|
4609
|
+
bidirectional: bool = False,
|
4610
|
+
includeAttributes: bool = False,
|
4611
|
+
includeLabel: bool = False,
|
4612
|
+
includeGeometry: bool = False,
|
4613
|
+
siteLabel: str = "Site_0001",
|
4614
|
+
siteDictionary: dict = None,
|
4615
|
+
buildingLabel: str = "Building_0001",
|
4616
|
+
buildingDictionary: dict = None ,
|
4617
|
+
storeyPrefix: str = "Storey",
|
4618
|
+
floorLevels: list = [],
|
4619
|
+
vertexLabelKey: str = "label",
|
4620
|
+
typeKey: str = "type",
|
4621
|
+
verticesKey: str = "vertices",
|
4622
|
+
edgesKey: str = "edges",
|
4623
|
+
edgeLabelKey: str = "",
|
4624
|
+
sourceKey: str = "source",
|
4625
|
+
targetKey: str = "target",
|
4626
|
+
xKey: str = "hasX",
|
4627
|
+
yKey: str = "hasY",
|
4628
|
+
zKey: str = "hasZ",
|
4629
|
+
geometryKey: str = "brep",
|
4630
|
+
spaceType: str = "space",
|
4631
|
+
wallType: str = "wall",
|
4632
|
+
slabType: str = "slab",
|
4633
|
+
doorType: str = "door",
|
4634
|
+
windowType: str = "window",
|
4635
|
+
contentType: str = "content",
|
4636
|
+
namespace: str = "http://github.com/wassimj/topologicpy/resources",
|
4637
|
+
mantissa: int = 6
|
4384
4638
|
):
|
4385
4639
|
|
4386
4640
|
"""
|
4387
|
-
|
4641
|
+
Exports the input graph to an RDF graph serialized according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.
|
4388
4642
|
|
4389
4643
|
Parameters
|
4390
4644
|
----------
|
4391
4645
|
graph : topologic_core.Graph
|
4392
4646
|
The input graph.
|
4647
|
+
path : str
|
4648
|
+
The desired path to where the RDF/BOT file will be saved.
|
4393
4649
|
format : str , optional
|
4394
4650
|
The desired output format, the options are listed below. Thde default is "turtle".
|
4395
4651
|
turtle, ttl or turtle2 : Turtle, turtle2 is just turtle with more spacing & linebreaks
|
@@ -4400,10 +4656,6 @@ class Graph:
|
|
4400
4656
|
trig : Trig , Turtle-like format for RDF triples + context (RDF quads) and thus multiple graphs
|
4401
4657
|
trix : Trix , RDF/XML-like format for RDF quads
|
4402
4658
|
nquads : N-Quads , N-Triples-like format for RDF quads
|
4403
|
-
namespace : str , optional
|
4404
|
-
The desired namespace for creating IRIs for entities. The default is "http://github.com/wassimj/topologicpy/resources".
|
4405
|
-
path : str
|
4406
|
-
The desired path to where the RDF/BOT file will be saved.
|
4407
4659
|
overwrite : bool , optional
|
4408
4660
|
If set to True, any existing file is overwritten. Otherwise, it is not. The default is False.
|
4409
4661
|
bidirectional : bool , optional
|
@@ -4413,7 +4665,7 @@ class Graph:
|
|
4413
4665
|
includeLabel : bool , optional
|
4414
4666
|
If set to True, a label is attached to each node. Otherwise, it is not. The default is False.
|
4415
4667
|
includeGeometry : bool , optional
|
4416
|
-
If set to True, the geometry associated with vertices in the graph are written out. Otherwise,
|
4668
|
+
If set to True, the geometry associated with vertices in the graph are written out. Otherwise, they are not. The default is False.
|
4417
4669
|
siteLabel : str , optional
|
4418
4670
|
The desired site label. The default is "Site_0001".
|
4419
4671
|
siteDictionary : dict , optional
|
@@ -4426,35 +4678,49 @@ class Graph:
|
|
4426
4678
|
The desired prefixed to use for each building storey. The default is "Storey".
|
4427
4679
|
floorLevels : list , optional
|
4428
4680
|
The list of floor levels. This should be a numeric list, sorted from lowest to highest.
|
4429
|
-
If not provided, floorLevels will be computed automatically based on the
|
4681
|
+
If not provided, floorLevels will be computed automatically based on the vertices' (zKey)) attribute. See below.
|
4682
|
+
verticesKey : str , optional
|
4683
|
+
The desired key name to call vertices. The default is "vertices".
|
4684
|
+
edgesKey : str , optional
|
4685
|
+
The desired key name to call edges. The default is "edges".
|
4686
|
+
vertexLabelKey : str , optional
|
4687
|
+
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.
|
4688
|
+
Note: If vertex labels are not unique, they will be forced to be unique.
|
4689
|
+
edgeLabelKey : str , optional
|
4690
|
+
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.
|
4691
|
+
Note: If edge labels are not unique, they will be forced to be unique.
|
4692
|
+
sourceKey : str , optional
|
4693
|
+
The dictionary key used to store the source vertex. The default is "source".
|
4694
|
+
targetKey : str , optional
|
4695
|
+
The dictionary key used to store the target vertex. The default is "target".
|
4696
|
+
xKey : str , optional
|
4697
|
+
The desired key name to use for x-coordinates. The default is "hasX".
|
4698
|
+
yKey : str , optional
|
4699
|
+
The desired key name to use for y-coordinates. The default is "hasY".
|
4700
|
+
zKey : str , optional
|
4701
|
+
The desired key name to use for z-coordinates. The default is "hasZ".
|
4702
|
+
geometryKey : str , optional
|
4703
|
+
The desired key name to use for geometry. The default is "brep".
|
4430
4704
|
typeKey : str , optional
|
4431
4705
|
The dictionary key to use to look up the type of the node. The default is "type".
|
4432
|
-
labelKey : str , optional
|
4433
|
-
The dictionary key to use to look up the label of the node. The default is "label".
|
4434
4706
|
geometryKey : str , optional
|
4435
|
-
The dictionary key to use to look up the
|
4707
|
+
The dictionary key to use to look up the geometry of the node. The default is "brep".
|
4436
4708
|
spaceType : str , optional
|
4437
|
-
The dictionary string value to use to look up
|
4709
|
+
The dictionary string value to use to look up vertices of type "space". The default is "space".
|
4438
4710
|
wallType : str , optional
|
4439
|
-
The dictionary string value to use to look up
|
4711
|
+
The dictionary string value to use to look up vertices of type "wall". The default is "wall".
|
4440
4712
|
slabType : str , optional
|
4441
|
-
The dictionary string value to use to look up
|
4713
|
+
The dictionary string value to use to look up vertices of type "slab". The default is "slab".
|
4442
4714
|
doorType : str , optional
|
4443
|
-
The dictionary string value to use to look up
|
4715
|
+
The dictionary string value to use to look up vertices of type "door". The default is "door".
|
4444
4716
|
windowType : str , optional
|
4445
|
-
The dictionary string value to use to look up
|
4717
|
+
The dictionary string value to use to look up vertices of type "window". The default is "window".
|
4446
4718
|
contentType : str , optional
|
4447
|
-
The dictionary string value to use to look up
|
4448
|
-
|
4449
|
-
The desired
|
4450
|
-
|
4451
|
-
|
4452
|
-
json-ld : JSON-LD , There are further options for compact syntax and other JSON-LD variants
|
4453
|
-
ntriples, nt or nt11 : N-Triples , nt11 is exactly like nt, only utf8 encoded
|
4454
|
-
n3 : Notation-3 , N3 is a superset of Turtle that also caters for rules and a few other things
|
4455
|
-
trig : Trig , Turtle-like format for RDF triples + context (RDF quads) and thus multiple graphs
|
4456
|
-
trix : Trix , RDF/XML-like format for RDF quads
|
4457
|
-
nquads : N-Quads , N-Triples-like format for RDF quads
|
4719
|
+
The dictionary string value to use to look up vertices of type "content". The default is "contents".
|
4720
|
+
namespace : str , optional
|
4721
|
+
The desired namespace to use in the BOT graph. The default is "http://github.com/wassimj/topologicpy/resources".
|
4722
|
+
mantissa : int , optional
|
4723
|
+
The desired length of the mantissa. The default is 6.
|
4458
4724
|
|
4459
4725
|
Returns
|
4460
4726
|
-------
|
@@ -4462,28 +4728,37 @@ class Graph:
|
|
4462
4728
|
The rdf graph serialized string using the BOT ontology.
|
4463
4729
|
"""
|
4464
4730
|
from os.path import exists
|
4465
|
-
bot_graph = Graph.BOTGraph(graph,
|
4466
|
-
|
4467
|
-
|
4468
|
-
|
4469
|
-
|
4470
|
-
|
4471
|
-
|
4472
|
-
|
4473
|
-
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4731
|
+
bot_graph = Graph.BOTGraph(graph= graph,
|
4732
|
+
bidirectional= bidirectional,
|
4733
|
+
includeAttributes= includeAttributes,
|
4734
|
+
includeLabel= includeLabel,
|
4735
|
+
includeGeometry= includeGeometry,
|
4736
|
+
siteLabel= siteLabel,
|
4737
|
+
siteDictionary= siteDictionary,
|
4738
|
+
buildingLabel= buildingLabel,
|
4739
|
+
buildingDictionary= buildingDictionary,
|
4740
|
+
storeyPrefix= storeyPrefix,
|
4741
|
+
floorLevels= floorLevels,
|
4742
|
+
vertexLabelKey= vertexLabelKey,
|
4743
|
+
typeKey= typeKey,
|
4744
|
+
verticesKey= verticesKey,
|
4745
|
+
edgesKey= edgesKey,
|
4746
|
+
edgeLabelKey= edgeLabelKey,
|
4747
|
+
sourceKey= sourceKey,
|
4748
|
+
targetKey= targetKey,
|
4749
|
+
xKey= xKey,
|
4750
|
+
yKey= yKey,
|
4751
|
+
zKey= zKey,
|
4752
|
+
geometryKey= geometryKey,
|
4753
|
+
spaceType= spaceType,
|
4754
|
+
wallType= wallType,
|
4755
|
+
slabType= slabType,
|
4756
|
+
doorType= doorType,
|
4757
|
+
windowType= windowType,
|
4758
|
+
contentType= contentType,
|
4759
|
+
namespace= namespace,
|
4760
|
+
mantissa= mantissa)
|
4761
|
+
|
4487
4762
|
if "turtle" in format.lower() or "ttl" in format.lower() or "turtle2" in format.lower():
|
4488
4763
|
ext = ".ttl"
|
4489
4764
|
elif "xml" in format.lower() or "pretty=xml" in format.lower() or "rdf/xml" in format.lower():
|
@@ -6032,7 +6307,7 @@ class Graph:
|
|
6032
6307
|
d = Dictionary.SetValueAtKey(d, zKey, Vertex.Z(v, mantissa=mantissa))
|
6033
6308
|
if geometryKey:
|
6034
6309
|
v_d = Topology.Dictionary(v)
|
6035
|
-
brep = Dictionary.ValueAtKey(v_d,
|
6310
|
+
brep = Dictionary.ValueAtKey(v_d, geometryKey)
|
6036
6311
|
if brep:
|
6037
6312
|
d = Dictionary.SetValueAtKey(d, geometryKey, brep)
|
6038
6313
|
v_dict = Dictionary.PythonDictionary(d)
|
@@ -6579,7 +6854,7 @@ class Graph:
|
|
6579
6854
|
return mst
|
6580
6855
|
|
6581
6856
|
@staticmethod
|
6582
|
-
def NavigationGraph(face, sources=None, destinations=None, tolerance=0.0001,
|
6857
|
+
def NavigationGraph(face, sources=None, destinations=None, tolerance=0.0001, numWorkers=None):
|
6583
6858
|
"""
|
6584
6859
|
Creates a 2D navigation graph.
|
6585
6860
|
|
@@ -6593,8 +6868,8 @@ class Graph:
|
|
6593
6868
|
The input list of destinations (vertices). Navigation edges will connect these vertices to sources.
|
6594
6869
|
tolerance : float , optional
|
6595
6870
|
The desired tolerance. The default is 0.0001.
|
6596
|
-
|
6597
|
-
|
6871
|
+
numWorkers : int, optional
|
6872
|
+
Number of workers run in parallel to process. The default is None which sets the number to twice the number of CPU cores.
|
6598
6873
|
|
6599
6874
|
Returns
|
6600
6875
|
-------
|
@@ -6602,15 +6877,15 @@ class Graph:
|
|
6602
6877
|
The navigation graph.
|
6603
6878
|
|
6604
6879
|
"""
|
6605
|
-
|
6606
|
-
from topologicpy.
|
6880
|
+
|
6881
|
+
from topologicpy.Topology import Topology
|
6607
6882
|
from topologicpy.Wire import Wire
|
6608
6883
|
from topologicpy.Face import Face
|
6609
|
-
from topologicpy.Graph import Graph
|
6610
6884
|
from topologicpy.Cluster import Cluster
|
6611
|
-
|
6612
|
-
|
6613
|
-
|
6885
|
+
|
6886
|
+
if not numWorkers:
|
6887
|
+
import multiprocessing
|
6888
|
+
numWorkers = multiprocessing.cpu_count()*2
|
6614
6889
|
|
6615
6890
|
if not Topology.IsInstance(face, "Face"):
|
6616
6891
|
print("Graph.NavigationGraph - Error: The input face parameter is not a valid face. Returning None")
|
@@ -6631,8 +6906,6 @@ class Graph:
|
|
6631
6906
|
print("Graph.NavigationGraph - Error: The input sources parameter does not contain any vertices. Returning None")
|
6632
6907
|
return None
|
6633
6908
|
destinations = [v for v in destinations if Topology.IsInstance(v, "Vertex")]
|
6634
|
-
#if len(destinations) < 1: #Nothing to navigate to, so return a graph made of sources
|
6635
|
-
#return Graph.ByVerticesEdges(sources, [])
|
6636
6909
|
|
6637
6910
|
# Add obstuse angles of external boundary to viewpoints
|
6638
6911
|
e_boundary = Face.ExternalBoundary(face)
|
@@ -6659,27 +6932,28 @@ class Graph:
|
|
6659
6932
|
temp_row.append(0)
|
6660
6933
|
used.append(temp_row)
|
6661
6934
|
|
6662
|
-
|
6663
|
-
|
6664
|
-
|
6665
|
-
|
6666
|
-
|
6667
|
-
for
|
6668
|
-
|
6669
|
-
|
6670
|
-
|
6671
|
-
|
6672
|
-
|
6673
|
-
|
6674
|
-
|
6675
|
-
|
6676
|
-
|
6677
|
-
|
6678
|
-
|
6679
|
-
|
6680
|
-
|
6681
|
-
|
6682
|
-
|
6935
|
+
queue = Queue()
|
6936
|
+
mergingProcess = MergingProcess(queue)
|
6937
|
+
mergingProcess.start()
|
6938
|
+
|
6939
|
+
sources_str = [Topology.BREPString(s) for s in sources]
|
6940
|
+
destinations_str = [Topology.BREPString(s) for s in destinations]
|
6941
|
+
face_str = Topology.BREPString(face)
|
6942
|
+
workerProcessPool = WorkerProcessPool(numWorkers,
|
6943
|
+
queue,
|
6944
|
+
used,
|
6945
|
+
face_str,
|
6946
|
+
sources_str,
|
6947
|
+
destinations_str,
|
6948
|
+
tolerance)
|
6949
|
+
workerProcessPool.startProcesses()
|
6950
|
+
workerProcessPool.join()
|
6951
|
+
|
6952
|
+
queue.put_nowait(None)
|
6953
|
+
it = queue.get()
|
6954
|
+
final_edges = [Topology.ByBREPString(edge_str) for edge_str in it.edges]
|
6955
|
+
mergingProcess.join()
|
6956
|
+
|
6683
6957
|
if len(i_boundaries) > 0:
|
6684
6958
|
holes_edges = Topology.Edges(Cluster.ByTopologies(i_boundaries))
|
6685
6959
|
final_edges += holes_edges
|