topologicpy 0.7.66__py3-none-any.whl → 0.7.68__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/Cell.py +6 -4
- topologicpy/CellComplex.py +2 -20
- topologicpy/Cluster.py +41 -66
- topologicpy/Edge.py +1 -1
- topologicpy/EnergyModel.py +4 -4
- topologicpy/Face.py +28 -36
- topologicpy/Graph.py +111 -169
- topologicpy/Grid.py +2 -3
- topologicpy/Honeybee.py +6 -9
- topologicpy/Plotly.py +29 -6
- topologicpy/Shell.py +10 -13
- topologicpy/Topology.py +137 -123
- topologicpy/Vertex.py +3 -6
- topologicpy/Wire.py +16 -15
- topologicpy/version.py +1 -1
- {topologicpy-0.7.66.dist-info → topologicpy-0.7.68.dist-info}/METADATA +1 -1
- topologicpy-0.7.68.dist-info/RECORD +36 -0
- topologicpy-0.7.66.dist-info/RECORD +0 -36
- {topologicpy-0.7.66.dist-info → topologicpy-0.7.68.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.66.dist-info → topologicpy-0.7.68.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.66.dist-info → topologicpy-0.7.68.dist-info}/top_level.txt +0 -0
topologicpy/Graph.py
CHANGED
@@ -575,7 +575,7 @@ class Graph:
|
|
575
575
|
return graph
|
576
576
|
graph_vertices = Graph.Vertices(graph)
|
577
577
|
graph_edges = Graph.Edges(graph, graph_vertices, tolerance)
|
578
|
-
vertices =
|
578
|
+
vertices = Topology.Vertices(edge)
|
579
579
|
new_vertices = []
|
580
580
|
for vertex in vertices:
|
581
581
|
graph_vertices, nv = addIfUnique(graph_vertices, vertex, tolerance)
|
@@ -623,7 +623,7 @@ class Graph:
|
|
623
623
|
if not silent:
|
624
624
|
print("Graph.AddVertex - Error: The input vertex is not a valid vertex. Returning the input graph.")
|
625
625
|
return graph
|
626
|
-
_ = graph.AddVertices([vertex], tolerance) # Hook to
|
626
|
+
_ = graph.AddVertices([vertex], tolerance) # Hook to Core
|
627
627
|
return graph
|
628
628
|
|
629
629
|
@staticmethod
|
@@ -663,7 +663,7 @@ class Graph:
|
|
663
663
|
if not silent:
|
664
664
|
print("Graph.AddVertices - Error: Could not find any valid vertices in the input list of vertices. Returning None.")
|
665
665
|
return None
|
666
|
-
_ = graph.AddVertices(vertices, tolerance) # Hook to
|
666
|
+
_ = graph.AddVertices(vertices, tolerance) # Hook to Core
|
667
667
|
return graph
|
668
668
|
|
669
669
|
@staticmethod
|
@@ -697,7 +697,7 @@ class Graph:
|
|
697
697
|
print("Graph.AdjacentVertices - Error: The input vertex is not a valid vertex. Returning None.")
|
698
698
|
return None
|
699
699
|
vertices = []
|
700
|
-
_ = graph.AdjacentVertices(vertex, vertices) # Hook to
|
700
|
+
_ = graph.AdjacentVertices(vertex, vertices) # Hook to Core
|
701
701
|
return list(vertices)
|
702
702
|
|
703
703
|
@staticmethod
|
@@ -739,7 +739,7 @@ class Graph:
|
|
739
739
|
print("Graph.AllPaths - Error: The input vertexB is not a valid vertex. Returning None.")
|
740
740
|
return None
|
741
741
|
paths = []
|
742
|
-
_ = graph.AllPaths(vertexA, vertexB, True, timeLimit, paths) # Hook to
|
742
|
+
_ = graph.AllPaths(vertexA, vertexB, True, timeLimit, paths) # Hook to Core
|
743
743
|
return paths
|
744
744
|
|
745
745
|
@staticmethod
|
@@ -1631,7 +1631,7 @@ class Graph:
|
|
1631
1631
|
edgeValidateMaskHeader="val_mask", edgeTestMaskHeader="test_mask", edgeFeaturesHeader="feat", edgeFeaturesKeys=[],
|
1632
1632
|
nodeIDHeader="node_id", nodeLabelHeader="label", nodeTrainMaskHeader="train_mask",
|
1633
1633
|
nodeValidateMaskHeader="val_mask", nodeTestMaskHeader="test_mask", nodeFeaturesHeader="feat", nodeXHeader="X", nodeYHeader="Y", nodeZHeader="Z",
|
1634
|
-
nodeFeaturesKeys=[], tolerance=0.0001):
|
1634
|
+
nodeFeaturesKeys=[], tolerance=0.0001, silent=False):
|
1635
1635
|
"""
|
1636
1636
|
Returns graphs according to the input folder path. This method assumes the CSV files follow DGL's schema.
|
1637
1637
|
|
@@ -1681,6 +1681,8 @@ class Graph:
|
|
1681
1681
|
The column header string used to specify the Z coordinate of nodes. The default is "Z".
|
1682
1682
|
tolerance : float , optional
|
1683
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.
|
1684
1686
|
|
1685
1687
|
Returns
|
1686
1688
|
-------
|
@@ -1717,15 +1719,18 @@ class Graph:
|
|
1717
1719
|
return graphs_path, edges_path, nodes_path
|
1718
1720
|
|
1719
1721
|
if not exists(path):
|
1720
|
-
|
1722
|
+
if not silent:
|
1723
|
+
print("Graph.ByCSVPath - Error: the input path parameter does not exists. Returning None.")
|
1721
1724
|
return None
|
1722
1725
|
if not isdir(path):
|
1723
|
-
|
1726
|
+
if not silent:
|
1727
|
+
print("Graph.ByCSVPath - Error: the input path parameter is not a folder. Returning None.")
|
1724
1728
|
return None
|
1725
1729
|
|
1726
1730
|
yaml_files = find_yaml_files(path)
|
1727
1731
|
if len(yaml_files) < 1:
|
1728
|
-
|
1732
|
+
if not silent:
|
1733
|
+
print("Graph.ByCSVPath - Error: the input path parameter does not contain any valid YAML files. Returning None.")
|
1729
1734
|
return None
|
1730
1735
|
yaml_file = yaml_files[0]
|
1731
1736
|
yaml_file_path = os.path.join(path, yaml_file)
|
@@ -1734,7 +1739,8 @@ class Graph:
|
|
1734
1739
|
if not graphs_path == None:
|
1735
1740
|
graphs_path = os.path.join(path, graphs_path)
|
1736
1741
|
if graphs_path == None:
|
1737
|
-
|
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.")
|
1738
1744
|
graphs_df = pd.DataFrame()
|
1739
1745
|
graph_ids=[0]
|
1740
1746
|
graph_labels=[0]
|
@@ -1748,7 +1754,8 @@ class Graph:
|
|
1748
1754
|
if not edges_path == None:
|
1749
1755
|
edges_path = os.path.join(path, edges_path)
|
1750
1756
|
if not exists(edges_path):
|
1751
|
-
|
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.")
|
1752
1759
|
return None
|
1753
1760
|
edges_path = os.path.join(path, edges_path)
|
1754
1761
|
edges_df = pd.read_csv(edges_path)
|
@@ -1756,7 +1763,8 @@ class Graph:
|
|
1756
1763
|
if not nodes_path == None:
|
1757
1764
|
nodes_path = os.path.join(path, nodes_path)
|
1758
1765
|
if not exists(nodes_path):
|
1759
|
-
|
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.")
|
1760
1768
|
return None
|
1761
1769
|
nodes_df = pd.read_csv(nodes_path)
|
1762
1770
|
# Group nodes and nodes by their 'graph_id'
|
@@ -1830,10 +1838,12 @@ class Graph:
|
|
1830
1838
|
if Topology.IsInstance(d, "Dictionary"):
|
1831
1839
|
v = Topology.SetDictionary(v, d)
|
1832
1840
|
else:
|
1833
|
-
|
1841
|
+
if not silent:
|
1842
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a dictionary to the created vertex.")
|
1834
1843
|
vertices.append(v)
|
1835
1844
|
else:
|
1836
|
-
|
1845
|
+
if not silent:
|
1846
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a vertex to the list of vertices.")
|
1837
1847
|
vertices_ds.append(vertices)
|
1838
1848
|
edges_ds = [] # A list to hold the vertices data structures until we can build the actual graphs
|
1839
1849
|
# Access specific columns within the grouped DataFrame
|
@@ -1870,21 +1880,25 @@ class Graph:
|
|
1870
1880
|
try:
|
1871
1881
|
edge = Edge.ByVertices([vertices[src_id], vertices[dst_id]], tolerance=tolerance)
|
1872
1882
|
except:
|
1873
|
-
|
1883
|
+
if not silent:
|
1884
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a edge to the list of edges.")
|
1874
1885
|
edge = None
|
1875
1886
|
if Topology.IsInstance(edge, "Edge"):
|
1876
1887
|
d = Dictionary.ByKeysValues(edge_keys, values)
|
1877
1888
|
if Topology.IsInstance(d, "Dictionary"):
|
1878
1889
|
edge = Topology.SetDictionary(edge, d)
|
1879
1890
|
else:
|
1880
|
-
|
1891
|
+
if not silent:
|
1892
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a dictionary to the created edge.")
|
1881
1893
|
edges.append(edge)
|
1882
1894
|
else:
|
1883
|
-
|
1895
|
+
if not silent:
|
1896
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add an edge to the list of edges.")
|
1884
1897
|
else:
|
1885
1898
|
duplicate_edges += 1
|
1886
1899
|
if duplicate_edges > 0:
|
1887
|
-
|
1900
|
+
if not silent:
|
1901
|
+
print("Graph.ByCSVPath - Warning: Found", duplicate_edges, "duplicate edges in graph id:", graph_id)
|
1888
1902
|
edges_ds.append(edges)
|
1889
1903
|
|
1890
1904
|
# Build the graphs
|
@@ -1905,16 +1919,19 @@ class Graph:
|
|
1905
1919
|
l1 = len(graph_keys)
|
1906
1920
|
l2 = len(values)
|
1907
1921
|
if not l1 == l2:
|
1908
|
-
|
1922
|
+
if not silent:
|
1923
|
+
print("Graph.ByCSVPath - Error: The length of the keys and values lists do not match. Returning None.")
|
1909
1924
|
return None
|
1910
1925
|
d = Dictionary.ByKeysValues(graph_keys, values)
|
1911
1926
|
if Topology.IsInstance(d, "Dictionary"):
|
1912
1927
|
g = Graph.SetDictionary(g, d)
|
1913
1928
|
else:
|
1914
|
-
|
1929
|
+
if not silent:
|
1930
|
+
print("Graph.ByCSVPath - Warning: Failed to create and add a dictionary to the created graph.")
|
1915
1931
|
graphs.append(g)
|
1916
1932
|
else:
|
1917
|
-
|
1933
|
+
if not silent:
|
1934
|
+
print("Graph.ByCSVPath - Error: Failed to create and add a graph to the list of graphs.")
|
1918
1935
|
return {"graphs": graphs, "labels": graph_labels, "features": graph_features}
|
1919
1936
|
|
1920
1937
|
@staticmethod
|
@@ -3485,142 +3502,6 @@ class Graph:
|
|
3485
3502
|
return [graph_vertices, graph_edges]
|
3486
3503
|
|
3487
3504
|
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3492
|
-
# def processEdge(item):
|
3493
|
-
# topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3494
|
-
# vertices = []
|
3495
|
-
# edges = []
|
3496
|
-
|
3497
|
-
# if useInternalVertex == True:
|
3498
|
-
# try:
|
3499
|
-
# vEdge = Edge.VertexByParameter(topology, 0.5)
|
3500
|
-
# except:
|
3501
|
-
# vEdge = topology.CenterOfMass()
|
3502
|
-
# else:
|
3503
|
-
# vEdge = topology.CenterOfMass()
|
3504
|
-
|
3505
|
-
# d1 = vEdge.GetDictionary()
|
3506
|
-
# d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 0) # main topology
|
3507
|
-
# if storeBREP:
|
3508
|
-
# d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(topology), Topology.Type(topology), Topology.TypeAsString(topology)])
|
3509
|
-
# d3 = mergeDictionaries2([d1, d2])
|
3510
|
-
# _ = vEdge.SetDictionary(d3)
|
3511
|
-
# else:
|
3512
|
-
# _ = vEdge.SetDictionary(topology.GetDictionary())
|
3513
|
-
|
3514
|
-
# vertices.append(vEdge)
|
3515
|
-
|
3516
|
-
# if toOutposts and others:
|
3517
|
-
# d = Topology.Dictionary(topology)
|
3518
|
-
# if not d == None:
|
3519
|
-
# keys = Dictionary.Keys(d)
|
3520
|
-
# else:
|
3521
|
-
# keys = []
|
3522
|
-
# k = None
|
3523
|
-
# for key in keys:
|
3524
|
-
# if key.lower() == outpostsKey.lower():
|
3525
|
-
# k = key
|
3526
|
-
# if k:
|
3527
|
-
# ids = Dictionary.ValueAtKey(d, k)
|
3528
|
-
# outposts = outpostsByID(others, ids, idKey)
|
3529
|
-
# else:
|
3530
|
-
# outposts = []
|
3531
|
-
# for outpost in outposts:
|
3532
|
-
# if useInternalVertex == True:
|
3533
|
-
# vop = Topology.InternalVertex(outpost, tolerance)
|
3534
|
-
# else:
|
3535
|
-
# vop = Topology.CenterOfMass(outpost)
|
3536
|
-
# tempe = Edge.ByStartVertexEndVertex(vEdge, vop, tolerance=tolerance)
|
3537
|
-
# tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Outposts", 6])
|
3538
|
-
# _ = tempe.SetDictionary(tempd)
|
3539
|
-
# edges.append(tempe)
|
3540
|
-
|
3541
|
-
# if (toExteriorTopologies == True) or (toExteriorApertures == True) or (toContents == True):
|
3542
|
-
# eVertices = []
|
3543
|
-
# _ = topology.Vertices(None, eVertices)
|
3544
|
-
# exteriorTopologies = []
|
3545
|
-
# exteriorApertures = []
|
3546
|
-
# for aVertex in eVertices:
|
3547
|
-
# exteriorTopologies.append(aVertex)
|
3548
|
-
# apertures = Topology.Apertures(aVertex)
|
3549
|
-
# for anAperture in apertures:
|
3550
|
-
# exteriorApertures.append(anAperture)
|
3551
|
-
# if toExteriorTopologies:
|
3552
|
-
# for exteriorTopology in exteriorTopologies:
|
3553
|
-
# if useInternalVertex == True:
|
3554
|
-
# vst = Topology.InternalVertex(exteriorTopology, tolerance)
|
3555
|
-
# else:
|
3556
|
-
# vst = exteriorTopology.CenterOfMass()
|
3557
|
-
# d1 = exteriorTopology.GetDictionary()
|
3558
|
-
# d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 3) # exterior topology
|
3559
|
-
# if storeBREP:
|
3560
|
-
# d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exteriorTopology), Topology.Type(exteriorTopology), Topology.TypeAsString(exteriorTopology)])
|
3561
|
-
# d3 = mergeDictionaries2([d1, d2])
|
3562
|
-
# _ = vst.SetDictionary(d3)
|
3563
|
-
# else:
|
3564
|
-
# _ = vst.SetDictionary(d1)
|
3565
|
-
# vertices.append(vst)
|
3566
|
-
# tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3567
|
-
# tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Topologies", 3])
|
3568
|
-
# _ = tempe.SetDictionary(tempd)
|
3569
|
-
# edges.append(tempe)
|
3570
|
-
# if toContents:
|
3571
|
-
# contents = []
|
3572
|
-
# _ = vst.Contents(contents)
|
3573
|
-
# for content in contents:
|
3574
|
-
# if Topology.IsInstance(content, "Aperture"):
|
3575
|
-
# content = Aperture.Topology(content)
|
3576
|
-
# if useInternalVertex == True:
|
3577
|
-
# vst2 = Topology.InternalVertex(content, tolerance)
|
3578
|
-
# else:
|
3579
|
-
# vst2 = content.CenterOfMass()
|
3580
|
-
# vst2 = Vertex.ByCoordinates(Vertex.X(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst2, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst2, mantissa=mantissa)+(tolerance*100))
|
3581
|
-
# d1 = content.GetDictionary()
|
3582
|
-
# d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 5) # content
|
3583
|
-
# if storeBREP:
|
3584
|
-
# d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(content), Topology.Type(content), Topology.TypeAsString(content)])
|
3585
|
-
# d3 = mergeDictionaries2([d1, d2])
|
3586
|
-
# _ = vst2.SetDictionary(d3)
|
3587
|
-
# else:
|
3588
|
-
# _ = vst2.SetDictionary(d1)
|
3589
|
-
# vertices.append(vst2)
|
3590
|
-
# tempe = Edge.ByStartVertexEndVertex(vst, vst2, tolerance=tolerance)
|
3591
|
-
# tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Contents", 5])
|
3592
|
-
# _ = tempe.SetDictionary(tempd)
|
3593
|
-
# edges.append(tempe)
|
3594
|
-
# if toExteriorApertures:
|
3595
|
-
# for exTop in exteriorApertures:
|
3596
|
-
# if useInternalVertex == True:
|
3597
|
-
# vst = Topology.InternalVertex(exTop, tolerance)
|
3598
|
-
# else:
|
3599
|
-
# vst = exTop.CenterOfMass()
|
3600
|
-
# d1 = exTop.GetDictionary()
|
3601
|
-
# d1 = Dictionary.SetValueAtKey(d1, vertexCategoryKey, 4) # exterior aperture
|
3602
|
-
# vst = Vertex.ByCoordinates(Vertex.X(vst, mantissa=mantissa)+(tolerance*100), Vertex.Y(vst, mantissa=mantissa)+(tolerance*100), Vertex.Z(vst, mantissa=mantissa)+(tolerance*100))
|
3603
|
-
# if storeBREP:
|
3604
|
-
# d2 = Dictionary.ByKeysValues(["brep", "brepType", "brepTypeString"], [Topology.BREPString(exTop), Topology.Type(exTop), Topology.TypeAsString(exTop)])
|
3605
|
-
# d3 = mergeDictionaries2([d1, d2])
|
3606
|
-
# _ = vst.SetDictionary(d3)
|
3607
|
-
# else:
|
3608
|
-
# _ = vst.SetDictionary(d1)
|
3609
|
-
# _ = vst.SetDictionary(exTop.GetDictionary())
|
3610
|
-
# vertices.append(vst)
|
3611
|
-
# tempe = Edge.ByStartVertexEndVertex(vEdge, vst, tolerance=tolerance)
|
3612
|
-
# tempd = Dictionary.ByKeysValues(["relationship", edgeCategoryKey],["To_Exterior_Apertures", 4])
|
3613
|
-
# _ = tempe.SetDictionary(tempd)
|
3614
|
-
# edges.append(tempe)
|
3615
|
-
|
3616
|
-
# return [vertices, edges]
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
3505
|
def processVertex(item):
|
3625
3506
|
topology, others, outpostsKey, idKey, direct, directApertures, viaSharedTopologies, viaSharedApertures, toExteriorTopologies, toExteriorApertures, toContents, toOutposts, useInternalVertex, storeBREP, tolerance = item
|
3626
3507
|
vertices = [topology]
|
@@ -4158,7 +4039,7 @@ class Graph:
|
|
4158
4039
|
if not len(verticesA) == len(verticesB):
|
4159
4040
|
print("Graph.Connect - Error: The input lists verticesA and verticesB have different lengths. Returning None.")
|
4160
4041
|
return None
|
4161
|
-
_ = graph.Connect(verticesA, verticesB, tolerance) # Hook to
|
4042
|
+
_ = graph.Connect(verticesA, verticesB, tolerance) # Hook to Core
|
4162
4043
|
return graph
|
4163
4044
|
|
4164
4045
|
@staticmethod
|
@@ -4298,7 +4179,7 @@ class Graph:
|
|
4298
4179
|
print("Graph.DegreeSequence - Error: The input graph is not a valid graph. Returning None.")
|
4299
4180
|
return None
|
4300
4181
|
sequence = []
|
4301
|
-
_ = graph.DegreeSequence(sequence) # Hook to
|
4182
|
+
_ = graph.DegreeSequence(sequence) # Hook to Core
|
4302
4183
|
return sequence
|
4303
4184
|
|
4304
4185
|
@staticmethod
|
@@ -4612,7 +4493,7 @@ class Graph:
|
|
4612
4493
|
return None
|
4613
4494
|
if not vertices:
|
4614
4495
|
edges = []
|
4615
|
-
_ = graph.Edges(edges, tolerance) # Hook to
|
4496
|
+
_ = graph.Edges(edges, tolerance) # Hook to Core
|
4616
4497
|
return edges
|
4617
4498
|
else:
|
4618
4499
|
vertices = [v for v in vertices if Topology.IsInstance(v, "Vertex")]
|
@@ -4620,7 +4501,7 @@ class Graph:
|
|
4620
4501
|
print("Graph.Edges - Error: The input list of vertices does not contain any valid vertices. Returning None.")
|
4621
4502
|
return None
|
4622
4503
|
edges = []
|
4623
|
-
_ = graph.Edges(vertices, tolerance, edges) # Hook to
|
4504
|
+
_ = graph.Edges(vertices, tolerance, edges) # Hook to Core
|
4624
4505
|
return list(dict.fromkeys(edges)) # remove duplicates
|
4625
4506
|
|
4626
4507
|
@staticmethod
|
@@ -5645,7 +5526,7 @@ class Graph:
|
|
5645
5526
|
return False
|
5646
5527
|
|
5647
5528
|
@staticmethod
|
5648
|
-
def Flatten(graph, layout="spring", k=0.8, seed=None, iterations=50, rootVertex=None, tolerance=0.0001):
|
5529
|
+
def Flatten(graph, layout="spring", k=0.8, seed=None, iterations=50, rootVertex=None, radius=0.5, tolerance=0.0001):
|
5649
5530
|
"""
|
5650
5531
|
Flattens the input graph.
|
5651
5532
|
|
@@ -5655,8 +5536,9 @@ class Graph:
|
|
5655
5536
|
The input graph.
|
5656
5537
|
layout : str , optional
|
5657
5538
|
The desired mode for flattening. If set to 'spring', the algorithm uses a simplified version of the Fruchterman-Reingold force-directed algorithm to flatten and distribute the vertices.
|
5658
|
-
If set to 'radial', the nodes will be distributed along
|
5659
|
-
If set to 'tree', the nodes will be distributed using the Reingold-Tillford layout.
|
5539
|
+
If set to 'radial', the nodes will be distributed along concentric circles.
|
5540
|
+
If set to 'tree', the nodes will be distributed using the Reingold-Tillford layout.
|
5541
|
+
If set to 'circle', the nodes will be distributed on the cirumference of a circle. The default is 'spring'.
|
5660
5542
|
k : float, optional
|
5661
5543
|
The desired spring constant to use for the attractive and repulsive forces. The default is 0.8.
|
5662
5544
|
seed : int , optional
|
@@ -5665,6 +5547,8 @@ class Graph:
|
|
5665
5547
|
The desired maximum number of iterations to solve the forces in the 'spring' mode. The default is 50.
|
5666
5548
|
rootVertex : topologic_core.Vertex , optional
|
5667
5549
|
The desired vertex to use as the root of the tree and radial layouts.
|
5550
|
+
radius : float, optional
|
5551
|
+
The desired radius for the circle layout option. The default is 0.5.
|
5668
5552
|
tolerance : float , optional
|
5669
5553
|
The desired tolerance. The default is 0.0001.
|
5670
5554
|
|
@@ -5831,6 +5715,60 @@ class Graph:
|
|
5831
5715
|
old_roots = new_roots
|
5832
5716
|
return root, num_nodes
|
5833
5717
|
|
5718
|
+
|
5719
|
+
def circle_layout(graph, radius=0.5):
|
5720
|
+
from topologicpy.Vertex import Vertex
|
5721
|
+
from topologicpy.Vector import Vector
|
5722
|
+
from topologicpy.Wire import Wire
|
5723
|
+
from topologicpy.Graph import Graph
|
5724
|
+
from topologicpy.Edge import Edge
|
5725
|
+
|
5726
|
+
vertices = Graph.Vertices(graph)
|
5727
|
+
edges = Graph.Edges(graph)
|
5728
|
+
edge_dict = {}
|
5729
|
+
|
5730
|
+
for i, edge in enumerate(edges):
|
5731
|
+
sv = Edge.StartVertex(edge)
|
5732
|
+
ev = Edge.EndVertex(edge)
|
5733
|
+
si = Vertex.Index(sv, vertices)
|
5734
|
+
ei = Vertex.Index(ev, vertices)
|
5735
|
+
edge_dict[str(si)+"_"+str(ei)] = i
|
5736
|
+
edge_dict[str(ei)+"_"+str(si)] = i
|
5737
|
+
|
5738
|
+
n = len(vertices)
|
5739
|
+
c = Wire.Circle(radius=radius, sides=n)
|
5740
|
+
c_vertices = Topology.Vertices(c)
|
5741
|
+
|
5742
|
+
for i, c_v in enumerate(c_vertices):
|
5743
|
+
d = Topology.Dictionary(vertices[i])
|
5744
|
+
c_v = Topology.SetDictionary(c_v, d)
|
5745
|
+
adj_dict = Graph.AdjacencyDictionary(graph)
|
5746
|
+
keys = adj_dict.keys()
|
5747
|
+
c_edges = []
|
5748
|
+
used = [[0] * n for _ in range(n)]
|
5749
|
+
for key in keys:
|
5750
|
+
x = int(key)
|
5751
|
+
adj_vertices = [int(v) for v in adj_dict[key]]
|
5752
|
+
for y in adj_vertices:
|
5753
|
+
if used[x][y] == 0:
|
5754
|
+
v1 = Vector.ByCoordinates(Vertex.X(c_vertices[x]), Vertex.Y(c_vertices[x]), Vertex.Z(c_vertices[x]))
|
5755
|
+
v2 = Vector.ByCoordinates(Vertex.X(c_vertices[y]), Vertex.Y(c_vertices[y]), Vertex.Z(c_vertices[y]))
|
5756
|
+
ang1 = Vector.CompassAngle(v1, [0,1,0])
|
5757
|
+
ang2 = Vector.CompassAngle(v2, [0,1,0])
|
5758
|
+
if ang2-ang1 < 180:
|
5759
|
+
e = Edge.ByVertices(c_vertices[x], c_vertices[y])
|
5760
|
+
else:
|
5761
|
+
e = Edge.ByVertices(c_vertices[y], c_vertices[x])
|
5762
|
+
|
5763
|
+
orig_edge_index = edge_dict[str(x)+"_"+str(y)]
|
5764
|
+
d = Topology.Dictionary(edges[orig_edge_index])
|
5765
|
+
e = Topology.SetDictionary(e, d)
|
5766
|
+
c_edges.append(e)
|
5767
|
+
used[x][y] = 1
|
5768
|
+
used[y][x] = 1
|
5769
|
+
new_g = Graph.ByVerticesEdges(c_vertices, c_edges)
|
5770
|
+
return new_g
|
5771
|
+
|
5834
5772
|
def spring_layout(edge_list, iterations=500, k=None, seed=None):
|
5835
5773
|
# Compute the layout of a graph using the Fruchterman-Reingold algorithm
|
5836
5774
|
# with a force-directed layout approach.
|
@@ -5969,6 +5907,10 @@ class Graph:
|
|
5969
5907
|
if not Topology.IsInstance(graph, "Graph"):
|
5970
5908
|
print("Graph.Flatten - Error: The input graph is not a valid topologic graph. Returning None.")
|
5971
5909
|
return None
|
5910
|
+
|
5911
|
+
if 'circ' in layout.lower():
|
5912
|
+
new_graph = circle_layout(graph, radius=radius)
|
5913
|
+
return new_graph
|
5972
5914
|
d = Graph.MeshData(graph)
|
5973
5915
|
vertices = d['vertices']
|
5974
5916
|
edges = d['edges']
|
@@ -6299,7 +6241,7 @@ class Graph:
|
|
6299
6241
|
print("Graph.IsolatedVertices - Error: The input graph is not a valid graph. Returning None.")
|
6300
6242
|
return None
|
6301
6243
|
vertices = []
|
6302
|
-
_ = graph.IsolatedVertices(vertices) # Hook to
|
6244
|
+
_ = graph.IsolatedVertices(vertices) # Hook to Core
|
6303
6245
|
return vertices
|
6304
6246
|
|
6305
6247
|
@staticmethod
|
@@ -7700,7 +7642,7 @@ class Graph:
|
|
7700
7642
|
if not Topology.IsInstance(edge, "Edge"):
|
7701
7643
|
print("Graph.RemoveEdge - Error: The input edge is not a valid edge. Returning None.")
|
7702
7644
|
return None
|
7703
|
-
_ = graph.RemoveEdges([edge], tolerance) # Hook to
|
7645
|
+
_ = graph.RemoveEdges([edge], tolerance) # Hook to Core
|
7704
7646
|
return graph
|
7705
7647
|
|
7706
7648
|
@staticmethod
|
@@ -7732,7 +7674,7 @@ class Graph:
|
|
7732
7674
|
print("Graph.RemoveVertex - Error: The input vertex is not a valid vertex. Returning None.")
|
7733
7675
|
return None
|
7734
7676
|
graphVertex = Graph.NearestVertex(graph, vertex)
|
7735
|
-
_ = graph.RemoveVertices([graphVertex]) # Hook to
|
7677
|
+
_ = graph.RemoveVertices([graphVertex]) # Hook to Core
|
7736
7678
|
return graph
|
7737
7679
|
|
7738
7680
|
@staticmethod
|
@@ -7767,7 +7709,7 @@ class Graph:
|
|
7767
7709
|
if len(dictionary.Keys()) < 1:
|
7768
7710
|
print("Graph.SetDictionary - Warning: the input dictionary parameter is empty. Returning original input.")
|
7769
7711
|
return graph
|
7770
|
-
_ = graph.SetDictionary(dictionary) # Hook to
|
7712
|
+
_ = graph.SetDictionary(dictionary) # Hook to Core
|
7771
7713
|
return graph
|
7772
7714
|
|
7773
7715
|
@staticmethod
|
@@ -8292,7 +8234,7 @@ class Graph:
|
|
8292
8234
|
vertices = []
|
8293
8235
|
if graph:
|
8294
8236
|
try:
|
8295
|
-
_ = graph.Vertices(vertices) # Hook to
|
8237
|
+
_ = graph.Vertices(vertices) # Hook to Core
|
8296
8238
|
except:
|
8297
8239
|
vertices = []
|
8298
8240
|
if not vertexKey == None:
|
topologicpy/Grid.py
CHANGED
@@ -202,11 +202,10 @@ class Grid():
|
|
202
202
|
e.SetDictionary(d)
|
203
203
|
gridEdges.append(e)
|
204
204
|
elif Topology.Type(e) > Topology.TypeID("Edge"):
|
205
|
-
tempEdges =
|
206
|
-
_ = e.Edges(None, tempEdges)
|
205
|
+
tempEdges = Topology.Edges(e)
|
207
206
|
for tempEdge in tempEdges:
|
208
207
|
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
209
|
-
tempEdge.SetDictionary(d)
|
208
|
+
tempEdge = Topology.SetDictionary(tempEdge, d)
|
210
209
|
gridEdges.append(tempEdge)
|
211
210
|
grid = None
|
212
211
|
if len(gridEdges) > 0:
|
topologicpy/Honeybee.py
CHANGED
@@ -254,8 +254,7 @@ class Honeybee:
|
|
254
254
|
from topologicpy.Dictionary import Dictionary
|
255
255
|
|
256
256
|
def cellFloor(cell):
|
257
|
-
faces =
|
258
|
-
_ = cell.Faces(None, faces)
|
257
|
+
faces = Topology.Faces(cell)
|
259
258
|
c = [x.CenterOfMass().Z() for x in faces]
|
260
259
|
return round(min(c),2)
|
261
260
|
|
@@ -293,8 +292,7 @@ class Honeybee:
|
|
293
292
|
if not Topology.IsInstance(tpBuilding, "Topology"):
|
294
293
|
return None
|
295
294
|
rooms = []
|
296
|
-
tpCells =
|
297
|
-
_ = tpBuilding.Cells(None, tpCells)
|
295
|
+
tpCells = Topology.Cells(tpBuilding)
|
298
296
|
# Sort cells by Z Levels
|
299
297
|
tpCells.sort(key=lambda c: cellFloor(c), reverse=False)
|
300
298
|
fl = floorLevels(tpCells, 2)
|
@@ -351,14 +349,13 @@ class Honeybee:
|
|
351
349
|
constr_set = constr_set_lib.construction_set_by_identifier("Default Generic Construction Set")
|
352
350
|
spaceNames.append(tpCellName)
|
353
351
|
|
354
|
-
tpCellFaces =
|
355
|
-
_ = tpCell.Faces(None, tpCellFaces)
|
352
|
+
tpCellFaces = Topology.Faces(tpCell)
|
356
353
|
if tpCellFaces:
|
357
354
|
hbRoomFaces = []
|
358
355
|
for tpFaceNumber, tpCellFace in enumerate(tpCellFaces):
|
359
356
|
tpCellFaceNormal = Face.Normal(tpCellFace, mantissa=mantissa)
|
360
357
|
hbRoomFacePoints = []
|
361
|
-
tpFaceVertices =
|
358
|
+
tpFaceVertices = Topology.Vertices(Face.ExternalBoundary(tpCellFace))
|
362
359
|
for tpVertex in tpFaceVertices:
|
363
360
|
hbRoomFacePoints.append(Point3D(Vertex.X(tpVertex, mantissa=mantissa), Vertex.Y(tpVertex, mantissa=mantissa), Vertex.Z(tpVertex, mantissa=mantissa)))
|
364
361
|
hbRoomFace = HBFace(tpCellName+'_Face_'+str(tpFaceNumber+1), Face3D(hbRoomFacePoints))
|
@@ -372,7 +369,7 @@ class Honeybee:
|
|
372
369
|
tpFaceApertureType = Dictionary.ValueAtKey(tpFaceApertureDictionary,apertureKeyName)
|
373
370
|
hbFaceAperturePoints = []
|
374
371
|
tpFaceApertureVertices = []
|
375
|
-
tpFaceApertureVertices =
|
372
|
+
tpFaceApertureVertices = Topology.Vertices(Face.ExternalBoundary(apertureTopology))
|
376
373
|
for tpFaceApertureVertex in tpFaceApertureVertices:
|
377
374
|
hbFaceAperturePoints.append(Point3D(Vertex.X(tpFaceApertureVertex, mantissa=mantissa), Vertex.Y(tpFaceApertureVertex, mantissa=mantissa), Vertex.Z(tpFaceApertureVertex, mantissa=mantissa)))
|
378
375
|
if(tpFaceApertureType):
|
@@ -420,7 +417,7 @@ class Honeybee:
|
|
420
417
|
tpShadingFaces = Topology.SubTopologies(tpShadingFacesCluster, subTopologyType="face")
|
421
418
|
for faceIndex, tpShadingFace in enumerate(tpShadingFaces):
|
422
419
|
faceVertices = []
|
423
|
-
faceVertices =
|
420
|
+
faceVertices = Topology.Vertices(Face.ExternalBoundary(tpShadingFace))
|
424
421
|
facePoints = []
|
425
422
|
for aVertex in faceVertices:
|
426
423
|
facePoints.append(Point3D(Vertex.X(aVertex, mantissa=mantissa), Vertex.Y(aVertex, mantissa=mantissa), Vertex.Z(aVertex, mantissa=mantissa)))
|