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/Topology.py
CHANGED
@@ -1044,7 +1044,7 @@ class Topology():
|
|
1044
1044
|
if diff1 == None:
|
1045
1045
|
return topologyA
|
1046
1046
|
else:
|
1047
|
-
return Topology.Difference(topologyA,diff1)
|
1047
|
+
return Topology.Difference(topologyA, diff1)
|
1048
1048
|
elif isinstance(topologyB, topologic.CellComplex):
|
1049
1049
|
cells = Topology.Cells(topologyB)
|
1050
1050
|
intersections = []
|
@@ -1373,7 +1373,7 @@ class Topology():
|
|
1373
1373
|
@staticmethod
|
1374
1374
|
def BoundingBox(topology, optimize=0, axes="xyz", tolerance=0.0001):
|
1375
1375
|
"""
|
1376
|
-
Returns a cell representing a bounding box of the input topology. The returned cell contains a dictionary with keys "xrot", "yrot", and "zrot" that represents rotations around the X,Y, and Z axes. If applied in the order of Z,Y,
|
1376
|
+
Returns a cell representing a bounding box of the input topology. The returned cell contains a dictionary with keys "xrot", "yrot", and "zrot" that represents rotations around the X, Y, and Z axes. If applied in the order of Z, Y, X, the resulting box will become axis-aligned.
|
1377
1377
|
|
1378
1378
|
Parameters
|
1379
1379
|
----------
|
@@ -1451,7 +1451,7 @@ class Topology():
|
|
1451
1451
|
if optimize > 0:
|
1452
1452
|
factor = (round(((11 - optimize)/30 + 0.57), 2))
|
1453
1453
|
flag = False
|
1454
|
-
for n in range(10,0
|
1454
|
+
for n in range(10, 0, -1):
|
1455
1455
|
if flag:
|
1456
1456
|
break
|
1457
1457
|
if x_flag:
|
@@ -1487,9 +1487,9 @@ class Topology():
|
|
1487
1487
|
for z in range(za,zb,zc):
|
1488
1488
|
if flag:
|
1489
1489
|
break
|
1490
|
-
t = Topology.Rotate(topology, origin=origin,
|
1491
|
-
t = Topology.Rotate(t, origin=origin,
|
1492
|
-
t = Topology.Rotate(t, origin=origin,
|
1490
|
+
t = Topology.Rotate(topology, origin=origin, axis=[0, 0, 1], angle=z)
|
1491
|
+
t = Topology.Rotate(t, origin=origin, axis=[0, 1, 0], angle=y)
|
1492
|
+
t = Topology.Rotate(t, origin=origin, axis=[1, 0, 0], angle=x)
|
1493
1493
|
minX, minY, minZ, maxX, maxY, maxZ = bb(t)
|
1494
1494
|
w = abs(maxX - minX)
|
1495
1495
|
l = abs(maxY - minY)
|
@@ -1525,9 +1525,9 @@ class Topology():
|
|
1525
1525
|
box = baseFace
|
1526
1526
|
else:
|
1527
1527
|
box = Cell.ByThickenedFace(baseFace, planarize=False, thickness=abs(maxZ-minZ), bothSides=False)
|
1528
|
-
box = Topology.Rotate(box, origin=origin,
|
1529
|
-
box = Topology.Rotate(box, origin=origin,
|
1530
|
-
box = Topology.Rotate(box, origin=origin,
|
1528
|
+
box = Topology.Rotate(box, origin=origin, axis=[1, 0, 0], angle=-best_x)
|
1529
|
+
box = Topology.Rotate(box, origin=origin, axis=[0, 1, 0], angle=-best_y)
|
1530
|
+
box = Topology.Rotate(box, origin=origin, axis=[0, 0, 1], angle=-best_z)
|
1531
1531
|
dictionary = Dictionary.ByKeysValues(["xrot","yrot","zrot", "minx", "miny", "minz", "maxx", "maxy", "maxz", "width", "length", "height"], [best_x, best_y, best_z, minX, minY, minZ, maxX, maxY, maxZ, (maxX-minX), (maxY-minY), (maxZ-minZ)])
|
1532
1532
|
box = Topology.SetDictionary(box, dictionary)
|
1533
1533
|
return box
|
@@ -1564,7 +1564,7 @@ class Topology():
|
|
1564
1564
|
return st
|
1565
1565
|
|
1566
1566
|
@staticmethod
|
1567
|
-
def ByGeometry(vertices=[], edges=[], faces=[], color=[1.0,1.0,1.0,1.0], id=None, name=None, lengthUnit="METERS", outputMode="default", tolerance=0.0001):
|
1567
|
+
def ByGeometry(vertices=[], edges=[], faces=[], color=[1.0, 1.0, 1.0, 1.0], id=None, name=None, lengthUnit="METERS", outputMode="default", tolerance=0.0001):
|
1568
1568
|
"""
|
1569
1569
|
Create a topology by the input lists of vertices, edges, and faces.
|
1570
1570
|
|
@@ -1717,7 +1717,7 @@ class Topology():
|
|
1717
1717
|
color = list(color[0])
|
1718
1718
|
values.append(color)
|
1719
1719
|
else:
|
1720
|
-
values.append([1.0,1.0,1.0,1.0])
|
1720
|
+
values.append([1.0, 1.0, 1.0, 1.0])
|
1721
1721
|
if id:
|
1722
1722
|
values.append(id)
|
1723
1723
|
else:
|
@@ -1834,7 +1834,7 @@ class Topology():
|
|
1834
1834
|
keys = []
|
1835
1835
|
values = []
|
1836
1836
|
keys.append("TOPOLOGIC_color")
|
1837
|
-
values.append([1.0,1.0,1.0,1.0])
|
1837
|
+
values.append([1.0, 1.0, 1.0, 1.0])
|
1838
1838
|
keys.append("TOPOLOGIC_id")
|
1839
1839
|
values.append(str(uuid.uuid4()))
|
1840
1840
|
keys.append("TOPOLOGIC_name")
|
@@ -2062,7 +2062,7 @@ class Topology():
|
|
2062
2062
|
def buildVertex(json_item):
|
2063
2063
|
x, y, z = json_item['coordinates']
|
2064
2064
|
d = json_item['dictionary']
|
2065
|
-
v = Vertex.ByCoordinates(x,y,z)
|
2065
|
+
v = Vertex.ByCoordinates(x, y, z)
|
2066
2066
|
if v == None:
|
2067
2067
|
print("Topology.ByJSONString - Error: Could not build a vertex. Returning None.")
|
2068
2068
|
return None
|
@@ -2510,7 +2510,7 @@ class Topology():
|
|
2510
2510
|
if vertices or faces:
|
2511
2511
|
topology = Topology.ByGeometry(vertices = vertices, faces = faces, outputMode="default", tolerance=tolerance)
|
2512
2512
|
if transposeAxes == True:
|
2513
|
-
topology = Topology.Rotate(topology, Vertex.Origin(), 1,0,0,90)
|
2513
|
+
topology = Topology.Rotate(topology, origin=Vertex.Origin(), axis=[1, 0, 0], angle=90)
|
2514
2514
|
return Topology.SelfMerge(topology)
|
2515
2515
|
print("Topology.ByOBJString - Error: Could not find vertices or faces. Returning None.")
|
2516
2516
|
return None
|
@@ -2916,7 +2916,7 @@ class Topology():
|
|
2916
2916
|
for i in range(len(matrix)):
|
2917
2917
|
for j in range(len(matrix)):
|
2918
2918
|
if collinear(samples[i], samples[j], tol):
|
2919
|
-
matrix[i,j] = 1
|
2919
|
+
matrix[i, j] = 1
|
2920
2920
|
return matrix
|
2921
2921
|
|
2922
2922
|
def determineRow(matrix):
|
@@ -2959,8 +2959,8 @@ class Topology():
|
|
2959
2959
|
|
2960
2960
|
def deleteChosenRowsAndCols(matrix, indexes):
|
2961
2961
|
for i in indexes:
|
2962
|
-
matrix[i
|
2963
|
-
matrix[:,i] = 0
|
2962
|
+
matrix[i, :] = 0
|
2963
|
+
matrix[:, i] = 0
|
2964
2964
|
return matrix
|
2965
2965
|
if not isinstance(topology, topologic.Topology):
|
2966
2966
|
print("Topology.ClusterFaces - Error: the input topology parameter is not a valid topology. Returning None.")
|
@@ -3099,7 +3099,7 @@ class Topology():
|
|
3099
3099
|
return returnObject
|
3100
3100
|
|
3101
3101
|
@staticmethod
|
3102
|
-
def Copy(topology):
|
3102
|
+
def Copy(topology, deep=False):
|
3103
3103
|
"""
|
3104
3104
|
Returns a copy of the input topology
|
3105
3105
|
|
@@ -3107,6 +3107,8 @@ class Topology():
|
|
3107
3107
|
----------
|
3108
3108
|
topology : topologic.Topology
|
3109
3109
|
The input topology.
|
3110
|
+
deep : bool , optional
|
3111
|
+
If set to True, a deep copy will be performed (this is slow). Othwerwise, it will not. The default is False
|
3110
3112
|
|
3111
3113
|
Returns
|
3112
3114
|
-------
|
@@ -3114,10 +3116,18 @@ class Topology():
|
|
3114
3116
|
A copy of the input topology.
|
3115
3117
|
|
3116
3118
|
"""
|
3119
|
+
from topologicpy.Dictionary import Dictionary
|
3117
3120
|
if not isinstance(topology, topologic.Topology):
|
3118
3121
|
print("Topology.Copy - Error: the input topology parameter is not a valid topology. Returning None.")
|
3119
3122
|
return None
|
3120
|
-
|
3123
|
+
if deep:
|
3124
|
+
return Topology.ByJSONString(Topology.JSONString([topology]), progressBar=False)
|
3125
|
+
d = Topology.Dictionary(topology)
|
3126
|
+
return_topology = Topology.ByBREPString(Topology.BREPString(topology))
|
3127
|
+
keys = Dictionary.Keys(d)
|
3128
|
+
if len(keys) > 0:
|
3129
|
+
return_topology = Topology.SetDictionary(return_topology, d)
|
3130
|
+
return return_topology
|
3121
3131
|
|
3122
3132
|
@staticmethod
|
3123
3133
|
def Dictionary(topology):
|
@@ -4119,7 +4129,7 @@ class Topology():
|
|
4119
4129
|
return {"filtered": filteredTopologies, "other": otherTopologies}
|
4120
4130
|
|
4121
4131
|
@staticmethod
|
4122
|
-
def Flatten(topology, origin=None, direction=[0,0,1]):
|
4132
|
+
def Flatten(topology, origin=None, direction=[0, 0, 1]):
|
4123
4133
|
"""
|
4124
4134
|
Flattens the input topology such that the input origin is located at the world origin and the input topology is rotated such that the input vector is pointed in the Up direction (see Vector.Up()).
|
4125
4135
|
|
@@ -4192,7 +4202,7 @@ class Topology():
|
|
4192
4202
|
|
4193
4203
|
def triangulateFace(face):
|
4194
4204
|
faceTriangles = []
|
4195
|
-
for i in range(0,5,1):
|
4205
|
+
for i in range(0, 5, 1):
|
4196
4206
|
try:
|
4197
4207
|
_ = topologic.FaceUtility.Triangulate(face, float(i)*0.1, faceTriangles)
|
4198
4208
|
return faceTriangles
|
@@ -4322,40 +4332,41 @@ class Topology():
|
|
4322
4332
|
from topologicpy.Cell import Cell
|
4323
4333
|
from topologicpy.CellComplex import CellComplex
|
4324
4334
|
from topologicpy.Aperture import Aperture
|
4335
|
+
|
4325
4336
|
if not isinstance(topology, topologic.Topology):
|
4326
4337
|
print("Topology.InternalVertex - Error: the input topology parameter is not a valid topology. Returning None.")
|
4327
4338
|
return None
|
4328
4339
|
vst = None
|
4329
|
-
|
4330
|
-
if isinstance(
|
4331
|
-
tempCell = Topology.Cells(
|
4340
|
+
top = Topology.Copy(topology)
|
4341
|
+
if isinstance(top, topologic.CellComplex): #CellComplex
|
4342
|
+
tempCell = Topology.Cells(top)[0]
|
4332
4343
|
vst = Cell.InternalVertex(tempCell, tolerance=tolerance)
|
4333
|
-
elif isinstance(
|
4334
|
-
vst = Cell.InternalVertex(
|
4335
|
-
elif isinstance(
|
4336
|
-
tempFace = Topology.Faces(
|
4344
|
+
elif isinstance(top, topologic.Cell): #Cell
|
4345
|
+
vst = Cell.InternalVertex(top, tolerance=tolerance)
|
4346
|
+
elif isinstance(top, topologic.Shell): #Shell
|
4347
|
+
tempFace = Topology.Faces(top)[0]
|
4337
4348
|
vst = Face.InternalVertex(tempFace, tolerance=tolerance)
|
4338
|
-
elif isinstance(
|
4339
|
-
vst = Face.InternalVertex(
|
4340
|
-
elif isinstance(
|
4341
|
-
if
|
4349
|
+
elif isinstance(top, topologic.Face): #Face
|
4350
|
+
vst = Face.InternalVertex(top, tolerance=tolerance)
|
4351
|
+
elif isinstance(top, topologic.Wire): #Wire
|
4352
|
+
if top.IsClosed():
|
4342
4353
|
internalBoundaries = []
|
4343
4354
|
try:
|
4344
|
-
tempFace = topologic.Face.ByExternalInternalBoundaries(
|
4355
|
+
tempFace = topologic.Face.ByExternalInternalBoundaries(top, internalBoundaries)
|
4345
4356
|
vst = Face.InternalVertex(tempFace, tolerance=tolerance)
|
4346
4357
|
except:
|
4347
|
-
vst = Topology.Centroid(
|
4358
|
+
vst = Topology.Centroid(top)
|
4348
4359
|
else:
|
4349
|
-
tempEdge = Topology.Edges(
|
4360
|
+
tempEdge = Topology.Edges(top)[0]
|
4350
4361
|
vst = Edge.VertexByParameter(tempEdge, 0.5)
|
4351
|
-
elif isinstance(
|
4352
|
-
vst = Edge.VertexByParameter(
|
4353
|
-
elif isinstance(
|
4354
|
-
vst =
|
4362
|
+
elif isinstance(top, topologic.Edge): #Edge
|
4363
|
+
vst = Edge.VertexByParameter(top, 0.5)
|
4364
|
+
elif isinstance(top, topologic.Vertex): #Vertex
|
4365
|
+
vst = top
|
4355
4366
|
elif isinstance(topology, topologic.Aperture): #Aperture
|
4356
|
-
vst = Face.InternalVertex(Aperture.Topology(
|
4367
|
+
vst = Face.InternalVertex(Aperture.Topology(top), tolerance)
|
4357
4368
|
else:
|
4358
|
-
vst = Topology.Centroid(
|
4369
|
+
vst = Topology.Centroid(top)
|
4359
4370
|
return vst
|
4360
4371
|
|
4361
4372
|
@staticmethod
|
@@ -4395,7 +4406,7 @@ class Topology():
|
|
4395
4406
|
b = a2 * c1 - a1 * c2
|
4396
4407
|
c = a1 * b2 - b1 * a2
|
4397
4408
|
d = (- a * v1.X() - b * v1.Y() - c * v1.Z())
|
4398
|
-
return [a,b,c,d]
|
4409
|
+
return [a, b, c, d]
|
4399
4410
|
|
4400
4411
|
if not isinstance(topology, topologic.Topology):
|
4401
4412
|
print("Topology.IsPlanar - Error: the input topology parameter is not a valid topology. Returning None.")
|
@@ -4625,7 +4636,7 @@ class Topology():
|
|
4625
4636
|
return [v for v in Topology.SubTopologies(topology, subTopologyType="vertex") if Topology.Degree(v, hostTopology=topology) < 2]
|
4626
4637
|
|
4627
4638
|
@staticmethod
|
4628
|
-
def Orient(topology, origin=None, dirA=[0,0,1], dirB=[0,0,1], tolerance=0.0001):
|
4639
|
+
def Orient(topology, origin=None, dirA=[0, 0, 1], dirB=[0, 0, 1], tolerance=0.0001):
|
4629
4640
|
"""
|
4630
4641
|
Orients the input topology such that the input such that the input dirA vector is parallel to the input dirB vector.
|
4631
4642
|
|
@@ -4636,9 +4647,9 @@ class Topology():
|
|
4636
4647
|
origin : topologic.Vertex , optional
|
4637
4648
|
The input origin. If set to None, The object's centroid will be used to locate the input topology. The default is None.
|
4638
4649
|
dirA : list , optional
|
4639
|
-
The first input direction vector. The input topology will be rotated such that this vector is parallel to the input dirB vector. The default is [0,0,1].
|
4650
|
+
The first input direction vector. The input topology will be rotated such that this vector is parallel to the input dirB vector. The default is [0, 0, 1].
|
4640
4651
|
dirB : list , optional
|
4641
|
-
The target direction vector. The input topology will be rotated such that the input dirA vector is parallel to this vector. The default is [0,0,1].
|
4652
|
+
The target direction vector. The input topology will be rotated such that the input dirA vector is parallel to this vector. The default is [0, 0, 1].
|
4642
4653
|
tolerance : float , optional
|
4643
4654
|
The desired tolerance. The default is 0.0001
|
4644
4655
|
|
@@ -4673,7 +4684,7 @@ class Topology():
|
|
4673
4684
|
originA : topologic.Vertex , optional
|
4674
4685
|
The old location to use as the origin of the movement. If set to None, the centroid of the input topology is used. The default is None.
|
4675
4686
|
originB : topologic.Vertex , optional
|
4676
|
-
The new location at which to place the topology. If set to None, the world origin (0,0,0) is used. The default is None.
|
4687
|
+
The new location at which to place the topology. If set to None, the world origin (0, 0, 0) is used. The default is None.
|
4677
4688
|
|
4678
4689
|
Returns
|
4679
4690
|
-------
|
@@ -4687,7 +4698,7 @@ class Topology():
|
|
4687
4698
|
if not isinstance(originA, topologic.Vertex):
|
4688
4699
|
originA = Topology.Centroid(topology)
|
4689
4700
|
if not isinstance(originA, topologic.Vertex):
|
4690
|
-
originA = Vertex.ByCoordinates(0,0,0)
|
4701
|
+
originA = Vertex.ByCoordinates(0, 0, 0)
|
4691
4702
|
|
4692
4703
|
x = originB.X() - originA.X()
|
4693
4704
|
y = originB.Y() - originA.Y()
|
@@ -5164,7 +5175,7 @@ class Topology():
|
|
5164
5175
|
return new_topology
|
5165
5176
|
|
5166
5177
|
@staticmethod
|
5167
|
-
def Rotate(topology, origin=None,
|
5178
|
+
def Rotate(topology, origin=None, axis: list = [0, 0, 1], angle: float = 0, angTolerance: float =0.001, tolerance: float =0.0001):
|
5168
5179
|
"""
|
5169
5180
|
Rotates the input topology
|
5170
5181
|
|
@@ -5173,14 +5184,10 @@ class Topology():
|
|
5173
5184
|
topology : topologic.Topology
|
5174
5185
|
The input topology.
|
5175
5186
|
origin : topologic.Vertex , optional
|
5176
|
-
The origin (center) of the rotation. If set to None, the world origin (0,0,0) is used. The default is None.
|
5177
|
-
|
5178
|
-
The
|
5179
|
-
|
5180
|
-
The 'y' component of the rotation axis. The default is 0.
|
5181
|
-
z : float , optional
|
5182
|
-
The 'z' component of the rotation axis. The default is 0.
|
5183
|
-
degree : float , optional
|
5187
|
+
The origin (center) of the rotation. If set to None, the world origin (0, 0, 0) is used. The default is None.
|
5188
|
+
axis : list , optional
|
5189
|
+
The vector representing the axis of rotation. The default is [0, 0, 1] which equates to the Z axis.
|
5190
|
+
angle : float , optional
|
5184
5191
|
The angle of rotation in degrees. The default is 0.
|
5185
5192
|
angTolerance : float , optional
|
5186
5193
|
The angle tolerance in degrees under which no rotation is carried out. The default is 0.001 degrees.
|
@@ -5224,22 +5231,22 @@ class Topology():
|
|
5224
5231
|
print("Topology.Rotate - Error: The input topology parameter is not a valid topologic topology. Returning None.")
|
5225
5232
|
return None
|
5226
5233
|
if not origin:
|
5227
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
5234
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
5228
5235
|
if not isinstance(origin, topologic.Vertex):
|
5229
5236
|
print("Topology.Rotate - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
5230
5237
|
return None
|
5231
5238
|
returnTopology = topology
|
5232
|
-
if abs(
|
5239
|
+
if abs(angle) >= angTolerance:
|
5233
5240
|
try:
|
5234
|
-
|
5241
|
+
x, y, z = axis
|
5242
|
+
returnTopology = topologic.TopologyUtility.Rotate(topology, origin, x, y, z, angle)
|
5235
5243
|
except:
|
5236
5244
|
print("Topology.Rotate - Warning: (topologic.TopologyUtility.Rotate) operation failed. Trying a workaround.")
|
5237
5245
|
vertices = [Vertex.Coordinates(v) for v in Topology.Vertices(topology)]
|
5238
|
-
axis = [x,y,z]
|
5239
5246
|
origin = Vertex.Coordinates(origin)
|
5240
5247
|
rot_vertices = []
|
5241
5248
|
for v in vertices:
|
5242
|
-
rot_vertices.append(rotate_vertex_3d(v, axis,
|
5249
|
+
rot_vertices.append(rotate_vertex_3d(v, axis, angle, origin))
|
5243
5250
|
rot_vertices = [Vertex.ByCoordinates(rot_v) for rot_v in rot_vertices]
|
5244
5251
|
new_topology = Topology.ReplaceVertices(topology, verticesA=Topology.Vertices(topology), verticesB=rot_vertices)
|
5245
5252
|
new_topology = Topology.SelfMerge(new_topology, tolerance=tolerance)
|
@@ -5256,7 +5263,7 @@ class Topology():
|
|
5256
5263
|
topology : topologic.Topology
|
5257
5264
|
The input topology.
|
5258
5265
|
origin : topologic.Vertex , optional
|
5259
|
-
The origin (center) of the scaling. If set to None, the world origin (0,0,0) is used. The default is None.
|
5266
|
+
The origin (center) of the scaling. If set to None, the world origin (0, 0, 0) is used. The default is None.
|
5260
5267
|
x : float , optional
|
5261
5268
|
The 'x' component of the scaling factor. The default is 1.
|
5262
5269
|
y : float , optional
|
@@ -5274,7 +5281,7 @@ class Topology():
|
|
5274
5281
|
if not isinstance(topology, topologic.Topology):
|
5275
5282
|
return None
|
5276
5283
|
if not origin:
|
5277
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
5284
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
5278
5285
|
if not isinstance(origin, topologic.Vertex):
|
5279
5286
|
return None
|
5280
5287
|
newTopology = None
|
@@ -5487,8 +5494,6 @@ class Topology():
|
|
5487
5494
|
return None
|
5488
5495
|
if not isinstance(snapshot, topologic.Topology):
|
5489
5496
|
snapshot = Topology.Copy(topology)
|
5490
|
-
d = Topology.Dictionary(topology)
|
5491
|
-
snapshot = Topology.SetDictionary(snapshot, d)
|
5492
5497
|
if not isinstance(snapshot, topologic.Topology):
|
5493
5498
|
if not silent:
|
5494
5499
|
print("Topology.SetSnapshot - Error: The input snapshot parameter is not a valid topology. Returning None.")
|
@@ -5808,11 +5813,11 @@ class Topology():
|
|
5808
5813
|
marginBottom : int , optional
|
5809
5814
|
The size in pixels of the bottom margin. The default value is 0.
|
5810
5815
|
camera : list , optional
|
5811
|
-
The desired location of the camera). The default is [-1.25
|
5816
|
+
The desired location of the camera). The default is [-1.25, -1.25, 1.25].
|
5812
5817
|
center : list , optional
|
5813
|
-
The desired center (camera target). The default is [0,0,0].
|
5818
|
+
The desired center (camera target). The default is [0, 0, 0].
|
5814
5819
|
up : list , optional
|
5815
|
-
The desired up vector. The default is [0,0,1].
|
5820
|
+
The desired up vector. The default is [0, 0, 1].
|
5816
5821
|
projection : str , optional
|
5817
5822
|
The desired type of projection. The options are "orthographic" or "perspective". It is case insensitive. The default is "perspective"
|
5818
5823
|
renderer : str , optional
|
@@ -5999,8 +6004,8 @@ class Topology():
|
|
5999
6004
|
return snapshots
|
6000
6005
|
|
6001
6006
|
@staticmethod
|
6002
|
-
def Spin(topology, origin=None, triangulate=True, direction=[0,0,1],
|
6003
|
-
tolerance=0.0001, silent=False):
|
6007
|
+
def Spin(topology, origin=None, triangulate: bool = True, direction: list = [0, 0, 1], angle: float = 360, sides: int = 16,
|
6008
|
+
tolerance: float = 0.0001, silent: bool = False):
|
6004
6009
|
"""
|
6005
6010
|
Spins the input topology around an axis to create a new topology.See https://en.wikipedia.org/wiki/Solid_of_revolution.
|
6006
6011
|
|
@@ -6013,8 +6018,8 @@ class Topology():
|
|
6013
6018
|
triangulate : bool , optional
|
6014
6019
|
If set to True, the result will be triangulated. The default is True.
|
6015
6020
|
direction : list , optional
|
6016
|
-
The vector representing the direction of the spin axis. The default is [0,0,1].
|
6017
|
-
|
6021
|
+
The vector representing the direction of the spin axis. The default is [0, 0, 1].
|
6022
|
+
angle : float , optional
|
6018
6023
|
The angle in degrees for the spin. The default is 360.
|
6019
6024
|
sides : int , optional
|
6020
6025
|
The desired number of sides. The default is 16.
|
@@ -6035,7 +6040,7 @@ class Topology():
|
|
6035
6040
|
from topologicpy.Cluster import Cluster
|
6036
6041
|
|
6037
6042
|
if not origin:
|
6038
|
-
origin = Vertex.ByCoordinates(0,0,0)
|
6043
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
6039
6044
|
if not isinstance(topology, topologic.Topology):
|
6040
6045
|
if not silent:
|
6041
6046
|
print("Topology.Spin - Error: the input topology parameter is not a valid topology. Returning None.")
|
@@ -6045,9 +6050,9 @@ class Topology():
|
|
6045
6050
|
print("Topology.Spin - Error: the input origin parameter is not a valid vertex. Returning None.")
|
6046
6051
|
return None
|
6047
6052
|
topologies = []
|
6048
|
-
unit_degree =
|
6053
|
+
unit_degree = angle / float(sides)
|
6049
6054
|
for i in range(sides+1):
|
6050
|
-
tempTopology = Topology.Rotate(topology, origin, direction
|
6055
|
+
tempTopology = Topology.Rotate(topology, origin=origin, axis=direction, angle=unit_degree*i)
|
6051
6056
|
if tempTopology:
|
6052
6057
|
topologies.append(tempTopology)
|
6053
6058
|
returnTopology = None
|
@@ -6120,7 +6125,7 @@ class Topology():
|
|
6120
6125
|
return returnTopology
|
6121
6126
|
|
6122
6127
|
@staticmethod
|
6123
|
-
def Taper(topology, origin=None, ratioRange=[0,1], triangulate=False, tolerance=0.0001):
|
6128
|
+
def Taper(topology, origin=None, ratioRange=[0, 1], triangulate=False, tolerance=0.0001):
|
6124
6129
|
"""
|
6125
6130
|
Tapers the input topology. This method tapers the input geometry along its Z-axis based on the ratio range input.
|
6126
6131
|
|
@@ -6145,9 +6150,9 @@ class Topology():
|
|
6145
6150
|
"""
|
6146
6151
|
from topologicpy.Vertex import Vertex
|
6147
6152
|
ratioRange = [min(1,ratioRange[0]), min(1,ratioRange[1])]
|
6148
|
-
if ratioRange == [0,0]:
|
6153
|
+
if ratioRange == [0, 0]:
|
6149
6154
|
return topology
|
6150
|
-
if ratioRange == [1,1]:
|
6155
|
+
if ratioRange == [1, 1]:
|
6151
6156
|
print("Topology.Taper - Error: Degenerate result. Returning original topology.")
|
6152
6157
|
return topology
|
6153
6158
|
if triangulate == True:
|
@@ -6176,7 +6181,7 @@ class Topology():
|
|
6176
6181
|
return return_topology
|
6177
6182
|
|
6178
6183
|
@staticmethod
|
6179
|
-
def Twist(topology, origin=None,
|
6184
|
+
def Twist(topology, origin=None, angleRange=[45, 90], triangulate=False):
|
6180
6185
|
"""
|
6181
6186
|
Twists the input topology. This method twists the input geometry along its Z-axis based on the degree range input.
|
6182
6187
|
|
@@ -6186,7 +6191,7 @@ class Topology():
|
|
6186
6191
|
The input topology.
|
6187
6192
|
origin : topologic.Vertex , optional
|
6188
6193
|
The desired origin for tapering. If not specified, the centroid of the input topology is used. The tapering will use the X, Y coordinates of the specified origin, but will use the Z of the point being tapered. The default is None.
|
6189
|
-
|
6194
|
+
angleRange : list , optional
|
6190
6195
|
The desired angle range in degrees. This will specify a linear range from bottom to top for twisting the vertices. positive numbers mean a clockwise rotation.
|
6191
6196
|
triangulate : bool , optional
|
6192
6197
|
If set to true, the input topology is triangulated before tapering. Otherwise, it will not be traingulated. The default is False.
|
@@ -6199,7 +6204,7 @@ class Topology():
|
|
6199
6204
|
"""
|
6200
6205
|
from topologicpy.Vertex import Vertex
|
6201
6206
|
|
6202
|
-
if
|
6207
|
+
if angleRange == [0, 0]:
|
6203
6208
|
return topology
|
6204
6209
|
if triangulate == True:
|
6205
6210
|
topology = Topology.Triangulate(topology)
|
@@ -6214,15 +6219,15 @@ class Topology():
|
|
6214
6219
|
new_vertices = []
|
6215
6220
|
for v in vertices:
|
6216
6221
|
ht = (Vertex.Z(v)-minZ)/(maxZ - minZ)
|
6217
|
-
new_rot =
|
6222
|
+
new_rot = angleRange[0] + ht*(angleRange[1] - angleRange[0])
|
6218
6223
|
orig = Vertex.ByCoordinates(Vertex.X(origin), Vertex.Y(origin), Vertex.Z(v))
|
6219
|
-
new_vertices.append(Topology.Rotate(v, origin=orig,
|
6224
|
+
new_vertices.append(Topology.Rotate(v, origin=orig, axis=[0, 0, 1], angle=new_rot))
|
6220
6225
|
return_topology = Topology.ReplaceVertices(topology, vertices, new_vertices)
|
6221
6226
|
return_topology = Topology.Fix(return_topology, topologyType=Topology.TypeAsString(topology))
|
6222
6227
|
return return_topology
|
6223
6228
|
|
6224
6229
|
@staticmethod
|
6225
|
-
def Unflatten(topology, origin=None, direction=[0,0,1]):
|
6230
|
+
def Unflatten(topology, origin=None, direction=[0, 0, 1]):
|
6226
6231
|
"""
|
6227
6232
|
Unflattens the input topology such that the world origin is translated to the input origin and the input topology is rotated such that the Up direction (see Vector.Up()) is aligned with the input vector.
|
6228
6233
|
|
@@ -6738,7 +6743,7 @@ class Topology():
|
|
6738
6743
|
return topology
|
6739
6744
|
|
6740
6745
|
@staticmethod
|
6741
|
-
def TranslateByDirectionDistance(topology, direction=[0,0,0], distance=0):
|
6746
|
+
def TranslateByDirectionDistance(topology, direction: list = [0, 0, 0], distance: float = 0):
|
6742
6747
|
"""
|
6743
6748
|
Translates (moves) the input topology along the input direction by the specified distance.
|
6744
6749
|
|
@@ -6747,7 +6752,7 @@ class Topology():
|
|
6747
6752
|
topology : topologic.topology
|
6748
6753
|
The input topology.
|
6749
6754
|
direction : list , optional
|
6750
|
-
The direction vector in which the topology should be moved. The default is [0,0,0]
|
6755
|
+
The direction vector in which the topology should be moved. The default is [0, 0, 0]
|
6751
6756
|
distance : float , optional
|
6752
6757
|
The distance by which the toplogy should be moved. The default is 0.
|
6753
6758
|
|
@@ -6766,7 +6771,7 @@ class Topology():
|
|
6766
6771
|
|
6767
6772
|
|
6768
6773
|
@staticmethod
|
6769
|
-
def Triangulate(topology, transferDictionaries = False, tolerance=0.0001):
|
6774
|
+
def Triangulate(topology, transferDictionaries: bool = False, mode: str ="classic", meshSize: float = None, tolerance: float = 0.0001):
|
6770
6775
|
"""
|
6771
6776
|
Triangulates the input topology.
|
6772
6777
|
|
@@ -6776,6 +6781,12 @@ class Topology():
|
|
6776
6781
|
The input topologgy.
|
6777
6782
|
transferDictionaries : bool , optional
|
6778
6783
|
If set to True, the dictionaries of the faces in the input topology will be transferred to the created triangular faces. The default is False.
|
6784
|
+
mode : str , optional
|
6785
|
+
The desired mode of meshing. Two options are available: "classic" and "mesh". They are case insensitive.
|
6786
|
+
The "mesh" option uses the gmsh library.
|
6787
|
+
meshSize : float , optional
|
6788
|
+
The desired size of the mesh when using the "mesh" option. If set to None, it will be
|
6789
|
+
calculated automatically and set to 10% of the overall size of the face.
|
6779
6790
|
tolerance : float , optional
|
6780
6791
|
The desired tolerance. The default is 0.0001.
|
6781
6792
|
|
@@ -6819,7 +6830,7 @@ class Topology():
|
|
6819
6830
|
selectors = []
|
6820
6831
|
for aFace in topologyFaces:
|
6821
6832
|
if len(Topology.Vertices(aFace)) > 3:
|
6822
|
-
triFaces = Face.Triangulate(aFace, tolerance=tolerance)
|
6833
|
+
triFaces = Face.Triangulate(aFace, mode=mode, meshSize=meshSize, tolerance=tolerance)
|
6823
6834
|
else:
|
6824
6835
|
triFaces = [aFace]
|
6825
6836
|
for triFace in triFaces:
|