topologicpy 0.2.2__py3-none-any.whl → 0.2.3__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 +129 -127
- topologicpy/CellComplex.py +21 -23
- topologicpy/Cluster.py +7 -11
- topologicpy/DGL.py +8 -3
- topologicpy/Face.py +124 -38
- topologicpy/Plotly.py +47 -29
- topologicpy/Shell.py +30 -50
- topologicpy/Topology.py +70 -19
- topologicpy/UnitTest.py +2 -2
- topologicpy/Vector.py +242 -17
- topologicpy/Wire.py +38 -66
- topologicpy/__init__.py +1 -1
- {topologicpy-0.2.2.dist-info → topologicpy-0.2.3.dist-info}/METADATA +1 -1
- {topologicpy-0.2.2.dist-info → topologicpy-0.2.3.dist-info}/RECORD +17 -17
- {topologicpy-0.2.2.dist-info → topologicpy-0.2.3.dist-info}/LICENSE +0 -0
- {topologicpy-0.2.2.dist-info → topologicpy-0.2.3.dist-info}/WHEEL +0 -0
- {topologicpy-0.2.2.dist-info → topologicpy-0.2.3.dist-info}/top_level.txt +0 -0
topologicpy/Plotly.py
CHANGED
|
@@ -92,7 +92,7 @@ class Plotly:
|
|
|
92
92
|
edgeGroupKey : str , optional
|
|
93
93
|
The dictionary key to use to display the edge group. The default is None.
|
|
94
94
|
edgeColor : str , optional
|
|
95
|
-
The desired color of the output
|
|
95
|
+
The desired color of the output edges. This can be any plotly color string and may be specified as:
|
|
96
96
|
- A hex string (e.g. '#ff0000')
|
|
97
97
|
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
|
|
98
98
|
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
|
|
@@ -250,14 +250,14 @@ class Plotly:
|
|
|
250
250
|
return data
|
|
251
251
|
|
|
252
252
|
@staticmethod
|
|
253
|
-
def DataByTopology(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor="white", faceOpacity=0.5, edgeColor="black", edgeWidth=1, vertexColor="black", vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True):
|
|
253
|
+
def DataByTopology(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor="white", faceOpacity=0.5, edgeColor="black", edgeWidth=1, vertexColor="black", vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True, verticesLabel="Topology Vertices", edgesLabel="Topology Edges", facesLabel="Topology Faces"):
|
|
254
254
|
"""
|
|
255
|
-
Creates plotly face,
|
|
255
|
+
Creates plotly face, edge, and vertex data.
|
|
256
256
|
|
|
257
257
|
Parameters
|
|
258
258
|
----------
|
|
259
259
|
topology : topologic.Topology
|
|
260
|
-
The input topology. This must contain faces and or
|
|
260
|
+
The input topology. This must contain faces and or edges.
|
|
261
261
|
vertexLabelKey : str , optional
|
|
262
262
|
The dictionary key to use to display the vertex label. The default is None.
|
|
263
263
|
vertexGroupKey : str , optional
|
|
@@ -287,7 +287,7 @@ class Plotly:
|
|
|
287
287
|
faceOpacity : float , optional
|
|
288
288
|
The desired opacity of the output faces (0=transparent, 1=opaque). The default is 0.5.
|
|
289
289
|
edgeColor : str , optional
|
|
290
|
-
The desired color of the output
|
|
290
|
+
The desired color of the output edges. This can be any plotly color string and may be specified as:
|
|
291
291
|
- A hex string (e.g. '#ff0000')
|
|
292
292
|
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
|
|
293
293
|
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
|
|
@@ -312,7 +312,12 @@ class Plotly:
|
|
|
312
312
|
If set to True the edges will be drawn. Otherwise, they will not be drawn. The default is True.
|
|
313
313
|
showVertices : bool , optional
|
|
314
314
|
If set to True the vertices will be drawn. Otherwise, they will not be drawn. The default is True.
|
|
315
|
-
|
|
315
|
+
verticesLabel : str , optional
|
|
316
|
+
The legend label string used to identify vertices. The default is "Topology Vertices".
|
|
317
|
+
edgesLabel : str , optional
|
|
318
|
+
The legend label string used to identify edges. The default is "Topology Edges".
|
|
319
|
+
facesLabel : str , optional
|
|
320
|
+
The legend label string used to idenitfy edges. The default is "Topology Faces".
|
|
316
321
|
Returns
|
|
317
322
|
-------
|
|
318
323
|
list
|
|
@@ -322,7 +327,7 @@ class Plotly:
|
|
|
322
327
|
from topologicpy.Topology import Topology
|
|
323
328
|
from topologicpy.Dictionary import Dictionary
|
|
324
329
|
|
|
325
|
-
def vertexData(vertices, dictionaries=None, vertexColor="black", vertexSize=1.1, vertexLabelKey=None, vertexGroupKey=None, vertexGroups=[]):
|
|
330
|
+
def vertexData(vertices, dictionaries=None, vertexColor="black", vertexSize=1.1, vertexLabelKey=None, vertexGroupKey=None, vertexGroups=[], verticesLabel="Topology Vertices"):
|
|
326
331
|
x = []
|
|
327
332
|
y = []
|
|
328
333
|
z = []
|
|
@@ -368,7 +373,7 @@ class Plotly:
|
|
|
368
373
|
return go.Scatter3d(x=x,
|
|
369
374
|
y=y,
|
|
370
375
|
z=z,
|
|
371
|
-
name=
|
|
376
|
+
name=verticesLabel,
|
|
372
377
|
showlegend=True,
|
|
373
378
|
marker=dict(color=v_groupList, size=vertexSize),
|
|
374
379
|
mode='markers',
|
|
@@ -378,7 +383,7 @@ class Plotly:
|
|
|
378
383
|
hoverinfo='text',
|
|
379
384
|
hovertext=v_labels)
|
|
380
385
|
|
|
381
|
-
def edgeData(vertices, edges, dictionaries=None, edgeColor="black", edgeWidth=1, edgeLabelKey=None, edgeGroupKey=None, edgeGroups=[]):
|
|
386
|
+
def edgeData(vertices, edges, dictionaries=None, edgeColor="black", edgeWidth=1, edgeLabelKey=None, edgeGroupKey=None, edgeGroups=[], edgesLabel="Topology Edges"):
|
|
382
387
|
x = []
|
|
383
388
|
y = []
|
|
384
389
|
z = []
|
|
@@ -427,7 +432,7 @@ class Plotly:
|
|
|
427
432
|
return go.Scatter3d(x=x,
|
|
428
433
|
y=y,
|
|
429
434
|
z=z,
|
|
430
|
-
name=
|
|
435
|
+
name=edgesLabel,
|
|
431
436
|
showlegend=True,
|
|
432
437
|
marker_size=0,
|
|
433
438
|
mode="lines",
|
|
@@ -554,7 +559,7 @@ class Plotly:
|
|
|
554
559
|
ev = Edge.EndVertex(tp_edge)
|
|
555
560
|
ei = Vertex.Index(ev, tp_verts)
|
|
556
561
|
edges.append([si, ei])
|
|
557
|
-
data.append(edgeData(vertices, edges, dictionaries=[], edgeColor=edgeColor, edgeWidth=edgeWidth, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, edgeGroups=edgeGroups))
|
|
562
|
+
data.append(edgeData(vertices, edges, dictionaries=[], edgeColor=edgeColor, edgeWidth=edgeWidth, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, edgeGroups=edgeGroups, edgesLabel=edgesLabel))
|
|
558
563
|
if showFaces and topology.Type() >= topologic.Face.Type():
|
|
559
564
|
tp_faces = Topology.SubTopologies(topology, subTopologyType="face")
|
|
560
565
|
triangles = []
|
|
@@ -591,6 +596,7 @@ class Plotly:
|
|
|
591
596
|
height=500,
|
|
592
597
|
showScale = True,
|
|
593
598
|
colorScale='Viridis',
|
|
599
|
+
colorSamples=10,
|
|
594
600
|
backgroundColor='rgba(0,0,0,0)',
|
|
595
601
|
marginLeft=0,
|
|
596
602
|
marginRight=0,
|
|
@@ -623,6 +629,8 @@ class Plotly:
|
|
|
623
629
|
If set to True, a color scale is shown on the right side of the figure. The default is True.
|
|
624
630
|
colorScale : str , optional
|
|
625
631
|
The desired type of plotly color scales to use (e.g. "Viridis", "Plasma"). The default is "Viridis". For a full list of names, see https://plotly.com/python/builtin-colorscales/.
|
|
632
|
+
colorSamples : int , optional
|
|
633
|
+
The number of discrete color samples to use for displaying the data. The default is 10.
|
|
626
634
|
backgroundColor : str , optional
|
|
627
635
|
The desired background color. This can be any plotly color string and may be specified as:
|
|
628
636
|
- A hex string (e.g. '#ff0000')
|
|
@@ -643,9 +651,13 @@ class Plotly:
|
|
|
643
651
|
"""
|
|
644
652
|
#import plotly.figure_factory as ff
|
|
645
653
|
import plotly.graph_objects as go
|
|
654
|
+
import plotly.express as px
|
|
646
655
|
|
|
647
656
|
annotations = []
|
|
648
|
-
|
|
657
|
+
|
|
658
|
+
# Transpose the confusion matrix
|
|
659
|
+
matrix = matrix.T
|
|
660
|
+
colors = px.colors.sample_colorscale(colorScale, [n/(colorSamples -1) for n in range(colorSamples)])
|
|
649
661
|
if not minValue:
|
|
650
662
|
minValue = 0
|
|
651
663
|
if not maxValue:
|
|
@@ -655,10 +667,12 @@ class Plotly:
|
|
|
655
667
|
for j, value in enumerate(row):
|
|
656
668
|
annotations.append(
|
|
657
669
|
{
|
|
658
|
-
"x": categories[
|
|
659
|
-
"y": categories[
|
|
660
|
-
"font": {"color": "
|
|
661
|
-
"
|
|
670
|
+
"x": categories[j],
|
|
671
|
+
"y": categories[i],
|
|
672
|
+
"font": {"color": "black"},
|
|
673
|
+
"bgcolor": "white",
|
|
674
|
+
"opacity": 0.5,
|
|
675
|
+
"text": str(round(value,2)),
|
|
662
676
|
"xref": "x1",
|
|
663
677
|
"yref": "y1",
|
|
664
678
|
"showarrow": False
|
|
@@ -670,16 +684,18 @@ class Plotly:
|
|
|
670
684
|
for j, value in enumerate(row):
|
|
671
685
|
annotations.append(
|
|
672
686
|
{
|
|
673
|
-
"x": categories[
|
|
674
|
-
"y": categories[
|
|
675
|
-
"font": {"color": "
|
|
676
|
-
"
|
|
687
|
+
"x": categories[j],
|
|
688
|
+
"y": categories[i],
|
|
689
|
+
"font": {"color": "black"},
|
|
690
|
+
"bgcolor": "white",
|
|
691
|
+
"opacity": 0.5,
|
|
692
|
+
"text": str(round(value,2)),
|
|
677
693
|
"xref": "x1",
|
|
678
694
|
"yref": "y1",
|
|
679
695
|
"showarrow": False
|
|
680
696
|
}
|
|
681
697
|
)
|
|
682
|
-
data = go.Heatmap(z=matrix, y=categories, x=categories, zmin=minValue, zmax=maxValue, showscale=showScale, colorscale=
|
|
698
|
+
data = go.Heatmap(z=matrix, y=categories, x=categories, zmin=minValue, zmax=maxValue, showscale=showScale, colorscale=colors)
|
|
683
699
|
|
|
684
700
|
layout = {
|
|
685
701
|
"width": width,
|
|
@@ -690,7 +706,7 @@ class Plotly:
|
|
|
690
706
|
"annotations": annotations,
|
|
691
707
|
"paper_bgcolor": backgroundColor,
|
|
692
708
|
"plot_bgcolor": backgroundColor,
|
|
693
|
-
"margin":dict(l=marginLeft, r=marginRight, t=marginTop, b=marginBottom)
|
|
709
|
+
"margin":dict(l=marginLeft, r=marginRight, t=marginTop, b=marginBottom)
|
|
694
710
|
}
|
|
695
711
|
fig = go.Figure(data=data, layout=layout)
|
|
696
712
|
return fig
|
|
@@ -752,7 +768,7 @@ class Plotly:
|
|
|
752
768
|
return fig
|
|
753
769
|
|
|
754
770
|
@staticmethod
|
|
755
|
-
def FigureByData(data, color=None, width=950, height=500, xAxis=False, yAxis=False, zAxis=False, backgroundColor='rgba(0,0,0,0)', marginLeft=0, marginRight=0, marginTop=20, marginBottom=0):
|
|
771
|
+
def FigureByData(data, color=None, width=950, height=500, xAxis=False, yAxis=False, zAxis=False, axisSize=1, backgroundColor='rgba(0,0,0,0)', marginLeft=0, marginRight=0, marginTop=20, marginBottom=0):
|
|
756
772
|
"""
|
|
757
773
|
Creates a plotly figure.
|
|
758
774
|
|
|
@@ -770,6 +786,8 @@ class Plotly:
|
|
|
770
786
|
If set to True the y axis is drawn. Otherwise it is not drawn. The default is False.
|
|
771
787
|
zAxis : bool , optional
|
|
772
788
|
If set to True the z axis is drawn. Otherwise it is not drawn. The default is False.
|
|
789
|
+
axisSize : float , optional
|
|
790
|
+
The size of the X,Y,Z, axes. The default is 1.
|
|
773
791
|
backgroundColor : str , optional
|
|
774
792
|
The desired color of the background. This can be any plotly color string and may be specified as:
|
|
775
793
|
- A hex string (e.g. '#ff0000')
|
|
@@ -800,24 +818,24 @@ class Plotly:
|
|
|
800
818
|
return None
|
|
801
819
|
|
|
802
820
|
v0 = Vertex.ByCoordinates(0,0,0)
|
|
803
|
-
v1 = Vertex.ByCoordinates(
|
|
804
|
-
v2 = Vertex.ByCoordinates(0,
|
|
805
|
-
v3 = Vertex.ByCoordinates(0,0,
|
|
821
|
+
v1 = Vertex.ByCoordinates(axisSize,0,0)
|
|
822
|
+
v2 = Vertex.ByCoordinates(0,axisSize,0)
|
|
823
|
+
v3 = Vertex.ByCoordinates(0,0,axisSize)
|
|
806
824
|
|
|
807
825
|
if xAxis:
|
|
808
826
|
xEdge = Edge.ByVertices([v0,v1])
|
|
809
827
|
xWire = Wire.ByEdges([xEdge])
|
|
810
|
-
xData = Plotly.DataByTopology(xWire,
|
|
828
|
+
xData = Plotly.DataByTopology(xWire, edgeColor="red", edgeWidth=6, showFaces=False, showEdges=True, showVertices=False, edgesLabel="X-Axis")
|
|
811
829
|
data = data + xData
|
|
812
830
|
if yAxis:
|
|
813
831
|
yEdge = Edge.ByVertices([v0,v2])
|
|
814
832
|
yWire = Wire.ByEdges([yEdge])
|
|
815
|
-
yData = Plotly.DataByTopology(yWire,
|
|
833
|
+
yData = Plotly.DataByTopology(yWire, edgeColor="green", edgeWidth=6, showFaces=False, showEdges=True, showVertices=False, edgesLabel="Y-Axis")
|
|
816
834
|
data = data + yData
|
|
817
835
|
if zAxis:
|
|
818
836
|
zEdge = Edge.ByVertices([v0,v3])
|
|
819
837
|
zWire = Wire.ByEdges([zEdge])
|
|
820
|
-
zData = Plotly.DataByTopology(zWire,
|
|
838
|
+
zData = Plotly.DataByTopology(zWire, edgeColor="blue", edgeWidth=6, showFaces=False, showEdges=True, showVertices=False, edgesLabel="Z-Axis")
|
|
821
839
|
data = data + zData
|
|
822
840
|
|
|
823
841
|
figure = go.Figure(data=data)
|
topologicpy/Shell.py
CHANGED
|
@@ -187,7 +187,7 @@ class Shell(Topology):
|
|
|
187
187
|
return Shell.ByWires(wires, triangulate=triangulate, tolerance=tolerance)
|
|
188
188
|
|
|
189
189
|
@staticmethod
|
|
190
|
-
def Circle(origin=None, radius=0.5, sides=32, fromAngle=0, toAngle=360,
|
|
190
|
+
def Circle(origin=None, radius=0.5, sides=32, fromAngle=0, toAngle=360, direction=[0,0,1], placement="center", tolerance=0.0001):
|
|
191
191
|
"""
|
|
192
192
|
Creates a circle.
|
|
193
193
|
|
|
@@ -203,12 +203,8 @@ class Shell(Topology):
|
|
|
203
203
|
The angle in degrees from which to start creating the arc of the circle. The default is 0.
|
|
204
204
|
toAngle : float , optional
|
|
205
205
|
The angle in degrees at which to end creating the arc of the circle. The default is 360.
|
|
206
|
-
|
|
207
|
-
The
|
|
208
|
-
dirY : float , optional
|
|
209
|
-
The Y component of the vector representing the up direction of the circle. The default is 0.
|
|
210
|
-
dirZ : float , optional
|
|
211
|
-
The Z component of the vector representing the up direction of the circle. The default is 1.
|
|
206
|
+
direction : list , optional
|
|
207
|
+
The vector representing the up direction of the circle. The default is [0,0,1].
|
|
212
208
|
placement : str , optional
|
|
213
209
|
The description of the placement of the origin of the pie. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
214
210
|
tolerance : float , optional
|
|
@@ -219,7 +215,7 @@ class Shell(Topology):
|
|
|
219
215
|
topologic.Shell
|
|
220
216
|
The created circle.
|
|
221
217
|
"""
|
|
222
|
-
return Shell.Pie(origin=origin, radiusA=radius, radiusB=0, sides=sides, rings=1, fromAngle=fromAngle, toAngle=toAngle,
|
|
218
|
+
return Shell.Pie(origin=origin, radiusA=radius, radiusB=0, sides=sides, rings=1, fromAngle=fromAngle, toAngle=toAngle, direction=direction, placement=placement, tolerance=tolerance)
|
|
223
219
|
|
|
224
220
|
@staticmethod
|
|
225
221
|
def Delaunay(vertices, face=None):
|
|
@@ -393,7 +389,7 @@ class Shell(Topology):
|
|
|
393
389
|
return faces
|
|
394
390
|
|
|
395
391
|
@staticmethod
|
|
396
|
-
def HyperbolicParaboloidRectangularDomain(origin=None, llVertex=None, lrVertex=None, ulVertex=None, urVertex=None, u=10, v=10,
|
|
392
|
+
def HyperbolicParaboloidRectangularDomain(origin=None, llVertex=None, lrVertex=None, ulVertex=None, urVertex=None, u=10, v=10, direction=[0,0,1], placement="bottom"):
|
|
397
393
|
"""
|
|
398
394
|
Creates a hyperbolic paraboloid with a rectangular domain.
|
|
399
395
|
|
|
@@ -413,14 +409,10 @@ class Shell(Topology):
|
|
|
413
409
|
The number of segments along the X axis. The default is 10.
|
|
414
410
|
v : int , optional
|
|
415
411
|
The number of segments along the Y axis. The default is 10.
|
|
416
|
-
|
|
417
|
-
The
|
|
418
|
-
dirY : float , optional
|
|
419
|
-
The Y component of the vector representing the up direction of the circle. The default is 0.
|
|
420
|
-
dirZ : float , optional
|
|
421
|
-
The Z component of the vector representing the up direction of the circle. The default is 1.
|
|
412
|
+
direction : list , optional
|
|
413
|
+
The vector representing the up direction of the hyperbolic parabolid. The default is [0,0,1].
|
|
422
414
|
placement : str , optional
|
|
423
|
-
The description of the placement of the origin of the
|
|
415
|
+
The description of the placement of the origin of the hyperbolic parabolid. This can be "center", "lowerleft", "bottom". It is case insensitive. The default is "center".
|
|
424
416
|
|
|
425
417
|
Returns
|
|
426
418
|
-------
|
|
@@ -487,9 +479,9 @@ class Shell(Topology):
|
|
|
487
479
|
x1 = 0
|
|
488
480
|
y1 = 0
|
|
489
481
|
z1 = 0
|
|
490
|
-
x2 = 0 +
|
|
491
|
-
y2 = 0 +
|
|
492
|
-
z2 = 0 +
|
|
482
|
+
x2 = 0 + direction[0]
|
|
483
|
+
y2 = 0 + direction[1]
|
|
484
|
+
z2 = 0 + direction[2]
|
|
493
485
|
dx = x2 - x1
|
|
494
486
|
dy = y2 - y1
|
|
495
487
|
dz = z2 - z1
|
|
@@ -505,7 +497,7 @@ class Shell(Topology):
|
|
|
505
497
|
return returnTopology
|
|
506
498
|
|
|
507
499
|
@staticmethod
|
|
508
|
-
def HyperbolicParaboloidCircularDomain(origin=None, radius=0.5, sides=36, rings=10, A=1.0, B=-1.0,
|
|
500
|
+
def HyperbolicParaboloidCircularDomain(origin=None, radius=0.5, sides=36, rings=10, A=1.0, B=-1.0, direction=[0,0,1], placement="bottom"):
|
|
509
501
|
"""
|
|
510
502
|
Creates a hyperbolic paraboloid with a circular domain. See https://en.wikipedia.org/wiki/Compactness_measure_of_a_shape
|
|
511
503
|
|
|
@@ -523,12 +515,8 @@ class Shell(Topology):
|
|
|
523
515
|
The *A* constant in the equation z = A*x^2^ + B*y^2^. The default is 1.0.
|
|
524
516
|
B : float , optional
|
|
525
517
|
The *B* constant in the equation z = A*x^2^ + B*y^2^. The default is -1.0.
|
|
526
|
-
|
|
527
|
-
The
|
|
528
|
-
dirY : float , optional
|
|
529
|
-
The Y component of the vector representing the up direction of the circle. The default is 0.
|
|
530
|
-
dirZ : float , optional
|
|
531
|
-
The Z component of the vector representing the up direction of the circle. The default is 1.
|
|
518
|
+
direction : list , optional
|
|
519
|
+
The vector representing the up direction of the hyperbolic paraboloid. The default is [0,0,1.
|
|
532
520
|
placement : str , optional
|
|
533
521
|
The description of the placement of the origin of the circle. This can be "center", "lowerleft", "bottom". It is case insensitive. The default is "center".
|
|
534
522
|
|
|
@@ -663,9 +651,9 @@ class Shell(Topology):
|
|
|
663
651
|
x1 = 0
|
|
664
652
|
y1 = 0
|
|
665
653
|
z1 = 0
|
|
666
|
-
x2 = 0 +
|
|
667
|
-
y2 = 0 +
|
|
668
|
-
z2 = 0 +
|
|
654
|
+
x2 = 0 + direction[0]
|
|
655
|
+
y2 = 0 + direction[1]
|
|
656
|
+
z2 = 0 + direction[2]
|
|
669
657
|
dx = x2 - x1
|
|
670
658
|
dy = y2 - y1
|
|
671
659
|
dz = z2 - z1
|
|
@@ -727,7 +715,7 @@ class Shell(Topology):
|
|
|
727
715
|
return shell.IsClosed()
|
|
728
716
|
|
|
729
717
|
@staticmethod
|
|
730
|
-
def Pie(origin=None, radiusA=0.5, radiusB=0, sides=32, rings=1, fromAngle=0, toAngle=360,
|
|
718
|
+
def Pie(origin=None, radiusA=0.5, radiusB=0, sides=32, rings=1, fromAngle=0, toAngle=360, direction=[0,0,1], placement="center", tolerance=0.0001):
|
|
731
719
|
"""
|
|
732
720
|
Creates a pie shape.
|
|
733
721
|
|
|
@@ -747,12 +735,8 @@ class Shell(Topology):
|
|
|
747
735
|
The angle in degrees from which to start creating the arc of the pie. The default is 0.
|
|
748
736
|
toAngle : float , optional
|
|
749
737
|
The angle in degrees at which to end creating the arc of the pie. The default is 360.
|
|
750
|
-
|
|
751
|
-
The
|
|
752
|
-
dirY : float , optional
|
|
753
|
-
The Y component of the vector representing the up direction of the pie. The default is 0.
|
|
754
|
-
dirZ : float , optional
|
|
755
|
-
The Z component of the vector representing the up direction of the pie. The default is 1.
|
|
738
|
+
direction : list , optional
|
|
739
|
+
The vector representing the up direction of the pie. The default is [0,0,1].
|
|
756
740
|
placement : str , optional
|
|
757
741
|
The description of the placement of the origin of the pie. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
758
742
|
tolerance : float , optional
|
|
@@ -852,9 +836,9 @@ class Shell(Topology):
|
|
|
852
836
|
x1 = 0
|
|
853
837
|
y1 = 0
|
|
854
838
|
z1 = 0
|
|
855
|
-
x2 = 0 +
|
|
856
|
-
y2 = 0 +
|
|
857
|
-
z2 = 0 +
|
|
839
|
+
x2 = 0 + direction[0]
|
|
840
|
+
y2 = 0 + direction[1]
|
|
841
|
+
z2 = 0 + direction[2]
|
|
858
842
|
dx = x2 - x1
|
|
859
843
|
dy = y2 - y1
|
|
860
844
|
dz = z2 - z1
|
|
@@ -870,7 +854,7 @@ class Shell(Topology):
|
|
|
870
854
|
return shell
|
|
871
855
|
|
|
872
856
|
@staticmethod
|
|
873
|
-
def Rectangle(origin=None, width=1.0, length=1.0, uSides=2, vSides=2,
|
|
857
|
+
def Rectangle(origin=None, width=1.0, length=1.0, uSides=2, vSides=2, direction=[0,0,1], placement="center", tolerance=0.0001):
|
|
874
858
|
"""
|
|
875
859
|
Creates a rectangle.
|
|
876
860
|
|
|
@@ -886,12 +870,8 @@ class Shell(Topology):
|
|
|
886
870
|
The number of sides along the width. The default is 2.
|
|
887
871
|
vSides : int , optional
|
|
888
872
|
The number of sides along the length. The default is 2.
|
|
889
|
-
|
|
890
|
-
The
|
|
891
|
-
dirY : float , optional
|
|
892
|
-
The Y component of the vector representing the up direction of the rectangle. The default is 0.
|
|
893
|
-
dirZ : float , optional
|
|
894
|
-
The Z component of the vector representing the up direction of the rectangle. The default is 1.
|
|
873
|
+
direction : list , optional
|
|
874
|
+
The vector representing the up direction of the rectangle. The default is [0,0,1].
|
|
895
875
|
placement : str , optional
|
|
896
876
|
The description of the placement of the origin of the rectangle. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
|
897
877
|
tolerance : float , optional
|
|
@@ -922,16 +902,16 @@ class Shell(Topology):
|
|
|
922
902
|
for i in range(uSides):
|
|
923
903
|
for j in range(vSides):
|
|
924
904
|
rOrigin = Vertex.ByCoordinates(i*uOffset - wOffset, j*vOffset - lOffset, 0)
|
|
925
|
-
w = Wire.Rectangle(origin=rOrigin, width=uOffset, length=vOffset,
|
|
905
|
+
w = Wire.Rectangle(origin=rOrigin, width=uOffset, length=vOffset, placement="lowerleft", tolerance=tolerance)
|
|
926
906
|
f = Face.ByWire(w)
|
|
927
907
|
faces.append(f)
|
|
928
908
|
shell = Shell.ByFaces(faces)
|
|
929
909
|
x1 = origin.X()
|
|
930
910
|
y1 = origin.Y()
|
|
931
911
|
z1 = origin.Z()
|
|
932
|
-
x2 = origin.X() +
|
|
933
|
-
y2 = origin.Y() +
|
|
934
|
-
z2 = origin.Z() +
|
|
912
|
+
x2 = origin.X() + direction[0]
|
|
913
|
+
y2 = origin.Y() + direction[1]
|
|
914
|
+
z2 = origin.Z() + direction[2]
|
|
935
915
|
dx = x2 - x1
|
|
936
916
|
dy = y2 - y1
|
|
937
917
|
dz = z2 - z1
|
topologicpy/Topology.py
CHANGED
|
@@ -1073,13 +1073,13 @@ class Topology():
|
|
|
1073
1073
|
if len(faces) == 1:
|
|
1074
1074
|
return faces[0]
|
|
1075
1075
|
if outputMode.lower() == "cell":
|
|
1076
|
-
output = Cell.ByFaces(faces, tolerance)
|
|
1076
|
+
output = Cell.ByFaces(faces, tolerance=tolerance)
|
|
1077
1077
|
if output:
|
|
1078
1078
|
return output
|
|
1079
1079
|
else:
|
|
1080
1080
|
return None
|
|
1081
1081
|
if outputMode.lower() == "cellcomplex":
|
|
1082
|
-
output = CellComplex.ByFaces(faces, tolerance)
|
|
1082
|
+
output = CellComplex.ByFaces(faces, tolerance=tolerance)
|
|
1083
1083
|
if output:
|
|
1084
1084
|
return output
|
|
1085
1085
|
else:
|
|
@@ -2010,7 +2010,7 @@ class Topology():
|
|
|
2010
2010
|
from topologicpy.Shell import Shell
|
|
2011
2011
|
from topologicpy.Cell import Cell
|
|
2012
2012
|
from topologicpy.Cluster import Cluster
|
|
2013
|
-
def convexHull3D(item,
|
|
2013
|
+
def convexHull3D(item, tolerance, option):
|
|
2014
2014
|
if item:
|
|
2015
2015
|
vertices = []
|
|
2016
2016
|
_ = item.Vertices(None, vertices)
|
|
@@ -2038,7 +2038,7 @@ class Topology():
|
|
|
2038
2038
|
edges.append(Edge.ByVertices([sv, ev]))
|
|
2039
2039
|
faces.append(Face.ByWire(Wire.ByEdges(edges)))
|
|
2040
2040
|
try:
|
|
2041
|
-
c = Cell.ByFaces(faces,
|
|
2041
|
+
c = Cell.ByFaces(faces, tolerance=tolerance)
|
|
2042
2042
|
return c
|
|
2043
2043
|
except:
|
|
2044
2044
|
returnTopology = Cluster.SelfMerge(Cluster.ByTopologies(faces))
|
|
@@ -3420,6 +3420,27 @@ class Topology():
|
|
|
3420
3420
|
return 0
|
|
3421
3421
|
return len(superTopologies)
|
|
3422
3422
|
|
|
3423
|
+
def NonPlanarFaces(topology, tolerance=0.0001):
|
|
3424
|
+
"""
|
|
3425
|
+
Returns any nonplanar faces in the input topology
|
|
3426
|
+
|
|
3427
|
+
Parameters
|
|
3428
|
+
----------
|
|
3429
|
+
topology : topologic.Topology
|
|
3430
|
+
The input topology.
|
|
3431
|
+
tolerance : float , optional
|
|
3432
|
+
The desired tolerance. The default is 0.0001.
|
|
3433
|
+
Returns
|
|
3434
|
+
-------
|
|
3435
|
+
list
|
|
3436
|
+
The list of nonplanar faces.
|
|
3437
|
+
|
|
3438
|
+
"""
|
|
3439
|
+
if not isinstance(topology, topologic.Topology):
|
|
3440
|
+
return None
|
|
3441
|
+
faces = Topology.SubTopologies(topology, subTopologyType="face")
|
|
3442
|
+
return [f for f in faces if not Topology.IsPlanar(f, tolerance=tolerance)]
|
|
3443
|
+
|
|
3423
3444
|
def OpenFaces(topology):
|
|
3424
3445
|
"""
|
|
3425
3446
|
Returns the faces that border no cells.
|
|
@@ -3713,7 +3734,7 @@ class Topology():
|
|
|
3713
3734
|
returnTopology = topology
|
|
3714
3735
|
elif t == 32: # Cell
|
|
3715
3736
|
try:
|
|
3716
|
-
returnTopology = topologic.Cell.ByFaces(stl_final_faces, tolerance)
|
|
3737
|
+
returnTopology = topologic.Cell.ByFaces(stl_final_faces, tolerance=tolerance)
|
|
3717
3738
|
except:
|
|
3718
3739
|
returnTopology = topology
|
|
3719
3740
|
elif t == 64: #CellComplex
|
|
@@ -3747,7 +3768,7 @@ class Topology():
|
|
|
3747
3768
|
return topology.RemoveContents(contents)
|
|
3748
3769
|
|
|
3749
3770
|
@staticmethod
|
|
3750
|
-
def RemoveCoplanarFaces(topology, angTolerance=0.1, tolerance=0.0001):
|
|
3771
|
+
def RemoveCoplanarFaces(topology, planarize=False, angTolerance=0.1, tolerance=0.0001):
|
|
3751
3772
|
"""
|
|
3752
3773
|
Removes coplanar faces in the input topology
|
|
3753
3774
|
|
|
@@ -3755,6 +3776,8 @@ class Topology():
|
|
|
3755
3776
|
----------
|
|
3756
3777
|
topology : topologic.Topology
|
|
3757
3778
|
The input topology.
|
|
3779
|
+
planarize : bool , optional
|
|
3780
|
+
If set to True, the algorithm will attempt to planarize the final merged faces. Otherwise, it will triangulate any final nonplanar faces. The default is False.
|
|
3758
3781
|
angTolerance : float , optional
|
|
3759
3782
|
The desired angular tolerance for removing coplanar faces. The default is 0.1.
|
|
3760
3783
|
tolerance : float , optional
|
|
@@ -3769,6 +3792,7 @@ class Topology():
|
|
|
3769
3792
|
from topologicpy.Wire import Wire
|
|
3770
3793
|
from topologicpy.Face import Face
|
|
3771
3794
|
from topologicpy.Shell import Shell
|
|
3795
|
+
from topologicpy.Cell import Cell
|
|
3772
3796
|
from topologicpy.Cluster import Cluster
|
|
3773
3797
|
from topologicpy.Topology import Topology
|
|
3774
3798
|
t = topology.Type()
|
|
@@ -3843,15 +3867,17 @@ class Topology():
|
|
|
3843
3867
|
if not returnTopology:
|
|
3844
3868
|
returnTopology = topologic.Cluster.ByTopologies(faces, False)
|
|
3845
3869
|
elif t == 32:
|
|
3846
|
-
|
|
3870
|
+
print("Trying to build a Cell")
|
|
3871
|
+
returnTopology = Cell.ByFaces(faces, planarize=planarize, tolerance=tolerance)
|
|
3847
3872
|
if not returnTopology:
|
|
3873
|
+
print("Failed, trying to build a Shell instead")
|
|
3848
3874
|
returnTopology = topologic.Shell.ByFaces(faces, tolerance)
|
|
3849
3875
|
if not returnTopology:
|
|
3850
3876
|
returnTopology = topologic.Cluster.ByTopologies(faces, False)
|
|
3851
3877
|
elif t == 64:
|
|
3852
3878
|
returnTopology = topologic.CellComplex.ByFaces(faces, tolerance, False)
|
|
3853
3879
|
if not returnTopology:
|
|
3854
|
-
returnTopology =
|
|
3880
|
+
returnTopology = Cell.ByFaces(faces, planarize=planarize, tolerance=tolerance)
|
|
3855
3881
|
if not returnTopology:
|
|
3856
3882
|
returnTopology = topologic.Shell.ByFaces(faces, tolerance)
|
|
3857
3883
|
if not returnTopology:
|
|
@@ -4121,7 +4147,7 @@ class Topology():
|
|
|
4121
4147
|
return {"vertices":vOutput, "edges":eOutput, "wires":wOutput, "faces":fOutput}
|
|
4122
4148
|
|
|
4123
4149
|
@staticmethod
|
|
4124
|
-
def Show(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor='white', faceOpacity=0.5, edgeColor='black', edgeWidth=1, vertexColor='black', vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True, width=950, height=500, xAxis=False, yAxis=False, zAxis=False, backgroundColor='rgba(0,0,0,0)', marginLeft=0, marginRight=0, marginTop=20, marginBottom=0, camera=[1.25, 1.25, 1.25], target=[0, 0, 0], up=[0, 0, 1], renderer="notebook"):
|
|
4150
|
+
def Show(topology, vertexLabelKey=None, vertexGroupKey=None, edgeLabelKey=None, edgeGroupKey=None, faceLabelKey=None, faceGroupKey=None, vertexGroups=[], edgeGroups=[], faceGroups=[], faceColor='white', faceOpacity=0.5, edgeColor='black', edgeWidth=1, vertexColor='black', vertexSize=1.1, showFaces=True, showEdges=True, showVertices=True, width=950, height=500, xAxis=False, yAxis=False, zAxis=False, axisSize=1, backgroundColor='rgba(0,0,0,0)', marginLeft=0, marginRight=0, marginTop=20, marginBottom=0, camera=[1.25, 1.25, 1.25], target=[0, 0, 0], up=[0, 0, 1], renderer="notebook"):
|
|
4125
4151
|
"""
|
|
4126
4152
|
Shows the input topology on screen.
|
|
4127
4153
|
|
|
@@ -4227,7 +4253,7 @@ class Topology():
|
|
|
4227
4253
|
if not isinstance(topology, topologic.Topology):
|
|
4228
4254
|
return None
|
|
4229
4255
|
data = Plotly.DataByTopology(topology=topology, vertexLabelKey=vertexLabelKey, vertexGroupKey=vertexGroupKey, edgeLabelKey=edgeLabelKey, edgeGroupKey=edgeGroupKey, faceLabelKey=faceLabelKey, faceGroupKey=faceGroupKey, vertexGroups=vertexGroups, edgeGroups=edgeGroups, faceGroups=faceGroups, faceColor=faceColor, faceOpacity=faceOpacity, edgeColor=edgeColor, edgeWidth=edgeWidth, vertexColor=vertexColor, vertexSize=vertexSize, showFaces=showFaces, showEdges=showEdges, showVertices=showVertices)
|
|
4230
|
-
figure = Plotly.FigureByData(data=data, width=width, height=height, xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, backgroundColor=backgroundColor, marginLeft=marginLeft, marginRight=marginRight, marginTop=marginTop, marginBottom=marginBottom)
|
|
4256
|
+
figure = Plotly.FigureByData(data=data, width=width, height=height, xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, axisSize=axisSize, backgroundColor=backgroundColor, marginLeft=marginLeft, marginRight=marginRight, marginTop=marginTop, marginBottom=marginBottom)
|
|
4231
4257
|
Plotly.Show(figure=figure, renderer=renderer, camera=camera, target=target, up=up)
|
|
4232
4258
|
|
|
4233
4259
|
@staticmethod
|
|
@@ -4276,7 +4302,7 @@ class Topology():
|
|
|
4276
4302
|
return {"sorted":sortedTopologies, "unsorted":unsortedTopologies}
|
|
4277
4303
|
|
|
4278
4304
|
@staticmethod
|
|
4279
|
-
def Spin(topology, origin=None, triangulate=True,
|
|
4305
|
+
def Spin(topology, origin=None, triangulate=True, direction=[0,0,1], degree=360, sides=16,
|
|
4280
4306
|
tolerance=0.0001):
|
|
4281
4307
|
"""
|
|
4282
4308
|
Spins the input topology around an axis to create a new topology.See https://en.wikipedia.org/wiki/Solid_of_revolution.
|
|
@@ -4289,12 +4315,8 @@ class Topology():
|
|
|
4289
4315
|
The origin (center) of the spin.
|
|
4290
4316
|
triangulate : bool , optional
|
|
4291
4317
|
If set to True, the result will be triangulated. The default is True.
|
|
4292
|
-
|
|
4293
|
-
The
|
|
4294
|
-
dirY : float , optional
|
|
4295
|
-
The 'y' component of the axis (vector) of spin. The default is 0.
|
|
4296
|
-
dirZ : float , optional
|
|
4297
|
-
The 'z' component of the axis (vector) of spin. The default is 1.
|
|
4318
|
+
direction : list , optional
|
|
4319
|
+
The vector representing the direction of the spin axis. The default is [0,0,1].
|
|
4298
4320
|
degree : float , optional
|
|
4299
4321
|
The angle in degrees for the spin. The default is 360.
|
|
4300
4322
|
sides : int , optional
|
|
@@ -4323,7 +4345,7 @@ class Topology():
|
|
|
4323
4345
|
topologies = []
|
|
4324
4346
|
unit_degree = degree / float(sides)
|
|
4325
4347
|
for i in range(sides+1):
|
|
4326
|
-
topologies.append(topologic.TopologyUtility.Rotate(topology, origin,
|
|
4348
|
+
topologies.append(topologic.TopologyUtility.Rotate(topology, origin, direction[0], direction[1], direction[2], unit_degree*i))
|
|
4327
4349
|
returnTopology = None
|
|
4328
4350
|
if topology.Type() == topologic.Vertex.Type():
|
|
4329
4351
|
returnTopology = Wire.ByVertices(topologies, False)
|
|
@@ -4487,6 +4509,7 @@ class Topology():
|
|
|
4487
4509
|
superTopologies = []
|
|
4488
4510
|
|
|
4489
4511
|
if not topologyType:
|
|
4512
|
+
print("Topology.SuperTopologies 4515 - ", topology)
|
|
4490
4513
|
typeID = 2*Topology.TypeID(topology)
|
|
4491
4514
|
else:
|
|
4492
4515
|
typeID = Topology.TypeID(topologyType)
|
|
@@ -4745,6 +4768,34 @@ class Topology():
|
|
|
4745
4768
|
if not isinstance(topology, topologic.Topology):
|
|
4746
4769
|
return None
|
|
4747
4770
|
return topologic.TopologyUtility.Translate(topology, x, y, z)
|
|
4771
|
+
|
|
4772
|
+
@staticmethod
|
|
4773
|
+
def TranslateByDirectionDistance(topology, direction, distance):
|
|
4774
|
+
"""
|
|
4775
|
+
Translates (moves) the input topology along the input direction by the specified distance.
|
|
4776
|
+
|
|
4777
|
+
Parameters
|
|
4778
|
+
----------
|
|
4779
|
+
topology : topologic.topology
|
|
4780
|
+
The input topology.
|
|
4781
|
+
x : float , optional
|
|
4782
|
+
The x translation value. The default is 0.
|
|
4783
|
+
y : float , optional
|
|
4784
|
+
The y translation value. The default is 0.
|
|
4785
|
+
z : float , optional
|
|
4786
|
+
The z translation value. The default is 0.
|
|
4787
|
+
|
|
4788
|
+
Returns
|
|
4789
|
+
-------
|
|
4790
|
+
topologic.Topology
|
|
4791
|
+
The translated topology.
|
|
4792
|
+
|
|
4793
|
+
"""
|
|
4794
|
+
from topologicpy.Vector import Vector
|
|
4795
|
+
if not isinstance(topology, topologic.Topology):
|
|
4796
|
+
return None
|
|
4797
|
+
v = Vector.SetMagnitude(direction, distance)
|
|
4798
|
+
return topologic.TopologyUtility.Translate(topology, v[0], v[1], v[2])
|
|
4748
4799
|
|
|
4749
4800
|
|
|
4750
4801
|
@staticmethod
|
|
@@ -4811,7 +4862,7 @@ class Topology():
|
|
|
4811
4862
|
shell = Topology.TransferDictionariesBySelectors(shell, selectors, tranFaces=True)
|
|
4812
4863
|
return shell
|
|
4813
4864
|
elif t == 32: # Cell
|
|
4814
|
-
cell = Cell.ByFaces(faceTriangles, tolerance)
|
|
4865
|
+
cell = Cell.ByFaces(faceTriangles, tolerance=tolerance)
|
|
4815
4866
|
if transferDictionaries:
|
|
4816
4867
|
cell = Topology.TransferDictionariesBySelectors(cell, selectors, tranFaces=True)
|
|
4817
4868
|
return cell
|
topologicpy/UnitTest.py
CHANGED
|
@@ -24,6 +24,6 @@ assert d == 17.321, "Vertex.Distance. Should be 17.321"
|
|
|
24
24
|
|
|
25
25
|
origin = Vertex.ByCoordinates(0,0,0)
|
|
26
26
|
cc = CellComplex.Prism(origin=origin, width=10, length=10, height=10, uSides=2, vSides=2, wSides=2,
|
|
27
|
-
|
|
27
|
+
direction=[0,0,1], originLocation="Center")
|
|
28
28
|
assert isinstance(cc, topologic.CellComplex), "Vertex.EnclosingCell. Should be topologic.CellComplex"
|
|
29
|
-
EnclosingCell(vertex, topology, exclusive=True, tolerance=0.0001)
|
|
29
|
+
EnclosingCell(vertex, topology, exclusive=True, tolerance=0.0001)
|