topologicpy 0.5.3__py3-none-any.whl → 0.5.5__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 +112 -135
- topologicpy/CellComplex.py +15 -18
- topologicpy/Cluster.py +3 -3
- topologicpy/Color.py +10 -10
- topologicpy/Edge.py +12 -9
- topologicpy/Face.py +189 -44
- topologicpy/Graph.py +639 -69
- topologicpy/Grid.py +9 -9
- topologicpy/Plotly.py +2025 -2025
- topologicpy/Shell.py +42 -43
- topologicpy/Speckle.py +1 -1
- topologicpy/Topology.py +99 -88
- topologicpy/Vector.py +36 -36
- topologicpy/Vertex.py +12 -12
- topologicpy/Wire.py +80 -76
- topologicpy/__init__.py +1 -1
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.5.dist-info}/METADATA +2 -2
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.5.dist-info}/RECORD +21 -21
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.5.dist-info}/LICENSE +0 -0
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.5.dist-info}/WHEEL +0 -0
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.5.dist-info}/top_level.txt +0 -0
topologicpy/Cell.py
CHANGED
@@ -18,22 +18,6 @@ import topologic
|
|
18
18
|
from topologicpy.Wire import Wire
|
19
19
|
from topologicpy.Topology import Topology
|
20
20
|
import math
|
21
|
-
import os
|
22
|
-
import warnings
|
23
|
-
|
24
|
-
try:
|
25
|
-
import numpy as np
|
26
|
-
except:
|
27
|
-
print("Cell - Installing required numpy library.")
|
28
|
-
try:
|
29
|
-
os.system("pip install numpy")
|
30
|
-
except:
|
31
|
-
os.system("pip install numpy --user")
|
32
|
-
try:
|
33
|
-
import numpy as np
|
34
|
-
print("Cell - numpy library installed correctly.")
|
35
|
-
except:
|
36
|
-
warnings.warn("Cell - Error: Could not import numpy.")
|
37
21
|
|
38
22
|
class Cell(Topology):
|
39
23
|
@staticmethod
|
@@ -66,15 +50,15 @@ class Cell(Topology):
|
|
66
50
|
@staticmethod
|
67
51
|
def Box(origin: topologic.Vertex = None,
|
68
52
|
width: float = 1, length: float = 1, height: float = 1,
|
69
|
-
uSides: int = 1, vSides:int = 1, wSides:int = 1,
|
70
|
-
direction: list = [0,0,1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
53
|
+
uSides: int = 1, vSides: int = 1, wSides: int = 1,
|
54
|
+
direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
71
55
|
"""
|
72
56
|
Creates a box.
|
73
57
|
|
74
58
|
Parameters
|
75
59
|
----------
|
76
60
|
origin : topologic.Vertex , optional
|
77
|
-
The origin location of the box. The default is None which results in the box being placed at (0,0,0).
|
61
|
+
The origin location of the box. The default is None which results in the box being placed at (0, 0, 0).
|
78
62
|
width : float , optional
|
79
63
|
The width of the box. The default is 1.
|
80
64
|
length : float , optional
|
@@ -88,7 +72,7 @@ class Cell(Topology):
|
|
88
72
|
wSides : int , optional
|
89
73
|
The number of sides along the height. The default is 1.
|
90
74
|
direction : list , optional
|
91
|
-
The vector representing the up direction of the box. The default is [0,0,1].
|
75
|
+
The vector representing the up direction of the box. The default is [0, 0, 1].
|
92
76
|
placement : str , optional
|
93
77
|
The description of the placement of the origin of the box. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
94
78
|
tolerance : float , optional
|
@@ -179,7 +163,7 @@ class Cell(Topology):
|
|
179
163
|
for f in faceList:
|
180
164
|
centroid = Topology.Centroid(f)
|
181
165
|
n = Face.Normal(f)
|
182
|
-
v = Topology.Translate(centroid, n[0]*0.01,n[1]*0.01,n[2]*0.01)
|
166
|
+
v = Topology.Translate(centroid, n[0]*0.01, n[1]*0.01, n[2]*0.01)
|
183
167
|
if not Vertex.IsInternal(v, cell):
|
184
168
|
finalFaces.append(f)
|
185
169
|
finalFinalFaces = []
|
@@ -226,15 +210,9 @@ class Cell(Topology):
|
|
226
210
|
The created offset topology. WARNING: This method may fail to create a cell if the offset creates self-intersecting faces. Always check the type being returned by this method.
|
227
211
|
|
228
212
|
"""
|
229
|
-
from topologicpy.Vertex import Vertex
|
230
|
-
from topologicpy.Wire import Wire
|
231
213
|
from topologicpy.Face import Face
|
232
|
-
from topologicpy.Cluster import Cluster
|
233
|
-
from topologicpy.Helper import Helper
|
234
214
|
from topologicpy.Topology import Topology
|
235
215
|
from topologicpy.Vector import Vector
|
236
|
-
from operator import add
|
237
|
-
import numpy as np
|
238
216
|
|
239
217
|
vertices = Topology.Vertices(cell)
|
240
218
|
new_vertices = []
|
@@ -334,7 +312,7 @@ class Cell(Topology):
|
|
334
312
|
return Cell.ByFaces(cellFaces, planarize=planarize, tolerance=tolerance)
|
335
313
|
|
336
314
|
@staticmethod
|
337
|
-
def ByThickenedShell(shell: topologic.Shell, direction: list = [0,0,1], thickness: float = 1.0, bothSides: bool = True, reverse: bool = False,
|
315
|
+
def ByThickenedShell(shell: topologic.Shell, direction: list = [0, 0, 1], thickness: float = 1.0, bothSides: bool = True, reverse: bool = False,
|
338
316
|
planarize: bool = False, tolerance: float = 0.0001) -> topologic.Cell:
|
339
317
|
"""
|
340
318
|
Creates a cell by thickening the input shell. The shell must be open.
|
@@ -558,14 +536,14 @@ class Cell(Topology):
|
|
558
536
|
return Cell.ByWires(wires, close=close, triangulate=triangulate, planarize=planarize, tolerance=tolerance)
|
559
537
|
|
560
538
|
@staticmethod
|
561
|
-
def Capsule(origin: topologic.Vertex = None, radius: float = 0.25, height: float = 1, uSides: int = 16, vSidesEnds:int = 8, vSidesMiddle: int = 1, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
539
|
+
def Capsule(origin: topologic.Vertex = None, radius: float = 0.25, height: float = 1, uSides: int = 16, vSidesEnds:int = 8, vSidesMiddle: int = 1, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
562
540
|
"""
|
563
541
|
Creates a capsule shape. A capsule is a cylinder with hemispherical ends.
|
564
542
|
|
565
543
|
Parameters
|
566
544
|
----------
|
567
545
|
origin : topologic.Vertex , optional
|
568
|
-
The location of the origin of the cylinder. The default is None which results in the cylinder being placed at (0,0,0).
|
546
|
+
The location of the origin of the cylinder. The default is None which results in the cylinder being placed at (0, 0, 0).
|
569
547
|
radius : float , optional
|
570
548
|
The radius of the capsule. The default is 0.25.
|
571
549
|
height : float , optional
|
@@ -577,7 +555,7 @@ class Cell(Topology):
|
|
577
555
|
vSidesMiddle : int , optional
|
578
556
|
The number of vertical segments of the middle cylinder. The default is 1.
|
579
557
|
direction : list , optional
|
580
|
-
The vector representing the up direction of the capsule. The default is [0,0,1].
|
558
|
+
The vector representing the up direction of the capsule. The default is [0, 0, 1].
|
581
559
|
placement : str , optional
|
582
560
|
The description of the placement of the origin of the capsule. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "bottom".
|
583
561
|
tolerance : float , optional
|
@@ -593,7 +571,7 @@ class Cell(Topology):
|
|
593
571
|
from topologicpy.Cell import Cell
|
594
572
|
from topologicpy.Vertex import Vertex
|
595
573
|
if not origin:
|
596
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
574
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
597
575
|
if not isinstance(origin, topologic.Vertex):
|
598
576
|
print("Cell.Capsule - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
599
577
|
return None
|
@@ -604,9 +582,9 @@ class Cell(Topology):
|
|
604
582
|
cyl = Cell.Cylinder(origin=Vertex.Origin(),
|
605
583
|
radius=radius,
|
606
584
|
height=cyl_height,
|
607
|
-
uSides=uSides, vSides=vSidesMiddle, direction=[0,0,1], placement="center", tolerance=tolerance)
|
608
|
-
o1 = Vertex.ByCoordinates(0,0,cyl_height*0.5)
|
609
|
-
o2 = Vertex.ByCoordinates(0,0
|
585
|
+
uSides=uSides, vSides=vSidesMiddle, direction=[0, 0, 1], placement="center", tolerance=tolerance)
|
586
|
+
o1 = Vertex.ByCoordinates(0, 0, cyl_height*0.5)
|
587
|
+
o2 = Vertex.ByCoordinates(0, 0, -cyl_height*0.5)
|
610
588
|
s1 = Cell.Sphere(origin=o1, radius=radius, uSides=uSides, vSides=vSidesEnds*2, tolerance=tolerance)
|
611
589
|
s2 = Cell.Sphere(origin=o2, radius=radius, uSides=uSides, vSides=vSidesEnds*2, tolerance=tolerance)
|
612
590
|
capsule = Topology.Union(cyl, s1, tolerance=tolerance)
|
@@ -617,7 +595,7 @@ class Cell(Topology):
|
|
617
595
|
capsule = Topology.Translate(capsule, 0, 0, height/2)
|
618
596
|
capsule = Topology.Translate(capsule, radius, radius)
|
619
597
|
|
620
|
-
capsule = Topology.Orient(capsule, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction)
|
598
|
+
capsule = Topology.Orient(capsule, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction)
|
621
599
|
capsule = Topology.Place(capsule, originA=Vertex.Origin(), originB=origin)
|
622
600
|
return capsule
|
623
601
|
|
@@ -661,7 +639,7 @@ class Cell(Topology):
|
|
661
639
|
return round(compactness, mantissa)
|
662
640
|
|
663
641
|
@staticmethod
|
664
|
-
def Cone(origin: topologic.Vertex = None, baseRadius: float = 0.5, topRadius: float = 0, height: float = 1, uSides: int = 16, vSides: int = 1, direction: list = [0,0,1],
|
642
|
+
def Cone(origin: topologic.Vertex = None, baseRadius: float = 0.5, topRadius: float = 0, height: float = 1, uSides: int = 16, vSides: int = 1, direction: list = [0, 0, 1],
|
665
643
|
dirZ: float = 1, placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
666
644
|
"""
|
667
645
|
Creates a cone.
|
@@ -669,7 +647,7 @@ class Cell(Topology):
|
|
669
647
|
Parameters
|
670
648
|
----------
|
671
649
|
origin : topologic.Vertex , optional
|
672
|
-
The location of the origin of the cone. The default is None which results in the cone being placed at (0,0,0).
|
650
|
+
The location of the origin of the cone. The default is None which results in the cone being placed at (0, 0, 0).
|
673
651
|
baseRadius : float , optional
|
674
652
|
The radius of the base circle of the cone. The default is 0.5.
|
675
653
|
topRadius : float , optional
|
@@ -679,7 +657,7 @@ class Cell(Topology):
|
|
679
657
|
sides : int , optional
|
680
658
|
The number of sides of the cone. The default is 16.
|
681
659
|
direction : list , optional
|
682
|
-
The vector representing the up direction of the cone. The default is [0,0,1].
|
660
|
+
The vector representing the up direction of the cone. The default is [0, 0, 1].
|
683
661
|
placement : str , optional
|
684
662
|
The description of the placement of the origin of the cone. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
685
663
|
tolerance : float , optional
|
@@ -720,7 +698,7 @@ class Cell(Topology):
|
|
720
698
|
faces.append(f)
|
721
699
|
return Cell.ByFaces(faces, tolerance=tolerance)
|
722
700
|
if not origin:
|
723
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
701
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
724
702
|
if not isinstance(origin, topologic.Vertex):
|
725
703
|
print("Cell.Cone - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
726
704
|
return None
|
@@ -779,7 +757,7 @@ class Cell(Topology):
|
|
779
757
|
shell = Cell.Shells(cone)[0]
|
780
758
|
shell = shell.Slice(cutting_planes_cluster)
|
781
759
|
cone = Cell.ByShell(shell)
|
782
|
-
cone = Topology.Orient(cone, origin=origin, dirA=[0,0,1], dirB=direction)
|
760
|
+
cone = Topology.Orient(cone, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
783
761
|
return cone
|
784
762
|
|
785
763
|
@staticmethod
|
@@ -821,7 +799,7 @@ class Cell(Topology):
|
|
821
799
|
return None
|
822
800
|
|
823
801
|
@staticmethod
|
824
|
-
def Cylinder(origin: topologic.Vertex = None, radius: float = 0.5, height: float = 1, uSides: int = 16, vSides:int = 1, direction: list = [0,0,1],
|
802
|
+
def Cylinder(origin: topologic.Vertex = None, radius: float = 0.5, height: float = 1, uSides: int = 16, vSides: int = 1, direction: list = [0, 0, 1],
|
825
803
|
placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
826
804
|
"""
|
827
805
|
Creates a cylinder.
|
@@ -829,7 +807,7 @@ class Cell(Topology):
|
|
829
807
|
Parameters
|
830
808
|
----------
|
831
809
|
origin : topologic.Vertex , optional
|
832
|
-
The location of the origin of the cylinder. The default is None which results in the cylinder being placed at (0,0,0).
|
810
|
+
The location of the origin of the cylinder. The default is None which results in the cylinder being placed at (0, 0, 0).
|
833
811
|
radius : float , optional
|
834
812
|
The radius of the cylinder. The default is 0.5.
|
835
813
|
height : float , optional
|
@@ -839,7 +817,7 @@ class Cell(Topology):
|
|
839
817
|
vSides : int , optional
|
840
818
|
The number of vertical segments of the cylinder. The default is 1.
|
841
819
|
direction : list , optional
|
842
|
-
The vector representing the up direction of the cylinder. The default is [0,0,1].
|
820
|
+
The vector representing the up direction of the cylinder. The default is [0, 0, 1].
|
843
821
|
placement : str , optional
|
844
822
|
The description of the placement of the origin of the cylinder. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "bottom".
|
845
823
|
tolerance : float , optional
|
@@ -857,7 +835,7 @@ class Cell(Topology):
|
|
857
835
|
from topologicpy.Cluster import Cluster
|
858
836
|
from topologicpy.Topology import Topology
|
859
837
|
if not origin:
|
860
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
838
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
861
839
|
if not isinstance(origin, topologic.Vertex):
|
862
840
|
print("Cell.Cylinder - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
863
841
|
return None
|
@@ -871,7 +849,7 @@ class Cell(Topology):
|
|
871
849
|
yOffset = radius
|
872
850
|
circle_origin = Vertex.ByCoordinates(origin.X() + xOffset, origin.Y() + yOffset, origin.Z() + zOffset)
|
873
851
|
|
874
|
-
baseWire = Wire.Circle(origin=circle_origin, radius=radius, sides=uSides, fromAngle=0, toAngle=360, close=True, direction=[0,0,1], placement="center", tolerance=tolerance)
|
852
|
+
baseWire = Wire.Circle(origin=circle_origin, radius=radius, sides=uSides, fromAngle=0, toAngle=360, close=True, direction=[0, 0, 1], placement="center", tolerance=tolerance)
|
875
853
|
baseFace = Face.ByWire(baseWire, tolerance=tolerance)
|
876
854
|
cylinder = Cell.ByThickenedFace(face=baseFace, thickness=height, bothSides=False, reverse=True,
|
877
855
|
tolerance=tolerance)
|
@@ -887,7 +865,7 @@ class Cell(Topology):
|
|
887
865
|
cutting_planes_cluster = Cluster.ByTopologies(cutting_planes)
|
888
866
|
cylinder = CellComplex.ExternalBoundary(cylinder.Slice(cutting_planes_cluster))
|
889
867
|
|
890
|
-
cylinder = Topology.Orient(cylinder, origin=origin, dirA=[0,0,1], dirB=direction)
|
868
|
+
cylinder = Topology.Orient(cylinder, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
891
869
|
return cylinder
|
892
870
|
|
893
871
|
@staticmethod
|
@@ -922,7 +900,6 @@ class Cell(Topology):
|
|
922
900
|
from topologicpy.Vector import Vector
|
923
901
|
from topologicpy.Aperture import Aperture
|
924
902
|
from topologicpy.Topology import Topology
|
925
|
-
from numpy import arctan, pi, signbit, arctan2, rad2deg
|
926
903
|
|
927
904
|
def angleCode(f, up, tiltAngle):
|
928
905
|
dirA = Face.NormalAtParameters(f)
|
@@ -963,7 +940,7 @@ class Cell(Topology):
|
|
963
940
|
zList.append(f.Centroid().Z())
|
964
941
|
zMin = min(zList)
|
965
942
|
zMax = max(zList)
|
966
|
-
up = [0,0,1]
|
943
|
+
up = [0, 0, 1]
|
967
944
|
for aFace in faces:
|
968
945
|
aCode = angleCode(aFace, up, tiltAngle)
|
969
946
|
|
@@ -1001,7 +978,7 @@ class Cell(Topology):
|
|
1001
978
|
|
1002
979
|
@staticmethod
|
1003
980
|
def Dodecahedron(origin: topologic.Vertex = None, radius: float = 0.5,
|
1004
|
-
direction: list = [0,0,1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
981
|
+
direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1005
982
|
"""
|
1006
983
|
Description
|
1007
984
|
----------
|
@@ -1010,11 +987,11 @@ class Cell(Topology):
|
|
1010
987
|
Parameters
|
1011
988
|
----------
|
1012
989
|
origin : topologic.Vertex , optional
|
1013
|
-
The origin location of the dodecahedron. The default is None which results in the dodecahedron being placed at (0,0,0).
|
990
|
+
The origin location of the dodecahedron. The default is None which results in the dodecahedron being placed at (0, 0, 0).
|
1014
991
|
radius : float , optional
|
1015
992
|
The radius of the dodecahedron's circumscribed sphere. The default is 0.5.
|
1016
993
|
direction : list , optional
|
1017
|
-
The vector representing the up direction of the dodecahedron. The default is [0,0,1].
|
994
|
+
The vector representing the up direction of the dodecahedron. The default is [0, 0, 1].
|
1018
995
|
placement : str , optional
|
1019
996
|
The description of the placement of the origin of the dodecahedron. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
1020
997
|
tolerance : float , optional
|
@@ -1033,7 +1010,7 @@ class Cell(Topology):
|
|
1033
1010
|
from topologicpy.Topology import Topology
|
1034
1011
|
|
1035
1012
|
if not origin:
|
1036
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1013
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1037
1014
|
if not isinstance(origin, topologic.Vertex):
|
1038
1015
|
print("Cell.Dodecahedron - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1039
1016
|
return None
|
@@ -1043,12 +1020,12 @@ class Cell(Topology):
|
|
1043
1020
|
for edge in edges:
|
1044
1021
|
o = Topology.Centroid(edge)
|
1045
1022
|
e_dir = Edge.Direction(edge)
|
1046
|
-
pentagons.append(Topology.Rotate(pen, origin=o,
|
1023
|
+
pentagons.append(Topology.Rotate(pen, origin=o, axis=e_dir, angle=116.565))
|
1047
1024
|
|
1048
1025
|
cluster = Cluster.ByTopologies(pentagons)
|
1049
1026
|
|
1050
|
-
cluster2 = Topology.Rotate(cluster, origin=Vertex.Origin(),
|
1051
|
-
cluster2 = Topology.Rotate(cluster2, origin=Vertex.Origin(),
|
1027
|
+
cluster2 = Topology.Rotate(cluster, origin=Vertex.Origin(), axis=[1, 0, 0], angle=180)
|
1028
|
+
cluster2 = Topology.Rotate(cluster2, origin=Vertex.Origin(), axis=[0, 0, 1], angle=36)
|
1052
1029
|
vertices = Topology.Vertices(cluster2)
|
1053
1030
|
zList = [Vertex.Z(v) for v in vertices]
|
1054
1031
|
zList = list(set(zList))
|
@@ -1068,7 +1045,7 @@ class Cell(Topology):
|
|
1068
1045
|
elif placement == "lowerleft":
|
1069
1046
|
dodecahedron = Topology.Translate(dodecahedron, radius, radius, radius)
|
1070
1047
|
|
1071
|
-
dodecahedron = Topology.Orient(dodecahedron, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction, tolerance=tolerance)
|
1048
|
+
dodecahedron = Topology.Orient(dodecahedron, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction, tolerance=tolerance)
|
1072
1049
|
dodecahedron = Topology.Place(dodecahedron, originA=Vertex.Origin(), originB=origin)
|
1073
1050
|
return dodecahedron
|
1074
1051
|
|
@@ -1096,7 +1073,7 @@ class Cell(Topology):
|
|
1096
1073
|
return edges
|
1097
1074
|
|
1098
1075
|
@staticmethod
|
1099
|
-
def Egg(origin: topologic.Vertex = None, height: float = 1.0, uSides: int = 16, vSides: int = 8, direction: list = [0,0,1],
|
1076
|
+
def Egg(origin: topologic.Vertex = None, height: float = 1.0, uSides: int = 16, vSides: int = 8, direction: list = [0, 0, 1],
|
1100
1077
|
placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
1101
1078
|
"""
|
1102
1079
|
Creates a sphere.
|
@@ -1104,7 +1081,7 @@ class Cell(Topology):
|
|
1104
1081
|
Parameters
|
1105
1082
|
----------
|
1106
1083
|
origin : topologic.Vertex , optional
|
1107
|
-
The origin location of the sphere. The default is None which results in the sphere being placed at (0,0,0).
|
1084
|
+
The origin location of the sphere. The default is None which results in the sphere being placed at (0, 0, 0).
|
1108
1085
|
radius : float , optional
|
1109
1086
|
The radius of the sphere. The default is 0.5.
|
1110
1087
|
uSides : int , optional
|
@@ -1112,7 +1089,7 @@ class Cell(Topology):
|
|
1112
1089
|
vSides : int , optional
|
1113
1090
|
The number of sides along the latitude of the sphere. The default is 8.
|
1114
1091
|
direction : list , optional
|
1115
|
-
The vector representing the up direction of the sphere. The default is [0,0,1].
|
1092
|
+
The vector representing the up direction of the sphere. The default is [0, 0, 1].
|
1116
1093
|
placement : str , optional
|
1117
1094
|
The description of the placement of the origin of the sphere. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
1118
1095
|
tolerance : float , optional
|
@@ -1130,7 +1107,7 @@ class Cell(Topology):
|
|
1130
1107
|
from topologicpy.Dictionary import Dictionary
|
1131
1108
|
|
1132
1109
|
if not origin:
|
1133
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1110
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1134
1111
|
if not isinstance(origin, topologic.Vertex):
|
1135
1112
|
print("Cell.Sphere - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1136
1113
|
return None
|
@@ -1161,7 +1138,7 @@ class Cell(Topology):
|
|
1161
1138
|
for i in range(vSides+1):
|
1162
1139
|
new_verts.append(Wire.VertexByParameter(c, i/vSides))
|
1163
1140
|
c = Wire.ByVertices(new_verts, close=False)
|
1164
|
-
egg = Topology.Spin(c, origin=Vertex.Origin(), triangulate=False, direction=[0,0,1],
|
1141
|
+
egg = Topology.Spin(c, origin=Vertex.Origin(), triangulate=False, direction=[0, 0, 1], angle=360, sides=uSides, tolerance=tolerance)
|
1165
1142
|
if egg.Type() == topologic.CellComplex.Type():
|
1166
1143
|
egg = egg.ExternalBoundary()
|
1167
1144
|
if egg.Type() == topologic.Shell.Type():
|
@@ -1175,7 +1152,7 @@ class Cell(Topology):
|
|
1175
1152
|
width = Dictionary.ValueAtKey(d, 'width')
|
1176
1153
|
length = Dictionary.ValueAtKey(d, 'length')
|
1177
1154
|
egg = Topology.Translate(egg, width*0.5, length*0.5, height*0.5)
|
1178
|
-
egg = Topology.Orient(egg, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction)
|
1155
|
+
egg = Topology.Orient(egg, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction)
|
1179
1156
|
egg = Topology.Place(egg, originA=Vertex.Origin(), originB=origin)
|
1180
1157
|
return egg
|
1181
1158
|
|
@@ -1229,7 +1206,7 @@ class Cell(Topology):
|
|
1229
1206
|
return faces
|
1230
1207
|
|
1231
1208
|
@staticmethod
|
1232
|
-
def Hyperboloid(origin: topologic.Cell = None, baseRadius: float = 0.5, topRadius: float = 0.5, height: float = 1, sides: int = 24, direction: list = [0,0,1],
|
1209
|
+
def Hyperboloid(origin: topologic.Cell = None, baseRadius: float = 0.5, topRadius: float = 0.5, height: float = 1, sides: int = 24, direction: list = [0, 0, 1],
|
1233
1210
|
twist: float = 60, placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
1234
1211
|
"""
|
1235
1212
|
Creates a hyperboloid.
|
@@ -1237,7 +1214,7 @@ class Cell(Topology):
|
|
1237
1214
|
Parameters
|
1238
1215
|
----------
|
1239
1216
|
origin : topologic.Vertex , optional
|
1240
|
-
The location of the origin of the hyperboloid. The default is None which results in the hyperboloid being placed at (0,0,0).
|
1217
|
+
The location of the origin of the hyperboloid. The default is None which results in the hyperboloid being placed at (0, 0, 0).
|
1241
1218
|
baseRadius : float , optional
|
1242
1219
|
The radius of the base circle of the hyperboloid. The default is 0.5.
|
1243
1220
|
topRadius : float , optional
|
@@ -1247,7 +1224,7 @@ class Cell(Topology):
|
|
1247
1224
|
sides : int , optional
|
1248
1225
|
The number of sides of the cone. The default is 24.
|
1249
1226
|
direction : list , optional
|
1250
|
-
The vector representing the up direction of the hyperboloid. The default is [0,0,1].
|
1227
|
+
The vector representing the up direction of the hyperboloid. The default is [0, 0, 1].
|
1251
1228
|
twist : float , optional
|
1252
1229
|
The angle to twist the base cylinder. The default is 60.
|
1253
1230
|
placement : str , optional
|
@@ -1291,7 +1268,7 @@ class Cell(Topology):
|
|
1291
1268
|
return returnTopology
|
1292
1269
|
|
1293
1270
|
if not origin:
|
1294
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1271
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1295
1272
|
if not isinstance(origin, topologic.Vertex):
|
1296
1273
|
print("Cell.Hyperboloid - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1297
1274
|
return None
|
@@ -1325,13 +1302,13 @@ class Cell(Topology):
|
|
1325
1302
|
print("Cell.Hyperboloid - Error: Could not create a hyperboloid. Returning None.")
|
1326
1303
|
return None
|
1327
1304
|
|
1328
|
-
hyperboloid = Topology.Orient(hyperboloid, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction, tolerance=tolerance)
|
1305
|
+
hyperboloid = Topology.Orient(hyperboloid, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction, tolerance=tolerance)
|
1329
1306
|
hyperboloid = Topology.Place(hyperboloid, originA=Vertex.Origin(), originB=origin)
|
1330
1307
|
return hyperboloid
|
1331
1308
|
|
1332
1309
|
@staticmethod
|
1333
1310
|
def Icosahedron(origin: topologic.Vertex = None, radius: float = 0.5,
|
1334
|
-
direction: list = [0,0,1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1311
|
+
direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1335
1312
|
"""
|
1336
1313
|
Description
|
1337
1314
|
----------
|
@@ -1340,11 +1317,11 @@ class Cell(Topology):
|
|
1340
1317
|
Parameters
|
1341
1318
|
----------
|
1342
1319
|
origin : topologic.Vertex , optional
|
1343
|
-
The origin location of the icosahedron. The default is None which results in the icosahedron being placed at (0,0,0).
|
1320
|
+
The origin location of the icosahedron. The default is None which results in the icosahedron being placed at (0, 0, 0).
|
1344
1321
|
radius : float , optional
|
1345
1322
|
The radius of the icosahedron's circumscribed sphere. The default is 0.5.
|
1346
1323
|
direction : list , optional
|
1347
|
-
The vector representing the up direction of the icosahedron. The default is [0,0,1].
|
1324
|
+
The vector representing the up direction of the icosahedron. The default is [0, 0, 1].
|
1348
1325
|
placement : str , optional
|
1349
1326
|
The description of the placement of the origin of the icosahedron. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
1350
1327
|
tolerance : float , optional
|
@@ -1363,15 +1340,15 @@ class Cell(Topology):
|
|
1363
1340
|
import math
|
1364
1341
|
|
1365
1342
|
if not origin:
|
1366
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1343
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1367
1344
|
if not isinstance(origin, topologic.Vertex):
|
1368
1345
|
print("Cell.Dodecahedron - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1369
1346
|
return None
|
1370
1347
|
rect1 = Wire.Rectangle(width=(1+math.sqrt(5))/2, length=1)
|
1371
1348
|
rect2 = Wire.Rectangle(width=1, length=(1+math.sqrt(5))/2)
|
1372
|
-
rect2 = Topology.Rotate(rect2,
|
1349
|
+
rect2 = Topology.Rotate(rect2, origin=Vertex.Origin(), axis=[1, 0, 0], angle=90)
|
1373
1350
|
rect3 = Wire.Rectangle(width=1, length=(1+math.sqrt(5))/2)
|
1374
|
-
rect3 = Topology.Rotate(rect3,
|
1351
|
+
rect3 = Topology.Rotate(rect3, origin=Vertex.Origin(), axis=[0, 1, 0], angle=90)
|
1375
1352
|
vertices = Topology.Vertices(rect1)
|
1376
1353
|
v1, v2, v3, v4 = vertices
|
1377
1354
|
vertices = Topology.Vertices(rect2)
|
@@ -1410,7 +1387,7 @@ class Cell(Topology):
|
|
1410
1387
|
elif placement == "lowerleft":
|
1411
1388
|
icosahedron = Topology.Translate(icosahedron, radius, radius, radius)
|
1412
1389
|
|
1413
|
-
icosahedron = Topology.Orient(icosahedron, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction, tolerance=tolerance)
|
1390
|
+
icosahedron = Topology.Orient(icosahedron, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction, tolerance=tolerance)
|
1414
1391
|
icosahedron = Topology.Place(icosahedron, originA=Vertex.Origin(), originB=origin)
|
1415
1392
|
return icosahedron
|
1416
1393
|
|
@@ -1498,7 +1475,7 @@ class Cell(Topology):
|
|
1498
1475
|
|
1499
1476
|
@staticmethod
|
1500
1477
|
def Octahedron(origin: topologic.Vertex = None, radius: float = 0.5,
|
1501
|
-
direction: list = [0,0,1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1478
|
+
direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1502
1479
|
"""
|
1503
1480
|
Description
|
1504
1481
|
----------
|
@@ -1507,11 +1484,11 @@ class Cell(Topology):
|
|
1507
1484
|
Parameters
|
1508
1485
|
----------
|
1509
1486
|
origin : topologic.Vertex , optional
|
1510
|
-
The origin location of the octahedron. The default is None which results in the octahedron being placed at (0,0,0).
|
1487
|
+
The origin location of the octahedron. The default is None which results in the octahedron being placed at (0, 0, 0).
|
1511
1488
|
radius : float , optional
|
1512
1489
|
The radius of the octahedron's circumscribed sphere. The default is 0.5.
|
1513
1490
|
direction : list , optional
|
1514
|
-
The vector representing the up direction of the octahedron. The default is [0,0,1].
|
1491
|
+
The vector representing the up direction of the octahedron. The default is [0, 0, 1].
|
1515
1492
|
placement : str , optional
|
1516
1493
|
The description of the placement of the origin of the octahedron. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
1517
1494
|
tolerance : float , optional
|
@@ -1529,33 +1506,33 @@ class Cell(Topology):
|
|
1529
1506
|
from topologicpy.Topology import Topology
|
1530
1507
|
|
1531
1508
|
if not origin:
|
1532
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1509
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1533
1510
|
if not isinstance(origin, topologic.Vertex):
|
1534
1511
|
print("Cell.Octahedron - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1535
1512
|
return None
|
1536
1513
|
|
1537
|
-
vb1 = Vertex.ByCoordinates(-0.5,0,0)
|
1538
|
-
vb2 = Vertex.ByCoordinates(0
|
1539
|
-
vb3 = Vertex.ByCoordinates(0.5,0,0)
|
1540
|
-
vb4 = Vertex.ByCoordinates(0,0.5,0)
|
1514
|
+
vb1 = Vertex.ByCoordinates(-0.5, 0, 0)
|
1515
|
+
vb2 = Vertex.ByCoordinates(0, -0.5, 0)
|
1516
|
+
vb3 = Vertex.ByCoordinates(0.5, 0, 0)
|
1517
|
+
vb4 = Vertex.ByCoordinates(0, 0.5, 0)
|
1541
1518
|
top = Vertex.ByCoordinates(0, 0, 0.5)
|
1542
1519
|
bottom = Vertex.ByCoordinates(0, 0, -0.5)
|
1543
|
-
f1 = Face.ByVertices([top,vb1,vb2])
|
1544
|
-
f2 = Face.ByVertices([top,vb2,vb3])
|
1545
|
-
f3 = Face.ByVertices([top,vb3,vb4])
|
1546
|
-
f4 = Face.ByVertices([top,vb4,vb1])
|
1547
|
-
f5 = Face.ByVertices([bottom,vb1,vb2])
|
1548
|
-
f6 = Face.ByVertices([bottom,vb2,vb3])
|
1549
|
-
f7 = Face.ByVertices([bottom,vb3,vb4])
|
1550
|
-
f8 = Face.ByVertices([bottom,vb4,vb1])
|
1551
|
-
|
1552
|
-
octahedron = Cell.ByFaces([f1,f2,f3,f4,f5,f6,f7,f8], tolerance=tolerance)
|
1520
|
+
f1 = Face.ByVertices([top, vb1, vb2])
|
1521
|
+
f2 = Face.ByVertices([top, vb2, vb3])
|
1522
|
+
f3 = Face.ByVertices([top, vb3, vb4])
|
1523
|
+
f4 = Face.ByVertices([top, vb4, vb1])
|
1524
|
+
f5 = Face.ByVertices([bottom, vb1, vb2])
|
1525
|
+
f6 = Face.ByVertices([bottom, vb2, vb3])
|
1526
|
+
f7 = Face.ByVertices([bottom, vb3, vb4])
|
1527
|
+
f8 = Face.ByVertices([bottom, vb4, vb1])
|
1528
|
+
|
1529
|
+
octahedron = Cell.ByFaces([f1, f2, f3, f4, f5, f6, f7, f8], tolerance=tolerance)
|
1553
1530
|
octahedron = Topology.Scale(octahedron, origin=Vertex.Origin(), x=radius/0.5, y=radius/0.5, z=radius/0.5)
|
1554
1531
|
if placement == "bottom":
|
1555
1532
|
octahedron = Topology.Translate(octahedron, 0, 0, radius)
|
1556
1533
|
elif placement == "lowerleft":
|
1557
1534
|
octahedron = Topology.Translate(octahedron, radius, radius, radius)
|
1558
|
-
octahedron = Topology.Orient(octahedron, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction)
|
1535
|
+
octahedron = Topology.Orient(octahedron, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction)
|
1559
1536
|
octahedron = Topology.Place(octahedron, originA=Vertex.Origin(), originB=origin)
|
1560
1537
|
return octahedron
|
1561
1538
|
|
@@ -1630,8 +1607,8 @@ class Cell(Topology):
|
|
1630
1607
|
x = math.sin(angle)*radius + sv.X()
|
1631
1608
|
y = math.cos(angle)*radius + sv.Y()
|
1632
1609
|
z = sv.Z()
|
1633
|
-
baseV.append(Vertex.ByCoordinates(x,y,z))
|
1634
|
-
topV.append(Vertex.ByCoordinates(x,y,z+dist))
|
1610
|
+
baseV.append(Vertex.ByCoordinates(x, y, z))
|
1611
|
+
topV.append(Vertex.ByCoordinates(x, y, z+dist))
|
1635
1612
|
|
1636
1613
|
baseWire = Wire.ByVertices(baseV)
|
1637
1614
|
topWire = Wire.ByVertices(topV)
|
@@ -1642,9 +1619,9 @@ class Cell(Topology):
|
|
1642
1619
|
theta = 0
|
1643
1620
|
else:
|
1644
1621
|
theta = math.degrees(math.acos(dz/dist)) # Rotation around Z-Axis
|
1645
|
-
pipe = Topology.Rotate(pipe, sv, 0, 1, 0, theta)
|
1646
|
-
pipe = Topology.Rotate(pipe, sv, 0, 0, 1, phi)
|
1647
|
-
zzz = Vertex.ByCoordinates(0,0,0)
|
1622
|
+
pipe = Topology.Rotate(pipe, origin=sv, axis=[0, 1, 0], angle=theta)
|
1623
|
+
pipe = Topology.Rotate(pipe, origin=sv, axis=[0, 0, 1], angle=phi)
|
1624
|
+
zzz = Vertex.ByCoordinates(0, 0, 0)
|
1648
1625
|
if endcapA:
|
1649
1626
|
origin = edge.StartVertex()
|
1650
1627
|
x1 = origin.X()
|
@@ -1663,8 +1640,8 @@ class Cell(Topology):
|
|
1663
1640
|
else:
|
1664
1641
|
theta = math.degrees(math.acos(dz/dist)) # Rotation around Z-Axis
|
1665
1642
|
endcapA = Topology.Copy(endcapA)
|
1666
|
-
endcapA = Topology.Rotate(endcapA, zzz, 0, 1, 0, theta)
|
1667
|
-
endcapA = Topology.Rotate(endcapA, zzz, 0, 0, 1, phi
|
1643
|
+
endcapA = Topology.Rotate(endcapA, origin=zzz, axis=[0, 1, 0], angle=theta)
|
1644
|
+
endcapA = Topology.Rotate(endcapA, origin=zzz, axis=[0, 0, 1], angle=phi+180)
|
1668
1645
|
endcapA = Topology.Translate(endcapA, origin.X(), origin.Y(), origin.Z())
|
1669
1646
|
if endcapB:
|
1670
1647
|
origin = edge.EndVertex()
|
@@ -1684,14 +1661,14 @@ class Cell(Topology):
|
|
1684
1661
|
else:
|
1685
1662
|
theta = math.degrees(math.acos(dz/dist)) # Rotation around Z-Axis
|
1686
1663
|
endcapB = Topology.Copy(endcapB)
|
1687
|
-
endcapB = Topology.Rotate(endcapB, zzz, 0, 1, 0, theta)
|
1688
|
-
endcapB = Topology.Rotate(endcapB, zzz, 0, 0, 1, phi
|
1664
|
+
endcapB = Topology.Rotate(endcapB, origin=zzz, axis=[0, 1, 0], angle=theta)
|
1665
|
+
endcapB = Topology.Rotate(endcapB, origin=zzz, axis=[0, 0, 1], angle=phi+180)
|
1689
1666
|
endcapB = Topology.Translate(endcapB, origin.X(), origin.Y(), origin.Z())
|
1690
1667
|
return {'pipe': pipe, 'endcapA': endcapA, 'endcapB': endcapB}
|
1691
1668
|
|
1692
1669
|
@staticmethod
|
1693
1670
|
def Prism(origin: topologic.Vertex = None, width: float = 1, length: float = 1, height: float = 1, uSides: int = 1, vSides: int = 1, wSides: int = 1,
|
1694
|
-
direction: list = [0,0,1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1671
|
+
direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1695
1672
|
"""
|
1696
1673
|
Description
|
1697
1674
|
----------
|
@@ -1700,7 +1677,7 @@ class Cell(Topology):
|
|
1700
1677
|
Parameters
|
1701
1678
|
----------
|
1702
1679
|
origin : topologic.Vertex , optional
|
1703
|
-
The origin location of the prism. The default is None which results in the prism being placed at (0,0,0).
|
1680
|
+
The origin location of the prism. The default is None which results in the prism being placed at (0, 0, 0).
|
1704
1681
|
width : float , optional
|
1705
1682
|
The width of the prism. The default is 1.
|
1706
1683
|
length : float , optional
|
@@ -1714,7 +1691,7 @@ class Cell(Topology):
|
|
1714
1691
|
wSides : int , optional
|
1715
1692
|
The number of sides along the height. The default is 1.
|
1716
1693
|
direction : list , optional
|
1717
|
-
The vector representing the up direction of the prism. The default is [0,0,1].
|
1694
|
+
The vector representing the up direction of the prism. The default is [0, 0, 1].
|
1718
1695
|
placement : str , optional
|
1719
1696
|
The description of the placement of the origin of the prism. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
1720
1697
|
tolerance : float , optional
|
@@ -1752,7 +1729,7 @@ class Cell(Topology):
|
|
1752
1729
|
from topologicpy.Topology import Topology
|
1753
1730
|
|
1754
1731
|
if not origin:
|
1755
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1732
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1756
1733
|
if not isinstance(origin, topologic.Vertex):
|
1757
1734
|
print("Cell.Prism - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1758
1735
|
return None
|
@@ -1776,7 +1753,7 @@ class Cell(Topology):
|
|
1776
1753
|
|
1777
1754
|
if uSides > 1 or vSides > 1 or wSides > 1:
|
1778
1755
|
prism = sliceCell(prism, width, length, height, uSides, vSides, wSides)
|
1779
|
-
prism = Topology.Orient(prism, origin=origin, dirA=[0,0,1], dirB=direction, tolerance=tolerance)
|
1756
|
+
prism = Topology.Orient(prism, origin=origin, dirA=[0, 0, 1], dirB=direction, tolerance=tolerance)
|
1780
1757
|
return prism
|
1781
1758
|
|
1782
1759
|
@staticmethod
|
@@ -1811,7 +1788,7 @@ class Cell(Topology):
|
|
1811
1788
|
return Cell.ByFaces(clean_faces, tolerance=tolerance)
|
1812
1789
|
|
1813
1790
|
@staticmethod
|
1814
|
-
def Roof(face,
|
1791
|
+
def Roof(face, angle: float = 45, epsilon: float = 0.01 , tolerance: float = 0.001):
|
1815
1792
|
"""
|
1816
1793
|
Creates a hipped roof through a straight skeleton. This method is contributed by 高熙鹏 xipeng gao <gaoxipeng1998@gmail.com>
|
1817
1794
|
This algorithm depends on the polyskel code which is included in the library. Polyskel code is found at: https://github.com/Botffy/polyskel
|
@@ -1820,7 +1797,7 @@ class Cell(Topology):
|
|
1820
1797
|
----------
|
1821
1798
|
face : topologic.Face
|
1822
1799
|
The input face.
|
1823
|
-
|
1800
|
+
angle : float , optioal
|
1824
1801
|
The desired angle in degrees of the roof. The default is 45.
|
1825
1802
|
epsilon : float , optional
|
1826
1803
|
The desired epsilon (another form of tolerance for distance from plane). The default is 0.01. (This is set to a larger number as it was found to work better)
|
@@ -1837,7 +1814,7 @@ class Cell(Topology):
|
|
1837
1814
|
from topologicpy.Cell import Cell
|
1838
1815
|
from topologicpy.Topology import Topology
|
1839
1816
|
|
1840
|
-
shell = Shell.Roof(face=face,
|
1817
|
+
shell = Shell.Roof(face=face, angle=angle, epsilon=epsilon, tolerance=tolerance)
|
1841
1818
|
faces = Topology.Faces(shell) + [face]
|
1842
1819
|
cell = Cell.ByFaces(faces, tolerance=tolerance)
|
1843
1820
|
if not cell:
|
@@ -1930,7 +1907,7 @@ class Cell(Topology):
|
|
1930
1907
|
return shells
|
1931
1908
|
|
1932
1909
|
@staticmethod
|
1933
|
-
def Sphere(origin: topologic.Vertex = None, radius: float = 0.5, uSides: int = 16, vSides: int = 8, direction: list = [0,0,1],
|
1910
|
+
def Sphere(origin: topologic.Vertex = None, radius: float = 0.5, uSides: int = 16, vSides: int = 8, direction: list = [0, 0, 1],
|
1934
1911
|
placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
1935
1912
|
"""
|
1936
1913
|
Creates a sphere.
|
@@ -1938,7 +1915,7 @@ class Cell(Topology):
|
|
1938
1915
|
Parameters
|
1939
1916
|
----------
|
1940
1917
|
origin : topologic.Vertex , optional
|
1941
|
-
The origin location of the sphere. The default is None which results in the sphere being placed at (0,0,0).
|
1918
|
+
The origin location of the sphere. The default is None which results in the sphere being placed at (0, 0, 0).
|
1942
1919
|
radius : float , optional
|
1943
1920
|
The radius of the sphere. The default is 0.5.
|
1944
1921
|
uSides : int , optional
|
@@ -1946,7 +1923,7 @@ class Cell(Topology):
|
|
1946
1923
|
vSides : int , optional
|
1947
1924
|
The number of sides along the latitude of the sphere. The default is 8.
|
1948
1925
|
direction : list , optional
|
1949
|
-
The vector representing the up direction of the sphere. The default is [0,0,1].
|
1926
|
+
The vector representing the up direction of the sphere. The default is [0, 0, 1].
|
1950
1927
|
placement : str , optional
|
1951
1928
|
The description of the placement of the origin of the sphere. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
1952
1929
|
tolerance : float , optional
|
@@ -1963,13 +1940,13 @@ class Cell(Topology):
|
|
1963
1940
|
from topologicpy.Topology import Topology
|
1964
1941
|
|
1965
1942
|
if not origin:
|
1966
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1943
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1967
1944
|
if not isinstance(origin, topologic.Vertex):
|
1968
1945
|
print("Cell.Sphere - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1969
1946
|
return None
|
1970
1947
|
c = Wire.Circle(origin=Vertex.Origin(), radius=radius, sides=vSides, fromAngle=-90, toAngle=90, close=False, direction=[0, 0, 1], placement="center")
|
1971
|
-
c = Topology.Rotate(c, origin=Vertex.Origin(),
|
1972
|
-
sphere = Topology.Spin(c, origin=Vertex.Origin(), triangulate=False, direction=[0,0,1],
|
1948
|
+
c = Topology.Rotate(c, origin=Vertex.Origin(), axis=[1, 0, 0], angle=90)
|
1949
|
+
sphere = Topology.Spin(c, origin=Vertex.Origin(), triangulate=False, direction=[0, 0, 1], angle=360, sides=uSides, tolerance=tolerance)
|
1973
1950
|
if sphere.Type() == topologic.CellComplex.Type():
|
1974
1951
|
sphere = sphere.ExternalBoundary()
|
1975
1952
|
if sphere.Type() == topologic.Shell.Type():
|
@@ -1978,7 +1955,7 @@ class Cell(Topology):
|
|
1978
1955
|
sphere = Topology.Translate(sphere, 0, 0, radius)
|
1979
1956
|
elif placement.lower() == "lowerleft":
|
1980
1957
|
sphere = Topology.Translate(sphere, radius, radius, radius)
|
1981
|
-
sphere = Topology.Orient(sphere, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction)
|
1958
|
+
sphere = Topology.Orient(sphere, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction)
|
1982
1959
|
sphere = Topology.Place(sphere, originA=Vertex.Origin(), originB=origin)
|
1983
1960
|
return sphere
|
1984
1961
|
|
@@ -2004,7 +1981,7 @@ class Cell(Topology):
|
|
2004
1981
|
|
2005
1982
|
@staticmethod
|
2006
1983
|
def Tetrahedron(origin: topologic.Vertex = None, radius: float = 0.5,
|
2007
|
-
direction: list = [0,0,1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
1984
|
+
direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Cell:
|
2008
1985
|
"""
|
2009
1986
|
Description
|
2010
1987
|
----------
|
@@ -2013,11 +1990,11 @@ class Cell(Topology):
|
|
2013
1990
|
Parameters
|
2014
1991
|
----------
|
2015
1992
|
origin : topologic.Vertex , optional
|
2016
|
-
The origin location of the tetrahedron. The default is None which results in the tetrahedron being placed at (0,0,0).
|
1993
|
+
The origin location of the tetrahedron. The default is None which results in the tetrahedron being placed at (0, 0, 0).
|
2017
1994
|
radius : float , optional
|
2018
1995
|
The radius of the tetrahedron's circumscribed sphere. The default is 0.5.
|
2019
1996
|
direction : list , optional
|
2020
|
-
The vector representing the up direction of the tetrahedron. The default is [0,0,1].
|
1997
|
+
The vector representing the up direction of the tetrahedron. The default is [0, 0, 1].
|
2021
1998
|
placement : str , optional
|
2022
1999
|
The description of the placement of the origin of the tetrahedron. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
2023
2000
|
tolerance : float , optional
|
@@ -2037,7 +2014,7 @@ class Cell(Topology):
|
|
2037
2014
|
import math
|
2038
2015
|
|
2039
2016
|
if not origin:
|
2040
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
2017
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
2041
2018
|
if not isinstance(origin, topologic.Vertex):
|
2042
2019
|
print("Cell.Tetrahedron - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
2043
2020
|
return None
|
@@ -2045,12 +2022,12 @@ class Cell(Topology):
|
|
2045
2022
|
vb1 = Vertex.ByCoordinates(math.sqrt(8/9), 0, -1/3)
|
2046
2023
|
vb2 = Vertex.ByCoordinates(-math.sqrt(2/9), math.sqrt(2/3), -1/3)
|
2047
2024
|
vb3 = Vertex.ByCoordinates(-math.sqrt(2/9), -math.sqrt(2/3), -1/3)
|
2048
|
-
vb4 = Vertex.ByCoordinates(0,0,1)
|
2049
|
-
f1 = Face.ByVertices([vb1,vb2,vb3])
|
2050
|
-
f2 = Face.ByVertices([vb4,vb1,vb2])
|
2051
|
-
f3 = Face.ByVertices([vb4,vb2,vb3])
|
2052
|
-
f4 = Face.ByVertices([vb4,vb3,vb1])
|
2053
|
-
tetrahedron = Cell.ByFaces([f1,f2,f3,f4])
|
2025
|
+
vb4 = Vertex.ByCoordinates(0, 0, 1)
|
2026
|
+
f1 = Face.ByVertices([vb1, vb2, vb3])
|
2027
|
+
f2 = Face.ByVertices([vb4, vb1, vb2])
|
2028
|
+
f3 = Face.ByVertices([vb4, vb2, vb3])
|
2029
|
+
f4 = Face.ByVertices([vb4, vb3, vb1])
|
2030
|
+
tetrahedron = Cell.ByFaces([f1, f2, f3, f4])
|
2054
2031
|
tetrahedron = Topology.Scale(tetrahedron, origin=Vertex.Origin(), x=0.5, y=0.5, z=0.5)
|
2055
2032
|
tetrahedron = Topology.Scale(tetrahedron, origin=Vertex.Origin(), x=radius/0.5, y=radius/0.5, z=radius/0.5)
|
2056
2033
|
|
@@ -2059,18 +2036,18 @@ class Cell(Topology):
|
|
2059
2036
|
elif placement.lower() == "bottom":
|
2060
2037
|
tetrahedron = Topology.Translate(tetrahedron, 0, 0, radius)
|
2061
2038
|
tetrahedron = Topology.Place(tetrahedron, originA=Vertex.Origin(), originB=origin)
|
2062
|
-
tetrahedron = Topology.Orient(tetrahedron, origin=origin, dirA=[0,0,1], dirB=direction, tolerance=tolerance)
|
2039
|
+
tetrahedron = Topology.Orient(tetrahedron, origin=origin, dirA=[0, 0, 1], dirB=direction, tolerance=tolerance)
|
2063
2040
|
return tetrahedron
|
2064
2041
|
|
2065
2042
|
@staticmethod
|
2066
|
-
def Torus(origin: topologic.Vertex = None, majorRadius: float = 0.5, minorRadius: float = 0.125, uSides: int = 16, vSides: int = 8, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
2043
|
+
def Torus(origin: topologic.Vertex = None, majorRadius: float = 0.5, minorRadius: float = 0.125, uSides: int = 16, vSides: int = 8, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Cell:
|
2067
2044
|
"""
|
2068
2045
|
Creates a torus.
|
2069
2046
|
|
2070
2047
|
Parameters
|
2071
2048
|
----------
|
2072
2049
|
origin : topologic.Vertex , optional
|
2073
|
-
The origin location of the torus. The default is None which results in the torus being placed at (0,0,0).
|
2050
|
+
The origin location of the torus. The default is None which results in the torus being placed at (0, 0, 0).
|
2074
2051
|
majorRadius : float , optional
|
2075
2052
|
The major radius of the torus. The default is 0.5.
|
2076
2053
|
minorRadius : float , optional
|
@@ -2080,7 +2057,7 @@ class Cell(Topology):
|
|
2080
2057
|
vSides : int , optional
|
2081
2058
|
The number of sides along the latitude of the torus. The default is 8.
|
2082
2059
|
direction : list , optional
|
2083
|
-
The vector representing the up direction of the torus. The default is [0,0,1].
|
2060
|
+
The vector representing the up direction of the torus. The default is [0, 0, 1].
|
2084
2061
|
placement : str , optional
|
2085
2062
|
The description of the placement of the origin of the torus. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
|
2086
2063
|
tolerance : float , optional
|
@@ -2097,13 +2074,13 @@ class Cell(Topology):
|
|
2097
2074
|
from topologicpy.Topology import Topology
|
2098
2075
|
|
2099
2076
|
if not origin:
|
2100
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
2077
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
2101
2078
|
if not isinstance(origin, topologic.Vertex):
|
2102
2079
|
print("Cell.Torus - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
2103
2080
|
return None
|
2104
2081
|
c = Wire.Circle(origin=Vertex.Origin(), radius=minorRadius, sides=vSides, fromAngle=0, toAngle=360, close=False, direction=[0, 1, 0], placement="center")
|
2105
2082
|
c = Topology.Translate(c, abs(majorRadius-minorRadius), 0, 0)
|
2106
|
-
torus = Topology.Spin(c, origin=Vertex.Origin(), triangulate=False, direction=[0,0,1],
|
2083
|
+
torus = Topology.Spin(c, origin=Vertex.Origin(), triangulate=False, direction=[0, 0, 1], angle=360, sides=uSides, tolerance=tolerance)
|
2107
2084
|
if torus.Type() == topologic.Shell.Type():
|
2108
2085
|
torus = topologic.Cell.ByShell(torus)
|
2109
2086
|
if placement.lower() == "bottom":
|
@@ -2111,7 +2088,7 @@ class Cell(Topology):
|
|
2111
2088
|
elif placement.lower() == "lowerleft":
|
2112
2089
|
torus = Topology.Translate(torus, majorRadius, majorRadius, minorRadius)
|
2113
2090
|
|
2114
|
-
torus = Topology.Orient(torus, origin=Vertex.Origin(), dirA=[0,0,1], dirB=direction)
|
2091
|
+
torus = Topology.Orient(torus, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction)
|
2115
2092
|
torus = Topology.Place(torus, originA=Vertex.Origin(), originB=origin)
|
2116
2093
|
return torus
|
2117
2094
|
|