topologicpy 0.7.5__py3-none-any.whl → 0.7.8__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 +23 -25
- topologicpy/Graph.py +385 -217
- topologicpy/Grid.py +23 -11
- topologicpy/Honeybee.py +16 -15
- topologicpy/Neo4j.py +22 -10
- topologicpy/Plotly.py +49 -62
- topologicpy/Shell.py +79 -54
- topologicpy/Topology.py +95 -50
- topologicpy/Vector.py +4 -2
- topologicpy/Vertex.py +64 -42
- topologicpy/Wire.py +23 -12
- topologicpy/version.py +1 -1
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.8.dist-info}/METADATA +1 -1
- topologicpy-0.7.8.dist-info/RECORD +33 -0
- topologicpy-0.7.5.dist-info/RECORD +0 -33
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.8.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.8.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.8.dist-info}/top_level.txt +0 -0
topologicpy/Topology.py
CHANGED
@@ -1111,7 +1111,7 @@ class Topology():
|
|
1111
1111
|
|
1112
1112
|
|
1113
1113
|
@staticmethod
|
1114
|
-
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):
|
1115
1115
|
"""
|
1116
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.
|
1117
1117
|
|
@@ -1123,6 +1123,8 @@ class Topology():
|
|
1123
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.
|
1124
1124
|
axes : str , optional
|
1125
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
|
1126
1128
|
tolerance : float , optional
|
1127
1129
|
The desired tolerance. The default is 0.0001.
|
1128
1130
|
|
@@ -1138,6 +1140,7 @@ class Topology():
|
|
1138
1140
|
from topologicpy.Cell import Cell
|
1139
1141
|
from topologicpy.Cluster import Cluster
|
1140
1142
|
from topologicpy.Dictionary import Dictionary
|
1143
|
+
|
1141
1144
|
def bb(topology):
|
1142
1145
|
vertices = []
|
1143
1146
|
_ = topology.Vertices(None, vertices)
|
@@ -1145,9 +1148,9 @@ class Topology():
|
|
1145
1148
|
y = []
|
1146
1149
|
z = []
|
1147
1150
|
for aVertex in vertices:
|
1148
|
-
x.append(
|
1149
|
-
y.append(
|
1150
|
-
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))
|
1151
1154
|
minX = min(x)
|
1152
1155
|
minY = min(y)
|
1153
1156
|
minZ = min(z)
|
@@ -2954,7 +2957,7 @@ class Topology():
|
|
2954
2957
|
return contexts
|
2955
2958
|
|
2956
2959
|
@staticmethod
|
2957
|
-
def ConvexHull(topology, tolerance=0.0001):
|
2960
|
+
def ConvexHull(topology, mantissa: int = 6, tolerance: float = 0.0001):
|
2958
2961
|
"""
|
2959
2962
|
Creates a convex hull
|
2960
2963
|
|
@@ -2962,6 +2965,8 @@ class Topology():
|
|
2962
2965
|
----------
|
2963
2966
|
topology : topologic_core.Topology
|
2964
2967
|
The input Topology.
|
2968
|
+
mantissa : int , optional
|
2969
|
+
The desired length of the mantissa. The default is 6.
|
2965
2970
|
tolerance : float , optional
|
2966
2971
|
The desired tolerance. The default is 0.0001.
|
2967
2972
|
|
@@ -2985,7 +2990,7 @@ class Topology():
|
|
2985
2990
|
_ = item.Vertices(None, vertices)
|
2986
2991
|
pointList = []
|
2987
2992
|
for v in vertices:
|
2988
|
-
pointList.append(
|
2993
|
+
pointList.append(Vertex.Coordinates(v, mantissa=mantissa))
|
2989
2994
|
points = np.array(pointList)
|
2990
2995
|
if option:
|
2991
2996
|
hull = ConvexHull(points, qhull_options=option)
|
@@ -3118,8 +3123,8 @@ class Topology():
|
|
3118
3123
|
The input topology with the divided topologies added to it as contents.
|
3119
3124
|
|
3120
3125
|
"""
|
3121
|
-
|
3122
3126
|
from topologicpy.Dictionary import Dictionary
|
3127
|
+
|
3123
3128
|
if not Topology.IsInstance(topologyA, "Topology"):
|
3124
3129
|
print("Topology.Divide - Error: the input topologyA parameter is not a valid topology. Returning None.")
|
3125
3130
|
return None
|
@@ -3186,7 +3191,7 @@ class Topology():
|
|
3186
3191
|
return topologyA
|
3187
3192
|
|
3188
3193
|
@staticmethod
|
3189
|
-
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):
|
3190
3195
|
"""
|
3191
3196
|
Explodes the input topology. See https://en.wikipedia.org/wiki/Exploded-view_drawing.
|
3192
3197
|
|
@@ -3202,6 +3207,8 @@ class Topology():
|
|
3202
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.
|
3203
3208
|
axes : str , optional
|
3204
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.
|
3205
3212
|
tolerance : float , optional
|
3206
3213
|
The desired tolerance. The default is 0.0001.
|
3207
3214
|
|
@@ -3288,19 +3295,19 @@ class Topology():
|
|
3288
3295
|
topologies = Topology.SubTopologies(topology, subTopologyType=typeFilter.lower())
|
3289
3296
|
for aTopology in topologies:
|
3290
3297
|
c = Topology.InternalVertex(aTopology, tolerance=tolerance)
|
3291
|
-
oldX =
|
3292
|
-
oldY =
|
3293
|
-
oldZ =
|
3298
|
+
oldX = Vertex.X(c, mantissa=mantissa)
|
3299
|
+
oldY = Vertex.Y(c, mantissa=mantissa)
|
3300
|
+
oldZ = Vertex.Z(c, mantissa=mantissa)
|
3294
3301
|
if x_flag:
|
3295
|
-
newX = (oldX -
|
3302
|
+
newX = (oldX - Vertex.X(origin, mantissa=mantissa))*scale + Vertex.X(origin, mantissa=mantissa)
|
3296
3303
|
else:
|
3297
3304
|
newX = oldX
|
3298
3305
|
if y_flag:
|
3299
|
-
newY = (oldY -
|
3306
|
+
newY = (oldY - Vertex.Y(origin, mantissa=mantissa))*scale + Vertex.Y(origin, mantissa=mantissa)
|
3300
3307
|
else:
|
3301
3308
|
newY = oldY
|
3302
3309
|
if z_flag:
|
3303
|
-
newZ = (oldZ -
|
3310
|
+
newZ = (oldZ - Vertex.Z(origin, mantissa=mantissa))*scale + Vertex.Z(origin, mantissa=mantissa)
|
3304
3311
|
else:
|
3305
3312
|
newZ = oldZ
|
3306
3313
|
xT = newX - oldX
|
@@ -3362,7 +3369,7 @@ class Topology():
|
|
3362
3369
|
return False
|
3363
3370
|
|
3364
3371
|
|
3365
|
-
def ExportToDXF(topologies, path, overwrite=False):
|
3372
|
+
def ExportToDXF(topologies, path: str, overwrite: bool = False, mantissa: int = 6):
|
3366
3373
|
"""
|
3367
3374
|
Exports the input topology to a DXF file. See https://en.wikipedia.org/wiki/AutoCAD_DXF.
|
3368
3375
|
THe DXF version is 'R2010'
|
@@ -3376,6 +3383,8 @@ class Topology():
|
|
3376
3383
|
The input file path.
|
3377
3384
|
overwrite : bool , optional
|
3378
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.
|
3379
3388
|
|
3380
3389
|
Returns
|
3381
3390
|
-------
|
@@ -3423,14 +3432,14 @@ class Topology():
|
|
3423
3432
|
def add_vertices(vertices, msp):
|
3424
3433
|
for v in vertices:
|
3425
3434
|
if Topology.IsInstance(v, "Vertex"):
|
3426
|
-
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)))
|
3427
3436
|
def add_edges(edges, msp):
|
3428
3437
|
for e in edges:
|
3429
3438
|
if Topology.IsInstance(e, "Edge"):
|
3430
3439
|
sv = Edge.StartVertex(e)
|
3431
3440
|
ev = Edge.EndVertex(e)
|
3432
|
-
start = (Vertex.X(sv), Vertex.Y(sv), Vertex.Z(sv))
|
3433
|
-
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))
|
3434
3443
|
msp.add_line(start, end)
|
3435
3444
|
def add_wires(wires, msp):
|
3436
3445
|
for i, w in enumerate(wires):
|
@@ -3442,8 +3451,8 @@ class Topology():
|
|
3442
3451
|
for edge in edges:
|
3443
3452
|
sv = Edge.StartVertex(edge)
|
3444
3453
|
ev = Edge.EndVertex(edge)
|
3445
|
-
start = (Vertex.X(sv), Vertex.Y(sv), Vertex.Z(sv))
|
3446
|
-
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))
|
3447
3456
|
block.add_line(start, end)
|
3448
3457
|
# Insert the block into the model space
|
3449
3458
|
msp.add_blockref(block_name, insert=(0, 0, 0))
|
@@ -4229,7 +4238,7 @@ class Topology():
|
|
4229
4238
|
return {"filtered": filteredTopologies, "other": otherTopologies}
|
4230
4239
|
|
4231
4240
|
@staticmethod
|
4232
|
-
def Flatten(topology, origin=None, direction=[0, 0, 1]):
|
4241
|
+
def Flatten(topology, origin=None, direction: list = [0, 0, 1], mantissa: int = 6):
|
4233
4242
|
"""
|
4234
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()).
|
4235
4244
|
|
@@ -4239,8 +4248,10 @@ class Topology():
|
|
4239
4248
|
The input topology.
|
4240
4249
|
origin : topologic_core.Vertex , optional
|
4241
4250
|
The input origin. If set to None, The object's centroid will be used to place the world origin. The default is None.
|
4242
|
-
|
4251
|
+
direction : list , optional
|
4243
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.
|
4244
4255
|
|
4245
4256
|
Returns
|
4246
4257
|
-------
|
@@ -4257,13 +4268,13 @@ class Topology():
|
|
4257
4268
|
if origin == None:
|
4258
4269
|
origin = Topology.Centroid(topology)
|
4259
4270
|
up = Vector.Up()
|
4260
|
-
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))
|
4261
4272
|
tran_mat = Vector.TransformationMatrix(direction, up)
|
4262
4273
|
flat_topology = Topology.Transform(flat_topology, tran_mat)
|
4263
4274
|
return flat_topology
|
4264
4275
|
|
4265
4276
|
@staticmethod
|
4266
|
-
def Geometry(topology, mantissa=6):
|
4277
|
+
def Geometry(topology, mantissa: int = 6):
|
4267
4278
|
"""
|
4268
4279
|
Returns the geometry (mesh data format) of the input topology as a dictionary of vertices, edges, and faces.
|
4269
4280
|
|
@@ -4543,7 +4554,7 @@ class Topology():
|
|
4543
4554
|
return None
|
4544
4555
|
|
4545
4556
|
@staticmethod
|
4546
|
-
def IsPlanar(topology, tolerance=0.0001):
|
4557
|
+
def IsPlanar(topology, mantissa: int = 6, tolerance: float = 0.0001):
|
4547
4558
|
"""
|
4548
4559
|
Returns True if all the vertices of the input topology are co-planar. Returns False otherwise.
|
4549
4560
|
|
@@ -4551,6 +4562,8 @@ class Topology():
|
|
4551
4562
|
----------
|
4552
4563
|
topology : topologic_core.Topology
|
4553
4564
|
The input topology.
|
4565
|
+
mantissa : int , optional
|
4566
|
+
The desired length of the mantissa. The default is 6
|
4554
4567
|
tolerance : float , optional
|
4555
4568
|
The desired tolerance. The default is 0.0001.
|
4556
4569
|
|
@@ -4560,7 +4573,8 @@ class Topology():
|
|
4560
4573
|
True if all the vertices of the input topology are co-planar. False otherwise.
|
4561
4574
|
|
4562
4575
|
"""
|
4563
|
-
|
4576
|
+
from topologicpy.Vertex import Vertex
|
4577
|
+
|
4564
4578
|
def isOnPlane(v, plane, tolerance):
|
4565
4579
|
x, y, z = v
|
4566
4580
|
a, b, c, d = plane
|
@@ -4569,16 +4583,16 @@ class Topology():
|
|
4569
4583
|
return False
|
4570
4584
|
|
4571
4585
|
def plane(v1, v2, v3):
|
4572
|
-
a1 =
|
4573
|
-
b1 =
|
4574
|
-
c1 =
|
4575
|
-
a2 =
|
4576
|
-
b2 =
|
4577
|
-
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)
|
4578
4592
|
a = b1 * c2 - b2 * c1
|
4579
4593
|
b = a2 * c1 - a1 * c2
|
4580
4594
|
c = a1 * b2 - b1 * a2
|
4581
|
-
d = (- a *
|
4595
|
+
d = (- a * Vertex.X(v1, mantissa=mantissa) - b * Vertex.Y(v1, mantissa=mantissa) - c * Vertex.Z(v1, mantissa=mantissa))
|
4582
4596
|
return [a, b, c, d]
|
4583
4597
|
|
4584
4598
|
if not Topology.IsInstance(topology, "Topology"):
|
@@ -4592,7 +4606,7 @@ class Topology():
|
|
4592
4606
|
else:
|
4593
4607
|
p = plane(vertices[0], vertices[1], vertices[2])
|
4594
4608
|
for i in range(len(vertices)):
|
4595
|
-
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:
|
4596
4610
|
result = False
|
4597
4611
|
break
|
4598
4612
|
return result
|
@@ -4846,7 +4860,7 @@ class Topology():
|
|
4846
4860
|
return return_topology
|
4847
4861
|
|
4848
4862
|
@staticmethod
|
4849
|
-
def Place(topology, originA=None, originB=None):
|
4863
|
+
def Place(topology, originA=None, originB=None, mantissa: int = 6):
|
4850
4864
|
"""
|
4851
4865
|
Places the input topology at the specified location.
|
4852
4866
|
|
@@ -4858,6 +4872,8 @@ class Topology():
|
|
4858
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.
|
4859
4873
|
originB : topologic_core.Vertex , optional
|
4860
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
|
4861
4877
|
|
4862
4878
|
Returns
|
4863
4879
|
-------
|
@@ -4873,9 +4889,9 @@ class Topology():
|
|
4873
4889
|
if not Topology.IsInstance(originA, "Vertex"):
|
4874
4890
|
originA = Vertex.ByCoordinates(0, 0, 0)
|
4875
4891
|
|
4876
|
-
x =
|
4877
|
-
y =
|
4878
|
-
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)
|
4879
4895
|
newTopology = None
|
4880
4896
|
try:
|
4881
4897
|
newTopology = Topology.Translate(topology, x, y, z)
|
@@ -5304,7 +5320,7 @@ class Topology():
|
|
5304
5320
|
return topology
|
5305
5321
|
|
5306
5322
|
@staticmethod
|
5307
|
-
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):
|
5308
5324
|
"""
|
5309
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.
|
5310
5326
|
|
@@ -5341,7 +5357,7 @@ class Topology():
|
|
5341
5357
|
n = Vertex.Index(v, verts, tolerance=tolerance)
|
5342
5358
|
if not n == None:
|
5343
5359
|
new_verts[n] = verticesB[i]
|
5344
|
-
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]
|
5345
5361
|
new_topology = Topology.ByGeometry(vertices=new_g_verts, edges=g_edges, faces=g_faces)
|
5346
5362
|
return new_topology
|
5347
5363
|
|
@@ -6286,7 +6302,7 @@ class Topology():
|
|
6286
6302
|
return returnTopology
|
6287
6303
|
|
6288
6304
|
@staticmethod
|
6289
|
-
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):
|
6290
6306
|
"""
|
6291
6307
|
Tapers the input topology. This method tapers the input geometry along its Z-axis based on the ratio range input.
|
6292
6308
|
|
@@ -6300,6 +6316,8 @@ class Topology():
|
|
6300
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.
|
6301
6317
|
triangulate : bool , optional
|
6302
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.
|
6303
6321
|
tolerance : float , optional
|
6304
6322
|
The desired tolerance. Vertices will not be moved if the calculated distance is at or less than this tolerance.
|
6305
6323
|
|
@@ -6321,17 +6339,17 @@ class Topology():
|
|
6321
6339
|
if origin == None:
|
6322
6340
|
origin = Topology.Centroid(topology)
|
6323
6341
|
vertices = Topology.Vertices(topology)
|
6324
|
-
zList = [Vertex.Z(v) for v in vertices]
|
6342
|
+
zList = [Vertex.Z(v, mantissa=mantissa) for v in vertices]
|
6325
6343
|
minZ = min(zList)
|
6326
6344
|
maxZ = max(zList)
|
6327
6345
|
new_vertices = []
|
6328
6346
|
for v in vertices:
|
6329
6347
|
ht = (Vertex.Z(v)-minZ)/(maxZ - minZ)
|
6330
6348
|
rt = ratioRange[0] + ht*(ratioRange[1] - ratioRange[0])
|
6331
|
-
new_origin = Vertex.ByCoordinates(Vertex.X(origin), Vertex.Y(origin), Vertex.Z(v))
|
6332
|
-
new_dist = Vertex.Distance(new_origin, v)*rt
|
6333
|
-
c_a = Vertex.Coordinates(new_origin)
|
6334
|
-
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)
|
6335
6353
|
new_dir = [(c_a[0]-c_b[0]), (c_a[1]-c_b[1]), 0]
|
6336
6354
|
if abs(new_dist) > tolerance:
|
6337
6355
|
new_v = Topology.TranslateByDirectionDistance(v, direction=new_dir, distance=new_dist)
|
@@ -6342,7 +6360,7 @@ class Topology():
|
|
6342
6360
|
return return_topology
|
6343
6361
|
|
6344
6362
|
@staticmethod
|
6345
|
-
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):
|
6346
6364
|
"""
|
6347
6365
|
Twists the input topology. This method twists the input geometry along its Z-axis based on the degree range input.
|
6348
6366
|
|
@@ -6356,6 +6374,8 @@ class Topology():
|
|
6356
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.
|
6357
6375
|
triangulate : bool , optional
|
6358
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.
|
6359
6379
|
|
6360
6380
|
Returns
|
6361
6381
|
-------
|
@@ -6373,7 +6393,7 @@ class Topology():
|
|
6373
6393
|
origin = Topology.Centroid(topology)
|
6374
6394
|
|
6375
6395
|
vertices = Topology.Vertices(topology)
|
6376
|
-
zList = [Vertex.Z(v) for v in vertices]
|
6396
|
+
zList = [Vertex.Z(v, mantissa=mantissa) for v in vertices]
|
6377
6397
|
minZ = min(zList)
|
6378
6398
|
maxZ = max(zList)
|
6379
6399
|
h = maxZ - minZ
|
@@ -6381,7 +6401,7 @@ class Topology():
|
|
6381
6401
|
for v in vertices:
|
6382
6402
|
ht = (Vertex.Z(v)-minZ)/(maxZ - minZ)
|
6383
6403
|
new_rot = angleRange[0] + ht*(angleRange[1] - angleRange[0])
|
6384
|
-
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))
|
6385
6405
|
new_vertices.append(Topology.Rotate(v, origin=orig, axis=[0, 0, 1], angle=new_rot))
|
6386
6406
|
return_topology = Topology.ReplaceVertices(topology, vertices, new_vertices)
|
6387
6407
|
return_topology = Topology.Fix(return_topology, topologyType=Topology.TypeAsString(topology))
|
@@ -7141,4 +7161,29 @@ class Topology():
|
|
7141
7161
|
typeID = 2048
|
7142
7162
|
elif name == "topology":
|
7143
7163
|
typeID = 4096
|
7144
|
-
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
|