topologicpy 0.7.67__py3-none-any.whl → 0.7.69__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 +82 -18
- topologicpy/Grid.py +2 -3
- topologicpy/Honeybee.py +6 -9
- topologicpy/Plotly.py +31 -6
- topologicpy/Shell.py +10 -13
- topologicpy/Topology.py +103 -107
- topologicpy/Vertex.py +3 -6
- topologicpy/Wire.py +16 -15
- topologicpy/version.py +1 -1
- {topologicpy-0.7.67.dist-info → topologicpy-0.7.69.dist-info}/METADATA +1 -1
- topologicpy-0.7.69.dist-info/RECORD +36 -0
- topologicpy-0.7.67.dist-info/RECORD +0 -36
- {topologicpy-0.7.67.dist-info → topologicpy-0.7.69.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.67.dist-info → topologicpy-0.7.69.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.67.dist-info → topologicpy-0.7.69.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
|
@@ -4039,7 +4039,7 @@ class Graph:
|
|
4039
4039
|
if not len(verticesA) == len(verticesB):
|
4040
4040
|
print("Graph.Connect - Error: The input lists verticesA and verticesB have different lengths. Returning None.")
|
4041
4041
|
return None
|
4042
|
-
_ = graph.Connect(verticesA, verticesB, tolerance) # Hook to
|
4042
|
+
_ = graph.Connect(verticesA, verticesB, tolerance) # Hook to Core
|
4043
4043
|
return graph
|
4044
4044
|
|
4045
4045
|
@staticmethod
|
@@ -4179,7 +4179,7 @@ class Graph:
|
|
4179
4179
|
print("Graph.DegreeSequence - Error: The input graph is not a valid graph. Returning None.")
|
4180
4180
|
return None
|
4181
4181
|
sequence = []
|
4182
|
-
_ = graph.DegreeSequence(sequence) # Hook to
|
4182
|
+
_ = graph.DegreeSequence(sequence) # Hook to Core
|
4183
4183
|
return sequence
|
4184
4184
|
|
4185
4185
|
@staticmethod
|
@@ -4493,7 +4493,7 @@ class Graph:
|
|
4493
4493
|
return None
|
4494
4494
|
if not vertices:
|
4495
4495
|
edges = []
|
4496
|
-
_ = graph.Edges(edges, tolerance) # Hook to
|
4496
|
+
_ = graph.Edges(edges, tolerance) # Hook to Core
|
4497
4497
|
return edges
|
4498
4498
|
else:
|
4499
4499
|
vertices = [v for v in vertices if Topology.IsInstance(v, "Vertex")]
|
@@ -4501,7 +4501,7 @@ class Graph:
|
|
4501
4501
|
print("Graph.Edges - Error: The input list of vertices does not contain any valid vertices. Returning None.")
|
4502
4502
|
return None
|
4503
4503
|
edges = []
|
4504
|
-
_ = graph.Edges(vertices, tolerance, edges) # Hook to
|
4504
|
+
_ = graph.Edges(vertices, tolerance, edges) # Hook to Core
|
4505
4505
|
return list(dict.fromkeys(edges)) # remove duplicates
|
4506
4506
|
|
4507
4507
|
@staticmethod
|
@@ -5526,7 +5526,7 @@ class Graph:
|
|
5526
5526
|
return False
|
5527
5527
|
|
5528
5528
|
@staticmethod
|
5529
|
-
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):
|
5530
5530
|
"""
|
5531
5531
|
Flattens the input graph.
|
5532
5532
|
|
@@ -5536,8 +5536,9 @@ class Graph:
|
|
5536
5536
|
The input graph.
|
5537
5537
|
layout : str , optional
|
5538
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.
|
5539
|
-
If set to 'radial', the nodes will be distributed along
|
5540
|
-
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'.
|
5541
5542
|
k : float, optional
|
5542
5543
|
The desired spring constant to use for the attractive and repulsive forces. The default is 0.8.
|
5543
5544
|
seed : int , optional
|
@@ -5546,6 +5547,8 @@ class Graph:
|
|
5546
5547
|
The desired maximum number of iterations to solve the forces in the 'spring' mode. The default is 50.
|
5547
5548
|
rootVertex : topologic_core.Vertex , optional
|
5548
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.
|
5549
5552
|
tolerance : float , optional
|
5550
5553
|
The desired tolerance. The default is 0.0001.
|
5551
5554
|
|
@@ -5712,6 +5715,60 @@ class Graph:
|
|
5712
5715
|
old_roots = new_roots
|
5713
5716
|
return root, num_nodes
|
5714
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
|
+
|
5715
5772
|
def spring_layout(edge_list, iterations=500, k=None, seed=None):
|
5716
5773
|
# Compute the layout of a graph using the Fruchterman-Reingold algorithm
|
5717
5774
|
# with a force-directed layout approach.
|
@@ -5850,6 +5907,10 @@ class Graph:
|
|
5850
5907
|
if not Topology.IsInstance(graph, "Graph"):
|
5851
5908
|
print("Graph.Flatten - Error: The input graph is not a valid topologic graph. Returning None.")
|
5852
5909
|
return None
|
5910
|
+
|
5911
|
+
if 'circ' in layout.lower():
|
5912
|
+
new_graph = circle_layout(graph, radius=radius)
|
5913
|
+
return new_graph
|
5853
5914
|
d = Graph.MeshData(graph)
|
5854
5915
|
vertices = d['vertices']
|
5855
5916
|
edges = d['edges']
|
@@ -6180,7 +6241,7 @@ class Graph:
|
|
6180
6241
|
print("Graph.IsolatedVertices - Error: The input graph is not a valid graph. Returning None.")
|
6181
6242
|
return None
|
6182
6243
|
vertices = []
|
6183
|
-
_ = graph.IsolatedVertices(vertices) # Hook to
|
6244
|
+
_ = graph.IsolatedVertices(vertices) # Hook to Core
|
6184
6245
|
return vertices
|
6185
6246
|
|
6186
6247
|
@staticmethod
|
@@ -7581,7 +7642,7 @@ class Graph:
|
|
7581
7642
|
if not Topology.IsInstance(edge, "Edge"):
|
7582
7643
|
print("Graph.RemoveEdge - Error: The input edge is not a valid edge. Returning None.")
|
7583
7644
|
return None
|
7584
|
-
_ = graph.RemoveEdges([edge], tolerance) # Hook to
|
7645
|
+
_ = graph.RemoveEdges([edge], tolerance) # Hook to Core
|
7585
7646
|
return graph
|
7586
7647
|
|
7587
7648
|
@staticmethod
|
@@ -7613,7 +7674,7 @@ class Graph:
|
|
7613
7674
|
print("Graph.RemoveVertex - Error: The input vertex is not a valid vertex. Returning None.")
|
7614
7675
|
return None
|
7615
7676
|
graphVertex = Graph.NearestVertex(graph, vertex)
|
7616
|
-
_ = graph.RemoveVertices([graphVertex]) # Hook to
|
7677
|
+
_ = graph.RemoveVertices([graphVertex]) # Hook to Core
|
7617
7678
|
return graph
|
7618
7679
|
|
7619
7680
|
@staticmethod
|
@@ -7648,7 +7709,7 @@ class Graph:
|
|
7648
7709
|
if len(dictionary.Keys()) < 1:
|
7649
7710
|
print("Graph.SetDictionary - Warning: the input dictionary parameter is empty. Returning original input.")
|
7650
7711
|
return graph
|
7651
|
-
_ = graph.SetDictionary(dictionary) # Hook to
|
7712
|
+
_ = graph.SetDictionary(dictionary) # Hook to Core
|
7652
7713
|
return graph
|
7653
7714
|
|
7654
7715
|
@staticmethod
|
@@ -7784,6 +7845,7 @@ class Graph:
|
|
7784
7845
|
sagitta = 0,
|
7785
7846
|
absolute = False,
|
7786
7847
|
sides = 8,
|
7848
|
+
angle = 0,
|
7787
7849
|
vertexColor="black",
|
7788
7850
|
vertexSize=6,
|
7789
7851
|
vertexLabelKey=None,
|
@@ -7832,6 +7894,8 @@ class Graph:
|
|
7832
7894
|
For example, if the length of the edge is 10, the sagitta is set to 0.5, and absolute is set to False, the sagitta length will be 5. The default is True.
|
7833
7895
|
sides : int , optional
|
7834
7896
|
The number of sides of the arc. The default is 8.
|
7897
|
+
angle : float, optional
|
7898
|
+
An additional angle in degrees to rotate arcs (where sagitta is more than 0). The default is 0.
|
7835
7899
|
vertexColor : str , optional
|
7836
7900
|
The desired color of the output vertices. This can be any plotly color string and may be specified as:
|
7837
7901
|
- A hex string (e.g. '#ff0000')
|
@@ -7933,7 +7997,7 @@ class Graph:
|
|
7933
7997
|
print("Graph.Show - Error: The input graph is not a valid graph. Returning None.")
|
7934
7998
|
return None
|
7935
7999
|
|
7936
|
-
data= Plotly.DataByGraph(graph, sagitta=sagitta, absolute=absolute, sides=sides, vertexColor=vertexColor, vertexSize=vertexSize, vertexLabelKey=vertexLabelKey, vertexGroupKey=vertexGroupKey, vertexGroups=vertexGroups, showVertices=showVertices, showVertexLabels=showVertexLabels, showVertexLegend=showVertexLegend, edgeColor=edgeColor, edgeWidth=edgeWidth, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, edgeGroups=edgeGroups, showEdges=showEdges, showEdgeLabels=showEdgeLabels, showEdgeLegend=showEdgeLegend, colorScale=colorScale, silent=silent)
|
8000
|
+
data= Plotly.DataByGraph(graph, sagitta=sagitta, absolute=absolute, sides=sides, angle=angle, vertexColor=vertexColor, vertexSize=vertexSize, vertexLabelKey=vertexLabelKey, vertexGroupKey=vertexGroupKey, vertexGroups=vertexGroups, showVertices=showVertices, showVertexLabels=showVertexLabels, showVertexLegend=showVertexLegend, edgeColor=edgeColor, edgeWidth=edgeWidth, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, edgeGroups=edgeGroups, showEdges=showEdges, showEdgeLabels=showEdgeLabels, showEdgeLegend=showEdgeLegend, colorScale=colorScale, silent=silent)
|
7937
8001
|
fig = Plotly.FigureByData(data, width=width, height=height, xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, axisSize=axisSize, backgroundColor=backgroundColor,
|
7938
8002
|
marginLeft=marginLeft, marginRight=marginRight, marginTop=marginTop, marginBottom=marginBottom, tolerance=tolerance)
|
7939
8003
|
Plotly.Show(fig, renderer=renderer, camera=camera, center=center, up=up, projection=projection)
|
@@ -8173,7 +8237,7 @@ class Graph:
|
|
8173
8237
|
vertices = []
|
8174
8238
|
if graph:
|
8175
8239
|
try:
|
8176
|
-
_ = graph.Vertices(vertices) # Hook to
|
8240
|
+
_ = graph.Vertices(vertices) # Hook to Core
|
8177
8241
|
except:
|
8178
8242
|
vertices = []
|
8179
8243
|
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)))
|
topologicpy/Plotly.py
CHANGED
@@ -276,6 +276,7 @@ class Plotly:
|
|
276
276
|
sagitta: float = 0,
|
277
277
|
absolute: bool = False,
|
278
278
|
sides: int = 8,
|
279
|
+
angle: float = 0,
|
279
280
|
vertexColor: str = "black",
|
280
281
|
vertexSize: float = 6,
|
281
282
|
vertexLabelKey: str = None,
|
@@ -370,6 +371,7 @@ class Plotly:
|
|
370
371
|
from topologicpy.Dictionary import Dictionary
|
371
372
|
from topologicpy.Topology import Topology
|
372
373
|
from topologicpy.Graph import Graph
|
374
|
+
from topologicpy.Color import Color
|
373
375
|
import plotly.graph_objs as go
|
374
376
|
|
375
377
|
if not Topology.IsInstance(graph, "Graph"):
|
@@ -377,6 +379,7 @@ class Plotly:
|
|
377
379
|
v_labels = []
|
378
380
|
v_groupList = []
|
379
381
|
data = []
|
382
|
+
|
380
383
|
if showVertices:
|
381
384
|
vertices = Graph.Vertices(graph)
|
382
385
|
if vertexLabelKey or vertexGroupKey:
|
@@ -452,9 +455,12 @@ class Plotly:
|
|
452
455
|
d = Topology.Dictionary(edge)
|
453
456
|
arc = Wire.ArcByEdge(edge, sagitta=sagitta, absolute=absolute, sides=sides, close=False, silent=silent)
|
454
457
|
if Topology.IsInstance(arc, "Wire"):
|
458
|
+
if not angle == 0:
|
459
|
+
direc = Edge.Direction(edge)
|
460
|
+
arc = Topology.Rotate(arc, origin=Topology.Centroid(edge), axis=direc, angle=angle)
|
455
461
|
arc_edges = Topology.Edges(arc)
|
456
462
|
for arc_edge in arc_edges:
|
457
|
-
arc_edge = Topology.SetDictionary(arc_edge, d, silent=
|
463
|
+
arc_edge = Topology.SetDictionary(arc_edge, d, silent=True)
|
458
464
|
new_edges.append(arc_edge)
|
459
465
|
else:
|
460
466
|
new_edges.append(edge)
|
@@ -473,9 +479,14 @@ class Plotly:
|
|
473
479
|
d = Topology.Dictionary(e)
|
474
480
|
if d:
|
475
481
|
if not edgeLabelKey == None:
|
476
|
-
e_label = str(Dictionary.ValueAtKey(d, key=edgeLabelKey))
|
482
|
+
e_label = str(Dictionary.ValueAtKey(d, key=edgeLabelKey))
|
483
|
+
if e_label == None:
|
484
|
+
e_label = ""
|
477
485
|
if not edgeGroupKey == None:
|
478
|
-
|
486
|
+
if edgeGroupKey:
|
487
|
+
e_group = Dictionary.ValueAtKey(d, key=edgeGroupKey)
|
488
|
+
if e_group == None:
|
489
|
+
e_group = ""
|
479
490
|
try:
|
480
491
|
e_groupList.append(edgeGroups.index(e_group))
|
481
492
|
except:
|
@@ -491,6 +502,7 @@ class Plotly:
|
|
491
502
|
Ye+=[Vertex.Y(sv, mantissa=mantissa), Vertex.Y(ev, mantissa=mantissa), None] # y-coordinates of edge ends
|
492
503
|
Ze+=[Vertex.Z(sv, mantissa=mantissa), Vertex.Z(ev, mantissa=mantissa), None] # z-coordinates of edge ends
|
493
504
|
|
505
|
+
|
494
506
|
if len(list(set(e_groupList))) < 2:
|
495
507
|
e_groupList = edgeColor
|
496
508
|
if len(e_labels) < 1:
|
@@ -500,6 +512,19 @@ class Plotly:
|
|
500
512
|
mode = "lines+text"
|
501
513
|
else:
|
502
514
|
mode = "lines"
|
515
|
+
|
516
|
+
final_categories = edgeColor # Start with the default edgeColor
|
517
|
+
if len(edgeGroups) > 0:
|
518
|
+
# Normalize categories to a range between 0 and 1 for the color scale
|
519
|
+
min_category = 0
|
520
|
+
max_category = max(len(edgeGroups), 1)
|
521
|
+
normalized_categories = [(cat - min_category) / (max_category - min_category) for cat in e_groupList]
|
522
|
+
|
523
|
+
final_categories = []
|
524
|
+
for c in normalized_categories:
|
525
|
+
color = Color.ByValueInRange(c, minValue=0, maxValue=1, colorScale=colorScale)
|
526
|
+
color = "rgb("+str(color[0])+","+str(color[1])+","+str(color[2])+")"
|
527
|
+
final_categories.append(color)
|
503
528
|
e_trace=go.Scatter3d(x=Xe,
|
504
529
|
y=Ye,
|
505
530
|
z=Ze,
|
@@ -508,12 +533,12 @@ class Plotly:
|
|
508
533
|
legendgroup=5,
|
509
534
|
legendrank=5,
|
510
535
|
showlegend=showEdgeLegend,
|
511
|
-
line=dict(color=
|
536
|
+
line=dict(color=final_categories, colorscale=Plotly.ColorScale(colorScale), cmin=0, cmax=1, width=edgeWidth),
|
512
537
|
text=e_labels,
|
513
538
|
hoverinfo='text'
|
514
539
|
)
|
515
540
|
data.append(e_trace)
|
516
|
-
|
541
|
+
|
517
542
|
return data
|
518
543
|
|
519
544
|
@staticmethod
|
@@ -1022,7 +1047,7 @@ class Plotly:
|
|
1022
1047
|
d = Topology.Dictionary(tp_face)
|
1023
1048
|
f_dictionaries.append(d)
|
1024
1049
|
if d:
|
1025
|
-
|
1050
|
+
tri = Topology.SetDictionary(tri, d)
|
1026
1051
|
all_triangles.append(tri)
|
1027
1052
|
if len(all_triangles) > 0:
|
1028
1053
|
f_cluster = Cluster.ByTopologies(all_triangles)
|
topologicpy/Shell.py
CHANGED
@@ -182,7 +182,7 @@ class Shell():
|
|
182
182
|
|
183
183
|
shell = Topology.Slice(internalBoundary, skeleton_cluster, tolerance=tolerance)
|
184
184
|
if mergeJunctions == True:
|
185
|
-
vertices =
|
185
|
+
vertices = Topology.Vertices(shell)
|
186
186
|
centers = []
|
187
187
|
used = []
|
188
188
|
for v in vertices:
|
@@ -264,7 +264,7 @@ class Shell():
|
|
264
264
|
s = Topology.InternalVertex(f, tolerance=tolerance)
|
265
265
|
s = Topology.SetDictionary(s, d)
|
266
266
|
selectors.append(s)
|
267
|
-
|
267
|
+
shell = Topology.TransferDictionariesBySelectors(topology=shell, selectors=selectors, tranFaces=True, tolerance=tolerance)
|
268
268
|
return shell
|
269
269
|
return None
|
270
270
|
|
@@ -330,8 +330,7 @@ class Shell():
|
|
330
330
|
|
331
331
|
if not Topology.IsInstance(cluster, "Cluster"):
|
332
332
|
return None
|
333
|
-
faces =
|
334
|
-
_ = cluster.Faces(None, faces)
|
333
|
+
faces = Topology.Faces(cluster)
|
335
334
|
return Shell.ByFaces(faces, tolerance=tolerance)
|
336
335
|
|
337
336
|
@staticmethod
|
@@ -619,7 +618,7 @@ class Shell():
|
|
619
618
|
origin = Topology.Centroid(face)
|
620
619
|
normal = Face.Normal(face, mantissa=mantissa)
|
621
620
|
flatFace = Topology.Flatten(face, origin=origin, direction=normal)
|
622
|
-
faceVertices =
|
621
|
+
faceVertices = Topology.Vertices(face)
|
623
622
|
vertices += faceVertices
|
624
623
|
|
625
624
|
# Create a cluster of the input vertices
|
@@ -628,7 +627,7 @@ class Shell():
|
|
628
627
|
# Flatten the cluster using the same transformations
|
629
628
|
verticesCluster = Topology.Flatten(verticesCluster, origin=origin, direction=normal)
|
630
629
|
|
631
|
-
vertices =
|
630
|
+
vertices = Topology.Vertices(verticesCluster)
|
632
631
|
points = []
|
633
632
|
for v in vertices:
|
634
633
|
points.append([Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa)])
|
@@ -682,7 +681,7 @@ class Shell():
|
|
682
681
|
if not Topology.IsInstance(shell, "Shell"):
|
683
682
|
return None
|
684
683
|
edges = []
|
685
|
-
_ = shell.Edges(None, edges)
|
684
|
+
_ = shell.Edges(None, edges) # Hook to Core
|
686
685
|
return edges
|
687
686
|
|
688
687
|
@staticmethod
|
@@ -708,12 +707,10 @@ class Shell():
|
|
708
707
|
|
709
708
|
if not Topology.IsInstance(shell, "Shell"):
|
710
709
|
return None
|
711
|
-
edges =
|
712
|
-
_ = shell.Edges(None, edges)
|
710
|
+
edges = Topology.Edges(shell)
|
713
711
|
obEdges = []
|
714
712
|
for anEdge in edges:
|
715
|
-
faces =
|
716
|
-
_ = anEdge.Faces(shell, faces)
|
713
|
+
faces = Topology.SuperTopologies(anEdge, shell, topologyType="face")
|
717
714
|
if len(faces) == 1:
|
718
715
|
obEdges.append(anEdge)
|
719
716
|
return Topology.SelfMerge(Cluster.ByTopologies(obEdges), tolerance=tolerance)
|
@@ -1748,7 +1745,7 @@ class Shell():
|
|
1748
1745
|
if isinstance(wire, list):
|
1749
1746
|
points = wire
|
1750
1747
|
else:
|
1751
|
-
points =
|
1748
|
+
points = Topology.Vertices(wire)
|
1752
1749
|
# points.insert(0, points.pop())
|
1753
1750
|
if len(points) <= 2:
|
1754
1751
|
return points
|
@@ -1937,7 +1934,7 @@ class Shell():
|
|
1937
1934
|
points.append([Vertex.X(flatVertex, mantissa=mantissa), Vertex.Y(flatVertex, mantissa=mantissa)])
|
1938
1935
|
|
1939
1936
|
br = Wire.BoundingRectangle(flatFace)
|
1940
|
-
br_vertices =
|
1937
|
+
br_vertices = Topology.Vertices(br)
|
1941
1938
|
br_x = []
|
1942
1939
|
br_y = []
|
1943
1940
|
for br_v in br_vertices:
|