topologicpy 0.5.3__py3-none-any.whl → 0.5.4__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 -112
- topologicpy/CellComplex.py +15 -15
- topologicpy/Cluster.py +3 -3
- topologicpy/Color.py +10 -10
- topologicpy/Edge.py +12 -9
- topologicpy/Face.py +32 -30
- topologicpy/Graph.py +29 -29
- topologicpy/Grid.py +9 -9
- topologicpy/Plotly.py +29 -29
- topologicpy/Shell.py +42 -43
- topologicpy/Speckle.py +1 -1
- topologicpy/Topology.py +58 -62
- 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.4.dist-info}/METADATA +1 -1
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.4.dist-info}/RECORD +21 -21
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.4.dist-info}/LICENSE +0 -0
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.4.dist-info}/WHEEL +0 -0
- {topologicpy-0.5.3.dist-info → topologicpy-0.5.4.dist-info}/top_level.txt +0 -0
topologicpy/Vertex.py
CHANGED
@@ -380,10 +380,10 @@ class Vertex(Topology):
|
|
380
380
|
x = round(vertex.X(), mantissa)
|
381
381
|
y = round(vertex.Y(), mantissa)
|
382
382
|
z = round(vertex.Z(), mantissa)
|
383
|
-
matrix = [[1,0,0,x],
|
384
|
-
[0,1,0,y],
|
385
|
-
[0,0,1,z],
|
386
|
-
[0,0,0,1]]
|
383
|
+
matrix = [[1, 0, 0, x],
|
384
|
+
[0, 1, 0, y],
|
385
|
+
[0, 0, 1, z],
|
386
|
+
[0, 0, 0, 1]]
|
387
387
|
output = []
|
388
388
|
outputType = outputType.lower()
|
389
389
|
if outputType == "matrix":
|
@@ -526,7 +526,7 @@ class Vertex(Topology):
|
|
526
526
|
def distance_to_vertex(vertexA, vertexB):
|
527
527
|
a = (Vertex.X(vertexA), Vertex.Y(vertexA), Vertex.Z(vertexA))
|
528
528
|
b = (Vertex.X(vertexB), Vertex.Y(vertexB), Vertex.Z(vertexB))
|
529
|
-
return distance_point_to_point(a,b)
|
529
|
+
return distance_point_to_point(a, b)
|
530
530
|
|
531
531
|
def distance_to_edge(vertex, edge):
|
532
532
|
a = (Vertex.X(vertex), Vertex.Y(vertex), Vertex.Z(vertex))
|
@@ -1290,7 +1290,7 @@ class Vertex(Topology):
|
|
1290
1290
|
@staticmethod
|
1291
1291
|
def Origin() -> topologic.Vertex:
|
1292
1292
|
"""
|
1293
|
-
Returns a vertex with coordinates (0,0,0)
|
1293
|
+
Returns a vertex with coordinates (0, 0, 0)
|
1294
1294
|
|
1295
1295
|
Parameters
|
1296
1296
|
-----------
|
@@ -1299,10 +1299,10 @@ class Vertex(Topology):
|
|
1299
1299
|
-----------
|
1300
1300
|
topologic.Vertex
|
1301
1301
|
"""
|
1302
|
-
return Vertex.ByCoordinates(0,0,0)
|
1302
|
+
return Vertex.ByCoordinates(0, 0, 0)
|
1303
1303
|
|
1304
1304
|
@staticmethod
|
1305
|
-
def PerpendicularDistance(vertex: topologic.Vertex, face: topologic.Face, mantissa: int=
|
1305
|
+
def PerpendicularDistance(vertex: topologic.Vertex, face: topologic.Face, mantissa: int = 6):
|
1306
1306
|
"""
|
1307
1307
|
Returns the perpendicular distance between the input vertex and the input face. The face is considered to be infinite.
|
1308
1308
|
|
@@ -1394,7 +1394,7 @@ class Vertex(Topology):
|
|
1394
1394
|
Return
|
1395
1395
|
-----------
|
1396
1396
|
dict
|
1397
|
-
The dictionary containing the values of a,b,c,d for the plane equation in the form of ax+by+cz+d=0.
|
1397
|
+
The dictionary containing the values of a, b, c, d for the plane equation in the form of ax+by+cz+d=0.
|
1398
1398
|
The keys in the dictionary are ["a", "b", "c". "d"]
|
1399
1399
|
"""
|
1400
1400
|
|
@@ -1449,7 +1449,7 @@ class Vertex(Topology):
|
|
1449
1449
|
topologic.Vertex
|
1450
1450
|
"""
|
1451
1451
|
|
1452
|
-
return Vertex.ByCoordinates(x,y,z)
|
1452
|
+
return Vertex.ByCoordinates(x, y, z)
|
1453
1453
|
|
1454
1454
|
@staticmethod
|
1455
1455
|
def Project(vertex: topologic.Vertex, face: topologic.Face, direction: bool = None, mantissa: int = 6) -> topologic.Vertex:
|
@@ -1465,7 +1465,7 @@ class Vertex(Topology):
|
|
1465
1465
|
direction : vector, optional
|
1466
1466
|
The direction in which to project the input vertex unto the input face. If not specified, the direction of the projection is the normal of the input face. The default is None.
|
1467
1467
|
mantissa : int , optional
|
1468
|
-
The length of the desired mantissa. The default is
|
1468
|
+
The length of the desired mantissa. The default is 6.
|
1469
1469
|
tolerance : float , optional
|
1470
1470
|
The desired tolerance. The default is 0.0001.
|
1471
1471
|
|
@@ -1513,7 +1513,7 @@ class Vertex(Topology):
|
|
1513
1513
|
if not isinstance(face, topologic.Face):
|
1514
1514
|
return None
|
1515
1515
|
eq = Face.PlaneEquation(face, mantissa= mantissa)
|
1516
|
-
if direction == None:
|
1516
|
+
if direction == None or direction == []:
|
1517
1517
|
direction = Face.Normal(face)
|
1518
1518
|
pt = project_point_onto_plane(Vertex.Coordinates(vertex), [eq["a"], eq["b"], eq["c"], eq["d"]], direction)
|
1519
1519
|
return Vertex.ByCoordinates(pt[0], pt[1], pt[2])
|
topologicpy/Wire.py
CHANGED
@@ -125,9 +125,9 @@ class Wire(Topology):
|
|
125
125
|
print("Wire.Arc - Error: The endVertex parameter is not a valid vertex. Returning None.")
|
126
126
|
return None
|
127
127
|
if Vertex.AreCollinear([startVertex, middleVertex, endVertex], tolerance = tolerance):
|
128
|
-
return Wire.ByVertices([startVertex,middleVertex,endVertex], close=False)
|
128
|
+
return Wire.ByVertices([startVertex, middleVertex, endVertex], close=False)
|
129
129
|
|
130
|
-
w = Wire.ByVertices([startVertex,middleVertex,endVertex], close=False)
|
130
|
+
w = Wire.ByVertices([startVertex, middleVertex, endVertex], close=False)
|
131
131
|
f = Face.ByWire(w, tolerance=tolerance)
|
132
132
|
normal = Face.Normal(f)
|
133
133
|
flat_w = Topology.Flatten(w, origin=startVertex, direction=normal)
|
@@ -224,7 +224,7 @@ class Wire(Topology):
|
|
224
224
|
if optimize > 0:
|
225
225
|
factor = (round(((11 - optimize)/30 + 0.57), 2))
|
226
226
|
flag = False
|
227
|
-
for n in range(10,0
|
227
|
+
for n in range(10, 0, -1):
|
228
228
|
if flag:
|
229
229
|
break
|
230
230
|
za = n
|
@@ -233,7 +233,7 @@ class Wire(Topology):
|
|
233
233
|
for z in range(za,zb,zc):
|
234
234
|
if flag:
|
235
235
|
break
|
236
|
-
t = Topology.Rotate(topology, origin=origin,
|
236
|
+
t = Topology.Rotate(topology, origin=origin, axis=[0, 0, 1], angle=z)
|
237
237
|
minX, minY, maxX, maxY = br(t)
|
238
238
|
w = abs(maxX - minX)
|
239
239
|
l = abs(maxY - minY)
|
@@ -259,7 +259,7 @@ class Wire(Topology):
|
|
259
259
|
vb4 = topologic.Vertex.ByCoordinates(minX, maxY, 0)
|
260
260
|
|
261
261
|
boundingRectangle = Wire.ByVertices([vb1, vb2, vb3, vb4], close=True)
|
262
|
-
boundingRectangle = Topology.Rotate(boundingRectangle, origin=origin,
|
262
|
+
boundingRectangle = Topology.Rotate(boundingRectangle, origin=origin, axis=[0, 0, 1], angle=-best_z)
|
263
263
|
boundingRectangle = Topology.Unflatten(boundingRectangle, origin=f_origin, direction=normal)
|
264
264
|
dictionary = Dictionary.ByKeysValues(["zrot"], [best_z])
|
265
265
|
boundingRectangle = Topology.SetDictionary(boundingRectangle, dictionary)
|
@@ -600,14 +600,14 @@ class Wire(Topology):
|
|
600
600
|
return Wire.ByVertices(vertices, close)
|
601
601
|
|
602
602
|
@staticmethod
|
603
|
-
def Circle(origin: topologic.Vertex = None, radius: float = 0.5, sides: int = 16, fromAngle: float = 0.0, toAngle: float = 360.0, close: bool = True, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
603
|
+
def Circle(origin: topologic.Vertex = None, radius: float = 0.5, sides: int = 16, fromAngle: float = 0.0, toAngle: float = 360.0, close: bool = True, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
604
604
|
"""
|
605
605
|
Creates a circle.
|
606
606
|
|
607
607
|
Parameters
|
608
608
|
----------
|
609
609
|
origin : topologic.Vertex , optional
|
610
|
-
The location of the origin of the circle. The default is None which results in the circle being placed at (0,0,0).
|
610
|
+
The location of the origin of the circle. The default is None which results in the circle being placed at (0, 0, 0).
|
611
611
|
radius : float , optional
|
612
612
|
The radius of the circle. The default is 0.5.
|
613
613
|
sides : int , optional
|
@@ -619,7 +619,7 @@ class Wire(Topology):
|
|
619
619
|
close : bool , optional
|
620
620
|
If set to True, arcs will be closed by connecting the last vertex to the first vertex. Otherwise, they will be left open.
|
621
621
|
direction : list , optional
|
622
|
-
The vector representing the up direction of the circle. The default is [0,0,1].
|
622
|
+
The vector representing the up direction of the circle. The default is [0, 0, 1].
|
623
623
|
placement : str , optional
|
624
624
|
The description of the placement of the origin of the circle. This can be "center", "lowerleft", "upperleft", "lowerright", or "upperright". It is case insensitive. The default is "center".
|
625
625
|
tolerance : float , optional
|
@@ -635,7 +635,7 @@ class Wire(Topology):
|
|
635
635
|
from topologicpy.Topology import Topology
|
636
636
|
|
637
637
|
if not origin:
|
638
|
-
origin = topologic.Vertex.ByCoordinates(0,0,0)
|
638
|
+
origin = topologic.Vertex.ByCoordinates(0, 0, 0)
|
639
639
|
if not isinstance(origin, topologic.Vertex):
|
640
640
|
return None
|
641
641
|
if not placement.lower() in ["center", "lowerleft", "upperleft", "lowerright", "upperright"]:
|
@@ -665,7 +665,7 @@ class Wire(Topology):
|
|
665
665
|
z = origin.Z()
|
666
666
|
xList.append(x)
|
667
667
|
yList.append(y)
|
668
|
-
baseV.append(Vertex.ByCoordinates(x,y,z))
|
668
|
+
baseV.append(Vertex.ByCoordinates(x, y, z))
|
669
669
|
|
670
670
|
if angleRange == 360:
|
671
671
|
baseWire = Wire.ByVertices(baseV[::-1], close=False) #reversing the list so that the normal points up in Blender
|
@@ -680,8 +680,8 @@ class Wire(Topology):
|
|
680
680
|
baseWire = Topology.Translate(baseWire, -radius, radius, 0)
|
681
681
|
elif placement.lower() == "upperright":
|
682
682
|
baseWire = Topology.Translate(baseWire, -radius, -radius, 0)
|
683
|
-
if direction != [0,0,1]:
|
684
|
-
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0,0,1], dirB=direction)
|
683
|
+
if direction != [0, 0, 1]:
|
684
|
+
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
685
685
|
return baseWire
|
686
686
|
|
687
687
|
@staticmethod
|
@@ -1025,18 +1025,18 @@ class Wire(Topology):
|
|
1025
1025
|
return edges
|
1026
1026
|
|
1027
1027
|
@staticmethod
|
1028
|
-
def Einstein(origin: topologic.Vertex = None, radius: float = 0.5, direction: list = [0,0,1], placement: str = "center") -> topologic.Wire:
|
1028
|
+
def Einstein(origin: topologic.Vertex = None, radius: float = 0.5, direction: list = [0, 0, 1], placement: str = "center") -> topologic.Wire:
|
1029
1029
|
"""
|
1030
1030
|
Creates an aperiodic monotile, also called an 'einstein' tile (meaning one tile in German, not the name of the famous physist). See https://arxiv.org/abs/2303.10798
|
1031
1031
|
|
1032
1032
|
Parameters
|
1033
1033
|
----------
|
1034
1034
|
origin : topologic.Vertex , optional
|
1035
|
-
The location of the origin of the tile. The default is None which results in the tiles first vertex being placed at (0,0,0).
|
1035
|
+
The location of the origin of the tile. The default is None which results in the tiles first vertex being placed at (0, 0, 0).
|
1036
1036
|
radius : float , optional
|
1037
1037
|
The radius of the hexagon determining the size of the tile. The default is 0.5.
|
1038
1038
|
direction : list , optional
|
1039
|
-
The vector representing the up direction of the ellipse. The default is [0,0,1].
|
1039
|
+
The vector representing the up direction of the ellipse. The default is [0, 0, 1].
|
1040
1040
|
placement : str , optional
|
1041
1041
|
The description of the placement of the origin of the hexagon determining the location of the tile. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
1042
1042
|
|
@@ -1049,9 +1049,9 @@ class Wire(Topology):
|
|
1049
1049
|
def sin(angle):
|
1050
1050
|
return math.sin(math.radians(angle))
|
1051
1051
|
if not origin:
|
1052
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
1052
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
1053
1053
|
d = cos(30)*radius
|
1054
|
-
v1 = Vertex.ByCoordinates(0,0,0)
|
1054
|
+
v1 = Vertex.ByCoordinates(0, 0, 0)
|
1055
1055
|
v2 = Vertex.ByCoordinates(cos(30)*d, sin(30)*d, 0)
|
1056
1056
|
v3 = Vertex.ByCoordinates(radius, 0)
|
1057
1057
|
v4 = Vertex.ByCoordinates(2*radius, 0)
|
@@ -1072,19 +1072,19 @@ class Wire(Topology):
|
|
1072
1072
|
dy = Vertex.Y(origin)
|
1073
1073
|
dz = Vertex.Z(origin)
|
1074
1074
|
einstein = Topology.Translate(einstein, dx, dy, dz)
|
1075
|
-
if direction != [0,0,1]:
|
1076
|
-
einstein = Topology.Orient(einstein, origin=origin, dirA=[0,0,1], dirB=direction)
|
1075
|
+
if direction != [0, 0, 1]:
|
1076
|
+
einstein = Topology.Orient(einstein, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
1077
1077
|
return einstein
|
1078
1078
|
|
1079
1079
|
@staticmethod
|
1080
|
-
def Ellipse(origin: topologic.Vertex = None, inputMode: int = 1, width: float = 2.0, length: float = 1.0, focalLength: float = 0.866025, eccentricity: float = 0.866025, majorAxisLength: float = 1.0, minorAxisLength: float = 0.5, sides: float = 32, fromAngle: float = 0.0, toAngle: float = 360.0, close: bool = True, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
1080
|
+
def Ellipse(origin: topologic.Vertex = None, inputMode: int = 1, width: float = 2.0, length: float = 1.0, focalLength: float = 0.866025, eccentricity: float = 0.866025, majorAxisLength: float = 1.0, minorAxisLength: float = 0.5, sides: float = 32, fromAngle: float = 0.0, toAngle: float = 360.0, close: bool = True, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
1081
1081
|
"""
|
1082
1082
|
Creates an ellipse and returns all its geometry and parameters.
|
1083
1083
|
|
1084
1084
|
Parameters
|
1085
1085
|
----------
|
1086
1086
|
origin : topologic.Vertex , optional
|
1087
|
-
The location of the origin of the ellipse. The default is None which results in the ellipse being placed at (0,0,0).
|
1087
|
+
The location of the origin of the ellipse. The default is None which results in the ellipse being placed at (0, 0, 0).
|
1088
1088
|
inputMode : int , optional
|
1089
1089
|
The method by wich the ellipse is defined. The default is 1.
|
1090
1090
|
Based on the inputMode value, only the following inputs will be considered. The options are:
|
@@ -1113,7 +1113,7 @@ class Wire(Topology):
|
|
1113
1113
|
close : bool , optional
|
1114
1114
|
If set to True, arcs will be closed by connecting the last vertex to the first vertex. Otherwise, they will be left open.
|
1115
1115
|
direction : list , optional
|
1116
|
-
The vector representing the up direction of the ellipse. The default is [0,0,1].
|
1116
|
+
The vector representing the up direction of the ellipse. The default is [0, 0, 1].
|
1117
1117
|
placement : str , optional
|
1118
1118
|
The description of the placement of the origin of the ellipse. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
1119
1119
|
tolerance : float , optional
|
@@ -1129,14 +1129,14 @@ class Wire(Topology):
|
|
1129
1129
|
return ellipseAll["ellipse"]
|
1130
1130
|
|
1131
1131
|
@staticmethod
|
1132
|
-
def EllipseAll(origin: topologic.Vertex = None, inputMode: int = 1, width: float = 2.0, length: float = 1.0, focalLength: float = 0.866025, eccentricity: float = 0.866025, majorAxisLength: float = 1.0, minorAxisLength: float = 0.5, sides: int = 32, fromAngle: float = 0.0, toAngle: float = 360.0, close: bool = True, direction: list = [0,0,1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Wire:
|
1132
|
+
def EllipseAll(origin: topologic.Vertex = None, inputMode: int = 1, width: float = 2.0, length: float = 1.0, focalLength: float = 0.866025, eccentricity: float = 0.866025, majorAxisLength: float = 1.0, minorAxisLength: float = 0.5, sides: int = 32, fromAngle: float = 0.0, toAngle: float = 360.0, close: bool = True, direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001) -> topologic.Wire:
|
1133
1133
|
"""
|
1134
1134
|
Creates an ellipse and returns all its geometry and parameters.
|
1135
1135
|
|
1136
1136
|
Parameters
|
1137
1137
|
----------
|
1138
1138
|
origin : topologic.Vertex , optional
|
1139
|
-
The location of the origin of the ellipse. The default is None which results in the ellipse being placed at (0,0,0).
|
1139
|
+
The location of the origin of the ellipse. The default is None which results in the ellipse being placed at (0, 0, 0).
|
1140
1140
|
inputMode : int , optional
|
1141
1141
|
The method by wich the ellipse is defined. The default is 1.
|
1142
1142
|
Based on the inputMode value, only the following inputs will be considered. The options are:
|
@@ -1165,7 +1165,7 @@ class Wire(Topology):
|
|
1165
1165
|
close : bool , optional
|
1166
1166
|
If set to True, arcs will be closed by connecting the last vertex to the first vertex. Otherwise, they will be left open.
|
1167
1167
|
direction : list , optional
|
1168
|
-
The vector representing the up direction of the ellipse. The default is [0,0,1].
|
1168
|
+
The vector representing the up direction of the ellipse. The default is [0, 0, 1].
|
1169
1169
|
placement : str , optional
|
1170
1170
|
The description of the placement of the origin of the ellipse. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
1171
1171
|
tolerance : float , optional
|
@@ -1188,10 +1188,10 @@ class Wire(Topology):
|
|
1188
1188
|
from topologicpy.Topology import Topology
|
1189
1189
|
|
1190
1190
|
if not origin:
|
1191
|
-
origin = topologic.Vertex.ByCoordinates(0,0,0)
|
1191
|
+
origin = topologic.Vertex.ByCoordinates(0, 0, 0)
|
1192
1192
|
if not isinstance(origin, topologic.Vertex):
|
1193
1193
|
return None
|
1194
|
-
if inputMode not in [1,2,3,4]:
|
1194
|
+
if inputMode not in [1, 2, 3, 4]:
|
1195
1195
|
return None
|
1196
1196
|
if placement.lower() not in ["center", "lowerleft"]:
|
1197
1197
|
return None
|
@@ -1256,7 +1256,7 @@ class Wire(Topology):
|
|
1256
1256
|
z = origin.Z()
|
1257
1257
|
xList.append(x)
|
1258
1258
|
yList.append(y)
|
1259
|
-
baseV.append(topologic.Vertex.ByCoordinates(x,y,z))
|
1259
|
+
baseV.append(topologic.Vertex.ByCoordinates(x, y, z))
|
1260
1260
|
|
1261
1261
|
if angleRange == 360:
|
1262
1262
|
baseWire = Wire.ByVertices(baseV[::-1], close=False) #reversing the list so that the normal points up in Blender
|
@@ -1265,14 +1265,14 @@ class Wire(Topology):
|
|
1265
1265
|
|
1266
1266
|
if placement.lower() == "lowerleft":
|
1267
1267
|
baseWire = Topology.Translate(baseWire, a, b, 0)
|
1268
|
-
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0,0,1], dirB=direction)
|
1268
|
+
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
1269
1269
|
# Create a Cluster of the two foci
|
1270
|
-
v1 = topologic.Vertex.ByCoordinates(c+origin.X(), 0+origin.Y(),0)
|
1271
|
-
v2 = topologic.Vertex.ByCoordinates(-c+origin.X(), 0+origin.Y(),0)
|
1270
|
+
v1 = topologic.Vertex.ByCoordinates(c+origin.X(), 0+origin.Y(), 0)
|
1271
|
+
v2 = topologic.Vertex.ByCoordinates(-c+origin.X(), 0+origin.Y(), 0)
|
1272
1272
|
foci = topologic.Cluster.ByTopologies([v1, v2])
|
1273
1273
|
if placement.lower() == "lowerleft":
|
1274
1274
|
foci = Topology.Translate(foci, a, b, 0)
|
1275
|
-
foci = Topology.Orient(foci, origin=origin, dirA=[0,0,1], dirB=direction)
|
1275
|
+
foci = Topology.Orient(foci, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
1276
1276
|
d = {}
|
1277
1277
|
d['ellipse'] = baseWire
|
1278
1278
|
d['foci'] = foci
|
@@ -1294,7 +1294,7 @@ class Wire(Topology):
|
|
1294
1294
|
return ev
|
1295
1295
|
|
1296
1296
|
@staticmethod
|
1297
|
-
def ExteriorAngles(wire: topologic.Wire, mantissa: int = 6) -> list:
|
1297
|
+
def ExteriorAngles(wire: topologic.Wire, tolerance: float = 0.0001, mantissa: int = 6) -> list:
|
1298
1298
|
"""
|
1299
1299
|
Returns the exterior angles of the input wire in degrees. The wire must be planar, manifold, and closed.
|
1300
1300
|
|
@@ -1302,11 +1302,15 @@ class Wire(Topology):
|
|
1302
1302
|
----------
|
1303
1303
|
wire : topologic.Wire
|
1304
1304
|
The input wire.
|
1305
|
+
tolerance : float , optional
|
1306
|
+
The desired tolerance. The default is 0.0001.
|
1307
|
+
mantissa : int , optional
|
1308
|
+
The length of the desired mantissa. The default is 6.
|
1305
1309
|
|
1306
1310
|
Returns
|
1307
1311
|
-------
|
1308
1312
|
list
|
1309
|
-
The list of
|
1313
|
+
The list of exterior angles.
|
1310
1314
|
"""
|
1311
1315
|
|
1312
1316
|
if not isinstance(wire, topologic.Wire):
|
@@ -1319,7 +1323,7 @@ class Wire(Topology):
|
|
1319
1323
|
print("Wire.InteriorAngles - Error: The input wire parameter is not closed. Returning None")
|
1320
1324
|
return None
|
1321
1325
|
|
1322
|
-
interior_angles = Wire.InteriorAngles(wire)
|
1326
|
+
interior_angles = Wire.InteriorAngles(wire, mantissa=mantissa)
|
1323
1327
|
exterior_angles = [round(360-a, mantissa) for a in interior_angles]
|
1324
1328
|
return exterior_angles
|
1325
1329
|
|
@@ -1816,18 +1820,18 @@ class Wire(Topology):
|
|
1816
1820
|
return totalLength
|
1817
1821
|
|
1818
1822
|
@staticmethod
|
1819
|
-
def Line(origin: topologic.Vertex = None, length: float = 1, direction: list = [1,0,0], sides: int = 2, placement: str ="center") -> topologic.Wire:
|
1823
|
+
def Line(origin: topologic.Vertex = None, length: float = 1, direction: list = [1, 0, 0], sides: int = 2, placement: str ="center") -> topologic.Wire:
|
1820
1824
|
"""
|
1821
1825
|
Creates a straight line wire using the input parameters.
|
1822
1826
|
|
1823
1827
|
Parameters
|
1824
1828
|
----------
|
1825
1829
|
origin : topologic.Vertex , optional
|
1826
|
-
The origin location of the box. The default is None which results in the edge being placed at (0,0,0).
|
1830
|
+
The origin location of the box. The default is None which results in the edge being placed at (0, 0, 0).
|
1827
1831
|
length : float , optional
|
1828
1832
|
The desired length of the edge. The default is 1.0.
|
1829
1833
|
direction : list , optional
|
1830
|
-
The desired direction (vector) of the edge. The default is [1,0,0] (along the X-axis).
|
1834
|
+
The desired direction (vector) of the edge. The default is [1, 0, 0] (along the X-axis).
|
1831
1835
|
sides : int , optional
|
1832
1836
|
The desired number of sides/segments. The minimum number of sides is 2. The default is 2.
|
1833
1837
|
placement : str , optional
|
@@ -2052,20 +2056,20 @@ class Wire(Topology):
|
|
2052
2056
|
return w
|
2053
2057
|
|
2054
2058
|
@staticmethod
|
2055
|
-
def Rectangle(origin: topologic.Vertex = None, width: float = 1.0, length: float = 1.0, direction: list = [0,0,1], placement: str = "center", angTolerance: float = 0.1, tolerance: float = 0.0001) -> topologic.Wire:
|
2059
|
+
def Rectangle(origin: topologic.Vertex = None, width: float = 1.0, length: float = 1.0, direction: list = [0, 0, 1], placement: str = "center", angTolerance: float = 0.1, tolerance: float = 0.0001) -> topologic.Wire:
|
2056
2060
|
"""
|
2057
2061
|
Creates a rectangle.
|
2058
2062
|
|
2059
2063
|
Parameters
|
2060
2064
|
----------
|
2061
2065
|
origin : topologic.Vertex , optional
|
2062
|
-
The location of the origin of the rectangle. The default is None which results in the rectangle being placed at (0,0,0).
|
2066
|
+
The location of the origin of the rectangle. The default is None which results in the rectangle being placed at (0, 0, 0).
|
2063
2067
|
width : float , optional
|
2064
2068
|
The width of the rectangle. The default is 1.0.
|
2065
2069
|
length : float , optional
|
2066
2070
|
The length of the rectangle. The default is 1.0.
|
2067
2071
|
direction : list , optional
|
2068
|
-
The vector representing the up direction of the rectangle. The default is [0,0,1].
|
2072
|
+
The vector representing the up direction of the rectangle. The default is [0, 0, 1].
|
2069
2073
|
placement : str , optional
|
2070
2074
|
The description of the placement of the origin of the rectangle. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
|
2071
2075
|
angTolerance : float , optional
|
@@ -2082,7 +2086,7 @@ class Wire(Topology):
|
|
2082
2086
|
from topologicpy.Vertex import Vertex
|
2083
2087
|
from topologicpy.Topology import Topology
|
2084
2088
|
if not origin:
|
2085
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
2089
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
2086
2090
|
if not isinstance(origin, topologic.Vertex):
|
2087
2091
|
print("Wire.Rectangle - Error: specified origin is not a topologic vertex. Retruning None.")
|
2088
2092
|
return None
|
@@ -2118,8 +2122,8 @@ class Wire(Topology):
|
|
2118
2122
|
vb4 = Vertex.ByCoordinates(origin.X()-width*0.5+xOffset,origin.Y()+length*0.5+yOffset,origin.Z())
|
2119
2123
|
|
2120
2124
|
baseWire = Wire.ByVertices([vb1, vb2, vb3, vb4], True)
|
2121
|
-
if direction != [0,0,1]:
|
2122
|
-
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0,0,1], dirB=direction)
|
2125
|
+
if direction != [0, 0, 1]:
|
2126
|
+
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
2123
2127
|
return baseWire
|
2124
2128
|
|
2125
2129
|
@staticmethod
|
@@ -2250,7 +2254,7 @@ class Wire(Topology):
|
|
2250
2254
|
new_wire = Wire.ByVertices(vertices, close=Wire.IsClosed(wire), tolerance=tolerance)
|
2251
2255
|
return new_wire
|
2252
2256
|
|
2253
|
-
def Roof(face,
|
2257
|
+
def Roof(face, angle: float = 45, tolerance: float = 0.001):
|
2254
2258
|
"""
|
2255
2259
|
Creates a hipped roof through a straight skeleton. This method is contributed by 高熙鹏 xipeng gao <gaoxipeng1998@gmail.com>
|
2256
2260
|
This algorithm depends on the polyskel code which is included in the library. Polyskel code is found at: https://github.com/Botffy/polyskel
|
@@ -2259,7 +2263,7 @@ class Wire(Topology):
|
|
2259
2263
|
----------
|
2260
2264
|
face : topologic.Face
|
2261
2265
|
The input face.
|
2262
|
-
|
2266
|
+
angle : float , optioal
|
2263
2267
|
The desired angle in degrees of the roof. The default is 45.
|
2264
2268
|
tolerance : float , optional
|
2265
2269
|
The desired tolerance. The default is 0.001. (This is set to a larger number as it was found to work better)
|
@@ -2317,7 +2321,7 @@ class Wire(Topology):
|
|
2317
2321
|
edges.append(e)
|
2318
2322
|
return edges
|
2319
2323
|
|
2320
|
-
def face_to_skeleton(face,
|
2324
|
+
def face_to_skeleton(face, angle=0):
|
2321
2325
|
normal = Face.Normal(face)
|
2322
2326
|
eb_wire = Face.ExternalBoundary(face)
|
2323
2327
|
ib_wires = Face.InternalBoundaries(face)
|
@@ -2338,7 +2342,7 @@ class Wire(Topology):
|
|
2338
2342
|
ib_polygonsxy.append(ib_polygonxy)
|
2339
2343
|
zero_coordinates += ib_polygon_coordinates
|
2340
2344
|
skeleton = Polyskel.skeletonize(eb_polygonxy, ib_polygonsxy)
|
2341
|
-
slope = math.tan(math.radians(
|
2345
|
+
slope = math.tan(math.radians(angle))
|
2342
2346
|
roofEdges = subtrees_to_edges(skeleton, zero_coordinates, slope)
|
2343
2347
|
roofEdges = Helper.Flatten(roofEdges)+Topology.Edges(face)
|
2344
2348
|
roofTopology = Topology.SelfMerge(Cluster.ByTopologies(roofEdges), tolerance=tolerance)
|
@@ -2346,14 +2350,14 @@ class Wire(Topology):
|
|
2346
2350
|
|
2347
2351
|
if not isinstance(face, topologic.Face):
|
2348
2352
|
return None
|
2349
|
-
|
2350
|
-
if
|
2353
|
+
angle = abs(angle)
|
2354
|
+
if angle >= 90-tolerance:
|
2351
2355
|
return None
|
2352
2356
|
origin = Topology.Centroid(face)
|
2353
2357
|
normal = Face.Normal(face)
|
2354
2358
|
flat_face = Topology.Flatten(face, origin=origin, direction=normal)
|
2355
2359
|
d = Topology.Dictionary(flat_face)
|
2356
|
-
roof = face_to_skeleton(flat_face,
|
2360
|
+
roof = face_to_skeleton(flat_face, angle)
|
2357
2361
|
if not roof:
|
2358
2362
|
return None
|
2359
2363
|
roof = Topology.Unflatten(roof, origin=origin, direction=normal)
|
@@ -2381,17 +2385,17 @@ class Wire(Topology):
|
|
2381
2385
|
"""
|
2382
2386
|
if not isinstance(face, topologic.Face):
|
2383
2387
|
return None
|
2384
|
-
return Wire.Roof(face,
|
2388
|
+
return Wire.Roof(face, angle=0, tolerance=tolerance)
|
2385
2389
|
|
2386
2390
|
@staticmethod
|
2387
|
-
def Spiral(origin : topologic.Vertex = None, radiusA : float = 0.05, radiusB : float = 0.5, height : float = 1, turns : int = 10, sides : int = 36, clockwise : bool = False, reverse : bool = False, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2391
|
+
def Spiral(origin : topologic.Vertex = None, radiusA : float = 0.05, radiusB : float = 0.5, height : float = 1, turns : int = 10, sides : int = 36, clockwise : bool = False, reverse : bool = False, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2388
2392
|
"""
|
2389
2393
|
Creates a spiral.
|
2390
2394
|
|
2391
2395
|
Parameters
|
2392
2396
|
----------
|
2393
2397
|
origin : topologic.Vertex , optional
|
2394
|
-
The location of the origin of the spiral. The default is None which results in the spiral being placed at (0,0,0).
|
2398
|
+
The location of the origin of the spiral. The default is None which results in the spiral being placed at (0, 0, 0).
|
2395
2399
|
radiusA : float , optional
|
2396
2400
|
The initial radius of the spiral. The default is 0.05.
|
2397
2401
|
radiusB : float , optional
|
@@ -2407,7 +2411,7 @@ class Wire(Topology):
|
|
2407
2411
|
reverse : bool , optional
|
2408
2412
|
If set to True, the spiral will increase in height from the center to the circumference. Otherwise, it will increase in height from the conference to the center. The default is False.
|
2409
2413
|
direction : list , optional
|
2410
|
-
The vector representing the up direction of the spiral. The default is [0,0,1].
|
2414
|
+
The vector representing the up direction of the spiral. The default is [0, 0, 1].
|
2411
2415
|
placement : str , optional
|
2412
2416
|
The description of the placement of the origin of the spiral. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
|
2413
2417
|
|
@@ -2422,7 +2426,7 @@ class Wire(Topology):
|
|
2422
2426
|
import math
|
2423
2427
|
|
2424
2428
|
if not origin:
|
2425
|
-
origin = topologic.Vertex.ByCoordinates(0,0,0)
|
2429
|
+
origin = topologic.Vertex.ByCoordinates(0, 0, 0)
|
2426
2430
|
if not isinstance(origin, topologic.Vertex):
|
2427
2431
|
print("Wire.Spiral - Error: the input origin is not a valid topologic Vertex. Returning None.")
|
2428
2432
|
return None
|
@@ -2480,7 +2484,7 @@ class Wire(Topology):
|
|
2480
2484
|
z = z - zOffset
|
2481
2485
|
else:
|
2482
2486
|
z = z + zOffset
|
2483
|
-
vertices.append(Vertex.ByCoordinates(x,y,z))
|
2487
|
+
vertices.append(Vertex.ByCoordinates(x, y, z))
|
2484
2488
|
ang = ang + angOffset
|
2485
2489
|
|
2486
2490
|
minX = min(xList)
|
@@ -2499,8 +2503,8 @@ class Wire(Topology):
|
|
2499
2503
|
baseWire = Topology.Translate(baseWire, -maxX, -minY, 0)
|
2500
2504
|
elif placement.lower() == "upperright":
|
2501
2505
|
baseWire = Topology.Translate(baseWire, -maxX, -maxY, 0)
|
2502
|
-
if direction != [0,0,1]:
|
2503
|
-
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0,0,1], dirB=direction)
|
2506
|
+
if direction != [0, 0, 1]:
|
2507
|
+
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
2504
2508
|
return baseWire
|
2505
2509
|
|
2506
2510
|
@staticmethod
|
@@ -2582,18 +2586,18 @@ class Wire(Topology):
|
|
2582
2586
|
return wires
|
2583
2587
|
|
2584
2588
|
@staticmethod
|
2585
|
-
def Square(origin: topologic.Vertex = None, size: float = 1.0, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2589
|
+
def Square(origin: topologic.Vertex = None, size: float = 1.0, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2586
2590
|
"""
|
2587
2591
|
Creates a square.
|
2588
2592
|
|
2589
2593
|
Parameters
|
2590
2594
|
----------
|
2591
2595
|
origin : topologic.Vertex , optional
|
2592
|
-
The location of the origin of the square. The default is None which results in the square being placed at (0,0,0).
|
2596
|
+
The location of the origin of the square. The default is None which results in the square being placed at (0, 0, 0).
|
2593
2597
|
size : float , optional
|
2594
2598
|
The size of the square. The default is 1.0.
|
2595
2599
|
direction : list , optional
|
2596
|
-
The vector representing the up direction of the square. The default is [0,0,1].
|
2600
|
+
The vector representing the up direction of the square. The default is [0, 0, 1].
|
2597
2601
|
placement : str , optional
|
2598
2602
|
The description of the placement of the origin of the square. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
|
2599
2603
|
tolerance : float , optional
|
@@ -2608,14 +2612,14 @@ class Wire(Topology):
|
|
2608
2612
|
return Wire.Rectangle(origin=origin, width=size, length=size, direction=direction, placement=placement, tolerance=tolerance)
|
2609
2613
|
|
2610
2614
|
@staticmethod
|
2611
|
-
def Star(origin: topologic.Wire = None, radiusA: float = 0.5, radiusB: float = 0.2, rays: int = 8, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2615
|
+
def Star(origin: topologic.Wire = None, radiusA: float = 0.5, radiusB: float = 0.2, rays: int = 8, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2612
2616
|
"""
|
2613
2617
|
Creates a star.
|
2614
2618
|
|
2615
2619
|
Parameters
|
2616
2620
|
----------
|
2617
2621
|
origin : topologic.Vertex , optional
|
2618
|
-
The location of the origin of the star. The default is None which results in the star being placed at (0,0,0).
|
2622
|
+
The location of the origin of the star. The default is None which results in the star being placed at (0, 0, 0).
|
2619
2623
|
radiusA : float , optional
|
2620
2624
|
The outer radius of the star. The default is 1.0.
|
2621
2625
|
radiusB : float , optional
|
@@ -2623,7 +2627,7 @@ class Wire(Topology):
|
|
2623
2627
|
rays : int , optional
|
2624
2628
|
The number of star rays. The default is 8.
|
2625
2629
|
direction : list , optional
|
2626
|
-
The vector representing the up direction of the star. The default is [0,0,1].
|
2630
|
+
The vector representing the up direction of the star. The default is [0, 0, 1].
|
2627
2631
|
placement : str , optional
|
2628
2632
|
The description of the placement of the origin of the star. This can be "center", "lowerleft", "upperleft", "lowerright", or "upperright". It is case insensitive. The default is "center".
|
2629
2633
|
tolerance : float , optional
|
@@ -2638,7 +2642,7 @@ class Wire(Topology):
|
|
2638
2642
|
from topologicpy.Topology import Topology
|
2639
2643
|
|
2640
2644
|
if not origin:
|
2641
|
-
origin = topologic.Vertex.ByCoordinates(0,0,0)
|
2645
|
+
origin = topologic.Vertex.ByCoordinates(0, 0, 0)
|
2642
2646
|
if not isinstance(origin, topologic.Vertex):
|
2643
2647
|
return None
|
2644
2648
|
radiusA = abs(radiusA)
|
@@ -2666,7 +2670,7 @@ class Wire(Topology):
|
|
2666
2670
|
z = origin.Z()
|
2667
2671
|
xList.append(x)
|
2668
2672
|
yList.append(y)
|
2669
|
-
baseV.append([x,y])
|
2673
|
+
baseV.append([x, y])
|
2670
2674
|
|
2671
2675
|
if placement.lower() == "lowerleft":
|
2672
2676
|
xmin = min(xList)
|
@@ -2696,8 +2700,8 @@ class Wire(Topology):
|
|
2696
2700
|
tranBase.append(topologic.Vertex.ByCoordinates(coord[0]+xOffset, coord[1]+yOffset, origin.Z()))
|
2697
2701
|
|
2698
2702
|
baseWire = Wire.ByVertices(tranBase[::-1], True) #reversing the list so that the normal points up in Blender
|
2699
|
-
if direction != [0,0,1]:
|
2700
|
-
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0,0,1], dirB=direction)
|
2703
|
+
if direction != [0, 0, 1]:
|
2704
|
+
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
2701
2705
|
return baseWire
|
2702
2706
|
|
2703
2707
|
@staticmethod
|
@@ -2740,14 +2744,14 @@ class Wire(Topology):
|
|
2740
2744
|
return sv
|
2741
2745
|
|
2742
2746
|
@staticmethod
|
2743
|
-
def Trapezoid(origin: topologic.Vertex = None, widthA: float = 1.0, widthB: float = 0.75, offsetA: float = 0.0, offsetB: float = 0.0, length: float = 1.0, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2747
|
+
def Trapezoid(origin: topologic.Vertex = None, widthA: float = 1.0, widthB: float = 0.75, offsetA: float = 0.0, offsetB: float = 0.0, length: float = 1.0, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Wire:
|
2744
2748
|
"""
|
2745
2749
|
Creates a trapezoid.
|
2746
2750
|
|
2747
2751
|
Parameters
|
2748
2752
|
----------
|
2749
2753
|
origin : topologic.Vertex , optional
|
2750
|
-
The location of the origin of the trapezoid. The default is None which results in the trapezoid being placed at (0,0,0).
|
2754
|
+
The location of the origin of the trapezoid. The default is None which results in the trapezoid being placed at (0, 0, 0).
|
2751
2755
|
widthA : float , optional
|
2752
2756
|
The width of the bottom edge of the trapezoid. The default is 1.0.
|
2753
2757
|
widthB : float , optional
|
@@ -2759,7 +2763,7 @@ class Wire(Topology):
|
|
2759
2763
|
length : float , optional
|
2760
2764
|
The length of the trapezoid. The default is 1.0.
|
2761
2765
|
direction : list , optional
|
2762
|
-
The vector representing the up direction of the trapezoid. The default is [0,0,1].
|
2766
|
+
The vector representing the up direction of the trapezoid. The default is [0, 0, 1].
|
2763
2767
|
placement : str , optional
|
2764
2768
|
The description of the placement of the origin of the trapezoid. This can be "center", or "lowerleft". It is case insensitive. The default is "center".
|
2765
2769
|
tolerance : float , optional
|
@@ -2774,7 +2778,7 @@ class Wire(Topology):
|
|
2774
2778
|
from topologicpy.Topology import Topology
|
2775
2779
|
|
2776
2780
|
if not origin:
|
2777
|
-
origin = topologic.Vertex.ByCoordinates(0,0,0)
|
2781
|
+
origin = topologic.Vertex.ByCoordinates(0, 0, 0)
|
2778
2782
|
if not isinstance(origin, topologic.Vertex):
|
2779
2783
|
return None
|
2780
2784
|
widthA = abs(widthA)
|
@@ -2808,8 +2812,8 @@ class Wire(Topology):
|
|
2808
2812
|
vb4 = topologic.Vertex.ByCoordinates(origin.X()-widthB*0.5++offsetB+xOffset,origin.Y()+length*0.5+yOffset,origin.Z())
|
2809
2813
|
|
2810
2814
|
baseWire = Wire.ByVertices([vb1, vb2, vb3, vb4], True)
|
2811
|
-
if direction != [0,0,1]:
|
2812
|
-
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0,0,1], dirB=direction)
|
2815
|
+
if direction != [0, 0, 1]:
|
2816
|
+
baseWire = Topology.Orient(baseWire, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
2813
2817
|
return baseWire
|
2814
2818
|
|
2815
2819
|
@staticmethod
|
@@ -2978,7 +2982,7 @@ class Wire(Topology):
|
|
2978
2982
|
print("Wire.VertexAtParameter - Error: The input wire parameter is not a valid topologic wire. Returning None.")
|
2979
2983
|
return None
|
2980
2984
|
if u < 0 or u > 1:
|
2981
|
-
print("Wire.VertexAtParameter - Error: The input u parameter is not within the valid range of [0,1]. Returning None.")
|
2985
|
+
print("Wire.VertexAtParameter - Error: The input u parameter is not within the valid range of [0, 1]. Returning None.")
|
2982
2986
|
return None
|
2983
2987
|
if not Wire.IsManifold(wire):
|
2984
2988
|
print("Wire.VertexAtParameter - Error: The input wire parameter is non-manifold. Returning None.")
|