topologicpy 0.7.65__py3-none-any.whl → 0.7.67__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/Face.py +4 -2
- topologicpy/Graph.py +839 -1142
- topologicpy/Plotly.py +2 -0
- topologicpy/Shell.py +1 -1
- topologicpy/Topology.py +36 -18
- topologicpy/Wire.py +13 -6
- topologicpy/__init__.py +3 -0
- topologicpy/version.py +1 -1
- {topologicpy-0.7.65.dist-info → topologicpy-0.7.67.dist-info}/METADATA +1 -1
- {topologicpy-0.7.65.dist-info → topologicpy-0.7.67.dist-info}/RECORD +13 -13
- {topologicpy-0.7.65.dist-info → topologicpy-0.7.67.dist-info}/WHEEL +1 -1
- {topologicpy-0.7.65.dist-info → topologicpy-0.7.67.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.65.dist-info → topologicpy-0.7.67.dist-info}/top_level.txt +0 -0
topologicpy/Graph.py
CHANGED
@@ -264,7 +264,7 @@ class _DrawTree(object):
|
|
264
264
|
return self.__str__()
|
265
265
|
|
266
266
|
class Graph:
|
267
|
-
def AdjacencyDictionary(graph, vertexLabelKey: str = "label", edgeKey: str = "Length", reverse: bool = False, mantissa: int = 6):
|
267
|
+
def AdjacencyDictionary(graph, vertexLabelKey: str = "label", edgeKey: str = "Length", includeWeights: bool = False, reverse: bool = False, mantissa: int = 6):
|
268
268
|
"""
|
269
269
|
Returns the adjacency dictionary of the input Graph.
|
270
270
|
|
@@ -277,6 +277,8 @@ class Graph:
|
|
277
277
|
If the vertexLabelKey does not exist, it will be created and the vertices are labelled numerically and stored in the vertex dictionary under this key. The default is "label".
|
278
278
|
edgeKey : str , optional
|
279
279
|
If set, the edges' dictionaries will be searched for this key to set their weight. If the key is set to "length" (case insensitive), the length of the edge will be used as its weight. If set to None, a weight of 1 will be used. The default is "Length".
|
280
|
+
includeWeights : bool , optional
|
281
|
+
If set to True, edge weights are included. Otherwise, they are not. The default is False.
|
280
282
|
reverse : bool , optional
|
281
283
|
If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. The default is False.
|
282
284
|
mantissa : int , optional
|
@@ -326,22 +328,29 @@ class Graph:
|
|
326
328
|
adjVertices = Graph.AdjacentVertices(graph, v)
|
327
329
|
temp_list = []
|
328
330
|
for adjVertex in adjVertices:
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
edge = Graph.Edge(graph, v, adjVertex)
|
333
|
-
weight = Edge.Length(edge, mantissa=mantissa)
|
331
|
+
adjIndex = Vertex.Index(adjVertex, vertices)
|
332
|
+
if not adjIndex == None:
|
333
|
+
adjLabel = labels[adjIndex]
|
334
334
|
else:
|
335
|
-
|
336
|
-
|
337
|
-
if
|
335
|
+
adjLabel = None
|
336
|
+
if includeWeights == True:
|
337
|
+
if edgeKey == None:
|
338
|
+
weight = 1
|
339
|
+
elif "length" in edgeKey.lower():
|
340
|
+
edge = Graph.Edge(graph, v, adjVertex)
|
338
341
|
weight = Edge.Length(edge, mantissa=mantissa)
|
339
342
|
else:
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
343
|
+
edge = Graph.Edge(graph, v, adjVertex)
|
344
|
+
weight = Dictionary.ValueAtKey(Topology.Dictionary(edge), edgeKey)
|
345
|
+
if weight == None:
|
346
|
+
weight = Edge.Length(edge, mantissa=mantissa)
|
347
|
+
else:
|
348
|
+
weight = round(weight, mantissa)
|
349
|
+
if not adjIndex == None:
|
350
|
+
temp_list.append((adjLabel, weight))
|
351
|
+
else:
|
352
|
+
if not adjIndex == None:
|
353
|
+
temp_list.append(adjLabel)
|
345
354
|
temp_list.sort()
|
346
355
|
adjDict[vertex_label] = temp_list
|
347
356
|
return adjDict
|
@@ -548,7 +557,7 @@ class Graph:
|
|
548
557
|
elif (len(gk) < 1) and (len(vk) > 0):
|
549
558
|
d = vd
|
550
559
|
if d:
|
551
|
-
_ = Topology.SetDictionary(gv, d)
|
560
|
+
_ = Topology.SetDictionary(gv, d, silent=True)
|
552
561
|
unique = False
|
553
562
|
returnVertex = gv
|
554
563
|
break
|
@@ -577,7 +586,7 @@ class Graph:
|
|
577
586
|
keys = Dictionary.Keys(d)
|
578
587
|
if isinstance(keys, list):
|
579
588
|
if len(keys) > 0:
|
580
|
-
_ = Topology.SetDictionary(new_edge, d)
|
589
|
+
_ = Topology.SetDictionary(new_edge, d, silent=True)
|
581
590
|
graph_edges.append(new_edge)
|
582
591
|
new_graph = Graph.ByVerticesEdges(graph_vertices, graph_edges)
|
583
592
|
return new_graph
|
@@ -614,7 +623,7 @@ class Graph:
|
|
614
623
|
if not silent:
|
615
624
|
print("Graph.AddVertex - Error: The input vertex is not a valid vertex. Returning the input graph.")
|
616
625
|
return graph
|
617
|
-
_ = graph.AddVertices([vertex], tolerance)
|
626
|
+
_ = graph.AddVertices([vertex], tolerance) # Hook to core library
|
618
627
|
return graph
|
619
628
|
|
620
629
|
@staticmethod
|
@@ -654,7 +663,7 @@ class Graph:
|
|
654
663
|
if not silent:
|
655
664
|
print("Graph.AddVertices - Error: Could not find any valid vertices in the input list of vertices. Returning None.")
|
656
665
|
return None
|
657
|
-
_ = graph.AddVertices(vertices, tolerance)
|
666
|
+
_ = graph.AddVertices(vertices, tolerance) # Hook to core library
|
658
667
|
return graph
|
659
668
|
|
660
669
|
@staticmethod
|
@@ -688,7 +697,7 @@ class Graph:
|
|
688
697
|
print("Graph.AdjacentVertices - Error: The input vertex is not a valid vertex. Returning None.")
|
689
698
|
return None
|
690
699
|
vertices = []
|
691
|
-
_ = graph.AdjacentVertices(vertex, vertices)
|
700
|
+
_ = graph.AdjacentVertices(vertex, vertices) # Hook to core library
|
692
701
|
return list(vertices)
|
693
702
|
|
694
703
|
@staticmethod
|
@@ -730,7 +739,7 @@ class Graph:
|
|
730
739
|
print("Graph.AllPaths - Error: The input vertexB is not a valid vertex. Returning None.")
|
731
740
|
return None
|
732
741
|
paths = []
|
733
|
-
_ = graph.AllPaths(vertexA, vertexB, True, timeLimit, paths)
|
742
|
+
_ = graph.AllPaths(vertexA, vertexB, True, timeLimit, paths) # Hook to core library
|
734
743
|
return paths
|
735
744
|
|
736
745
|
@staticmethod
|
@@ -1622,7 +1631,7 @@ class Graph:
|
|
1622
1631
|
edgeValidateMaskHeader="val_mask", edgeTestMaskHeader="test_mask", edgeFeaturesHeader="feat", edgeFeaturesKeys=[],
|
1623
1632
|
nodeIDHeader="node_id", nodeLabelHeader="label", nodeTrainMaskHeader="train_mask",
|
1624
1633
|
nodeValidateMaskHeader="val_mask", nodeTestMaskHeader="test_mask", nodeFeaturesHeader="feat", nodeXHeader="X", nodeYHeader="Y", nodeZHeader="Z",
|
1625
|
-
nodeFeaturesKeys=[], tolerance=0.0001):
|
1634
|
+
nodeFeaturesKeys=[], tolerance=0.0001, silent=False):
|
1626
1635
|
"""
|
1627
1636
|
Returns graphs according to the input folder path. This method assumes the CSV files follow DGL's schema.
|
1628
1637
|
|
@@ -1672,6 +1681,8 @@ class Graph:
|
|
1672
1681
|
The column header string used to specify the Z coordinate of nodes. The default is "Z".
|
1673
1682
|
tolerance : float , optional
|
1674
1683
|
The desired tolerance. The default is 0.0001.
|
1684
|
+
silent : bool , optional
|
1685
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
1675
1686
|
|
1676
1687
|
Returns
|
1677
1688
|
-------
|
@@ -1708,15 +1719,18 @@ class Graph:
|
|
1708
1719
|
return graphs_path, edges_path, nodes_path
|
1709
1720
|
|
1710
1721
|
if not exists(path):
|
1711
|
-
|
1722
|
+
if not silent:
|
1723
|
+
print("Graph.ByCSVPath - Error: the input path parameter does not exists. Returning None.")
|
1712
1724
|
return None
|
1713
1725
|
if not isdir(path):
|
1714
|
-
|
1726
|
+
if not silent:
|
1727
|
+
print("Graph.ByCSVPath - Error: the input path parameter is not a folder. Returning None.")
|
1715
1728
|
return None
|
1716
1729
|
|
1717
1730
|
yaml_files = find_yaml_files(path)
|
1718
1731
|
if len(yaml_files) < 1:
|
1719
|
-
|
1732
|
+
if not silent:
|
1733
|
+
print("Graph.ByCSVPath - Error: the input path parameter does not contain any valid YAML files. Returning None.")
|
1720
1734
|
return None
|
1721
1735
|
yaml_file = yaml_files[0]
|
1722
1736
|
yaml_file_path = os.path.join(path, yaml_file)
|
@@ -1725,7 +1739,8 @@ class Graph:
|
|
1725
1739
|
if not graphs_path == None:
|
1726
1740
|
graphs_path = os.path.join(path, graphs_path)
|
1727
1741
|
if graphs_path == None:
|
1728
|
-
|
1742
|
+
if not silent:
|
1743
|
+
print("Graph.ByCSVPath - Warning: a graphs.csv file does not exist inside the folder specified by the input path parameter. Will assume the dataset includes only one graph.")
|
1729
1744
|
graphs_df = pd.DataFrame()
|
1730
1745
|
graph_ids=[0]
|
1731
1746
|
graph_labels=[0]
|
@@ -1739,7 +1754,8 @@ class Graph:
|
|
1739
1754
|
if not edges_path == None:
|
1740
1755
|
edges_path = os.path.join(path, edges_path)
|
1741
1756
|
if not exists(edges_path):
|
1742
|
-
|
1757
|
+
if not silent:
|
1758
|
+
print("Graph.ByCSVPath - Error: an edges.csv file does not exist inside the folder specified by the input path parameter. Returning None.")
|
1743
1759
|
return None
|
1744
1760
|
edges_path = os.path.join(path, edges_path)
|
1745
1761
|
edges_df = pd.read_csv(edges_path)
|
@@ -1747,7 +1763,8 @@ class Graph:
|
|
1747
1763
|
if not nodes_path == None:
|
1748
1764
|
nodes_path = os.path.join(path, nodes_path)
|
1749
1765
|
if not exists(nodes_path):
|
1750
|
-
|
1766
|
+
if not silent:
|
1767
|
+
print("Graph.ByCSVPath - Error: a nodes.csv file does not exist inside the folder specified by the input path parameter. Returning None.")
|
1751
1768
|
return None
|
1752
1769
|
nodes_df = pd.read_csv(nodes_path)
|
1753
1770
|
# Group nodes and nodes by their 'graph_id'
|
@@ -1821,10 +1838,12 @@ class Graph:
|
|
1821
1838
|
if Topology.IsInstance(d, "Dictionary"):
|
1822
1839
|
v = Topology.SetDictionary(v, d)
|
1823
1840
|
else:
|
1824
|
-
|
1841
|
+
if not silent:
|
1842
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a dictionary to the created vertex.")
|
1825
1843
|
vertices.append(v)
|
1826
1844
|
else:
|
1827
|
-
|
1845
|
+
if not silent:
|
1846
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a vertex to the list of vertices.")
|
1828
1847
|
vertices_ds.append(vertices)
|
1829
1848
|
edges_ds = [] # A list to hold the vertices data structures until we can build the actual graphs
|
1830
1849
|
# Access specific columns within the grouped DataFrame
|
@@ -1861,21 +1880,25 @@ class Graph:
|
|
1861
1880
|
try:
|
1862
1881
|
edge = Edge.ByVertices([vertices[src_id], vertices[dst_id]], tolerance=tolerance)
|
1863
1882
|
except:
|
1864
|
-
|
1883
|
+
if not silent:
|
1884
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a edge to the list of edges.")
|
1865
1885
|
edge = None
|
1866
1886
|
if Topology.IsInstance(edge, "Edge"):
|
1867
1887
|
d = Dictionary.ByKeysValues(edge_keys, values)
|
1868
1888
|
if Topology.IsInstance(d, "Dictionary"):
|
1869
1889
|
edge = Topology.SetDictionary(edge, d)
|
1870
1890
|
else:
|
1871
|
-
|
1891
|
+
if not silent:
|
1892
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a dictionary to the created edge.")
|
1872
1893
|
edges.append(edge)
|
1873
1894
|
else:
|
1874
|
-
|
1895
|
+
if not silent:
|
1896
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add an edge to the list of edges.")
|
1875
1897
|
else:
|
1876
1898
|
duplicate_edges += 1
|
1877
1899
|
if duplicate_edges > 0:
|
1878
|
-
|
1900
|
+
if not silent:
|
1901
|
+
print("Graph.ByCSVPath - Warning: Found", duplicate_edges, "duplicate edges in graph id:", graph_id)
|
1879
1902
|
edges_ds.append(edges)
|
1880
1903
|
|
1881
1904
|
# Build the graphs
|
@@ -1896,16 +1919,19 @@ class Graph:
|
|
1896
1919
|
l1 = len(graph_keys)
|
1897
1920
|
l2 = len(values)
|
1898
1921
|
if not l1 == l2:
|
1899
|
-
|
1922
|
+
if not silent:
|
1923
|
+
print("Graph.ByCSVPath - Error: The length of the keys and values lists do not match. Returning None.")
|
1900
1924
|
return None
|
1901
1925
|
d = Dictionary.ByKeysValues(graph_keys, values)
|
1902
1926
|
if Topology.IsInstance(d, "Dictionary"):
|
1903
1927
|
g = Graph.SetDictionary(g, d)
|
1904
1928
|
else:
|
1905
|
-
|
1929
|
+
if not silent:
|
1930
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a dictionary to the created graph.")
|
1906
1931
|
graphs.append(g)
|
1907
1932
|
else:
|
1908
|
-
|
1933
|
+
if not silent:
|
1934
|
+
print("Graph.ByCSVPath - Error: Failed to create and add a graph to the list of graphs.")
|
1909
1935
|
return {"graphs": graphs, "labels": graph_labels, "features": graph_features}
|
1910
1936
|
|
1911
1937
|
@staticmethod
|
@@ -2478,20 +2504,179 @@ class Graph:
|
|
2478
2504
|
from topologicpy.Cluster import Cluster
|
2479
2505
|
from topologicpy.Topology import Topology
|
2480
2506
|
from topologicpy.Aperture import Aperture
|
2507
|
+
|
2508
|
+
def _viaSharedTopologies(vt, sharedTops):
|
2509
|
+
verts = []
|
2510
|
+
eds = []
|
2511
|
+
for sharedTopology in sharedTops:
|
2512
|
+
if useInternalVertex == True:
|
2513
|
+
vst = Topology.InternalVertex(sharedTopology, tolerance)
|
2514
|
+
else:
|
2515
|
+
vst = Topology.CenterOfMass(sharedTopology)
|
2516
|
+
d1 = Topology.Dictionary(sharedTopology)
|
2517
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 1) # shared topology
|
2518
|
+
if storeBREP:
|
2519
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2520
|
+
d3 = mergeDictionaries2([d1, d2])
|
2521
|
+
vst = Topology.SetDictionary(vst, d3, silent=True)
|
2522
|
+
else:
|
2523
|
+
vst = Topology.SetDictionary(vst, d1, silent=True)
|
2524
|
+
verts.append(vst)
|
2525
|
+
tempe = Edge.ByStartVertexEndVertex(vt, vst, tolerance=tolerance)
|
2526
|
+
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Topologies", 1])
|
2527
|
+
tempe = Topology.SetDictionary(tempe, tempd, silent=True)
|
2528
|
+
eds.append(tempe)
|
2529
|
+
return verts, eds
|
2530
|
+
|
2531
|
+
def _viaSharedApertures(vt, sharedAps):
|
2532
|
+
verts = []
|
2533
|
+
eds = []
|
2534
|
+
for sharedAp in sharedAps:
|
2535
|
+
if useInternalVertex == True:
|
2536
|
+
vsa = Topology.InternalVertex(sharedAp, tolerance)
|
2537
|
+
else:
|
2538
|
+
vsa = Topology.CenterOfMass(sharedAp)
|
2539
|
+
d1 = Topology.Dictionary(sharedAp)
|
2540
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 2) # shared aperture
|
2541
|
+
vsa = Vertex.ByCoordinates(Vertex.X(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Y(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Z(vsa, mantissa=mantissa)+(tolerance*100))
|
2542
|
+
if storeBREP:
|
2543
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
2544
|
+
d3 = mergeDictionaries2([d1, d2])
|
2545
|
+
vsa = Topology.SetDictionary(vsa, d3, silent=True)
|
2546
|
+
else:
|
2547
|
+
vsa = Topology.SetDictionary(vsa, d1, silent=True)
|
2548
|
+
verts.append(vsa)
|
2549
|
+
tempe = Edge.ByStartVertexEndVertex(vt, vsa, tolerance=tolerance)
|
2550
|
+
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Apertures", 2])
|
2551
|
+
tempe = Topology.SetDictionary(tempe, tempd, silent=True)
|
2552
|
+
eds.append(tempe)
|
2553
|
+
return verts, eds
|
2554
|
+
|
2555
|
+
def _toExteriorTopologies(vt, exteriorTops):
|
2556
|
+
verts = []
|
2557
|
+
eds = []
|
2558
|
+
for exteriorTop in exteriorTops:
|
2559
|
+
if useInternalVertex == True:
|
2560
|
+
vet = Topology.InternalVertex(exteriorTop, tolerance)
|
2561
|
+
else:
|
2562
|
+
vet = Topology.CenterOfMass(exteriorTop)
|
2563
|
+
vet = Topology.SetDictionary(vet, Topology.Dictionary(exteriorTop), silent=True)
|
2564
|
+
d1 = Topology.Dictionary(exteriorTop)
|
2565
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 3) # exterior topology
|
2566
|
+
if storeBREP:
|
2567
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTop), Topology.Type(exteriorTop), Topology.TypeAsString(exteriorTop)])
|
2568
|
+
d3 = mergeDictionaries2([d1, d2])
|
2569
|
+
vet = Topology.SetDictionary(vet, d3, silent=True)
|
2570
|
+
else:
|
2571
|
+
vet = Topology.SetDictionary(vet, d1, silent=True)
|
2572
|
+
verts.append(vet)
|
2573
|
+
tempe = Edge.ByStartVertexEndVertex(vt, vet, tolerance=tolerance)
|
2574
|
+
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Topologies", 3])
|
2575
|
+
tempe = Topology.SetDictionary(tempe, tempd, silent=True)
|
2576
|
+
eds.append(tempe)
|
2577
|
+
return verts, eds
|
2578
|
+
|
2579
|
+
def _toExteriorApertures(vt, exteriorAps):
|
2580
|
+
verts = []
|
2581
|
+
eds = []
|
2582
|
+
for exAp in exteriorAps:
|
2583
|
+
if useInternalVertex == True:
|
2584
|
+
vea = Topology.InternalVertex(exAp, tolerance)
|
2585
|
+
else:
|
2586
|
+
vea = Topology.CenterOfMass(exAp)
|
2587
|
+
d1 = Topology.Dictionary(exAp)
|
2588
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
2589
|
+
vea = Vertex.ByCoordinates(Vertex.X(vea, mantissa=mantissa)+(tolerance*100), Vertex.Y(vea, mantissa=mantissa)+(tolerance*100), Vertex.Z(vea, mantissa=mantissa)+(tolerance*100))
|
2590
|
+
if storeBREP:
|
2591
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exAp), Topology.Type(exAp), Topology.TypeAsString(exAp)])
|
2592
|
+
d3 = mergeDictionaries2([d1, d2])
|
2593
|
+
vea = Topology.SetDictionary(vea, d3, silent=True)
|
2594
|
+
else:
|
2595
|
+
vea = Topology.SetDictionary(vea, d1, silent=True)
|
2596
|
+
verts.append(vea)
|
2597
|
+
tempe = Edge.ByStartVertexEndVertex(vt, vea, tolerance=tolerance)
|
2598
|
+
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
2599
|
+
tempe = Topology.SetDictionary(tempe, tempd, silent=True)
|
2600
|
+
eds.append(tempe)
|
2601
|
+
return verts, eds
|
2602
|
+
|
2603
|
+
def _toContents(vt, contents):
|
2604
|
+
verts = []
|
2605
|
+
eds = []
|
2606
|
+
for content in contents:
|
2607
|
+
if Topology.IsInstance(content, "Aperture"):
|
2608
|
+
content = Aperture.Topology(content)
|
2609
|
+
if useInternalVertex == True:
|
2610
|
+
vct = Topology.InternalVertex(content, tolerance)
|
2611
|
+
else:
|
2612
|
+
vct = Topology.CenterOfMass(content)
|
2613
|
+
vct = Vertex.ByCoordinates(Vertex.X(vct, mantissa=mantissa)+(tolerance*100), Vertex.Y(vct, mantissa=mantissa)+(tolerance*100), Vertex.Z(vct, mantissa=mantissa)+(tolerance*100))
|
2614
|
+
d1 = Topology.Dictionary(content)
|
2615
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
2616
|
+
if storeBREP:
|
2617
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2618
|
+
d3 = mergeDictionaries2([d1, d2])
|
2619
|
+
vct = Topology.SetDictionary(vct, d3, silent=True)
|
2620
|
+
else:
|
2621
|
+
vct = Topology.SetDictionary(vct, d1, silent=True)
|
2622
|
+
verts.append(vct)
|
2623
|
+
tempe = Edge.ByStartVertexEndVertex(vt, vct, tolerance=tolerance)
|
2624
|
+
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
2625
|
+
tempe = Topology.SetDictionary(tempe, tempd, silent=True)
|
2626
|
+
eds.append(tempe)
|
2627
|
+
return verts, eds
|
2628
|
+
|
2629
|
+
def _toOutposts(vt, otherTops):
|
2630
|
+
verts = []
|
2631
|
+
eds = []
|
2632
|
+
d = Topology.Dictionary(vt)
|
2633
|
+
if not d == None:
|
2634
|
+
keys = Dictionary.Keys(d)
|
2635
|
+
else:
|
2636
|
+
keys = []
|
2637
|
+
k = None
|
2638
|
+
for key in keys:
|
2639
|
+
if key.lower() == outpostsKey.lower():
|
2640
|
+
k = key
|
2641
|
+
if k:
|
2642
|
+
ids = Dictionary.ValueAtKey(d,k)
|
2643
|
+
outposts = outpostsByID(otherTops, ids, idKey)
|
2644
|
+
else:
|
2645
|
+
outposts = []
|
2646
|
+
for outpost in outposts:
|
2647
|
+
if useInternalVertex == True:
|
2648
|
+
vop = Topology.InternalVertex(outpost, tolerance=tolerance)
|
2649
|
+
else:
|
2650
|
+
vop = Topology.CenterOfMass(outpost)
|
2481
2651
|
|
2652
|
+
d1 = Topology.Dictionary(vop)
|
2653
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 6) # outpost
|
2654
|
+
if storeBREP:
|
2655
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(outpost), Topology.Type(outpost), Topology.TypeAsString(outpost)])
|
2656
|
+
d3 = mergeDictionaries2([d1, d2])
|
2657
|
+
vop = Topology.SetDictionary(vop, d3, silent=True)
|
2658
|
+
else:
|
2659
|
+
vop = Topology.SetDictionary(vop, d1, silent=True)
|
2660
|
+
verts.append(vop)
|
2661
|
+
tempe = Edge.ByStartVertexEndVertex(vt, vop, tolerance=tolerance)
|
2662
|
+
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
2663
|
+
tempe = Topology.SetDictionary(tempe, tempd, silent=True)
|
2664
|
+
eds.append(tempe)
|
2665
|
+
return verts, eds
|
2666
|
+
|
2482
2667
|
def mergeDictionaries(sources):
|
2483
2668
|
if isinstance(sources, list) == False:
|
2484
2669
|
sources = [sources]
|
2485
2670
|
sinkKeys = []
|
2486
2671
|
sinkValues = []
|
2487
|
-
d = sources[0]
|
2672
|
+
d = Topology.Dictionary(sources[0])
|
2488
2673
|
if d != None:
|
2489
2674
|
stlKeys = d.Keys()
|
2490
2675
|
if len(stlKeys) > 0:
|
2491
2676
|
sinkKeys = d.Keys()
|
2492
2677
|
sinkValues = Dictionary.Values(d)
|
2493
2678
|
for i in range(1,len(sources)):
|
2494
|
-
d = sources[i]
|
2679
|
+
d = Topology.Dictionary(sources[i])
|
2495
2680
|
if d == None:
|
2496
2681
|
continue
|
2497
2682
|
stlKeys = d.Keys()
|
@@ -2582,12 +2767,27 @@ class Graph:
|
|
2582
2767
|
|
2583
2768
|
def processCellComplex(item):
|
2584
2769
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
2585
|
-
|
2586
|
-
|
2770
|
+
graph_vertices = []
|
2771
|
+
graph_edges = []
|
2587
2772
|
cellmat = []
|
2773
|
+
# Store all the vertices of the cells of the cellComplex
|
2774
|
+
cells = Topology.Cells(topology)
|
2775
|
+
for cell in cells:
|
2776
|
+
if useInternalVertex == True:
|
2777
|
+
vCell = Topology.InternalVertex(cell, tolerance=tolerance)
|
2778
|
+
else:
|
2779
|
+
vCell = Topology.CenterOfMass(cell)
|
2780
|
+
d1 = Topology.Dictionary(cell)
|
2781
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
2782
|
+
if storeBREP:
|
2783
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(cell), Topology.Type(cell), Topology.TypeAsString(cell)])
|
2784
|
+
d3 = mergeDictionaries2([d1, d2])
|
2785
|
+
vCell = Topology.SetDictionary(vCell, d3, silent=True)
|
2786
|
+
else:
|
2787
|
+
vCell = Topology.SetDictionary(vCell, d1, silent=True)
|
2788
|
+
graph_vertices.append(vCell)
|
2588
2789
|
if direct == True:
|
2589
|
-
cells =
|
2590
|
-
_ = topology.Cells(None, cells)
|
2790
|
+
cells = Topology.Cells(topology)
|
2591
2791
|
# Create a matrix of zeroes
|
2592
2792
|
for i in range(len(cells)):
|
2593
2793
|
cellRow = []
|
@@ -2605,8 +2805,8 @@ class Graph:
|
|
2605
2805
|
v1 = Topology.InternalVertex(cells[i], tolerance=tolerance)
|
2606
2806
|
v2 = Topology.InternalVertex(cells[j], tolerance=tolerance)
|
2607
2807
|
else:
|
2608
|
-
v1 = cells[i]
|
2609
|
-
v2 = cells[j]
|
2808
|
+
v1 = Topology.CenterOfMass(cells[i])
|
2809
|
+
v2 = Topology.CenterOfMass(cells[j])
|
2610
2810
|
e = Edge.ByStartVertexEndVertex(v1, v2, tolerance=tolerance)
|
2611
2811
|
mDict = mergeDictionaries(sharedt)
|
2612
2812
|
if not mDict == None:
|
@@ -2617,12 +2817,11 @@ class Graph:
|
|
2617
2817
|
values = ["Direct", 0]
|
2618
2818
|
mDict = Dictionary.ByKeysValues(keys, values)
|
2619
2819
|
if mDict:
|
2620
|
-
e.SetDictionary(mDict)
|
2621
|
-
|
2820
|
+
e = Topology.SetDictionary(e, mDict, silent=True)
|
2821
|
+
graph_edges.append(e)
|
2622
2822
|
if directApertures == True:
|
2623
2823
|
cellmat = []
|
2624
|
-
cells =
|
2625
|
-
_ = topology.Cells(None, cells)
|
2824
|
+
cells = Topology.Cells(topology)
|
2626
2825
|
# Create a matrix of zeroes
|
2627
2826
|
for i in range(len(cells)):
|
2628
2827
|
cellRow = []
|
@@ -2650,77 +2849,37 @@ class Graph:
|
|
2650
2849
|
v1 = Topology.InternalVertex(cells[i], tolerance=tolerance)
|
2651
2850
|
v2 = Topology.InternalVertex(cells[j], tolerance=tolerance)
|
2652
2851
|
else:
|
2653
|
-
v1 = cells[i]
|
2654
|
-
v2 = cells[j]
|
2852
|
+
v1 = Topology.CenterOfMass(cells[i])
|
2853
|
+
v2 = Topology.CenterOfMass(cells[j])
|
2655
2854
|
e = Edge.ByStartVertexEndVertex(v1, v2, tolerance=tolerance)
|
2656
2855
|
mDict = mergeDictionaries(apTopList)
|
2856
|
+
if not mDict == None:
|
2857
|
+
keys = (Dictionary.Keys(mDict) or [])+["relationship", edgeCategoryKey]
|
2858
|
+
values = (Dictionary.Values(mDict) or [])+["Direct", 0]
|
2859
|
+
else:
|
2860
|
+
keys = ["relationship", edgeCategoryKey]
|
2861
|
+
values = ["Direct", 0]
|
2862
|
+
mDict = Dictionary.ByKeysValues(keys, values)
|
2657
2863
|
if mDict:
|
2658
|
-
e.SetDictionary(mDict)
|
2659
|
-
|
2660
|
-
|
2661
|
-
d = Topology.Dictionary(topology)
|
2662
|
-
if not d == None:
|
2663
|
-
keys = Dictionary.Keys(d)
|
2664
|
-
else:
|
2665
|
-
keys = []
|
2666
|
-
k = None
|
2667
|
-
for key in keys:
|
2668
|
-
if key.lower() == outpostsKey.lower():
|
2669
|
-
k = key
|
2670
|
-
if k:
|
2671
|
-
ids = Dictionary.ValueAtKey(k)
|
2672
|
-
outposts = outpostsByID(others, ids, idKey)
|
2673
|
-
else:
|
2674
|
-
outposts = []
|
2675
|
-
for outpost in outposts:
|
2676
|
-
if useInternalVertex == True:
|
2677
|
-
vop = Topology.InternalVertex(outpost, tolerance=tolerance)
|
2678
|
-
vcc = Topology.InternalVertex(topology, tolerance=tolerance)
|
2679
|
-
else:
|
2680
|
-
vop = Topology.CenterOfMass(outpost)
|
2681
|
-
vcc = Topology.CenterOfMass(topology)
|
2682
|
-
d1 = Topology.Dictionary(vcc)
|
2683
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
2684
|
-
if storeBREP:
|
2685
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2686
|
-
d3 = mergeDictionaries2([d1, d2])
|
2687
|
-
_ = vcc.SetDictionary(d3)
|
2688
|
-
else:
|
2689
|
-
_ = vcc.SetDictionary(d1)
|
2690
|
-
d1 = Topology.Dictionary(vop)
|
2691
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 6) # outpost
|
2692
|
-
if storeBREP:
|
2693
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(outpost), Topology.Type(outpost), Topology.TypeAsString(outpost)])
|
2694
|
-
d3 = mergeDictionaries2([d1, d2])
|
2695
|
-
_ = vop.SetDictionary(d3)
|
2696
|
-
else:
|
2697
|
-
_ = vop.SetDictionary(d1)
|
2698
|
-
vertices.append(vcc)
|
2699
|
-
vertices.append(vop)
|
2700
|
-
tempe = Edge.ByStartVertexEndVertex(vcc, vop, tolerance=tolerance)
|
2701
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
2702
|
-
_ = tempe.SetDictionary(tempd)
|
2703
|
-
edges.append(tempe)
|
2704
|
-
|
2705
|
-
cells = []
|
2706
|
-
_ = topology.Cells(None, cells)
|
2864
|
+
e = Topology.SetDictionary(e, mDict, silent=True)
|
2865
|
+
graph_edges.append(e)
|
2866
|
+
cells = Topology.Cells(topology)
|
2707
2867
|
if any([viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents]):
|
2708
2868
|
for aCell in cells:
|
2709
2869
|
if useInternalVertex == True:
|
2710
2870
|
vCell = Topology.InternalVertex(aCell, tolerance=tolerance)
|
2711
2871
|
else:
|
2712
|
-
vCell =
|
2713
|
-
|
2714
|
-
|
2872
|
+
vCell = Topology.CenterOfMass(aCell)
|
2873
|
+
d = Topology.Dictionary(aCell)
|
2874
|
+
vCell = Topology.SetDictionary(vCell, d, silent=True)
|
2875
|
+
faces = Topology.Faces(aCell)
|
2715
2876
|
sharedTopologies = []
|
2716
2877
|
exteriorTopologies = []
|
2717
2878
|
sharedApertures = []
|
2718
2879
|
exteriorApertures = []
|
2719
|
-
|
2720
|
-
_ = aCell.Contents(contents)
|
2880
|
+
cell_contents = Topology.Contents(aCell)
|
2721
2881
|
for aFace in faces:
|
2722
|
-
cells1 =
|
2723
|
-
_ = aFace.Cells(topology, cells1)
|
2882
|
+
cells1 = Topology.SuperTopologies(aFace, topology, topologyType="Cell")
|
2724
2883
|
if len(cells1) > 1:
|
2725
2884
|
sharedTopologies.append(aFace)
|
2726
2885
|
apertures = Topology.Apertures(aFace)
|
@@ -2731,226 +2890,83 @@ class Graph:
|
|
2731
2890
|
apertures = Topology.Apertures(aFace)
|
2732
2891
|
for anAperture in apertures:
|
2733
2892
|
exteriorApertures.append(anAperture)
|
2734
|
-
|
2735
2893
|
if viaSharedTopologies:
|
2894
|
+
verts, eds = _viaSharedTopologies(vCell, sharedTopologies)
|
2895
|
+
graph_vertices += verts
|
2896
|
+
graph_edges += eds
|
2736
2897
|
for sharedTopology in sharedTopologies:
|
2737
2898
|
if useInternalVertex == True:
|
2738
2899
|
vst = Topology.InternalVertex(sharedTopology, tolerance)
|
2739
2900
|
else:
|
2740
|
-
vst =
|
2741
|
-
|
2742
|
-
|
2743
|
-
if storeBREP:
|
2744
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
2745
|
-
d3 = mergeDictionaries2([d1, d2])
|
2746
|
-
_ = vst.SetDictionary(d3)
|
2747
|
-
else:
|
2748
|
-
_ = vst.SetDictionary(d1)
|
2749
|
-
vertices.append(vst)
|
2750
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vst, tolerance=tolerance)
|
2751
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Topologies", 1])
|
2752
|
-
_ = tempe.SetDictionary(tempd)
|
2753
|
-
edges.append(tempe)
|
2901
|
+
vst = Topology.CenterOfMass(sharedTopology)
|
2902
|
+
d = Topology.Dictionary(sharedTopology)
|
2903
|
+
vst = Topology.SetDictionary(vst, d, silent=True)
|
2754
2904
|
if toContents:
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
vst2 = content.CenterOfMass()
|
2764
|
-
d1 = content.GetDictionary()
|
2765
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
2766
|
-
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa), Vertex.Y(vst2, mantissa=mantissa), Vertex.Z(vst2, mantissa=mantissa))
|
2767
|
-
if storeBREP:
|
2768
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2769
|
-
d3 = mergeDictionaries2([d1, d2])
|
2770
|
-
_ = vst2.SetDictionary(d3)
|
2771
|
-
else:
|
2772
|
-
_ = vst2.SetDictionary(d1)
|
2773
|
-
vertices.append(vst2)
|
2774
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
2775
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
2776
|
-
_ = tempe.SetDictionary(tempd)
|
2777
|
-
edges.append(tempe)
|
2905
|
+
shd_top_contents = Topology.Contents(sharedTopology)
|
2906
|
+
verts, eds = _toContents(vst, shd_top_contents)
|
2907
|
+
graph_vertices += verts
|
2908
|
+
graph_edges += eds
|
2909
|
+
if toOutposts and others:
|
2910
|
+
verts, eds = _toOutposts(vst, others)
|
2911
|
+
graph_vertices += verts
|
2912
|
+
graph_edges += eds
|
2778
2913
|
if viaSharedApertures:
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
else:
|
2783
|
-
vsa = sharedAp.CenterOfMass()
|
2784
|
-
d1 = sharedAp.GetDictionary()
|
2785
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 2) # shared aperture
|
2786
|
-
vsa = Vertex.ByCoordinates(Vertex.X(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Y(vsa, mantissa=mantissa)+(tolerance*100), Vertex.Z(vsa, mantissa=mantissa)+(tolerance*100))
|
2787
|
-
if storeBREP:
|
2788
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
2789
|
-
d3 = mergeDictionaries2([d1, d2])
|
2790
|
-
_ = vsa.SetDictionary(d3)
|
2791
|
-
else:
|
2792
|
-
_ = vsa.SetDictionary(d1)
|
2793
|
-
vertices.append(vsa)
|
2794
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vsa, tolerance=tolerance)
|
2795
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Apertures", 2])
|
2796
|
-
_ = tempe.SetDictionary(tempd)
|
2797
|
-
edges.append(tempe)
|
2914
|
+
verts, eds = _viaSharedTopologies(vCell, sharedApertures)
|
2915
|
+
graph_vertices += verts
|
2916
|
+
graph_edges += eds
|
2798
2917
|
if toExteriorTopologies:
|
2918
|
+
verts, eds = _toExteriorTopologies(vCell, exteriorTopologies)
|
2919
|
+
graph_vertices += verts
|
2920
|
+
graph_edges += eds
|
2799
2921
|
for exteriorTopology in exteriorTopologies:
|
2800
2922
|
if useInternalVertex == True:
|
2801
2923
|
vet = Topology.InternalVertex(exteriorTopology, tolerance)
|
2802
2924
|
else:
|
2803
|
-
vet =
|
2804
|
-
|
2805
|
-
|
2806
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 3) # exterior topology
|
2807
|
-
if storeBREP:
|
2808
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
2809
|
-
d3 = mergeDictionaries2([d1, d2])
|
2810
|
-
_ = vet.SetDictionary(d3)
|
2811
|
-
else:
|
2812
|
-
_ = vet.SetDictionary(d1)
|
2813
|
-
vertices.append(vet)
|
2814
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vet, tolerance=tolerance)
|
2815
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Topologies", 3])
|
2816
|
-
_ = tempe.SetDictionary(tempd)
|
2817
|
-
edges.append(tempe)
|
2925
|
+
vet = Topology.CenterOfMass(exteriorTopology)
|
2926
|
+
d = Topology.Dictionary(exteriorTopology)
|
2927
|
+
vet = Topology.SetDictionary(vet, d, silent=True)
|
2818
2928
|
if toContents:
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
vst2 = content.CenterOfMass()
|
2828
|
-
d1 = content.GetDictionary()
|
2829
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
2830
|
-
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
2831
|
-
if storeBREP:
|
2832
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2833
|
-
d3 = mergeDictionaries2([d1, d2])
|
2834
|
-
_ = vst2.SetDictionary(d3)
|
2835
|
-
else:
|
2836
|
-
_ = vst2.SetDictionary(d1)
|
2837
|
-
vertices.append(vst2)
|
2838
|
-
tempe = Edge.ByStartVertexEndVertex(vet, vst2, tolerance=tolerance)
|
2839
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
2840
|
-
_ = tempe.SetDictionary(tempd)
|
2841
|
-
edges.append(tempe)
|
2929
|
+
ext_top_contents = Topology.Contents(exteriorTopology)
|
2930
|
+
verts, eds = _toContents(vet, ext_top_contents)
|
2931
|
+
graph_vertices += verts
|
2932
|
+
graph_edges += eds
|
2933
|
+
if toOutposts and others:
|
2934
|
+
verts, eds = _toOutposts(vet, others)
|
2935
|
+
graph_vertices += verts
|
2936
|
+
graph_edges += eds
|
2842
2937
|
if toExteriorApertures:
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
else:
|
2847
|
-
vea = exTop.CenterOfMass()
|
2848
|
-
d1 = exTop.GetDictionary()
|
2849
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
2850
|
-
vea = Vertex.ByCoordinates(Vertex.X(vea, mantissa=mantissa)+(tolerance*100), Vertex.Y(vea, mantissa=mantissa)+(tolerance*100), Vertex.Z(vea, mantissa=mantissa)+(tolerance*100))
|
2851
|
-
if storeBREP:
|
2852
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
2853
|
-
d3 = mergeDictionaries2([d1, d2])
|
2854
|
-
_ = vea.SetDictionary(d3)
|
2855
|
-
else:
|
2856
|
-
_ = vea.SetDictionary(d1)
|
2857
|
-
vertices.append(vea)
|
2858
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vea, tolerance=tolerance)
|
2859
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
2860
|
-
_ = tempe.SetDictionary(tempd)
|
2861
|
-
edges.append(tempe)
|
2938
|
+
verts, eds = _toExteriorApertures(vCell, exteriorApertures)
|
2939
|
+
graph_vertices += verts
|
2940
|
+
graph_edges += eds
|
2862
2941
|
if toContents:
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2869
|
-
|
2870
|
-
|
2871
|
-
vcn = content.CenterOfMass()
|
2872
|
-
vcn = Vertex.ByCoordinates(Vertex.X(vcn, mantissa=mantissa)+(tolerance*100), Vertex.Y(vcn, mantissa=mantissa)+(tolerance*100), Vertex.Z(vcn, mantissa=mantissa)+(tolerance*100))
|
2873
|
-
d1 = content.GetDictionary()
|
2874
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
2875
|
-
if storeBREP:
|
2876
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2877
|
-
d3 = mergeDictionaries2([d1, d2])
|
2878
|
-
_ = vcn.SetDictionary(d3)
|
2879
|
-
else:
|
2880
|
-
_ = vcn.SetDictionary(d1)
|
2881
|
-
vertices.append(vcn)
|
2882
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vcn, tolerance=tolerance)
|
2883
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
2884
|
-
_ = tempe.SetDictionary(tempd)
|
2885
|
-
edges.append(tempe)
|
2886
|
-
|
2887
|
-
for aCell in cells:
|
2888
|
-
if useInternalVertex == True:
|
2889
|
-
vCell = Topology.InternalVertex(aCell, tolerance=tolerance)
|
2890
|
-
else:
|
2891
|
-
vCell = aCell.CenterOfMass()
|
2892
|
-
d1 = aCell.GetDictionary()
|
2893
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
2894
|
-
if storeBREP:
|
2895
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aCell), Topology.Type(aCell), Topology.TypeAsString(aCell)])
|
2896
|
-
d3 = mergeDictionaries2([d1, d2])
|
2897
|
-
_ = vCell.SetDictionary(d3)
|
2898
|
-
else:
|
2899
|
-
_ = vCell.SetDictionary(d1)
|
2900
|
-
vertices.append(vCell)
|
2901
|
-
return [vertices,edges]
|
2942
|
+
verts, eds = _toContents(vCell, cell_contents)
|
2943
|
+
graph_vertices += verts
|
2944
|
+
graph_edges += eds
|
2945
|
+
if toOutposts and others:
|
2946
|
+
verts, eds = toOutposts(vCell, others)
|
2947
|
+
graph_vertices += verts
|
2948
|
+
graph_edges += eds
|
2949
|
+
return [graph_vertices, graph_edges]
|
2902
2950
|
|
2903
2951
|
def processCell(item):
|
2904
2952
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
2905
|
-
|
2906
|
-
|
2953
|
+
graph_vertices = []
|
2954
|
+
graph_edges = []
|
2907
2955
|
if useInternalVertex == True:
|
2908
2956
|
vCell = Topology.InternalVertex(topology, tolerance=tolerance)
|
2909
2957
|
else:
|
2910
|
-
vCell =
|
2911
|
-
d1 =
|
2958
|
+
vCell = Topology.CenterOfMass(topology)
|
2959
|
+
d1 = Topology.Dictionary(topology)
|
2912
2960
|
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
2913
2961
|
if storeBREP:
|
2914
2962
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
2915
2963
|
d3 = mergeDictionaries2([d1, d2])
|
2916
|
-
|
2964
|
+
vCell = Topology.SetDictionary(vCell, d3, silent=True)
|
2917
2965
|
else:
|
2918
|
-
|
2919
|
-
|
2920
|
-
if
|
2921
|
-
|
2922
|
-
if not d == None:
|
2923
|
-
keys = Dictionary.Keys(d)
|
2924
|
-
else:
|
2925
|
-
keys = []
|
2926
|
-
k = None
|
2927
|
-
for key in keys:
|
2928
|
-
if key.lower() == outpostsKey.lower():
|
2929
|
-
k = key
|
2930
|
-
if k:
|
2931
|
-
ids = Dictionary.ValueAtKey(d, k)
|
2932
|
-
outposts = outpostsByID(others, ids, idKey)
|
2933
|
-
else:
|
2934
|
-
outposts = []
|
2935
|
-
for outpost in outposts:
|
2936
|
-
if useInternalVertex == True:
|
2937
|
-
vop = Topology.InternalVertex(outpost, tolerance)
|
2938
|
-
else:
|
2939
|
-
vop = Topology.CenterOfMass(outpost)
|
2940
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vop, tolerance=tolerance)
|
2941
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
2942
|
-
_ = tempe.SetDictionary(tempd)
|
2943
|
-
edges.append(tempe)
|
2944
|
-
d1 = outpost.GetDictionary()
|
2945
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 6) # outpost
|
2946
|
-
if storeBREP:
|
2947
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(outpost), Topology.Type(outpost), Topology.TypeAsString(outpost)])
|
2948
|
-
d3 = mergeDictionaries2([d1, d2])
|
2949
|
-
_ = vop.SetDictionary(d3)
|
2950
|
-
else:
|
2951
|
-
_ = vop.SetDictionary(d1)
|
2952
|
-
vertices.append(vop)
|
2953
|
-
if any([toExteriorTopologies, toExteriorApertures, toContents]):
|
2966
|
+
vCell = Topology.SetDictionary(vCell, d1, silent=True)
|
2967
|
+
graph_vertices.append(vCell)
|
2968
|
+
if any([toExteriorTopologies, toExteriorApertures, toContents, toOutposts]):
|
2969
|
+
cell_contents = Topology.Contents(topology)
|
2954
2970
|
faces = Topology.Faces(topology)
|
2955
2971
|
exteriorTopologies = []
|
2956
2972
|
exteriorApertures = []
|
@@ -2959,123 +2975,82 @@ class Graph:
|
|
2959
2975
|
apertures = Topology.Apertures(aFace)
|
2960
2976
|
for anAperture in apertures:
|
2961
2977
|
exteriorApertures.append(anAperture)
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2978
|
-
|
2979
|
-
|
2980
|
-
|
2981
|
-
|
2982
|
-
|
2983
|
-
|
2984
|
-
|
2985
|
-
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
|
2995
|
-
if storeBREP:
|
2996
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
2997
|
-
d3 = mergeDictionaries2([d1, d2])
|
2998
|
-
_ = vst2.SetDictionary(d3)
|
2999
|
-
else:
|
3000
|
-
_ = vst2.SetDictionary(d1)
|
3001
|
-
vertices.append(vst2)
|
3002
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3003
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3004
|
-
_ = tempe.SetDictionary(tempd)
|
3005
|
-
edges.append(tempe)
|
3006
|
-
if toExteriorApertures:
|
3007
|
-
for exTop in exteriorApertures:
|
3008
|
-
if useInternalVertex == True:
|
3009
|
-
vst = Topology.InternalVertex(exTop, tolerance)
|
3010
|
-
else:
|
3011
|
-
vst = exTop.CenterOfMass()
|
3012
|
-
d1 = exTop.GetDictionary()
|
3013
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
3014
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3015
|
-
if storeBREP:
|
3016
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3017
|
-
d3 = mergeDictionaries2([d1, d2])
|
3018
|
-
_ = vst.SetDictionary(d3)
|
3019
|
-
else:
|
3020
|
-
_ = vst.SetDictionary(d1)
|
3021
|
-
vertices.append(vst)
|
3022
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vst, tolerance=tolerance)
|
3023
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
3024
|
-
_ = tempe.SetDictionary(tempd)
|
3025
|
-
edges.append(tempe)
|
3026
|
-
if toContents:
|
3027
|
-
contents = []
|
3028
|
-
_ = topology.Contents(contents)
|
3029
|
-
for content in contents:
|
3030
|
-
if Topology.IsInstance(content, "Aperture"):
|
3031
|
-
content = Aperture.Topology(content)
|
3032
|
-
if useInternalVertex == True:
|
3033
|
-
vst = Topology.InternalVertex(content, tolerance)
|
3034
|
-
else:
|
3035
|
-
vst = content.CenterOfMass()
|
3036
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3037
|
-
d1 = content.GetDictionary()
|
3038
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3039
|
-
if storeBREP:
|
3040
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3041
|
-
d3 = mergeDictionaries2([d1, d2])
|
3042
|
-
_ = vst.SetDictionary(d3)
|
3043
|
-
else:
|
3044
|
-
_ = vst.SetDictionary(d1)
|
3045
|
-
vertices.append(vst)
|
3046
|
-
tempe = Edge.ByStartVertexEndVertex(vCell, vst, tolerance=tolerance)
|
3047
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3048
|
-
_ = tempe.SetDictionary(tempd)
|
3049
|
-
edges.append(tempe)
|
3050
|
-
return [vertices, edges]
|
2978
|
+
if toExteriorTopologies:
|
2979
|
+
verts, eds = _toExteriorTopologies(vCell, exteriorTopologies)
|
2980
|
+
graph_vertices += verts
|
2981
|
+
graph_edges += eds
|
2982
|
+
for exteriorTopology in exteriorTopologies:
|
2983
|
+
if useInternalVertex == True:
|
2984
|
+
vet = Topology.InternalVertex(exteriorTopology, tolerance)
|
2985
|
+
else:
|
2986
|
+
vet = Topology.CenterOfMass(exteriorTopology)
|
2987
|
+
d = Topology.Dictionary(exteriorTopology)
|
2988
|
+
vet = Topology.SetDictionary(vet, d, silent=True)
|
2989
|
+
if toContents:
|
2990
|
+
ext_top_contents = Topology.Contents(exteriorTopology)
|
2991
|
+
verts, eds = _toContents(vet, ext_top_contents)
|
2992
|
+
graph_vertices += verts
|
2993
|
+
graph_edges += eds
|
2994
|
+
if toOutposts and others:
|
2995
|
+
verts, eds = _toOutposts(vet, others)
|
2996
|
+
graph_vertices += verts
|
2997
|
+
graph_edges += eds
|
2998
|
+
if toExteriorApertures:
|
2999
|
+
verts, eds = _toExteriorApertures(vCell, exteriorApertures)
|
3000
|
+
graph_vertices += verts
|
3001
|
+
graph_edges += eds
|
3002
|
+
if toContents:
|
3003
|
+
verts, eds = _toContents(vCell, cell_contents)
|
3004
|
+
graph_vertices += verts
|
3005
|
+
graph_edges += eds
|
3006
|
+
if toOutposts and others:
|
3007
|
+
verts, eds = toOutposts(vCell, others)
|
3008
|
+
graph_vertices += verts
|
3009
|
+
graph_edges += eds
|
3010
|
+
return [graph_vertices, graph_edges]
|
3051
3011
|
|
3052
3012
|
def processShell(item):
|
3053
3013
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3054
|
-
|
3055
|
-
|
3014
|
+
graph_edges = []
|
3015
|
+
graph_vertices = []
|
3056
3016
|
facemat = []
|
3017
|
+
# Store all the vertices of the cells of the cellComplex
|
3018
|
+
faces = Topology.Faces(topology)
|
3019
|
+
for face in faces:
|
3020
|
+
if useInternalVertex == True:
|
3021
|
+
vFace = Topology.InternalVertex(face, tolerance=tolerance)
|
3022
|
+
else:
|
3023
|
+
vFace = Topology.CenterOfMass(face)
|
3024
|
+
d1 = Topology.Dictionary(face)
|
3025
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3026
|
+
if storeBREP:
|
3027
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(face), Topology.Type(face), Topology.TypeAsString(face)])
|
3028
|
+
d3 = mergeDictionaries2([d1, d2])
|
3029
|
+
vFace = Topology.SetDictionary(vFace, d3, silent=True)
|
3030
|
+
else:
|
3031
|
+
vFace = Topology.SetDictionary(vFace, d1, silent=True)
|
3032
|
+
graph_vertices.append(vFace)
|
3057
3033
|
if direct == True:
|
3058
|
-
|
3059
|
-
_ = topology.Faces(None, topFaces)
|
3034
|
+
faces = Topology.Faces(topology)
|
3060
3035
|
# Create a matrix of zeroes
|
3061
|
-
for i in range(len(
|
3036
|
+
for i in range(len(faces)):
|
3062
3037
|
faceRow = []
|
3063
|
-
for j in range(len(
|
3038
|
+
for j in range(len(faces)):
|
3064
3039
|
faceRow.append(0)
|
3065
3040
|
facemat.append(faceRow)
|
3066
|
-
for i in range(len(
|
3067
|
-
for j in range(len(
|
3041
|
+
for i in range(len(faces)):
|
3042
|
+
for j in range(len(faces)):
|
3068
3043
|
if (i != j) and facemat[i][j] == 0:
|
3069
3044
|
facemat[i][j] = 1
|
3070
3045
|
facemat[j][i] = 1
|
3071
|
-
sharedt = Topology.SharedEdges(
|
3046
|
+
sharedt = Topology.SharedEdges(faces[i], faces[j])
|
3072
3047
|
if len(sharedt) > 0:
|
3073
3048
|
if useInternalVertex == True:
|
3074
|
-
v1 = Topology.InternalVertex(
|
3075
|
-
v2 = Topology.InternalVertex(
|
3049
|
+
v1 = Topology.InternalVertex(faces[i], tolerance=tolerance)
|
3050
|
+
v2 = Topology.InternalVertex(faces[j], tolerance=tolerance)
|
3076
3051
|
else:
|
3077
|
-
v1 =
|
3078
|
-
v2 =
|
3052
|
+
v1 = Topology.CenterOfMass(faces[i])
|
3053
|
+
v2 = Topology.CenterOfMass(faces[j])
|
3079
3054
|
e = Edge.ByStartVertexEndVertex(v1, v2, tolerance=tolerance)
|
3080
3055
|
mDict = mergeDictionaries(sharedt)
|
3081
3056
|
if not mDict == None:
|
@@ -3086,63 +3061,70 @@ class Graph:
|
|
3086
3061
|
values = ["Direct", 0]
|
3087
3062
|
mDict = Dictionary.ByKeysValues(keys, values)
|
3088
3063
|
if mDict:
|
3089
|
-
e.SetDictionary(mDict)
|
3090
|
-
|
3064
|
+
e = Topology.SetDictionary(e, mDict, silent=True)
|
3065
|
+
graph_edges.append(e)
|
3091
3066
|
if directApertures == True:
|
3092
3067
|
facemat = []
|
3093
|
-
|
3094
|
-
_ = topology.Faces(None, topFaces)
|
3068
|
+
faces = Topology.Faces(topology)
|
3095
3069
|
# Create a matrix of zeroes
|
3096
|
-
for i in range(len(
|
3070
|
+
for i in range(len(faces)):
|
3097
3071
|
faceRow = []
|
3098
|
-
for j in range(len(
|
3072
|
+
for j in range(len(faces)):
|
3099
3073
|
faceRow.append(0)
|
3100
3074
|
facemat.append(faceRow)
|
3101
|
-
for i in range(len(
|
3102
|
-
for j in range(len(
|
3075
|
+
for i in range(len(faces)):
|
3076
|
+
for j in range(len(faces)):
|
3103
3077
|
if (i != j) and facemat[i][j] == 0:
|
3104
3078
|
facemat[i][j] = 1
|
3105
3079
|
facemat[j][i] = 1
|
3106
|
-
sharedt = Topology.SharedEdges(
|
3080
|
+
sharedt = Topology.SharedEdges(faces[i], faces[j])
|
3107
3081
|
if len(sharedt) > 0:
|
3108
3082
|
apertureExists = False
|
3109
3083
|
for x in sharedt:
|
3110
3084
|
apList = Topology.Apertures(x)
|
3111
3085
|
if len(apList) > 0:
|
3086
|
+
apTopList = []
|
3087
|
+
for ap in apList:
|
3088
|
+
apTopList.append(ap)
|
3112
3089
|
apertureExists = True
|
3113
3090
|
break
|
3114
3091
|
if apertureExists:
|
3115
3092
|
if useInternalVertex == True:
|
3116
|
-
v1 = Topology.InternalVertex(
|
3117
|
-
v2 = Topology.InternalVertex(
|
3093
|
+
v1 = Topology.InternalVertex(faces[i], tolerance=tolerance)
|
3094
|
+
v2 = Topology.InternalVertex(faces[j], tolerance=tolerance)
|
3118
3095
|
else:
|
3119
|
-
v1 =
|
3120
|
-
v2 =
|
3096
|
+
v1 = Topology.CenterOfMass(faces[i])
|
3097
|
+
v2 = Topology.CenterOfMass(faces[j])
|
3121
3098
|
e = Edge.ByStartVertexEndVertex(v1, v2, tolerance=tolerance)
|
3122
|
-
mDict = mergeDictionaries(
|
3099
|
+
mDict = mergeDictionaries(apTopList)
|
3100
|
+
if not mDict == None:
|
3101
|
+
keys = (Dictionary.Keys(mDict) or [])+["relationship", edgeCategoryKey]
|
3102
|
+
values = (Dictionary.Values(mDict) or [])+["Direct", 0]
|
3103
|
+
else:
|
3104
|
+
keys = ["relationship", edgeCategoryKey]
|
3105
|
+
values = ["Direct", 0]
|
3106
|
+
mDict = Dictionary.ByKeysValues(keys, values)
|
3123
3107
|
if mDict:
|
3124
|
-
e.SetDictionary(mDict)
|
3125
|
-
|
3126
|
-
|
3127
|
-
|
3128
|
-
|
3129
|
-
if any([viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents == True]):
|
3130
|
-
for aFace in topFaces:
|
3108
|
+
e = Topology.SetDictionary(e, mDict, silent=True)
|
3109
|
+
graph_edges.append(e)
|
3110
|
+
faces = Topology.Faces(topology)
|
3111
|
+
if any([viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents]):
|
3112
|
+
for aFace in faces:
|
3131
3113
|
if useInternalVertex == True:
|
3132
3114
|
vFace = Topology.InternalVertex(aFace, tolerance=tolerance)
|
3133
3115
|
else:
|
3134
|
-
vFace =
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3116
|
+
vFace = Topology.CenterOfMass(aFace)
|
3117
|
+
d = Topology.Dictionary(aFace)
|
3118
|
+
vFace = Topology.SetDictionary(vFace, d, silent=True)
|
3119
|
+
edges = Topology.Edges(aFace)
|
3138
3120
|
sharedTopologies = []
|
3139
3121
|
exteriorTopologies = []
|
3140
3122
|
sharedApertures = []
|
3141
3123
|
exteriorApertures = []
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
if len(
|
3124
|
+
face_contents = Topology.Contents(aFace)
|
3125
|
+
for anEdge in edges:
|
3126
|
+
faces1 = Topology.SuperTopologies(anEdge, hostTopology=topology, topologyType="Face")
|
3127
|
+
if len(faces1) > 1:
|
3146
3128
|
sharedTopologies.append(anEdge)
|
3147
3129
|
apertures = Topology.Apertures(anEdge)
|
3148
3130
|
for anAperture in apertures:
|
@@ -3153,387 +3135,168 @@ class Graph:
|
|
3153
3135
|
for anAperture in apertures:
|
3154
3136
|
exteriorApertures.append(anAperture)
|
3155
3137
|
if viaSharedTopologies:
|
3138
|
+
verts, eds = _viaSharedTopologies(vFace, sharedTopologies)
|
3139
|
+
graph_vertices += verts
|
3140
|
+
graph_edges += eds
|
3156
3141
|
for sharedTopology in sharedTopologies:
|
3157
3142
|
if useInternalVertex == True:
|
3158
3143
|
vst = Topology.InternalVertex(sharedTopology, tolerance)
|
3159
3144
|
else:
|
3160
|
-
vst =
|
3161
|
-
|
3162
|
-
|
3163
|
-
if storeBREP:
|
3164
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
3165
|
-
d3 = mergeDictionaries2([d1, d2])
|
3166
|
-
_ = vst.SetDictionary(d3)
|
3167
|
-
else:
|
3168
|
-
_ = vst.SetDictionary(d1)
|
3169
|
-
vertices.append(vst)
|
3170
|
-
tempe = Edge.ByStartVertexEndVertex(vFace, vst, tolerance=tolerance)
|
3171
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Topologies", 1])
|
3172
|
-
_ = tempe.SetDictionary(tempd)
|
3173
|
-
edges.append(tempe)
|
3145
|
+
vst = Topology.CenterOfMass(sharedTopology)
|
3146
|
+
d = Topology.Dictionary(sharedTopology)
|
3147
|
+
vst = Topology.SetDictionary(vst, d, silent=True)
|
3174
3148
|
if toContents:
|
3175
|
-
|
3176
|
-
|
3177
|
-
|
3178
|
-
|
3179
|
-
|
3180
|
-
|
3181
|
-
|
3182
|
-
|
3183
|
-
vst2 = content.CenterOfMass()
|
3184
|
-
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3185
|
-
d1 = content.GetDictionary()
|
3186
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3187
|
-
if storeBREP:
|
3188
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3189
|
-
d3 = mergeDictionaries2([d1, d2])
|
3190
|
-
_ = vst2.SetDictionary(d3)
|
3191
|
-
else:
|
3192
|
-
_ = vst2.SetDictionary(d1)
|
3193
|
-
vertices.append(vst2)
|
3194
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3195
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3196
|
-
_ = tempe.SetDictionary(tempd)
|
3197
|
-
edges.append(tempe)
|
3149
|
+
shd_top_contents = Topology.Contents(sharedTopology)
|
3150
|
+
verts, eds = _toContents(vst, shd_top_contents)
|
3151
|
+
graph_vertices += verts
|
3152
|
+
graph_edges += eds
|
3153
|
+
if toOutposts and others:
|
3154
|
+
verts, eds = _toOutposts(vst, others)
|
3155
|
+
graph_vertices += verts
|
3156
|
+
graph_edges += eds
|
3198
3157
|
if viaSharedApertures:
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
else:
|
3203
|
-
vst = sharedAp.CenterOfMass()
|
3204
|
-
d1 = sharedAp.GetDictionary()
|
3205
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 2) # shared aperture
|
3206
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3207
|
-
if storeBREP:
|
3208
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
3209
|
-
d3 = mergeDictionaries2([d1, d2])
|
3210
|
-
_ = vst.SetDictionary(d3)
|
3211
|
-
else:
|
3212
|
-
_ = vst.SetDictionary(d1)
|
3213
|
-
vertices.append(vst)
|
3214
|
-
tempe = Edge.ByStartVertexEndVertex(vFace, vst, tolerance=tolerance)
|
3215
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Apertures", 2])
|
3216
|
-
_ = tempe.SetDictionary(tempd)
|
3217
|
-
edges.append(tempe)
|
3158
|
+
verts, eds = _viaSharedTopologies(vFace, sharedApertures)
|
3159
|
+
graph_vertices += verts
|
3160
|
+
graph_edges += eds
|
3218
3161
|
if toExteriorTopologies:
|
3162
|
+
verts, eds = _toExteriorTopologies(vFace, exteriorTopologies)
|
3163
|
+
graph_vertices += verts
|
3164
|
+
graph_edges += eds
|
3219
3165
|
for exteriorTopology in exteriorTopologies:
|
3220
3166
|
if useInternalVertex == True:
|
3221
|
-
|
3222
|
-
else:
|
3223
|
-
vst = exteriorTopology.CenterOfMass()
|
3224
|
-
d1 = exteriorTopology.GetDictionary()
|
3225
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 3) # exterior topology
|
3226
|
-
if storeBREP:
|
3227
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
3228
|
-
d3 = mergeDictionaries2([d1, d2])
|
3229
|
-
_ = vst.SetDictionary(d3)
|
3167
|
+
vet = Topology.InternalVertex(exteriorTopology, tolerance)
|
3230
3168
|
else:
|
3231
|
-
|
3232
|
-
|
3233
|
-
|
3234
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
3235
|
-
_ = tempe.SetDictionary(tempd)
|
3236
|
-
edges.append(tempe)
|
3169
|
+
vet = Topology.CenterOfMass(exteriorTopology)
|
3170
|
+
d = Topology.Dictionary(exteriorTopology)
|
3171
|
+
vet = Topology.SetDictionary(vet, d, silent=True)
|
3237
3172
|
if toContents:
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
vst2 = content.CenterOfMass()
|
3247
|
-
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3248
|
-
d1 = content.GetDictionary()
|
3249
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3250
|
-
if storeBREP:
|
3251
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3252
|
-
d3 = mergeDictionaries2([d1, d2])
|
3253
|
-
_ = vst2.SetDictionary(d3)
|
3254
|
-
else:
|
3255
|
-
_ = vst2.SetDictionary(d1)
|
3256
|
-
vertices.append(vst2)
|
3257
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3258
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3259
|
-
_ = tempe.SetDictionary(tempd)
|
3260
|
-
edges.append(tempe)
|
3173
|
+
ext_top_contents = Topology.Contents(exteriorTopology)
|
3174
|
+
verts, eds = _toContents(vet, ext_top_contents)
|
3175
|
+
graph_vertices += verts
|
3176
|
+
graph_edges += eds
|
3177
|
+
if toOutposts and others:
|
3178
|
+
verts, eds = _toOutposts(vet, others)
|
3179
|
+
graph_vertices += verts
|
3180
|
+
graph_edges += eds
|
3261
3181
|
if toExteriorApertures:
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
else:
|
3266
|
-
vst = exTop.CenterOfMass()
|
3267
|
-
d1 = exTop.GetDictionary()
|
3268
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
3269
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3270
|
-
if storeBREP:
|
3271
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3272
|
-
d3 = mergeDictionaries2([d1, d2])
|
3273
|
-
_ = vst.SetDictionary(d3)
|
3274
|
-
else:
|
3275
|
-
_ = vst.SetDictionary(d1)
|
3276
|
-
vertices.append(vst)
|
3277
|
-
tempe = Edge.ByStartVertexEndVertex(vFace, vst, tolerance=tolerance)
|
3278
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
3279
|
-
_ = tempe.SetDictionary(tempd)
|
3280
|
-
edges.append(tempe)
|
3182
|
+
verts, eds = _toExteriorApertures(vFace, exteriorApertures)
|
3183
|
+
graph_vertices += verts
|
3184
|
+
graph_edges += eds
|
3281
3185
|
if toContents:
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
|
3290
|
-
vst = content.CenterOfMass()
|
3291
|
-
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
|
-
d1 = content.GetDictionary()
|
3293
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3294
|
-
if storeBREP:
|
3295
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3296
|
-
d3 = mergeDictionaries2([d1, d2])
|
3297
|
-
_ = vst.SetDictionary(d3)
|
3298
|
-
else:
|
3299
|
-
_ = vst.SetDictionary(d1)
|
3300
|
-
vertices.append(vst)
|
3301
|
-
tempe = Edge.ByStartVertexEndVertex(vFace, vst, tolerance=tolerance)
|
3302
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3303
|
-
_ = tempe.SetDictionary(tempd)
|
3304
|
-
edges.append(tempe)
|
3305
|
-
|
3306
|
-
for aFace in topFaces:
|
3307
|
-
if useInternalVertex == True:
|
3308
|
-
vFace = Topology.InternalVertex(aFace, tolerance)
|
3309
|
-
else:
|
3310
|
-
vFace = aFace.CenterOfMass()
|
3311
|
-
d1 = aFace.GetDictionary()
|
3312
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3313
|
-
if storeBREP:
|
3314
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(aFace), Topology.Type(aFace), Topology.TypeAsString(aFace)])
|
3315
|
-
d3 = mergeDictionaries2([d1, d2])
|
3316
|
-
_ = vFace.SetDictionary(d3)
|
3317
|
-
else:
|
3318
|
-
_ = vFace.SetDictionary(d1)
|
3319
|
-
vertices.append(vFace)
|
3320
|
-
if toOutposts and others:
|
3321
|
-
d = Topology.Dictionary(topology)
|
3322
|
-
if not d == None:
|
3323
|
-
keys = Dictionary.Keys(d)
|
3324
|
-
else:
|
3325
|
-
keys = []
|
3326
|
-
k = None
|
3327
|
-
for key in keys:
|
3328
|
-
if key.lower() == outpostsKey.lower():
|
3329
|
-
k = key
|
3330
|
-
if k:
|
3331
|
-
ids = Dictionary.ValueAtKey(k)
|
3332
|
-
outposts = outpostsByID(others, ids, idKey)
|
3333
|
-
else:
|
3334
|
-
outposts = []
|
3335
|
-
for outpost in outposts:
|
3336
|
-
if useInternalVertex == True:
|
3337
|
-
vop = Topology.InternalVertex(outpost, tolerance)
|
3338
|
-
vcc = Topology.InternalVertex(topology, tolerance)
|
3339
|
-
else:
|
3340
|
-
vop = Topology.CenterOfMass(outpost)
|
3341
|
-
vcc = Topology.CenterOfMass(topology)
|
3342
|
-
d1 = Topology.Dictionary(vcc)
|
3343
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3344
|
-
if storeBREP:
|
3345
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3346
|
-
d3 = mergeDictionaries2([d1, d2])
|
3347
|
-
_ = vcc.SetDictionary(d3)
|
3348
|
-
else:
|
3349
|
-
_ = vcc.SetDictionary(d1)
|
3350
|
-
vertices.append(vcc)
|
3351
|
-
d1 = Topology.Dictionary(vop)
|
3352
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 6) # outpost
|
3353
|
-
if storeBREP:
|
3354
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3355
|
-
d3 = mergeDictionaries2([d1, d2])
|
3356
|
-
_ = vop.SetDictionary(d3)
|
3357
|
-
else:
|
3358
|
-
_ = vop.SetDictionary(d1)
|
3359
|
-
vertices.append(vcc)
|
3360
|
-
tempe = Edge.ByStartVertexEndVertex(vcc, vop, tolerance=tolerance)
|
3361
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
3362
|
-
_ = tempe.SetDictionary(tempd)
|
3363
|
-
edges.append(tempe)
|
3364
|
-
return [vertices, edges]
|
3186
|
+
verts, eds = _toContents(vFace, face_contents)
|
3187
|
+
graph_vertices += verts
|
3188
|
+
graph_edges += eds
|
3189
|
+
if toOutposts and others:
|
3190
|
+
verts, eds = toOutposts(vFace, others)
|
3191
|
+
graph_vertices += verts
|
3192
|
+
graph_edges += eds
|
3193
|
+
return [graph_vertices, graph_edges]
|
3365
3194
|
|
3366
3195
|
def processFace(item):
|
3367
3196
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3368
|
-
|
3369
|
-
|
3370
|
-
|
3197
|
+
graph_vertices = []
|
3198
|
+
graph_edges = []
|
3371
3199
|
if useInternalVertex == True:
|
3372
3200
|
vFace = Topology.InternalVertex(topology, tolerance=tolerance)
|
3373
3201
|
else:
|
3374
|
-
vFace =
|
3375
|
-
d1 =
|
3202
|
+
vFace = Topology.CenterOfMass(topology)
|
3203
|
+
d1 = Topology.Dictionary(topology)
|
3376
3204
|
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3377
3205
|
if storeBREP:
|
3378
3206
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3379
3207
|
d3 = mergeDictionaries2([d1, d2])
|
3380
|
-
|
3208
|
+
vFace = Topology.SetDictionary(vFace, d3, silent=True)
|
3381
3209
|
else:
|
3382
|
-
|
3383
|
-
|
3384
|
-
if
|
3385
|
-
|
3386
|
-
|
3387
|
-
keys = Dictionary.Keys(d)
|
3388
|
-
else:
|
3389
|
-
keys = []
|
3390
|
-
k = None
|
3391
|
-
for key in keys:
|
3392
|
-
if key.lower() == outpostsKey.lower():
|
3393
|
-
k = key
|
3394
|
-
if k:
|
3395
|
-
ids = Dictionary.ValueAtKey(d, k)
|
3396
|
-
outposts = outpostsByID(others, ids, idKey)
|
3397
|
-
else:
|
3398
|
-
outposts = []
|
3399
|
-
for outpost in outposts:
|
3400
|
-
if useInternalVertex == True:
|
3401
|
-
vop = Topology.InternalVertex(outpost, tolerance)
|
3402
|
-
else:
|
3403
|
-
vop = Topology.CenterOfMass(outpost)
|
3404
|
-
tempe = Edge.ByStartVertexEndVertex(vFace, vop, tolerance=tolerance)
|
3405
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
3406
|
-
_ = tempe.SetDictionary(tempd)
|
3407
|
-
edges.append(tempe)
|
3408
|
-
if (toExteriorTopologies == True) or (toExteriorApertures == True) or (toContents == True):
|
3409
|
-
fEdges = []
|
3410
|
-
_ = topology.Edges(None, fEdges)
|
3210
|
+
vFace = Topology.SetDictionary(vFace, d1, silent=True)
|
3211
|
+
graph_vertices.append(vFace)
|
3212
|
+
if any([toExteriorTopologies, toExteriorApertures, toContents, toOutposts]):
|
3213
|
+
face_contents = Topology.Contents(topology)
|
3214
|
+
edges = Topology.Edges(topology)
|
3411
3215
|
exteriorTopologies = []
|
3412
3216
|
exteriorApertures = []
|
3413
|
-
|
3414
|
-
for anEdge in fEdges:
|
3217
|
+
for anEdge in edges:
|
3415
3218
|
exteriorTopologies.append(anEdge)
|
3416
3219
|
apertures = Topology.Apertures(anEdge)
|
3417
3220
|
for anAperture in apertures:
|
3418
3221
|
exteriorApertures.append(anAperture)
|
3419
|
-
|
3420
|
-
|
3421
|
-
|
3422
|
-
|
3423
|
-
|
3424
|
-
|
3425
|
-
|
3426
|
-
|
3427
|
-
|
3428
|
-
|
3429
|
-
|
3430
|
-
|
3431
|
-
|
3432
|
-
|
3433
|
-
|
3434
|
-
|
3435
|
-
|
3436
|
-
|
3437
|
-
|
3438
|
-
|
3439
|
-
|
3440
|
-
|
3441
|
-
|
3442
|
-
|
3443
|
-
|
3444
|
-
|
3445
|
-
|
3446
|
-
|
3447
|
-
|
3448
|
-
|
3449
|
-
|
3450
|
-
|
3451
|
-
|
3452
|
-
|
3453
|
-
|
3454
|
-
_ = vst2.SetDictionary(d3)
|
3455
|
-
else:
|
3456
|
-
_ = vst2.SetDictionary(d1)
|
3457
|
-
vertices.append(vst2)
|
3458
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3459
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3460
|
-
_ = tempe.SetDictionary(tempd)
|
3461
|
-
edges.append(tempe)
|
3462
|
-
if toExteriorApertures:
|
3463
|
-
for exTop in exteriorApertures:
|
3464
|
-
if useInternalVertex == True:
|
3465
|
-
vst = Topology.InternalVertex(exTop, tolerance)
|
3466
|
-
else:
|
3467
|
-
vst = exTop.CenterOfMass()
|
3468
|
-
d1 = exTop.GetDictionary()
|
3469
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
3470
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3471
|
-
if storeBREP:
|
3472
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3473
|
-
d3 = mergeDictionaries2([d1, d2])
|
3474
|
-
_ = vst.SetDictionary(d3)
|
3475
|
-
else:
|
3476
|
-
_ = vst.SetDictionary(d1)
|
3477
|
-
vertices.append(vst)
|
3478
|
-
tempe = Edge.ByStartVertexEndVertex(vFace, vst, tolerance=tolerance)
|
3479
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
3480
|
-
_ = tempe.SetDictionary(tempd)
|
3481
|
-
edges.append(tempe)
|
3482
|
-
if toContents:
|
3483
|
-
contents = []
|
3484
|
-
_ = topology.Contents(contents)
|
3485
|
-
for content in contents:
|
3486
|
-
if Topology.IsInstance(content, "Aperture"):
|
3487
|
-
content = Aperture.Topology(content)
|
3488
|
-
if useInternalVertex == True:
|
3489
|
-
vst = Topology.InternalVertex(content, tolerance)
|
3490
|
-
else:
|
3491
|
-
vst = content.CenterOfMass()
|
3492
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3493
|
-
d1 = content.GetDictionary()
|
3494
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3495
|
-
if storeBREP:
|
3496
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3497
|
-
d3 = mergeDictionaries2([d1, d2])
|
3498
|
-
_ = vst.SetDictionary(d3)
|
3499
|
-
else:
|
3500
|
-
_ = vst.SetDictionary(d1)
|
3501
|
-
vertices.append(vst)
|
3502
|
-
tempe = Edge.ByStartVertexEndVertex(vFace, vst, tolerance=tolerance)
|
3503
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3504
|
-
_ = tempe.SetDictionary(tempd)
|
3505
|
-
edges.append(tempe)
|
3506
|
-
return [vertices, edges]
|
3222
|
+
if toExteriorTopologies:
|
3223
|
+
verts, eds = _toExteriorTopologies(vFace, exteriorTopologies)
|
3224
|
+
graph_vertices += verts
|
3225
|
+
graph_edges += eds
|
3226
|
+
for exteriorTopology in exteriorTopologies:
|
3227
|
+
if useInternalVertex == True:
|
3228
|
+
vet = Topology.InternalVertex(exteriorTopology, tolerance)
|
3229
|
+
else:
|
3230
|
+
vet = Topology.CenterOfMass(exteriorTopology)
|
3231
|
+
d = Topology.Dictionary(exteriorTopology)
|
3232
|
+
vet = Topology.SetDictionary(vet, d, silent=True)
|
3233
|
+
if toContents:
|
3234
|
+
ext_top_contents = Topology.Contents(exteriorTopology)
|
3235
|
+
verts, eds = _toContents(vet, ext_top_contents)
|
3236
|
+
graph_vertices += verts
|
3237
|
+
graph_edges += eds
|
3238
|
+
if toOutposts and others:
|
3239
|
+
verts, eds = _toOutposts(vet, others)
|
3240
|
+
graph_vertices += verts
|
3241
|
+
graph_edges += eds
|
3242
|
+
if toExteriorApertures:
|
3243
|
+
verts, eds = _toExteriorApertures(vFace, exteriorApertures)
|
3244
|
+
graph_vertices += verts
|
3245
|
+
graph_edges += eds
|
3246
|
+
if toContents:
|
3247
|
+
verts, eds = _toContents(vFace, face_contents)
|
3248
|
+
graph_vertices += verts
|
3249
|
+
graph_edges += eds
|
3250
|
+
if toOutposts and others:
|
3251
|
+
verts, eds = toOutposts(vFace, others)
|
3252
|
+
graph_vertices += verts
|
3253
|
+
graph_edges += eds
|
3254
|
+
return [graph_vertices, graph_edges]
|
3255
|
+
|
3256
|
+
|
3507
3257
|
|
3508
3258
|
def processWire(item):
|
3509
3259
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3510
|
-
|
3511
|
-
|
3260
|
+
graph_vertices = []
|
3261
|
+
graph_edges = []
|
3512
3262
|
edgemat = []
|
3263
|
+
# Store all the vertices of the cells of the cellComplex
|
3264
|
+
edges = Topology.Edges(topology)
|
3265
|
+
for edge in edges:
|
3266
|
+
if useInternalVertex == True:
|
3267
|
+
vEdge = Topology.InternalVertex(edge, tolerance=tolerance)
|
3268
|
+
else:
|
3269
|
+
vEdge = Topology.CenterOfMass(edge)
|
3270
|
+
d1 = Topology.Dictionary(edge)
|
3271
|
+
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3272
|
+
if storeBREP:
|
3273
|
+
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(edge), Topology.Type(edge), Topology.TypeAsString(edge)])
|
3274
|
+
d3 = mergeDictionaries2([d1, d2])
|
3275
|
+
vEdge = Topology.SetDictionary(vEdge, d3, silent=True)
|
3276
|
+
else:
|
3277
|
+
vEdge = Topology.SetDictionary(vEdge, d1, silent=True)
|
3278
|
+
graph_vertices.append(vEdge)
|
3513
3279
|
if direct == True:
|
3514
|
-
|
3515
|
-
_ = topology.Edges(None, topEdges)
|
3280
|
+
edges = Topology.Edges(topology)
|
3516
3281
|
# Create a matrix of zeroes
|
3517
|
-
for i in range(len(
|
3282
|
+
for i in range(len(edges)):
|
3518
3283
|
edgeRow = []
|
3519
|
-
for j in range(len(
|
3284
|
+
for j in range(len(edges)):
|
3520
3285
|
edgeRow.append(0)
|
3521
3286
|
edgemat.append(edgeRow)
|
3522
|
-
for i in range(len(
|
3523
|
-
for j in range(len(
|
3287
|
+
for i in range(len(edges)):
|
3288
|
+
for j in range(len(edges)):
|
3524
3289
|
if (i != j) and edgemat[i][j] == 0:
|
3525
3290
|
edgemat[i][j] = 1
|
3526
3291
|
edgemat[j][i] = 1
|
3527
|
-
sharedt = Topology.SharedVertices(
|
3292
|
+
sharedt = Topology.SharedVertices(edges[i], edges[j])
|
3528
3293
|
if len(sharedt) > 0:
|
3529
|
-
|
3530
|
-
v1 =
|
3531
|
-
|
3532
|
-
|
3533
|
-
|
3534
|
-
v2 =
|
3535
|
-
except:
|
3536
|
-
v2 = topEdges[j].CenterOfMass()
|
3294
|
+
if useInternalVertex == True:
|
3295
|
+
v1 = Topology.InternalVertex(edges[i], tolerance=tolerance)
|
3296
|
+
v2 = Topology.InternalVertex(edges[j], tolerance=tolerance)
|
3297
|
+
else:
|
3298
|
+
v1 = Topology.CenterOfMass(edges[i])
|
3299
|
+
v2 = Topology.CenterOfMass(edges[j])
|
3537
3300
|
e = Edge.ByStartVertexEndVertex(v1, v2, tolerance=tolerance)
|
3538
3301
|
mDict = mergeDictionaries(sharedt)
|
3539
3302
|
if not mDict == None:
|
@@ -3544,75 +3307,70 @@ class Graph:
|
|
3544
3307
|
values = ["Direct", 0]
|
3545
3308
|
mDict = Dictionary.ByKeysValues(keys, values)
|
3546
3309
|
if mDict:
|
3547
|
-
e.SetDictionary(mDict)
|
3548
|
-
|
3310
|
+
e = Topology.SetDictionary(e, mDict, silent=True)
|
3311
|
+
graph_edges.append(e)
|
3549
3312
|
if directApertures == True:
|
3550
3313
|
edgemat = []
|
3551
|
-
|
3552
|
-
_ = topology.Edges(None, topEdges)
|
3314
|
+
edges = Topology.Edges(topology)
|
3553
3315
|
# Create a matrix of zeroes
|
3554
|
-
for i in range(len(
|
3555
|
-
|
3556
|
-
for j in range(len(
|
3316
|
+
for i in range(len(edges)):
|
3317
|
+
cellRow = []
|
3318
|
+
for j in range(len(edges)):
|
3557
3319
|
edgeRow.append(0)
|
3558
3320
|
edgemat.append(edgeRow)
|
3559
|
-
for i in range(len(
|
3560
|
-
for j in range(len(
|
3321
|
+
for i in range(len(edges)):
|
3322
|
+
for j in range(len(edges)):
|
3561
3323
|
if (i != j) and edgemat[i][j] == 0:
|
3562
3324
|
edgemat[i][j] = 1
|
3563
3325
|
edgemat[j][i] = 1
|
3564
|
-
sharedt = Topology.SharedVertices(
|
3326
|
+
sharedt = Topology.SharedVertices(edges[i], edges[j])
|
3565
3327
|
if len(sharedt) > 0:
|
3566
3328
|
apertureExists = False
|
3567
3329
|
for x in sharedt:
|
3568
3330
|
apList = Topology.Apertures(x)
|
3569
3331
|
if len(apList) > 0:
|
3332
|
+
apTopList = []
|
3333
|
+
for ap in apList:
|
3334
|
+
apTopList.append(ap)
|
3570
3335
|
apertureExists = True
|
3571
3336
|
break
|
3572
3337
|
if apertureExists:
|
3573
|
-
|
3574
|
-
v1 =
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
v2 =
|
3579
|
-
except:
|
3580
|
-
v2 = topEdges[j].CenterOfMass()
|
3338
|
+
if useInternalVertex == True:
|
3339
|
+
v1 = Topology.InternalVertex(edges[i], tolerance=tolerance)
|
3340
|
+
v2 = Topology.InternalVertex(edges[j], tolerance=tolerance)
|
3341
|
+
else:
|
3342
|
+
v1 = Topology.CenterOfMass(edges[i])
|
3343
|
+
v2 = Topology.CenterOfMass(edges[j])
|
3581
3344
|
e = Edge.ByStartVertexEndVertex(v1, v2, tolerance=tolerance)
|
3582
|
-
mDict = mergeDictionaries(
|
3345
|
+
mDict = mergeDictionaries(apTopList)
|
3346
|
+
if not mDict == None:
|
3347
|
+
keys = (Dictionary.Keys(mDict) or [])+["relationship", edgeCategoryKey]
|
3348
|
+
values = (Dictionary.Values(mDict) or [])+["Direct", 0]
|
3349
|
+
else:
|
3350
|
+
keys = ["relationship", edgeCategoryKey]
|
3351
|
+
values = ["Direct", 0]
|
3352
|
+
mDict = Dictionary.ByKeysValues(keys, values)
|
3583
3353
|
if mDict:
|
3584
|
-
e.SetDictionary(mDict)
|
3585
|
-
|
3586
|
-
|
3587
|
-
|
3588
|
-
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
3592
|
-
vEdge =
|
3593
|
-
|
3594
|
-
|
3595
|
-
|
3596
|
-
# d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3597
|
-
# if storeBREP:
|
3598
|
-
# d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(anEdge), Topology.Type(anEdge), Topology.TypeAsString(anEdge)])
|
3599
|
-
# d3 = mergeDictionaries2([d1, d2])
|
3600
|
-
# _ = vEdge.SetDictionary(d3)
|
3601
|
-
# else:
|
3602
|
-
# _ = vEdge.SetDictionary(d1)
|
3603
|
-
# vertices.append(vEdge)
|
3604
|
-
eVertices = []
|
3605
|
-
_ = anEdge.Vertices(None, eVertices)
|
3354
|
+
e = Topology.SetDictionary(e, mDict, silent=True)
|
3355
|
+
graph_edges.append(e)
|
3356
|
+
edges = Topology.Edges(topology)
|
3357
|
+
if any([viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents]):
|
3358
|
+
for anEdge in edges:
|
3359
|
+
if useInternalVertex == True:
|
3360
|
+
vEdge = Topology.InternalVertex(anEdge, tolerance=tolerance)
|
3361
|
+
else:
|
3362
|
+
vEdge = Topology.CenterOfMass(anEdge)
|
3363
|
+
d = Topology.Dictionary(anEdge)
|
3364
|
+
vCell = Topology.SetDictionary(vEdge, d, silent=True)
|
3365
|
+
vertices = Topology.Vertices(anEdge)
|
3606
3366
|
sharedTopologies = []
|
3607
3367
|
exteriorTopologies = []
|
3608
3368
|
sharedApertures = []
|
3609
3369
|
exteriorApertures = []
|
3610
|
-
|
3611
|
-
|
3612
|
-
|
3613
|
-
|
3614
|
-
_ = aVertex.Edges(topology, tempEdges)
|
3615
|
-
if len(tempEdges) > 1:
|
3370
|
+
edge_contents = Topology.Contents(anEdge)
|
3371
|
+
for aVertex in vertices:
|
3372
|
+
edges1 = Topology.SuperTopologies(aVertex, topology, topologyType="Edge")
|
3373
|
+
if len(edges1) > 1:
|
3616
3374
|
sharedTopologies.append(aVertex)
|
3617
3375
|
apertures = Topology.Apertures(aVertex)
|
3618
3376
|
for anAperture in apertures:
|
@@ -3623,328 +3381,126 @@ class Graph:
|
|
3623
3381
|
for anAperture in apertures:
|
3624
3382
|
exteriorApertures.append(anAperture)
|
3625
3383
|
if viaSharedTopologies:
|
3384
|
+
verts, eds = _viaSharedTopologies(vEdge, sharedTopologies)
|
3385
|
+
graph_vertices += verts
|
3386
|
+
graph_edges += eds
|
3626
3387
|
for sharedTopology in sharedTopologies:
|
3627
|
-
|
3628
|
-
|
3629
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 1) # shared topology
|
3630
|
-
if storeBREP:
|
3631
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedTopology), Topology.Type(sharedTopology), Topology.TypeAsString(sharedTopology)])
|
3632
|
-
d3 = mergeDictionaries2([d1, d2])
|
3633
|
-
_ = vst.SetDictionary(d3)
|
3388
|
+
if useInternalVertex == True:
|
3389
|
+
vst = Topology.InternalVertex(sharedTopology, tolerance)
|
3634
3390
|
else:
|
3635
|
-
|
3636
|
-
|
3637
|
-
|
3638
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Topologies", 1])
|
3639
|
-
_ = tempe.SetDictionary(tempd)
|
3640
|
-
edges.append(tempe)
|
3391
|
+
vst = Topology.CenterOfMass(sharedTopology)
|
3392
|
+
d = Topology.Dictionary(sharedTopology)
|
3393
|
+
vst = Topology.SetDictionary(vst, d, silent=True)
|
3641
3394
|
if toContents:
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
vst2 = content.CenterOfMass()
|
3651
|
-
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3652
|
-
d1 = content.GetDictionary()
|
3653
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3654
|
-
if storeBREP:
|
3655
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3656
|
-
d3 = mergeDictionaries2([d1, d2])
|
3657
|
-
_ = vst2.SetDictionary(d3)
|
3658
|
-
else:
|
3659
|
-
_ = vst2.SetDictionary(d1)
|
3660
|
-
vertices.append(vst2)
|
3661
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3662
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3663
|
-
_ = tempe.SetDictionary(tempd)
|
3664
|
-
edges.append(tempe)
|
3395
|
+
shd_top_contents = Topology.Contents(sharedTopology)
|
3396
|
+
verts, eds = _toContents(vst, shd_top_contents)
|
3397
|
+
graph_vertices += verts
|
3398
|
+
graph_edges += eds
|
3399
|
+
if toOutposts and others:
|
3400
|
+
verts, eds = _toOutposts(vst, others)
|
3401
|
+
graph_vertices += verts
|
3402
|
+
graph_edges += eds
|
3665
3403
|
if viaSharedApertures:
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
else:
|
3670
|
-
vst = sharedAp.CenterOfMass()
|
3671
|
-
d1 = sharedAp.GetDictionary()
|
3672
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 2) # shared aperture
|
3673
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3674
|
-
if storeBREP:
|
3675
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(sharedAp), Topology.Type(sharedAp), Topology.TypeAsString(sharedAp)])
|
3676
|
-
d3 = mergeDictionaries2([d1, d2])
|
3677
|
-
_ = vst.SetDictionary(d3)
|
3678
|
-
else:
|
3679
|
-
_ = vst.SetDictionary(d1)
|
3680
|
-
vertices.append(vst)
|
3681
|
-
tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3682
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["Via_Shared_Apertures", 2])
|
3683
|
-
_ = tempe.SetDictionary(tempd)
|
3684
|
-
edges.append(tempe)
|
3404
|
+
verts, eds = _viaSharedTopologies(vCell, sharedApertures)
|
3405
|
+
graph_vertices += verts
|
3406
|
+
graph_edges += eds
|
3685
3407
|
if toExteriorTopologies:
|
3408
|
+
verts, eds = _toExteriorTopologies(vCell, exteriorTopologies)
|
3409
|
+
graph_vertices += verts
|
3410
|
+
graph_edges += eds
|
3686
3411
|
for exteriorTopology in exteriorTopologies:
|
3687
|
-
vst = exteriorTopology
|
3688
|
-
vertices.append(exteriorTopology)
|
3689
|
-
tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3690
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Topologies", 3])
|
3691
|
-
_ = tempe.SetDictionary(tempd)
|
3692
|
-
edges.append(tempe)
|
3693
|
-
if toContents:
|
3694
|
-
contents = []
|
3695
|
-
_ = vst.Contents(contents)
|
3696
|
-
for content in contents:
|
3697
|
-
if Topology.IsInstance(content, "Aperture"):
|
3698
|
-
content = Aperture.Topology(content)
|
3699
|
-
if useInternalVertex == True:
|
3700
|
-
vst2 = Topology.InternalVertex(content, tolerance)
|
3701
|
-
else:
|
3702
|
-
vst2 = content.CenterOfMass()
|
3703
|
-
vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3704
|
-
d1 = content.GetDictionary()
|
3705
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3706
|
-
if storeBREP:
|
3707
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3708
|
-
d3 = mergeDictionaries2([d1, d2])
|
3709
|
-
_ = vst2.SetDictionary(d3)
|
3710
|
-
else:
|
3711
|
-
_ = vst2.SetDictionary(d1)
|
3712
|
-
vertices.append(vst2)
|
3713
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3714
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3715
|
-
_ = tempe.SetDictionary(tempd)
|
3716
|
-
edges.append(tempe)
|
3717
|
-
if toExteriorApertures:
|
3718
|
-
for exTop in exteriorApertures:
|
3719
3412
|
if useInternalVertex == True:
|
3720
|
-
|
3721
|
-
else:
|
3722
|
-
vst = exTop.CenterOfMass()
|
3723
|
-
d1 = exTop.GetDictionary()
|
3724
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
3725
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3726
|
-
if storeBREP:
|
3727
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3728
|
-
d3 = mergeDictionaries2([d1, d2])
|
3729
|
-
_ = vst.SetDictionary(d3)
|
3413
|
+
vet = Topology.InternalVertex(exteriorTopology, tolerance)
|
3730
3414
|
else:
|
3731
|
-
|
3732
|
-
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
|
3415
|
+
vet = Topology.CenterOfMass(exteriorTopology)
|
3416
|
+
d = Topology.Dictionary(exteriorTopology)
|
3417
|
+
vet = Topology.SetDictionary(vet, d, silent=True)
|
3418
|
+
if toContents:
|
3419
|
+
ext_top_contents = Topology.Contents(exteriorTopology)
|
3420
|
+
verts, eds = _toContents(vet, ext_top_contents)
|
3421
|
+
graph_vertices += verts
|
3422
|
+
graph_edges += eds
|
3423
|
+
if toOutposts and others:
|
3424
|
+
verts, eds = _toOutposts(vet, others)
|
3425
|
+
graph_vertices += verts
|
3426
|
+
graph_edges += eds
|
3427
|
+
if toExteriorApertures:
|
3428
|
+
verts, eds = _toExteriorApertures(vEdge, exteriorApertures)
|
3429
|
+
graph_vertices += verts
|
3430
|
+
graph_edges += eds
|
3737
3431
|
if toContents:
|
3738
|
-
|
3739
|
-
|
3740
|
-
|
3741
|
-
|
3742
|
-
|
3743
|
-
|
3744
|
-
|
3745
|
-
|
3746
|
-
|
3747
|
-
|
3748
|
-
d1 = content.GetDictionary()
|
3749
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3750
|
-
if storeBREP:
|
3751
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3752
|
-
d3 = mergeDictionaries2([d1, d2])
|
3753
|
-
_ = vst.SetDictionary(d3)
|
3754
|
-
else:
|
3755
|
-
_ = vst.SetDictionary(d1)
|
3756
|
-
vertices.append(vst)
|
3757
|
-
tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3758
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3759
|
-
_ = tempe.SetDictionary(tempd)
|
3760
|
-
edges.append(tempe)
|
3761
|
-
for anEdge in topEdges:
|
3762
|
-
try:
|
3763
|
-
vEdge = Edge.VertexByParameter(anEdge, 0.5)
|
3764
|
-
except:
|
3765
|
-
vEdge = anEdge.CenterOfMass()
|
3766
|
-
d1 = anEdge.GetDictionary()
|
3767
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topologuy
|
3768
|
-
if storeBREP:
|
3769
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(anEdge), Topology.Type(anEdge), Topology.TypeAsString(anEdge)])
|
3770
|
-
d3 = mergeDictionaries2([d1, d2])
|
3771
|
-
_ = vEdge.SetDictionary(d3)
|
3772
|
-
else:
|
3773
|
-
_ = vEdge.SetDictionary(d1)
|
3774
|
-
vertices.append(vEdge)
|
3775
|
-
|
3776
|
-
if toOutposts and others:
|
3777
|
-
d = Topology.Dictionary(topology)
|
3778
|
-
if not d == None:
|
3779
|
-
keys = Dictionary.Keys(d)
|
3780
|
-
else:
|
3781
|
-
keys = []
|
3782
|
-
k = None
|
3783
|
-
for key in keys:
|
3784
|
-
if key.lower() == outpostsKey.lower():
|
3785
|
-
k = key
|
3786
|
-
if k:
|
3787
|
-
ids = Dictionary.ValueAtKey(k)
|
3788
|
-
outposts = outpostsByID(others, ids, idKey)
|
3789
|
-
else:
|
3790
|
-
outposts = []
|
3791
|
-
for outpost in outposts:
|
3792
|
-
if useInternalVertex == True:
|
3793
|
-
vop = Topology.InternalVertex(outpost, tolerance)
|
3794
|
-
vcc = Topology.InternalVertex(topology, tolerance)
|
3795
|
-
else:
|
3796
|
-
vop = Topology.CenterOfMass(outpost)
|
3797
|
-
vcc = Topology.CenterOfMass(topology)
|
3798
|
-
d1 = Topology.Dictionary(vcc)
|
3799
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3800
|
-
if storeBREP:
|
3801
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3802
|
-
d3 = mergeDictionaries2([d1, d2])
|
3803
|
-
_ = vcc.SetDictionary(d3)
|
3804
|
-
else:
|
3805
|
-
_ = vcc.SetDictionary(d1)
|
3806
|
-
vertices.append(vcc)
|
3807
|
-
d1 = Topology.Dictionary(vop)
|
3808
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 6) # outpost
|
3809
|
-
if storeBREP:
|
3810
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3811
|
-
d3 = mergeDictionaries2([d1, d2])
|
3812
|
-
_ = vop.SetDictionary(d3)
|
3813
|
-
else:
|
3814
|
-
_ = vop.SetDictionary(d1)
|
3815
|
-
vertices.append(vop)
|
3816
|
-
tempe = Edge.ByStartVertexEndVertex(vcc, vop, tolerance=tolerance)
|
3817
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
3818
|
-
_ = tempe.SetDictionary(tempd)
|
3819
|
-
edges.append(tempe)
|
3820
|
-
|
3821
|
-
return [vertices, edges]
|
3432
|
+
verts, eds = _toContents(vEdge, edge_contents)
|
3433
|
+
graph_vertices += verts
|
3434
|
+
graph_edges += eds
|
3435
|
+
if toOutposts and others:
|
3436
|
+
verts, eds = toOutposts(vEdge, others)
|
3437
|
+
graph_vertices += verts
|
3438
|
+
graph_edges += eds
|
3439
|
+
return [graph_vertices, graph_edges]
|
3440
|
+
|
3441
|
+
|
3822
3442
|
|
3823
3443
|
def processEdge(item):
|
3824
3444
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3825
|
-
|
3826
|
-
|
3827
|
-
|
3445
|
+
graph_vertices = []
|
3446
|
+
graph_edges = []
|
3828
3447
|
if useInternalVertex == True:
|
3829
|
-
|
3830
|
-
vEdge = Edge.VertexByParameter(topology, 0.5)
|
3831
|
-
except:
|
3832
|
-
vEdge = topology.CenterOfMass()
|
3448
|
+
vEdge = Topology.InternalVertex(topology, tolerance=tolerance)
|
3833
3449
|
else:
|
3834
|
-
vEdge =
|
3835
|
-
|
3836
|
-
d1 = vEdge.GetDictionary()
|
3450
|
+
vEdge = Topology.CenterOfMass(topology)
|
3451
|
+
d1 = Topology.Dictionary(topology)
|
3837
3452
|
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3838
3453
|
if storeBREP:
|
3839
3454
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3840
3455
|
d3 = mergeDictionaries2([d1, d2])
|
3841
|
-
|
3456
|
+
vEdge = Topology.SetDictionary(vEdge, d3, silent=True)
|
3842
3457
|
else:
|
3843
|
-
|
3844
|
-
|
3845
|
-
|
3846
|
-
|
3847
|
-
|
3848
|
-
d = Topology.Dictionary(topology)
|
3849
|
-
if not d == None:
|
3850
|
-
keys = Dictionary.Keys(d)
|
3851
|
-
else:
|
3852
|
-
keys = []
|
3853
|
-
k = None
|
3854
|
-
for key in keys:
|
3855
|
-
if key.lower() == outpostsKey.lower():
|
3856
|
-
k = key
|
3857
|
-
if k:
|
3858
|
-
ids = Dictionary.ValueAtKey(d, k)
|
3859
|
-
outposts = outpostsByID(others, ids, idKey)
|
3860
|
-
else:
|
3861
|
-
outposts = []
|
3862
|
-
for outpost in outposts:
|
3863
|
-
if useInternalVertex == True:
|
3864
|
-
vop = Topology.InternalVertex(outpost, tolerance)
|
3865
|
-
else:
|
3866
|
-
vop = Topology.CenterOfMass(outpost)
|
3867
|
-
tempe = Edge.ByStartVertexEndVertex(vEdge, vop, tolerance=tolerance)
|
3868
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
3869
|
-
_ = tempe.SetDictionary(tempd)
|
3870
|
-
edges.append(tempe)
|
3871
|
-
|
3872
|
-
if (toExteriorTopologies == True) or (toExteriorApertures == True) or (toContents == True):
|
3873
|
-
eVertices = []
|
3874
|
-
_ = topology.Vertices(None, eVertices)
|
3458
|
+
vEdge = Topology.SetDictionary(vEdge, d1, silent=True)
|
3459
|
+
graph_vertices.append(vEdge)
|
3460
|
+
if any([toExteriorTopologies, toExteriorApertures, toContents, toOutposts]):
|
3461
|
+
edge_contents = Topology.Contents(topology)
|
3462
|
+
vertices = Topology.Vertices(topology)
|
3875
3463
|
exteriorTopologies = []
|
3876
3464
|
exteriorApertures = []
|
3877
|
-
for aVertex in
|
3465
|
+
for aVertex in vertices:
|
3878
3466
|
exteriorTopologies.append(aVertex)
|
3879
3467
|
apertures = Topology.Apertures(aVertex)
|
3880
3468
|
for anAperture in apertures:
|
3881
3469
|
exteriorApertures.append(anAperture)
|
3882
|
-
|
3883
|
-
|
3884
|
-
|
3885
|
-
|
3886
|
-
|
3887
|
-
|
3888
|
-
|
3889
|
-
|
3890
|
-
|
3891
|
-
|
3892
|
-
|
3893
|
-
|
3894
|
-
|
3895
|
-
|
3896
|
-
|
3897
|
-
|
3898
|
-
|
3899
|
-
|
3900
|
-
|
3901
|
-
|
3902
|
-
|
3903
|
-
|
3904
|
-
|
3905
|
-
|
3906
|
-
|
3907
|
-
|
3908
|
-
|
3909
|
-
|
3910
|
-
|
3911
|
-
|
3912
|
-
|
3913
|
-
|
3914
|
-
|
3915
|
-
|
3916
|
-
d3 = mergeDictionaries2([d1, d2])
|
3917
|
-
_ = vst2.SetDictionary(d3)
|
3918
|
-
else:
|
3919
|
-
_ = vst2.SetDictionary(d1)
|
3920
|
-
vertices.append(vst2)
|
3921
|
-
tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3922
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3923
|
-
_ = tempe.SetDictionary(tempd)
|
3924
|
-
edges.append(tempe)
|
3925
|
-
if toExteriorApertures:
|
3926
|
-
for exTop in exteriorApertures:
|
3927
|
-
if useInternalVertex == True:
|
3928
|
-
vst = Topology.InternalVertex(exTop, tolerance)
|
3929
|
-
else:
|
3930
|
-
vst = exTop.CenterOfMass()
|
3931
|
-
d1 = exTop.GetDictionary()
|
3932
|
-
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
3933
|
-
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3934
|
-
if storeBREP:
|
3935
|
-
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3936
|
-
d3 = mergeDictionaries2([d1, d2])
|
3937
|
-
_ = vst.SetDictionary(d3)
|
3938
|
-
else:
|
3939
|
-
_ = vst.SetDictionary(d1)
|
3940
|
-
_ = vst.SetDictionary(exTop.GetDictionary())
|
3941
|
-
vertices.append(vst)
|
3942
|
-
tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3943
|
-
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
3944
|
-
_ = tempe.SetDictionary(tempd)
|
3945
|
-
edges.append(tempe)
|
3946
|
-
|
3947
|
-
return [vertices, edges]
|
3470
|
+
if toExteriorTopologies:
|
3471
|
+
verts, eds = _toExteriorTopologies(vEdge, exteriorTopologies)
|
3472
|
+
graph_vertices += verts
|
3473
|
+
graph_edges += eds
|
3474
|
+
for exteriorTopology in exteriorTopologies:
|
3475
|
+
if useInternalVertex == True:
|
3476
|
+
vet = Topology.InternalVertex(exteriorTopology, tolerance)
|
3477
|
+
else:
|
3478
|
+
vet = Topology.CenterOfMass(exteriorTopology)
|
3479
|
+
d = Topology.Dictionary(exteriorTopology)
|
3480
|
+
vet = Topology.SetDictionary(vet, d, silent=True)
|
3481
|
+
if toContents:
|
3482
|
+
ext_top_contents = Topology.Contents(exteriorTopology)
|
3483
|
+
verts, eds = _toContents(vet, ext_top_contents)
|
3484
|
+
graph_vertices += verts
|
3485
|
+
graph_edges += eds
|
3486
|
+
if toOutposts and others:
|
3487
|
+
verts, eds = _toOutposts(vet, others)
|
3488
|
+
graph_vertices += verts
|
3489
|
+
graph_edges += eds
|
3490
|
+
if toExteriorApertures:
|
3491
|
+
verts, eds = _toExteriorApertures(vEdge, exteriorApertures)
|
3492
|
+
graph_vertices += verts
|
3493
|
+
graph_edges += eds
|
3494
|
+
if toContents:
|
3495
|
+
verts, eds = _toContents(vEdge, edge_contents)
|
3496
|
+
graph_vertices += verts
|
3497
|
+
graph_edges += eds
|
3498
|
+
if toOutposts and others:
|
3499
|
+
verts, eds = toOutposts(vEdge, others)
|
3500
|
+
graph_vertices += verts
|
3501
|
+
graph_edges += eds
|
3502
|
+
return [graph_vertices, graph_edges]
|
3503
|
+
|
3948
3504
|
|
3949
3505
|
def processVertex(item):
|
3950
3506
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
@@ -3952,28 +3508,27 @@ class Graph:
|
|
3952
3508
|
edges = []
|
3953
3509
|
|
3954
3510
|
if toContents:
|
3955
|
-
contents =
|
3956
|
-
_ = topology.Contents(contents)
|
3511
|
+
contents = Topology.Contents(topology)
|
3957
3512
|
for content in contents:
|
3958
3513
|
if Topology.IsInstance(content, "Aperture"):
|
3959
3514
|
content = Aperture.Topology(content)
|
3960
3515
|
if useInternalVertex == True:
|
3961
3516
|
vst = Topology.InternalVertex(content, tolerance)
|
3962
3517
|
else:
|
3963
|
-
vst =
|
3964
|
-
d1 =
|
3518
|
+
vst = Topology.CenterOfMass(content)
|
3519
|
+
d1 = Topology.Dictionary(content)
|
3965
3520
|
d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3966
3521
|
vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3967
3522
|
if storeBREP:
|
3968
3523
|
d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3969
3524
|
d3 = mergeDictionaries2([d1, d2])
|
3970
|
-
|
3525
|
+
vst = Topology.SetDictionary(vst, d3, silent=True)
|
3971
3526
|
else:
|
3972
|
-
|
3527
|
+
vst = Topology.SetDictionary(vst, d1, silent=True)
|
3973
3528
|
vertices.append(vst)
|
3974
3529
|
tempe = Edge.ByStartVertexEndVertex(topology, vst, tolerance=tolerance)
|
3975
3530
|
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3976
|
-
|
3531
|
+
tempe = Topology.SetDictionary(tempe, tempd, silent=True)
|
3977
3532
|
edges.append(tempe)
|
3978
3533
|
|
3979
3534
|
if toOutposts and others:
|
@@ -3998,7 +3553,7 @@ class Graph:
|
|
3998
3553
|
vop = Topology.CenterOfMass(outpost)
|
3999
3554
|
tempe = Edge.ByStartVertexEndVertex(topology, vop, tolerance=tolerance)
|
4000
3555
|
tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
4001
|
-
|
3556
|
+
tempd = Topology.SetDictionary(tempe, tempd, silent=True)
|
4002
3557
|
edges.append(tempe)
|
4003
3558
|
|
4004
3559
|
return [vertices, edges]
|
@@ -4007,7 +3562,15 @@ class Graph:
|
|
4007
3562
|
if not Topology.IsInstance(topology, "Topology"):
|
4008
3563
|
print("Graph.ByTopology - Error: The input topology is not a valid topology. Returning None.")
|
4009
3564
|
return None
|
4010
|
-
|
3565
|
+
c_cellComplexes = Topology.CellComplexes(topology)
|
3566
|
+
c_cells = Topology.Cells(topology)
|
3567
|
+
c_shells = Topology.Shells(topology)
|
3568
|
+
c_faces = Topology.Faces(topology)
|
3569
|
+
c_wires = Topology.Wires(topology)
|
3570
|
+
c_edges = Topology.Edges(topology)
|
3571
|
+
c_vertices = Topology.Vertices(topology)
|
3572
|
+
others = c_cellComplexes+c_cells+c_shells+c_faces+c_wires+c_edges+c_vertices
|
3573
|
+
item = [topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance]
|
4011
3574
|
vertices = []
|
4012
3575
|
edges = []
|
4013
3576
|
if Topology.IsInstance(topology, "CellComplex"):
|
@@ -4032,7 +3595,7 @@ class Graph:
|
|
4032
3595
|
c_wires = Cluster.FreeWires(topology, tolerance=tolerance)
|
4033
3596
|
c_edges = Cluster.FreeEdges(topology, tolerance=tolerance)
|
4034
3597
|
c_vertices = Cluster.FreeVertices(topology, tolerance=tolerance)
|
4035
|
-
others = c_cellComplexes+c_cells+c_shells+c_faces+c_wires+c_edges+c_vertices
|
3598
|
+
others = others+c_cellComplexes+c_cells+c_shells+c_faces+c_wires+c_edges+c_vertices
|
4036
3599
|
parameters = [others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance]
|
4037
3600
|
|
4038
3601
|
for t in c_cellComplexes:
|
@@ -4476,7 +4039,7 @@ class Graph:
|
|
4476
4039
|
if not len(verticesA) == len(verticesB):
|
4477
4040
|
print("Graph.Connect - Error: The input lists verticesA and verticesB have different lengths. Returning None.")
|
4478
4041
|
return None
|
4479
|
-
_ = graph.Connect(verticesA, verticesB, tolerance)
|
4042
|
+
_ = graph.Connect(verticesA, verticesB, tolerance) # Hook to core library
|
4480
4043
|
return graph
|
4481
4044
|
|
4482
4045
|
@staticmethod
|
@@ -4616,7 +4179,7 @@ class Graph:
|
|
4616
4179
|
print("Graph.DegreeSequence - Error: The input graph is not a valid graph. Returning None.")
|
4617
4180
|
return None
|
4618
4181
|
sequence = []
|
4619
|
-
_ = graph.DegreeSequence(sequence)
|
4182
|
+
_ = graph.DegreeSequence(sequence) # Hook to core library
|
4620
4183
|
return sequence
|
4621
4184
|
|
4622
4185
|
@staticmethod
|
@@ -4642,6 +4205,60 @@ class Graph:
|
|
4642
4205
|
return None
|
4643
4206
|
return graph.Density()
|
4644
4207
|
|
4208
|
+
@staticmethod
|
4209
|
+
def Depth(graph, vertex = None, tolerance: float = 0.0001, silent: bool = False):
|
4210
|
+
"""
|
4211
|
+
Computes the maximum depth of the input graph rooted at the input vertex.
|
4212
|
+
|
4213
|
+
Parameters
|
4214
|
+
----------
|
4215
|
+
graph : topologic_core.Graph
|
4216
|
+
The input graph.
|
4217
|
+
vertex : topologic_core.Vertex , optional
|
4218
|
+
The input root vertex. If not set, the first vertex in the graph is set as the root vertex. The default is None.
|
4219
|
+
tolerance : float , optional
|
4220
|
+
The desired tolerance. The default is 0.0001.
|
4221
|
+
silent : bool , optional
|
4222
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
4223
|
+
|
4224
|
+
Returns
|
4225
|
+
-------
|
4226
|
+
int
|
4227
|
+
The calculated maximum depth of the input graph rooted at the input vertex.
|
4228
|
+
|
4229
|
+
"""
|
4230
|
+
def dfs(node, depth, visited):
|
4231
|
+
visited.add(Vertex.Index(node, vertices, tolerance=tolerance))
|
4232
|
+
max_depth = depth
|
4233
|
+
for neighbor in Graph.AdjacentVertices(graph, node):
|
4234
|
+
if Vertex.Index(neighbor, vertices, tolerance=tolerance) not in visited:
|
4235
|
+
max_depth = max(max_depth, dfs(neighbor, depth + 1, visited))
|
4236
|
+
return max_depth
|
4237
|
+
|
4238
|
+
from topologicpy.Vertex import Vertex
|
4239
|
+
from topologicpy.Topology import Topology
|
4240
|
+
|
4241
|
+
if not Topology.IsInstance(graph, "Graph"):
|
4242
|
+
if not silent:
|
4243
|
+
print("Graph.Depth - Error: The input graph parameter is not a valid graph. Returning None.")
|
4244
|
+
return
|
4245
|
+
|
4246
|
+
vertices = Graph.Vertices(graph)
|
4247
|
+
if vertex == None:
|
4248
|
+
v_index = 0
|
4249
|
+
else:
|
4250
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
4251
|
+
if not silent:
|
4252
|
+
print("Graph.Depth - Error: The input rootVertex parameter is not a valid vertex. Returning None.")
|
4253
|
+
return None
|
4254
|
+
v_index = Vertex.Index(vertex, vertices, tolerance=tolerance)
|
4255
|
+
if v_index == None:
|
4256
|
+
if not silent:
|
4257
|
+
print("Graph.Depth - Error: Could not find the input root vertex in the graph's list of vertices. Returning None.")
|
4258
|
+
return None
|
4259
|
+
visited = set()
|
4260
|
+
return dfs(vertex, 1, visited) - 1
|
4261
|
+
|
4645
4262
|
@staticmethod
|
4646
4263
|
def DepthMap(graph, vertices=None, key: str = "depth", type: str = "topological", mantissa: int = 6, tolerance: float = 0.0001):
|
4647
4264
|
"""
|
@@ -4719,7 +4336,33 @@ class Graph:
|
|
4719
4336
|
if not Topology.IsInstance(graph, "Graph"):
|
4720
4337
|
print("Graph.Diameter - Error: The input graph is not a valid graph. Returning None.")
|
4721
4338
|
return None
|
4722
|
-
|
4339
|
+
|
4340
|
+
def dfs(node, visited):
|
4341
|
+
visited.add(node)
|
4342
|
+
max_depth = 0
|
4343
|
+
farthest_node = node
|
4344
|
+
for neighbor in adj_dict[node]:
|
4345
|
+
if neighbor not in visited:
|
4346
|
+
depth, end_node = dfs(neighbor, visited)
|
4347
|
+
if depth + 1 > max_depth:
|
4348
|
+
max_depth = depth + 1
|
4349
|
+
farthest_node = end_node
|
4350
|
+
return max_depth, farthest_node
|
4351
|
+
|
4352
|
+
adj_dict = Graph.AdjacencyDictionary(graph, includeWeights=False)
|
4353
|
+
|
4354
|
+
# Step 1: Pick an arbitrary starting node (first node in the graph)
|
4355
|
+
start_node = next(iter(adj_dict))
|
4356
|
+
|
4357
|
+
# Step 2: Run DFS to find the farthest node from the start_node
|
4358
|
+
visited = set()
|
4359
|
+
_, farthest_node = dfs(start_node, visited)
|
4360
|
+
|
4361
|
+
# Step 3: Run DFS from the farthest node found to get the maximum depth
|
4362
|
+
visited.clear()
|
4363
|
+
diameter, _ = dfs(farthest_node, visited)
|
4364
|
+
|
4365
|
+
return diameter
|
4723
4366
|
|
4724
4367
|
@staticmethod
|
4725
4368
|
def Dictionary(graph):
|
@@ -4742,7 +4385,7 @@ class Graph:
|
|
4742
4385
|
if not Topology.IsInstance(graph, "Graph"):
|
4743
4386
|
print("Graph.Dictionary - Error: the input graph parameter is not a valid graph. Returning None.")
|
4744
4387
|
return None
|
4745
|
-
return graph.GetDictionary()
|
4388
|
+
return graph.GetDictionary() # Hook to core library
|
4746
4389
|
|
4747
4390
|
@staticmethod
|
4748
4391
|
def Distance(graph, vertexA, vertexB, type: str = "topological", mantissa: int = 6, tolerance: float = 0.0001):
|
@@ -4850,7 +4493,7 @@ class Graph:
|
|
4850
4493
|
return None
|
4851
4494
|
if not vertices:
|
4852
4495
|
edges = []
|
4853
|
-
_ = graph.Edges(edges, tolerance)
|
4496
|
+
_ = graph.Edges(edges, tolerance) # Hook to core library
|
4854
4497
|
return edges
|
4855
4498
|
else:
|
4856
4499
|
vertices = [v for v in vertices if Topology.IsInstance(v, "Vertex")]
|
@@ -4858,7 +4501,7 @@ class Graph:
|
|
4858
4501
|
print("Graph.Edges - Error: The input list of vertices does not contain any valid vertices. Returning None.")
|
4859
4502
|
return None
|
4860
4503
|
edges = []
|
4861
|
-
_ = graph.Edges(vertices, tolerance, edges)
|
4504
|
+
_ = graph.Edges(vertices, tolerance, edges) # Hook to core library
|
4862
4505
|
return list(dict.fromkeys(edges)) # remove duplicates
|
4863
4506
|
|
4864
4507
|
@staticmethod
|
@@ -5693,13 +5336,23 @@ class Graph:
|
|
5693
5336
|
dict_color = Dictionary.ValueAtKey(d, vertexColorKey)
|
5694
5337
|
if not dict_color == None:
|
5695
5338
|
vertex_color = dict_color
|
5696
|
-
if
|
5697
|
-
vertex_color
|
5698
|
-
|
5699
|
-
|
5700
|
-
|
5701
|
-
|
5702
|
-
|
5339
|
+
if isinstance(vertex_color, list):
|
5340
|
+
if len(vertex_color) >= 3:
|
5341
|
+
node_dict['color'] = Color.CSSNamedColor(vertex_color)
|
5342
|
+
r, g, b = vertex_color
|
5343
|
+
node_dict['r'] = r
|
5344
|
+
node_dict['g'] = g
|
5345
|
+
node_dict['b'] = b
|
5346
|
+
else:
|
5347
|
+
vertex_color = defaultVertexColor
|
5348
|
+
else:
|
5349
|
+
if not vertex_color in Color.CSSNamedColors():
|
5350
|
+
vertex_color = defaultVertexColor
|
5351
|
+
node_dict['color'] = vertex_color
|
5352
|
+
r, g, b = Color.ByCSSNamedColor(vertex_color)
|
5353
|
+
node_dict['r'] = r
|
5354
|
+
node_dict['g'] = g
|
5355
|
+
node_dict['b'] = b
|
5703
5356
|
|
5704
5357
|
dict_size = None
|
5705
5358
|
if isinstance(vertexSizeKey, str):
|
@@ -6527,9 +6180,53 @@ class Graph:
|
|
6527
6180
|
print("Graph.IsolatedVertices - Error: The input graph is not a valid graph. Returning None.")
|
6528
6181
|
return None
|
6529
6182
|
vertices = []
|
6530
|
-
_ = graph.IsolatedVertices(vertices)
|
6183
|
+
_ = graph.IsolatedVertices(vertices) # Hook to core library
|
6531
6184
|
return vertices
|
6532
|
-
|
6185
|
+
|
6186
|
+
@staticmethod
|
6187
|
+
def IsTree(graph):
|
6188
|
+
"""
|
6189
|
+
Returns True if the input graph has a hierarchical tree-like structure. Returns False otherwise.
|
6190
|
+
|
6191
|
+
Parameters
|
6192
|
+
----------
|
6193
|
+
graph : topologic_core.Graph
|
6194
|
+
The input graph.
|
6195
|
+
|
6196
|
+
Returns
|
6197
|
+
-------
|
6198
|
+
bool
|
6199
|
+
True if the input graph has a hierarchical tree-like structure. False otherwise.
|
6200
|
+
|
6201
|
+
"""
|
6202
|
+
|
6203
|
+
adj_dict = Graph.AdjacencyDictionary(graph, includeWeights=False)
|
6204
|
+
# Helper function for Depth-First Search (DFS)
|
6205
|
+
def dfs(node, parent, visited):
|
6206
|
+
visited.add(node)
|
6207
|
+
for neighbor in adj_dict[node]:
|
6208
|
+
if neighbor not in visited:
|
6209
|
+
if not dfs(neighbor, node, visited):
|
6210
|
+
return False
|
6211
|
+
elif neighbor != parent:
|
6212
|
+
# A cycle is detected
|
6213
|
+
return False
|
6214
|
+
return True
|
6215
|
+
|
6216
|
+
# Initialize visited set
|
6217
|
+
visited = set()
|
6218
|
+
|
6219
|
+
# Start DFS from the first node in the graph
|
6220
|
+
start_node = next(iter(adj_dict)) # Get an arbitrary starting node
|
6221
|
+
if not dfs(start_node, None, visited):
|
6222
|
+
return False
|
6223
|
+
|
6224
|
+
# Check if all nodes were visited (the graph is connected)
|
6225
|
+
if len(visited) != len(adj_dict):
|
6226
|
+
return False
|
6227
|
+
|
6228
|
+
return True
|
6229
|
+
|
6533
6230
|
@staticmethod
|
6534
6231
|
def JSONData(graph,
|
6535
6232
|
verticesKey: str = "vertices",
|
@@ -7884,7 +7581,7 @@ class Graph:
|
|
7884
7581
|
if not Topology.IsInstance(edge, "Edge"):
|
7885
7582
|
print("Graph.RemoveEdge - Error: The input edge is not a valid edge. Returning None.")
|
7886
7583
|
return None
|
7887
|
-
_ = graph.RemoveEdges([edge], tolerance)
|
7584
|
+
_ = graph.RemoveEdges([edge], tolerance) # Hook to core library
|
7888
7585
|
return graph
|
7889
7586
|
|
7890
7587
|
@staticmethod
|
@@ -7916,7 +7613,7 @@ class Graph:
|
|
7916
7613
|
print("Graph.RemoveVertex - Error: The input vertex is not a valid vertex. Returning None.")
|
7917
7614
|
return None
|
7918
7615
|
graphVertex = Graph.NearestVertex(graph, vertex)
|
7919
|
-
_ = graph.RemoveVertices([graphVertex])
|
7616
|
+
_ = graph.RemoveVertices([graphVertex]) # Hook to core library
|
7920
7617
|
return graph
|
7921
7618
|
|
7922
7619
|
@staticmethod
|
@@ -7951,7 +7648,7 @@ class Graph:
|
|
7951
7648
|
if len(dictionary.Keys()) < 1:
|
7952
7649
|
print("Graph.SetDictionary - Warning: the input dictionary parameter is empty. Returning original input.")
|
7953
7650
|
return graph
|
7954
|
-
_ = graph.SetDictionary(dictionary)
|
7651
|
+
_ = graph.SetDictionary(dictionary) # Hook to core library
|
7955
7652
|
return graph
|
7956
7653
|
|
7957
7654
|
@staticmethod
|
@@ -8476,7 +8173,7 @@ class Graph:
|
|
8476
8173
|
vertices = []
|
8477
8174
|
if graph:
|
8478
8175
|
try:
|
8479
|
-
_ = graph.Vertices(vertices)
|
8176
|
+
_ = graph.Vertices(vertices) # Hook to core libraries
|
8480
8177
|
except:
|
8481
8178
|
vertices = []
|
8482
8179
|
if not vertexKey == None:
|