topologicpy 0.7.4__py3-none-any.whl → 0.7.6__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 +62 -53
- topologicpy/CellComplex.py +10 -8
- topologicpy/Edge.py +21 -16
- topologicpy/EnergyModel.py +20 -13
- topologicpy/Face.py +24 -26
- topologicpy/Graph.py +60 -37
- topologicpy/Grid.py +10 -7
- topologicpy/Honeybee.py +16 -15
- topologicpy/Neo4j.py +22 -10
- topologicpy/Plotly.py +49 -62
- topologicpy/Shell.py +79 -54
- topologicpy/Topology.py +112 -69
- topologicpy/Vector.py +4 -2
- topologicpy/Vertex.py +64 -42
- topologicpy/Wire.py +23 -12
- topologicpy/version.py +1 -1
- {topologicpy-0.7.4.dist-info → topologicpy-0.7.6.dist-info}/METADATA +1 -1
- topologicpy-0.7.6.dist-info/RECORD +33 -0
- topologicpy-0.7.4.dist-info/RECORD +0 -33
- {topologicpy-0.7.4.dist-info → topologicpy-0.7.6.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.4.dist-info → topologicpy-0.7.6.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.4.dist-info → topologicpy-0.7.6.dist-info}/top_level.txt +0 -0
topologicpy/Topology.py
CHANGED
@@ -871,6 +871,7 @@ class Topology():
|
|
871
871
|
See Topology.Boolean().
|
872
872
|
|
873
873
|
"""
|
874
|
+
from topologicpy.Cluster import Cluster
|
874
875
|
|
875
876
|
if topologyA == None:
|
876
877
|
return None
|
@@ -884,27 +885,24 @@ class Topology():
|
|
884
885
|
topologyA = topologyB
|
885
886
|
topologyB = temp
|
886
887
|
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
return Topology.Difference(merge, symdif)
|
888
|
+
results = []
|
889
|
+
if Topology.IsInstance(topologyA, "CellComplex"):
|
890
|
+
cellsA = Topology.Cells(topologyA)
|
891
891
|
else:
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
if Vertex.Distance(topologyA, topologyB) < tolerance:
|
897
|
-
return topologyA
|
898
|
-
else:
|
899
|
-
return None
|
900
|
-
# Edge/Wire/Face/Shell/Cell:
|
901
|
-
else:
|
902
|
-
if Vertex.IsInternal(topologyA, topologyB):
|
903
|
-
return topologyA
|
904
|
-
else:
|
905
|
-
return None
|
892
|
+
cellsA = [topologyA]
|
893
|
+
for cellA in cellsA:
|
894
|
+
if Topology.IsInstance(topologyB, "CellComplex"):
|
895
|
+
cellsB = Topology.Cells(topologyB)
|
906
896
|
else:
|
907
|
-
|
897
|
+
cellsB = [topologyB]
|
898
|
+
for cellB in cellsB:
|
899
|
+
cellC = cellA.Intersect(cellB)
|
900
|
+
results.append(cellC)
|
901
|
+
results = [x for x in results if results is not None]
|
902
|
+
if len(results) == 1:
|
903
|
+
return results[0]
|
904
|
+
else:
|
905
|
+
return Topology.SelfMerge(Topology.SelfMerge(Cluster.ByTopologies(results)))
|
908
906
|
|
909
907
|
@staticmethod
|
910
908
|
def SymmetricDifference(topologyA, topologyB, tranDict=False, tolerance=0.0001):
|
@@ -1113,7 +1111,7 @@ class Topology():
|
|
1113
1111
|
|
1114
1112
|
|
1115
1113
|
@staticmethod
|
1116
|
-
def BoundingBox(topology, optimize=0, axes="xyz", tolerance=0.0001):
|
1114
|
+
def BoundingBox(topology, optimize: int = 0, axes: str ="xyz", mantissa: int = 6, tolerance: float = 0.0001):
|
1117
1115
|
"""
|
1118
1116
|
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.
|
1119
1117
|
|
@@ -1125,6 +1123,8 @@ class Topology():
|
|
1125
1123
|
If set to an integer from 1 (low optimization) to 10 (high optimization), the method will attempt to optimize the bounding box so that it reduces its surface area. The default is 0 which will result in an axis-aligned bounding box. The default is 0.
|
1126
1124
|
axes : str , optional
|
1127
1125
|
Sets what axes are to be used for rotating the bounding box. This can be any permutation or substring of "xyz". It is not case sensitive. The default is "xyz".
|
1126
|
+
mantissa : int , optional
|
1127
|
+
The desired length of the mantissa. The default is 6
|
1128
1128
|
tolerance : float , optional
|
1129
1129
|
The desired tolerance. The default is 0.0001.
|
1130
1130
|
|
@@ -1140,6 +1140,7 @@ class Topology():
|
|
1140
1140
|
from topologicpy.Cell import Cell
|
1141
1141
|
from topologicpy.Cluster import Cluster
|
1142
1142
|
from topologicpy.Dictionary import Dictionary
|
1143
|
+
|
1143
1144
|
def bb(topology):
|
1144
1145
|
vertices = []
|
1145
1146
|
_ = topology.Vertices(None, vertices)
|
@@ -1147,9 +1148,9 @@ class Topology():
|
|
1147
1148
|
y = []
|
1148
1149
|
z = []
|
1149
1150
|
for aVertex in vertices:
|
1150
|
-
x.append(
|
1151
|
-
y.append(
|
1152
|
-
z.append(
|
1151
|
+
x.append(Vertex.X(aVertex, mantissa=mantissa))
|
1152
|
+
y.append(Vertex.Y(aVertex, mantissa=mantissa))
|
1153
|
+
z.append(Vertex.Z(aVertex, mantissa=mantissa))
|
1153
1154
|
minX = min(x)
|
1154
1155
|
minY = min(y)
|
1155
1156
|
minZ = min(z)
|
@@ -2956,7 +2957,7 @@ class Topology():
|
|
2956
2957
|
return contexts
|
2957
2958
|
|
2958
2959
|
@staticmethod
|
2959
|
-
def ConvexHull(topology, tolerance=0.0001):
|
2960
|
+
def ConvexHull(topology, mantissa: int = 6, tolerance: float = 0.0001):
|
2960
2961
|
"""
|
2961
2962
|
Creates a convex hull
|
2962
2963
|
|
@@ -2964,6 +2965,8 @@ class Topology():
|
|
2964
2965
|
----------
|
2965
2966
|
topology : topologic_core.Topology
|
2966
2967
|
The input Topology.
|
2968
|
+
mantissa : int , optional
|
2969
|
+
The desired length of the mantissa. The default is 6.
|
2967
2970
|
tolerance : float , optional
|
2968
2971
|
The desired tolerance. The default is 0.0001.
|
2969
2972
|
|
@@ -2987,7 +2990,7 @@ class Topology():
|
|
2987
2990
|
_ = item.Vertices(None, vertices)
|
2988
2991
|
pointList = []
|
2989
2992
|
for v in vertices:
|
2990
|
-
pointList.append(
|
2993
|
+
pointList.append(Vertex.Coordinates(v, mantissa=mantissa))
|
2991
2994
|
points = np.array(pointList)
|
2992
2995
|
if option:
|
2993
2996
|
hull = ConvexHull(points, qhull_options=option)
|
@@ -3120,8 +3123,8 @@ class Topology():
|
|
3120
3123
|
The input topology with the divided topologies added to it as contents.
|
3121
3124
|
|
3122
3125
|
"""
|
3123
|
-
|
3124
3126
|
from topologicpy.Dictionary import Dictionary
|
3127
|
+
|
3125
3128
|
if not Topology.IsInstance(topologyA, "Topology"):
|
3126
3129
|
print("Topology.Divide - Error: the input topologyA parameter is not a valid topology. Returning None.")
|
3127
3130
|
return None
|
@@ -3188,7 +3191,7 @@ class Topology():
|
|
3188
3191
|
return topologyA
|
3189
3192
|
|
3190
3193
|
@staticmethod
|
3191
|
-
def Explode(topology, origin=None, scale=1.25, typeFilter=None, axes="xyz", tolerance=0.0001):
|
3194
|
+
def Explode(topology, origin=None, scale: float = 1.25, typeFilter: str = None, axes: str = "xyz", mantissa: int = 6, tolerance: float = 0.0001):
|
3192
3195
|
"""
|
3193
3196
|
Explodes the input topology. See https://en.wikipedia.org/wiki/Exploded-view_drawing.
|
3194
3197
|
|
@@ -3204,6 +3207,8 @@ class Topology():
|
|
3204
3207
|
The type of the subtopologies to explode. This can be any of "vertex", "edge", "face", or "cell". If set to None, a subtopology one level below the type of the input topology will be used. The default is None.
|
3205
3208
|
axes : str , optional
|
3206
3209
|
Sets what axes are to be used for exploding the topology. This can be any permutation or substring of "xyz". It is not case sensitive. The default is "xyz".
|
3210
|
+
mantissa : int , optional
|
3211
|
+
The desired length of the mantissa. The default is 6.
|
3207
3212
|
tolerance : float , optional
|
3208
3213
|
The desired tolerance. The default is 0.0001.
|
3209
3214
|
|
@@ -3290,19 +3295,19 @@ class Topology():
|
|
3290
3295
|
topologies = Topology.SubTopologies(topology, subTopologyType=typeFilter.lower())
|
3291
3296
|
for aTopology in topologies:
|
3292
3297
|
c = Topology.InternalVertex(aTopology, tolerance=tolerance)
|
3293
|
-
oldX =
|
3294
|
-
oldY =
|
3295
|
-
oldZ =
|
3298
|
+
oldX = Vertex.X(c, mantissa=mantissa)
|
3299
|
+
oldY = Vertex.Y(c, mantissa=mantissa)
|
3300
|
+
oldZ = Vertex.Z(c, mantissa=mantissa)
|
3296
3301
|
if x_flag:
|
3297
|
-
newX = (oldX -
|
3302
|
+
newX = (oldX - Vertex.X(origin, mantissa=mantissa))*scale + Vertex.X(origin, mantissa=mantissa)
|
3298
3303
|
else:
|
3299
3304
|
newX = oldX
|
3300
3305
|
if y_flag:
|
3301
|
-
newY = (oldY -
|
3306
|
+
newY = (oldY - Vertex.Y(origin, mantissa=mantissa))*scale + Vertex.Y(origin, mantissa=mantissa)
|
3302
3307
|
else:
|
3303
3308
|
newY = oldY
|
3304
3309
|
if z_flag:
|
3305
|
-
newZ = (oldZ -
|
3310
|
+
newZ = (oldZ - Vertex.Z(origin, mantissa=mantissa))*scale + Vertex.Z(origin, mantissa=mantissa)
|
3306
3311
|
else:
|
3307
3312
|
newZ = oldZ
|
3308
3313
|
xT = newX - oldX
|
@@ -3364,7 +3369,7 @@ class Topology():
|
|
3364
3369
|
return False
|
3365
3370
|
|
3366
3371
|
|
3367
|
-
def ExportToDXF(topologies, path, overwrite=False):
|
3372
|
+
def ExportToDXF(topologies, path: str, overwrite: bool = False, mantissa: int = 6):
|
3368
3373
|
"""
|
3369
3374
|
Exports the input topology to a DXF file. See https://en.wikipedia.org/wiki/AutoCAD_DXF.
|
3370
3375
|
THe DXF version is 'R2010'
|
@@ -3378,6 +3383,8 @@ class Topology():
|
|
3378
3383
|
The input file path.
|
3379
3384
|
overwrite : bool , optional
|
3380
3385
|
If set to True the ouptut file will overwrite any pre-existing file. Otherwise, it won't. The default is False.
|
3386
|
+
mantissa : int , optional
|
3387
|
+
The desired length of the mantissa. The default is 6.
|
3381
3388
|
|
3382
3389
|
Returns
|
3383
3390
|
-------
|
@@ -3425,14 +3432,14 @@ class Topology():
|
|
3425
3432
|
def add_vertices(vertices, msp):
|
3426
3433
|
for v in vertices:
|
3427
3434
|
if Topology.IsInstance(v, "Vertex"):
|
3428
|
-
msp.add_point((Vertex.X(v), Vertex.Y(v), Vertex.Z(v)))
|
3435
|
+
msp.add_point((Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa), Vertex.Z(v, mantissa=mantissa)))
|
3429
3436
|
def add_edges(edges, msp):
|
3430
3437
|
for e in edges:
|
3431
3438
|
if Topology.IsInstance(e, "Edge"):
|
3432
3439
|
sv = Edge.StartVertex(e)
|
3433
3440
|
ev = Edge.EndVertex(e)
|
3434
|
-
start = (Vertex.X(sv), Vertex.Y(sv), Vertex.Z(sv))
|
3435
|
-
end = (Vertex.X(ev), Vertex.Y(ev), Vertex.Z(ev))
|
3441
|
+
start = (Vertex.X(sv, mantissa=mantissa), Vertex.Y(sv, mantissa=mantissa), Vertex.Z(sv, mantissa=mantissa))
|
3442
|
+
end = (Vertex.X(ev, mantissa=mantissa), Vertex.Y(ev, mantissa=mantissa), Vertex.Z(ev, mantissa=mantissa))
|
3436
3443
|
msp.add_line(start, end)
|
3437
3444
|
def add_wires(wires, msp):
|
3438
3445
|
for i, w in enumerate(wires):
|
@@ -3444,8 +3451,8 @@ class Topology():
|
|
3444
3451
|
for edge in edges:
|
3445
3452
|
sv = Edge.StartVertex(edge)
|
3446
3453
|
ev = Edge.EndVertex(edge)
|
3447
|
-
start = (Vertex.X(sv), Vertex.Y(sv), Vertex.Z(sv))
|
3448
|
-
end = (Vertex.X(ev), Vertex.Y(ev), Vertex.Z(ev))
|
3454
|
+
start = (Vertex.X(sv, mantissa=mantissa), Vertex.Y(sv, mantissa=mantissa), Vertex.Z(sv, mantissa=mantissa))
|
3455
|
+
end = (Vertex.X(ev, mantissa=mantissa), Vertex.Y(ev, mantissa=mantissa), Vertex.Z(ev, mantissa=mantissa))
|
3449
3456
|
block.add_line(start, end)
|
3450
3457
|
# Insert the block into the model space
|
3451
3458
|
msp.add_blockref(block_name, insert=(0, 0, 0))
|
@@ -4231,7 +4238,7 @@ class Topology():
|
|
4231
4238
|
return {"filtered": filteredTopologies, "other": otherTopologies}
|
4232
4239
|
|
4233
4240
|
@staticmethod
|
4234
|
-
def Flatten(topology, origin=None, direction=[0, 0, 1]):
|
4241
|
+
def Flatten(topology, origin=None, direction: list = [0, 0, 1], mantissa: int = 6):
|
4235
4242
|
"""
|
4236
4243
|
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()).
|
4237
4244
|
|
@@ -4241,8 +4248,10 @@ class Topology():
|
|
4241
4248
|
The input topology.
|
4242
4249
|
origin : topologic_core.Vertex , optional
|
4243
4250
|
The input origin. If set to None, The object's centroid will be used to place the world origin. The default is None.
|
4244
|
-
|
4251
|
+
direction : list , optional
|
4245
4252
|
The input direction vector. The input topology will be rotated such that this vector is pointed in the positive Z axis.
|
4253
|
+
mantissa : int , optional
|
4254
|
+
The desired length of the mantissa. The default is 6.
|
4246
4255
|
|
4247
4256
|
Returns
|
4248
4257
|
-------
|
@@ -4259,13 +4268,13 @@ class Topology():
|
|
4259
4268
|
if origin == None:
|
4260
4269
|
origin = Topology.Centroid(topology)
|
4261
4270
|
up = Vector.Up()
|
4262
|
-
flat_topology = Topology.Translate(topology, -Vertex.X(origin), -Vertex.Y(origin), -Vertex.Z(origin))
|
4271
|
+
flat_topology = Topology.Translate(topology, -Vertex.X(origin, mantissa=mantissa), -Vertex.Y(origin, mantissa=mantissa), -Vertex.Z(origin, mantissa=mantissa))
|
4263
4272
|
tran_mat = Vector.TransformationMatrix(direction, up)
|
4264
4273
|
flat_topology = Topology.Transform(flat_topology, tran_mat)
|
4265
4274
|
return flat_topology
|
4266
4275
|
|
4267
4276
|
@staticmethod
|
4268
|
-
def Geometry(topology, mantissa=6):
|
4277
|
+
def Geometry(topology, mantissa: int = 6):
|
4269
4278
|
"""
|
4270
4279
|
Returns the geometry (mesh data format) of the input topology as a dictionary of vertices, edges, and faces.
|
4271
4280
|
|
@@ -4545,7 +4554,7 @@ class Topology():
|
|
4545
4554
|
return None
|
4546
4555
|
|
4547
4556
|
@staticmethod
|
4548
|
-
def IsPlanar(topology, tolerance=0.0001):
|
4557
|
+
def IsPlanar(topology, mantissa: int = 6, tolerance: float = 0.0001):
|
4549
4558
|
"""
|
4550
4559
|
Returns True if all the vertices of the input topology are co-planar. Returns False otherwise.
|
4551
4560
|
|
@@ -4553,6 +4562,8 @@ class Topology():
|
|
4553
4562
|
----------
|
4554
4563
|
topology : topologic_core.Topology
|
4555
4564
|
The input topology.
|
4565
|
+
mantissa : int , optional
|
4566
|
+
The desired length of the mantissa. The default is 6
|
4556
4567
|
tolerance : float , optional
|
4557
4568
|
The desired tolerance. The default is 0.0001.
|
4558
4569
|
|
@@ -4562,7 +4573,8 @@ class Topology():
|
|
4562
4573
|
True if all the vertices of the input topology are co-planar. False otherwise.
|
4563
4574
|
|
4564
4575
|
"""
|
4565
|
-
|
4576
|
+
from topologicpy.Vertex import Vertex
|
4577
|
+
|
4566
4578
|
def isOnPlane(v, plane, tolerance):
|
4567
4579
|
x, y, z = v
|
4568
4580
|
a, b, c, d = plane
|
@@ -4571,16 +4583,16 @@ class Topology():
|
|
4571
4583
|
return False
|
4572
4584
|
|
4573
4585
|
def plane(v1, v2, v3):
|
4574
|
-
a1 =
|
4575
|
-
b1 =
|
4576
|
-
c1 =
|
4577
|
-
a2 =
|
4578
|
-
b2 =
|
4579
|
-
c2 =
|
4586
|
+
a1 = Vertex.X(v2, mantissa=mantissa) - Vertex.X(v1, mantissa=mantissa)
|
4587
|
+
b1 = Vertex.Y(v2, mantissa=mantissa) - Vertex.Y(v1, mantissa=mantissa)
|
4588
|
+
c1 = Vertex.Z(v2, mantissa=mantissa) - Vertex.Z(v1, mantissa=mantissa)
|
4589
|
+
a2 = Vertex.X(v3, mantissa=mantissa) - Vertex.X(v1, mantissa=mantissa)
|
4590
|
+
b2 = Vertex.Y(v3, mantissa=mantissa) - Vertex.Y(v1, mantissa=mantissa)
|
4591
|
+
c2 = Vertex.Z(v3, mantissa=mantissa) - Vertex.Z(v1, mantissa=mantissa)
|
4580
4592
|
a = b1 * c2 - b2 * c1
|
4581
4593
|
b = a2 * c1 - a1 * c2
|
4582
4594
|
c = a1 * b2 - b1 * a2
|
4583
|
-
d = (- a *
|
4595
|
+
d = (- a * Vertex.X(v1, mantissa=mantissa) - b * Vertex.Y(v1, mantissa=mantissa) - c * Vertex.Z(v1, mantissa=mantissa))
|
4584
4596
|
return [a, b, c, d]
|
4585
4597
|
|
4586
4598
|
if not Topology.IsInstance(topology, "Topology"):
|
@@ -4594,7 +4606,7 @@ class Topology():
|
|
4594
4606
|
else:
|
4595
4607
|
p = plane(vertices[0], vertices[1], vertices[2])
|
4596
4608
|
for i in range(len(vertices)):
|
4597
|
-
if isOnPlane([vertices[i]
|
4609
|
+
if isOnPlane([Vertex.X(vertices[i], mantissa=mantissa), Vertex.Y(vertices[i], mantissa=mantissa), Vertex.Z(vertices[i], mantissa=mantissa)], p, tolerance) == False:
|
4598
4610
|
result = False
|
4599
4611
|
break
|
4600
4612
|
return result
|
@@ -4848,7 +4860,7 @@ class Topology():
|
|
4848
4860
|
return return_topology
|
4849
4861
|
|
4850
4862
|
@staticmethod
|
4851
|
-
def Place(topology, originA=None, originB=None):
|
4863
|
+
def Place(topology, originA=None, originB=None, mantissa: int = 6):
|
4852
4864
|
"""
|
4853
4865
|
Places the input topology at the specified location.
|
4854
4866
|
|
@@ -4860,6 +4872,8 @@ class Topology():
|
|
4860
4872
|
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.
|
4861
4873
|
originB : topologic_core.Vertex , optional
|
4862
4874
|
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.
|
4875
|
+
mantissa : int , optional
|
4876
|
+
The desired length of the mantissa. The default is 6
|
4863
4877
|
|
4864
4878
|
Returns
|
4865
4879
|
-------
|
@@ -4875,9 +4889,9 @@ class Topology():
|
|
4875
4889
|
if not Topology.IsInstance(originA, "Vertex"):
|
4876
4890
|
originA = Vertex.ByCoordinates(0, 0, 0)
|
4877
4891
|
|
4878
|
-
x =
|
4879
|
-
y =
|
4880
|
-
z =
|
4892
|
+
x = Vertex.X(originB, mantissa=mantissa) - Vertex.X(originA, mantissa=mantissa)
|
4893
|
+
y = Vertex.Y(originB, mantissa=mantissa) - Vertex.Y(originA, mantissa=mantissa)
|
4894
|
+
z = Vertex.Z(originB, mantissa=mantissa) - Vertex.Z(originA, mantissa=mantissa)
|
4881
4895
|
newTopology = None
|
4882
4896
|
try:
|
4883
4897
|
newTopology = Topology.Translate(topology, x, y, z)
|
@@ -5306,7 +5320,7 @@ class Topology():
|
|
5306
5320
|
return topology
|
5307
5321
|
|
5308
5322
|
@staticmethod
|
5309
|
-
def ReplaceVertices(topology, verticesA=[], verticesB=[], mantissa=6, tolerance=0.0001):
|
5323
|
+
def ReplaceVertices(topology, verticesA: list = [], verticesB: list = [], mantissa: int = 6, tolerance: float = 0.0001):
|
5310
5324
|
"""
|
5311
5325
|
Replaces the vertices in the first input list with the vertices in the second input list and rebuilds the input topology. The two lists must be of the same length.
|
5312
5326
|
|
@@ -5343,7 +5357,7 @@ class Topology():
|
|
5343
5357
|
n = Vertex.Index(v, verts, tolerance=tolerance)
|
5344
5358
|
if not n == None:
|
5345
5359
|
new_verts[n] = verticesB[i]
|
5346
|
-
new_g_verts = [[Vertex.X(v),Vertex.Y(v),Vertex.Z(v)] for v in new_verts]
|
5360
|
+
new_g_verts = [[Vertex.X(v, mantissa=mantissa),Vertex.Y(v, mantissa=mantissa),Vertex.Z(v, mantissa=mantissa)] for v in new_verts]
|
5347
5361
|
new_topology = Topology.ByGeometry(vertices=new_g_verts, edges=g_edges, faces=g_faces)
|
5348
5362
|
return new_topology
|
5349
5363
|
|
@@ -6288,7 +6302,7 @@ class Topology():
|
|
6288
6302
|
return returnTopology
|
6289
6303
|
|
6290
6304
|
@staticmethod
|
6291
|
-
def Taper(topology, origin=None, ratioRange=[0, 1], triangulate=False, tolerance=0.0001):
|
6305
|
+
def Taper(topology, origin=None, ratioRange: list = [0, 1], triangulate: bool = False, mantissa: int = 6, tolerance: float = 0.0001):
|
6292
6306
|
"""
|
6293
6307
|
Tapers the input topology. This method tapers the input geometry along its Z-axis based on the ratio range input.
|
6294
6308
|
|
@@ -6302,6 +6316,8 @@ class Topology():
|
|
6302
6316
|
The desired ratio range. This will specify a linear range from bottom to top for tapering the vertices. 0 means no tapering, and 1 means maximum (inward) tapering. Negative numbers mean that tapering will be outwards.
|
6303
6317
|
triangulate : bool , optional
|
6304
6318
|
If set to true, the input topology is triangulated before tapering. Otherwise, it will not be traingulated. The default is False.
|
6319
|
+
mantissa : int , optional
|
6320
|
+
The desired length of the mantissa. The default is 6.
|
6305
6321
|
tolerance : float , optional
|
6306
6322
|
The desired tolerance. Vertices will not be moved if the calculated distance is at or less than this tolerance.
|
6307
6323
|
|
@@ -6323,17 +6339,17 @@ class Topology():
|
|
6323
6339
|
if origin == None:
|
6324
6340
|
origin = Topology.Centroid(topology)
|
6325
6341
|
vertices = Topology.Vertices(topology)
|
6326
|
-
zList = [Vertex.Z(v) for v in vertices]
|
6342
|
+
zList = [Vertex.Z(v, mantissa=mantissa) for v in vertices]
|
6327
6343
|
minZ = min(zList)
|
6328
6344
|
maxZ = max(zList)
|
6329
6345
|
new_vertices = []
|
6330
6346
|
for v in vertices:
|
6331
6347
|
ht = (Vertex.Z(v)-minZ)/(maxZ - minZ)
|
6332
6348
|
rt = ratioRange[0] + ht*(ratioRange[1] - ratioRange[0])
|
6333
|
-
new_origin = Vertex.ByCoordinates(Vertex.X(origin), Vertex.Y(origin), Vertex.Z(v))
|
6334
|
-
new_dist = Vertex.Distance(new_origin, v)*rt
|
6335
|
-
c_a = Vertex.Coordinates(new_origin)
|
6336
|
-
c_b = Vertex.Coordinates(v)
|
6349
|
+
new_origin = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa), Vertex.Y(origin, mantissa=mantissa), Vertex.Z(v, mantissa=mantissa))
|
6350
|
+
new_dist = Vertex.Distance(new_origin, v, mantissa=mantissa)*rt
|
6351
|
+
c_a = Vertex.Coordinates(new_origin, mantissa=mantissa)
|
6352
|
+
c_b = Vertex.Coordinates(v, mantissa=mantissa)
|
6337
6353
|
new_dir = [(c_a[0]-c_b[0]), (c_a[1]-c_b[1]), 0]
|
6338
6354
|
if abs(new_dist) > tolerance:
|
6339
6355
|
new_v = Topology.TranslateByDirectionDistance(v, direction=new_dir, distance=new_dist)
|
@@ -6344,7 +6360,7 @@ class Topology():
|
|
6344
6360
|
return return_topology
|
6345
6361
|
|
6346
6362
|
@staticmethod
|
6347
|
-
def Twist(topology, origin=None, angleRange=[45, 90], triangulate=False):
|
6363
|
+
def Twist(topology, origin=None, angleRange: list = [45, 90], triangulate: bool = False, mantissa: int = 6):
|
6348
6364
|
"""
|
6349
6365
|
Twists the input topology. This method twists the input geometry along its Z-axis based on the degree range input.
|
6350
6366
|
|
@@ -6358,6 +6374,8 @@ class Topology():
|
|
6358
6374
|
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.
|
6359
6375
|
triangulate : bool , optional
|
6360
6376
|
If set to true, the input topology is triangulated before tapering. Otherwise, it will not be traingulated. The default is False.
|
6377
|
+
mantissa : int , optional
|
6378
|
+
The desired length of the mantissa. The default is 6.
|
6361
6379
|
|
6362
6380
|
Returns
|
6363
6381
|
-------
|
@@ -6375,7 +6393,7 @@ class Topology():
|
|
6375
6393
|
origin = Topology.Centroid(topology)
|
6376
6394
|
|
6377
6395
|
vertices = Topology.Vertices(topology)
|
6378
|
-
zList = [Vertex.Z(v) for v in vertices]
|
6396
|
+
zList = [Vertex.Z(v, mantissa=mantissa) for v in vertices]
|
6379
6397
|
minZ = min(zList)
|
6380
6398
|
maxZ = max(zList)
|
6381
6399
|
h = maxZ - minZ
|
@@ -6383,7 +6401,7 @@ class Topology():
|
|
6383
6401
|
for v in vertices:
|
6384
6402
|
ht = (Vertex.Z(v)-minZ)/(maxZ - minZ)
|
6385
6403
|
new_rot = angleRange[0] + ht*(angleRange[1] - angleRange[0])
|
6386
|
-
orig = Vertex.ByCoordinates(Vertex.X(origin), Vertex.Y(origin), Vertex.Z(v))
|
6404
|
+
orig = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa), Vertex.Y(origin, mantissa=mantissa), Vertex.Z(v, mantissa=mantissa))
|
6387
6405
|
new_vertices.append(Topology.Rotate(v, origin=orig, axis=[0, 0, 1], angle=new_rot))
|
6388
6406
|
return_topology = Topology.ReplaceVertices(topology, vertices, new_vertices)
|
6389
6407
|
return_topology = Topology.Fix(return_topology, topologyType=Topology.TypeAsString(topology))
|
@@ -7143,4 +7161,29 @@ class Topology():
|
|
7143
7161
|
typeID = 2048
|
7144
7162
|
elif name == "topology":
|
7145
7163
|
typeID = 4096
|
7146
|
-
return typeID
|
7164
|
+
return typeID
|
7165
|
+
|
7166
|
+
@staticmethod
|
7167
|
+
def UUID(topology, namespace="topologicpy"):
|
7168
|
+
"""
|
7169
|
+
Generate a UUID v5 based on the provided content and a fixed namespace.
|
7170
|
+
|
7171
|
+
Parameters
|
7172
|
+
----------
|
7173
|
+
topology : topologic_core.Topology
|
7174
|
+
The input topology
|
7175
|
+
namespace : str , optional
|
7176
|
+
The base namescape to use for generating the UUID
|
7177
|
+
|
7178
|
+
Returns
|
7179
|
+
-------
|
7180
|
+
UUID
|
7181
|
+
The uuid of the input topology.
|
7182
|
+
|
7183
|
+
"""
|
7184
|
+
import uuid
|
7185
|
+
|
7186
|
+
predefined_namespace_dns = uuid.UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
|
7187
|
+
namespace_uuid = uuid.uuid5(predefined_namespace_dns, namespace)
|
7188
|
+
brep_string = Topology.BREPString(topology)
|
7189
|
+
return uuid.uuid5(namespace_uuid, brep_string)
|
topologicpy/Vector.py
CHANGED
@@ -248,7 +248,7 @@ class Vector(list):
|
|
248
248
|
return [x, y, z]
|
249
249
|
|
250
250
|
@staticmethod
|
251
|
-
def ByVertices(vertices, normalize=True):
|
251
|
+
def ByVertices(vertices, normalize: bool = True, mantissa: int = 6):
|
252
252
|
"""
|
253
253
|
Creates a vector by the specified input list of vertices.
|
254
254
|
|
@@ -258,6 +258,8 @@ class Vector(list):
|
|
258
258
|
The the input list of topologic vertices. The first element in the list is considered the start vertex. The last element in the list is considered the end vertex.
|
259
259
|
normalize : bool , optional
|
260
260
|
If set to True, the resulting vector is normalized (i.e. its length is set to 1)
|
261
|
+
mantissa : int , optional
|
262
|
+
The desired length of the mantissa. The default is 6.
|
261
263
|
|
262
264
|
Returns
|
263
265
|
-------
|
@@ -278,7 +280,7 @@ class Vector(list):
|
|
278
280
|
return None
|
279
281
|
v1 = vertices[0]
|
280
282
|
v2 = vertices[-1]
|
281
|
-
vector = [Vertex.X(v2)-Vertex.X(v1), Vertex.Y(v2)-Vertex.Y(v1), Vertex.Z(v2)-Vertex.Z(v1)]
|
283
|
+
vector = [Vertex.X(v2, mantissa=mantissa)-Vertex.X(v1, mantissa=mantissa), Vertex.Y(v2, mantissa=mantissa)-Vertex.Y(v1, mantissa=mantissa), Vertex.Z(v2, mantissa=mantissa)-Vertex.Z(v1, mantissa=mantissa)]
|
282
284
|
if normalize:
|
283
285
|
vector = Vector.Normalize(vector)
|
284
286
|
return vector
|