topologicpy 0.6.3__py3-none-any.whl → 0.7.0__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/Aperture.py +12 -13
- topologicpy/Cell.py +234 -210
- topologicpy/CellComplex.py +130 -118
- topologicpy/Cluster.py +108 -91
- topologicpy/Context.py +11 -7
- topologicpy/DGL.py +1 -1
- topologicpy/Dictionary.py +55 -65
- topologicpy/Edge.py +185 -148
- topologicpy/EnergyModel.py +23 -24
- topologicpy/Face.py +512 -313
- topologicpy/Graph.py +437 -349
- topologicpy/Grid.py +40 -43
- topologicpy/Honeybee.py +1 -1
- topologicpy/Matrix.py +28 -27
- topologicpy/Neo4j.py +5 -5
- topologicpy/Plotly.py +135 -51
- topologicpy/Shell.py +160 -145
- topologicpy/Sun.py +17 -13
- topologicpy/Topology.py +533 -765
- topologicpy/Vector.py +4 -3
- topologicpy/Vertex.py +145 -126
- topologicpy/Wire.py +542 -325
- topologicpy/version.py +1 -1
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.0.dist-info}/METADATA +1 -1
- topologicpy-0.7.0.dist-info/RECORD +33 -0
- topologicpy-0.6.3.dist-info/RECORD +0 -33
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.0.dist-info}/LICENSE +0 -0
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.0.dist-info}/WHEEL +0 -0
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.0.dist-info}/top_level.txt +0 -0
topologicpy/Edge.py
CHANGED
@@ -15,19 +15,16 @@
|
|
15
15
|
# this program. If not, see <https://www.gnu.org/licenses/>.
|
16
16
|
|
17
17
|
import topologic_core as topologic
|
18
|
-
from topologicpy.Vertex import Vertex
|
19
|
-
from topologicpy.Vector import Vector
|
20
|
-
from topologicpy.Topology import Topology
|
21
18
|
|
22
|
-
class Edge(
|
19
|
+
class Edge():
|
23
20
|
@staticmethod
|
24
|
-
def Angle(edgeA
|
21
|
+
def Angle(edgeA, edgeB, mantissa: int = 6, bracket: bool = False) -> float:
|
25
22
|
"""
|
26
23
|
Returns the angle in degrees between the two input edges.
|
27
24
|
|
28
25
|
Parameters
|
29
26
|
----------
|
30
|
-
edgeA :
|
27
|
+
edgeA : topologic_core.Edge
|
31
28
|
The first input edge.
|
32
29
|
edgeB : topologic Edge
|
33
30
|
The second input edge.
|
@@ -42,11 +39,13 @@ class Edge(Topology):
|
|
42
39
|
The angle in degrees between the two input edges.
|
43
40
|
|
44
41
|
"""
|
42
|
+
from topologicpy.Topology import Topology
|
43
|
+
from topologicpy.Vector import Vector
|
45
44
|
|
46
|
-
if not
|
45
|
+
if not Topology.IsInstance(edgeA, "Edge"):
|
47
46
|
print("Edge.Angle - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
|
48
47
|
return None
|
49
|
-
if not
|
48
|
+
if not Topology.IsInstance(edgeB, "Edge"):
|
50
49
|
print("Edge.Angle - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
|
51
50
|
return None
|
52
51
|
dirA = Edge.Direction(edgeA, mantissa)
|
@@ -58,13 +57,13 @@ class Edge(Topology):
|
|
58
57
|
return round(ang, mantissa)
|
59
58
|
|
60
59
|
@staticmethod
|
61
|
-
def Bisect(edgeA
|
60
|
+
def Bisect(edgeA, edgeB, length: float = 1.0, placement: int = 0, tolerance: float = 0.0001):
|
62
61
|
"""
|
63
62
|
Creates a bisecting edge between edgeA and edgeB.
|
64
63
|
|
65
64
|
Parameters
|
66
65
|
----------
|
67
|
-
edgeA :
|
66
|
+
edgeA : topologic_core.Edge
|
68
67
|
The first topologic Edge.
|
69
68
|
edgeB : topologic Edge
|
70
69
|
The second topologic Edge.
|
@@ -81,7 +80,7 @@ class Edge(Topology):
|
|
81
80
|
|
82
81
|
Returns
|
83
82
|
-------
|
84
|
-
|
83
|
+
topologic_core.Edge
|
85
84
|
The created bisecting edge.
|
86
85
|
|
87
86
|
"""
|
@@ -92,10 +91,10 @@ class Edge(Topology):
|
|
92
91
|
from topologicpy.Topology import Topology
|
93
92
|
from topologicpy.Vector import Vector
|
94
93
|
|
95
|
-
if not
|
94
|
+
if not Topology.IsInstance(edgeA, "Edge"):
|
96
95
|
print("Edge.Bisect - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
|
97
96
|
return None
|
98
|
-
if not
|
97
|
+
if not Topology.IsInstance(edgeB, "Edge"):
|
99
98
|
print("Edge.Bisect - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
|
100
99
|
return None
|
101
100
|
if Edge.Length(edgeA) < tolerance:
|
@@ -106,7 +105,7 @@ class Edge(Topology):
|
|
106
105
|
return None
|
107
106
|
|
108
107
|
wire = Topology.SelfMerge(Cluster.ByTopologies([edgeA, edgeB]), tolerance=tolerance)
|
109
|
-
if not
|
108
|
+
if not Topology.IsInstance(wire, "Wire"):
|
110
109
|
print("Edge.Bisect - Error: The input edgeA and edgeB parameters do not share a vertex and thus cannot be bisected. Returning None.")
|
111
110
|
return None
|
112
111
|
edges = Topology.Edges(wire)
|
@@ -123,13 +122,13 @@ class Edge(Topology):
|
|
123
122
|
return bisecting_edge
|
124
123
|
|
125
124
|
@staticmethod
|
126
|
-
def ByFaceNormal(face
|
125
|
+
def ByFaceNormal(face, origin= None, length: float = 1.0, tolerance: float = 0.0001):
|
127
126
|
"""
|
128
127
|
Creates a straight edge representing the normal to the input face.
|
129
128
|
|
130
129
|
Parameters
|
131
130
|
----------
|
132
|
-
face :
|
131
|
+
face : topologic_core.Face
|
133
132
|
The input face
|
134
133
|
origin : toopologic.Vertex , optional
|
135
134
|
The desired origin of the edge. If set to None, the centroid of the face is chosen as the origin of the edge. The default is None.
|
@@ -140,7 +139,7 @@ class Edge(Topology):
|
|
140
139
|
|
141
140
|
Returns
|
142
141
|
-------
|
143
|
-
edge :
|
142
|
+
edge : topologic_core.Edge
|
144
143
|
The created edge.
|
145
144
|
|
146
145
|
"""
|
@@ -148,34 +147,34 @@ class Edge(Topology):
|
|
148
147
|
from topologicpy.Face import Face
|
149
148
|
from topologicpy.Topology import Topology
|
150
149
|
edge = None
|
151
|
-
if not
|
150
|
+
if not Topology.IsInstance(face, "Face"):
|
152
151
|
print("Edge.ByFaceNormal - Error: The input face parameter is not a valid topologic face. Returning None.")
|
153
152
|
return None
|
154
|
-
if not
|
153
|
+
if not Topology.IsInstance(origin, "Vertex"):
|
155
154
|
origin = Topology.Centroid(face)
|
156
|
-
if not
|
155
|
+
if not Topology.IsInstance(origin, "Vertex"):
|
157
156
|
print("Edge.ByFaceNormal - Error: The input origin parameter is not a valid topologic origin. Returning None.")
|
158
157
|
return None
|
159
158
|
n = Face.Normal(face)
|
160
159
|
v2 = Topology.Translate(origin, n[0], n[1], n[2])
|
161
160
|
edge = Edge.ByStartVertexEndVertex(origin, v2, tolerance=tolerance, silent=True)
|
162
|
-
if not
|
161
|
+
if not Topology.IsInstance(edge, "Edge"):
|
163
162
|
print("Edge.ByFaceNormal - Error: Could not create an edge. Returning None.")
|
164
163
|
return None
|
165
164
|
edge = Edge.SetLength(edge, length, bothSides=False)
|
166
|
-
if not
|
165
|
+
if not Topology.IsInstance(edge, "Edge"):
|
167
166
|
print("Edge.ByFaceNormal - Error: Could not create an edge. Returning None.")
|
168
167
|
return None
|
169
168
|
return edge
|
170
169
|
|
171
170
|
@staticmethod
|
172
|
-
def ByOffset2D(edge
|
171
|
+
def ByOffset2D(edge, offset: float = 1.0, tolerance: float = 0.0001):
|
173
172
|
"""
|
174
173
|
Creates and edge offset from the input edge. This method is intended for edges that are in the XY plane.
|
175
174
|
|
176
175
|
Parameters
|
177
176
|
----------
|
178
|
-
edge :
|
177
|
+
edge : topologic_core.Edge
|
179
178
|
The input edge.
|
180
179
|
offset : float , optional
|
181
180
|
The desired offset. The default is 1.
|
@@ -184,11 +183,13 @@ class Edge(Topology):
|
|
184
183
|
|
185
184
|
Returns
|
186
185
|
-------
|
187
|
-
|
186
|
+
topologic_core.Edge
|
188
187
|
An edge offset from the input edge.
|
189
188
|
|
190
189
|
"""
|
191
190
|
from topologicpy.Topology import Topology
|
191
|
+
from topologicpy.Vector import Vector
|
192
|
+
|
192
193
|
n = Edge.Normal(edge)
|
193
194
|
n = Vector.Normalize(n)
|
194
195
|
n = Vector.Multiply(n, offset, tolerance)
|
@@ -197,13 +198,13 @@ class Edge(Topology):
|
|
197
198
|
|
198
199
|
|
199
200
|
@staticmethod
|
200
|
-
def ByStartVertexEndVertex(vertexA
|
201
|
+
def ByStartVertexEndVertex(vertexA, vertexB, tolerance: float = 0.0001, silent=False):
|
201
202
|
"""
|
202
203
|
Creates a straight edge that connects the input vertices.
|
203
204
|
|
204
205
|
Parameters
|
205
206
|
----------
|
206
|
-
vertexA :
|
207
|
+
vertexA : topologic_core.Vertex
|
207
208
|
The first input vertex. This is considered the start vertex.
|
208
209
|
vertexB : toopologic.Vertex
|
209
210
|
The second input vertex. This is considered the end vertex.
|
@@ -214,21 +215,23 @@ class Edge(Topology):
|
|
214
215
|
|
215
216
|
Returns
|
216
217
|
-------
|
217
|
-
edge :
|
218
|
+
edge : topologic_core.Edge
|
218
219
|
The created edge.
|
219
220
|
|
220
221
|
"""
|
221
222
|
from topologicpy.Vertex import Vertex
|
223
|
+
from topologicpy.Topology import Topology
|
224
|
+
|
222
225
|
edge = None
|
223
|
-
if not
|
226
|
+
if not Topology.IsInstance(vertexA, "Vertex"):
|
224
227
|
if not silent:
|
225
228
|
print("Edge.ByStartVertexEndVertex - Error: The input vertexA parameter is not a valid topologic vertex. Returning None.")
|
226
229
|
return None
|
227
|
-
if not
|
230
|
+
if not Topology.IsInstance(vertexB, "Vertex"):
|
228
231
|
if not silent:
|
229
232
|
print("Edge.ByStartVertexEndVertex - Error: The input vertexB parameter is not a valid topologic vertex. Returning None.")
|
230
233
|
return None
|
231
|
-
if
|
234
|
+
if Topology.IsSame(vertexA, vertexB):
|
232
235
|
if not silent:
|
233
236
|
print("Edge.ByStartVertexEndVertex - Error: The input vertexA and vertexB parameters are the same vertex. Returning None.")
|
234
237
|
return None
|
@@ -237,7 +240,7 @@ class Edge(Topology):
|
|
237
240
|
print("Edge.ByStartVertexEndVertex - Error: The distance between the input vertexA and vertexB parameters is less than the input tolerance. Returning None.")
|
238
241
|
return None
|
239
242
|
try:
|
240
|
-
edge = topologic.Edge.ByStartVertexEndVertex(vertexA, vertexB)
|
243
|
+
edge = topologic.Edge.ByStartVertexEndVertex(vertexA, vertexB) # Hook to Core
|
241
244
|
except:
|
242
245
|
if not silent:
|
243
246
|
print("Edge.ByStartVertexEndVertex - Error: Could not create an edge. Returning None.")
|
@@ -245,7 +248,7 @@ class Edge(Topology):
|
|
245
248
|
return edge
|
246
249
|
|
247
250
|
@staticmethod
|
248
|
-
def ByVertices(*args, tolerance: float = 0.0001, silent: bool = False)
|
251
|
+
def ByVertices(*args, tolerance: float = 0.0001, silent: bool = False):
|
249
252
|
"""
|
250
253
|
Creates a straight edge that connects the input list of vertices.
|
251
254
|
|
@@ -260,12 +263,12 @@ class Edge(Topology):
|
|
260
263
|
|
261
264
|
Returns
|
262
265
|
-------
|
263
|
-
|
266
|
+
topologic_core.Edge
|
264
267
|
The created edge.
|
265
268
|
|
266
269
|
"""
|
267
|
-
|
268
270
|
from topologicpy.Helper import Helper
|
271
|
+
from topologicpy.Topology import Topology
|
269
272
|
|
270
273
|
if len(args) == 0:
|
271
274
|
print("Edge.ByVertices - Error: The input vertices parameter is an empty list. Returning None.")
|
@@ -278,7 +281,7 @@ class Edge(Topology):
|
|
278
281
|
print("Edge.ByVertices - Error: The input vertices parameter is an empty list. Returning None.")
|
279
282
|
return None
|
280
283
|
else:
|
281
|
-
vertexList = [x for x in vertices if
|
284
|
+
vertexList = [x for x in vertices if Topology.IsInstance(x, "Vertex")]
|
282
285
|
if len(vertexList) == 0:
|
283
286
|
if not silent:
|
284
287
|
print("Edge.ByVertices - Error: The input vertices parameter does not contain any valid vertices. Returning None.")
|
@@ -289,7 +292,7 @@ class Edge(Topology):
|
|
289
292
|
return None
|
290
293
|
else:
|
291
294
|
vertexList = Helper.Flatten(list(args))
|
292
|
-
vertexList = [x for x in vertexList if
|
295
|
+
vertexList = [x for x in vertexList if Topology.IsInstance(x, "Vertex")]
|
293
296
|
if len(vertexList) < 2:
|
294
297
|
if not silent:
|
295
298
|
print("Edge.ByVertices - Error: The input vertices parameter has less than two vertices. Returning None.")
|
@@ -297,42 +300,44 @@ class Edge(Topology):
|
|
297
300
|
return Edge.ByStartVertexEndVertex(vertexList[0], vertexList[-1], tolerance=tolerance, silent=silent)
|
298
301
|
|
299
302
|
@staticmethod
|
300
|
-
def ByVerticesCluster(cluster
|
303
|
+
def ByVerticesCluster(cluster, tolerance: float = 0.0001):
|
301
304
|
"""
|
302
305
|
Creates a straight edge that connects the input cluster of vertices.
|
303
306
|
|
304
307
|
Parameters
|
305
308
|
----------
|
306
|
-
cluster :
|
309
|
+
cluster : topologic_core.Cluster
|
307
310
|
The input cluster of vertices. The first item is considered the start vertex and the last item is considered the end vertex.
|
308
311
|
tolerance : float , optional
|
309
312
|
The desired tolerance to decide if an edge can be created. The default is 0.0001.
|
310
313
|
|
311
314
|
Returns
|
312
315
|
-------
|
313
|
-
|
316
|
+
topologic_core.Edge
|
314
317
|
The created edge.
|
315
318
|
|
316
319
|
"""
|
317
320
|
from topologicpy.Cluster import Cluster
|
318
|
-
|
321
|
+
from topologicpy.Topology import Topology
|
322
|
+
|
323
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
319
324
|
print("Edge.ByVerticesCluster - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
320
325
|
return None
|
321
326
|
vertices = Cluster.Vertices(cluster)
|
322
|
-
vertexList = [x for x in vertices if
|
327
|
+
vertexList = [x for x in vertices if Topology.IsInstance(x, "Vertex")]
|
323
328
|
if len(vertexList) < 2:
|
324
329
|
print("Edge.ByVerticesCluster - Error: The input cluster parameter contains less than two vertices. Returning None.")
|
325
330
|
return None
|
326
331
|
return Edge.ByStartVertexEndVertex(vertexList[0], vertexList[-1], tolerance=tolerance)
|
327
332
|
|
328
333
|
@staticmethod
|
329
|
-
def Direction(edge
|
334
|
+
def Direction(edge, mantissa: int = 6) -> list:
|
330
335
|
"""
|
331
336
|
Returns the direction of the input edge expressed as a list of three numbers.
|
332
337
|
|
333
338
|
Parameters
|
334
339
|
----------
|
335
|
-
edge :
|
340
|
+
edge : topologic_core.Edge
|
336
341
|
The input edge.
|
337
342
|
mantissa : int , optional
|
338
343
|
The desired length of the mantissa. The default is 6.
|
@@ -343,10 +348,10 @@ class Edge(Topology):
|
|
343
348
|
The direction of the input edge.
|
344
349
|
|
345
350
|
"""
|
346
|
-
|
347
351
|
from topologicpy.Vector import Vector
|
352
|
+
from topologicpy.Topology import Topology
|
348
353
|
|
349
|
-
if not
|
354
|
+
if not Topology.IsInstance(edge, "Edge"):
|
350
355
|
print("Edge.Direction - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
351
356
|
return None
|
352
357
|
ev = edge.EndVertex()
|
@@ -361,22 +366,24 @@ class Edge(Topology):
|
|
361
366
|
return [x, y, z]
|
362
367
|
|
363
368
|
@staticmethod
|
364
|
-
def EndVertex(edge
|
369
|
+
def EndVertex(edge):
|
365
370
|
"""
|
366
371
|
Returns the end vertex of the input edge.
|
367
372
|
|
368
373
|
Parameters
|
369
374
|
----------
|
370
|
-
edge :
|
375
|
+
edge : topologic_core.Edge
|
371
376
|
The input edge.
|
372
377
|
|
373
378
|
Returns
|
374
379
|
-------
|
375
|
-
|
380
|
+
topologic_core.Vertex
|
376
381
|
The end vertex of the input edge.
|
377
382
|
|
378
383
|
"""
|
379
|
-
|
384
|
+
from topologicpy.Topology import Topology
|
385
|
+
|
386
|
+
if not Topology.IsInstance(edge, "Edge"):
|
380
387
|
print("Edge.EndVertex - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
381
388
|
return None
|
382
389
|
vert = None
|
@@ -387,13 +394,13 @@ class Edge(Topology):
|
|
387
394
|
return vert
|
388
395
|
|
389
396
|
@staticmethod
|
390
|
-
def Extend(edge
|
397
|
+
def Extend(edge, distance: float = 1.0, bothSides: bool = True, reverse: bool = False, tolerance: float = 0.0001):
|
391
398
|
"""
|
392
399
|
Extends the input edge by the input distance.
|
393
400
|
|
394
401
|
Parameters
|
395
402
|
----------
|
396
|
-
edge :
|
403
|
+
edge : topologic_core.Edge
|
397
404
|
The input edge.
|
398
405
|
distance : float , optional
|
399
406
|
The offset distance. The default is 1.
|
@@ -406,11 +413,13 @@ class Edge(Topology):
|
|
406
413
|
|
407
414
|
Returns
|
408
415
|
-------
|
409
|
-
|
416
|
+
topologic_core.Edge
|
410
417
|
The extended edge.
|
411
418
|
|
412
419
|
"""
|
413
|
-
|
420
|
+
from topologicpy.Topology import Topology
|
421
|
+
|
422
|
+
if not Topology.IsInstance(edge, "Edge"):
|
414
423
|
print("Edge.Extend - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
415
424
|
return None
|
416
425
|
distance = abs(distance)
|
@@ -430,22 +439,22 @@ class Edge(Topology):
|
|
430
439
|
return Edge.ByVertices([sve, eve], tolerance=tolerance, silent=True)
|
431
440
|
|
432
441
|
@staticmethod
|
433
|
-
def ExtendToEdge2D(edgeA
|
442
|
+
def ExtendToEdge2D(edgeA, edgeB, tolerance: float = 0.0001):
|
434
443
|
"""
|
435
444
|
Extends the first input edge to meet the second input edge. This works only in the XY plane. Z coordinates are ignored.
|
436
445
|
|
437
446
|
Parameters
|
438
447
|
----------
|
439
|
-
edgeA :
|
448
|
+
edgeA : topologic_core.Edge
|
440
449
|
The first input edge.
|
441
|
-
edgeB :
|
450
|
+
edgeB : topologic_core.Edge
|
442
451
|
The second input edge.
|
443
452
|
tolerance : float , optional
|
444
453
|
The desired tolerance. The default is 0.0001.
|
445
454
|
|
446
455
|
Returns
|
447
456
|
-------
|
448
|
-
|
457
|
+
topologic_core.Edge
|
449
458
|
The extended edge.
|
450
459
|
|
451
460
|
"""
|
@@ -453,10 +462,10 @@ class Edge(Topology):
|
|
453
462
|
from topologicpy.Vertex import Vertex
|
454
463
|
from topologicpy.Topology import Topology
|
455
464
|
|
456
|
-
if not
|
465
|
+
if not Topology.IsInstance(edgeA, "Edge"):
|
457
466
|
print("Edge.ExtendToEdge2D - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
|
458
467
|
return None
|
459
|
-
if not
|
468
|
+
if not Topology.IsInstance(edgeB, "Edge"):
|
460
469
|
print("Edge.ExtendToEdge2D - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
|
461
470
|
return None
|
462
471
|
sva = Edge.StartVertex(edgeA)
|
@@ -475,13 +484,13 @@ class Edge(Topology):
|
|
475
484
|
return None
|
476
485
|
|
477
486
|
@staticmethod
|
478
|
-
def Index(edge
|
487
|
+
def Index(edge, edges: list, strict: bool = False, tolerance: float = 0.0001) -> int:
|
479
488
|
"""
|
480
489
|
Returns index of the input edge in the input list of edges
|
481
490
|
|
482
491
|
Parameters
|
483
492
|
----------
|
484
|
-
edge :
|
493
|
+
edge : topologic_core.Edge
|
485
494
|
The input edge.
|
486
495
|
edges : list
|
487
496
|
The input list of edges.
|
@@ -497,13 +506,15 @@ class Edge(Topology):
|
|
497
506
|
|
498
507
|
"""
|
499
508
|
from topologicpy.Topology import Topology
|
500
|
-
|
509
|
+
from topologicpy.Vertex import Vertex
|
510
|
+
|
511
|
+
if not Topology.IsInstance(edge, "Edge"):
|
501
512
|
print("Edge.Index - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
502
513
|
return None
|
503
514
|
if not isinstance(edges, list):
|
504
515
|
print("Edge.Index - Error: The input edges parameter is not a valid list. Returning None.")
|
505
516
|
return None
|
506
|
-
edges = [e for e in edges if
|
517
|
+
edges = [e for e in edges if Topology.IsInstance(e, "Edge")]
|
507
518
|
if len(edges) < 1:
|
508
519
|
print("Edge.Index - Error: The input edges parameter contains no valid edges. Returning None.")
|
509
520
|
return None
|
@@ -527,30 +538,33 @@ class Edge(Topology):
|
|
527
538
|
return None
|
528
539
|
|
529
540
|
@staticmethod
|
530
|
-
def Intersect2D(edgeA
|
541
|
+
def Intersect2D(edgeA, edgeB, silent: bool = False):
|
531
542
|
"""
|
532
|
-
Returns the intersection of the two input edges as a
|
543
|
+
Returns the intersection of the two input edges as a topologic_core.Vertex. This works only in the XY plane. Z coordinates are ignored.
|
533
544
|
|
534
545
|
Parameters
|
535
546
|
----------
|
536
|
-
edgeA :
|
547
|
+
edgeA : topologic_core.Edge
|
537
548
|
The first input edge.
|
538
|
-
edgeB :
|
549
|
+
edgeB : topologic_core.Edge
|
539
550
|
The second input edge.
|
540
551
|
silent : bool , optional
|
541
552
|
If set to False, error and warning messages are displayed. Otherwise they are not. The default is False.
|
542
553
|
|
543
554
|
Returns
|
544
555
|
-------
|
545
|
-
|
556
|
+
topologic_core.Vertex
|
546
557
|
The intersection of the two input edges.
|
547
558
|
|
548
559
|
"""
|
549
|
-
|
560
|
+
from topologicpy.Vertex import Vertex
|
561
|
+
from topologicpy.Topology import Topology
|
562
|
+
|
563
|
+
if not Topology.IsInstance(edgeA, "Edge"):
|
550
564
|
if not silent:
|
551
565
|
print("Edge.Intersect2D - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
|
552
566
|
return None
|
553
|
-
if not
|
567
|
+
if not Topology.IsInstance(edgeB, "Edge"):
|
554
568
|
if not silent:
|
555
569
|
print("Edge.Intersect2D - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
|
556
570
|
return None
|
@@ -583,15 +597,15 @@ class Edge(Topology):
|
|
583
597
|
|
584
598
|
|
585
599
|
@staticmethod
|
586
|
-
def IsCollinear(edgeA
|
600
|
+
def IsCollinear(edgeA, edgeB, mantissa: int = 6, angTolerance: float = 0.1, tolerance: float = 0.0001) -> bool:
|
587
601
|
"""
|
588
602
|
Return True if the two input edges are collinear. Returns False otherwise.
|
589
603
|
|
590
604
|
Parameters
|
591
605
|
----------
|
592
|
-
edgeA :
|
606
|
+
edgeA : topologic_core.Edge
|
593
607
|
The first input edge.
|
594
|
-
edgeB :
|
608
|
+
edgeB : topologic_core.Edge
|
595
609
|
The second input edge.
|
596
610
|
mantissa : int , optional
|
597
611
|
The desired length of the mantissa. The default is 6.
|
@@ -606,10 +620,13 @@ class Edge(Topology):
|
|
606
620
|
True if the two edges are collinear. False otherwise.
|
607
621
|
|
608
622
|
"""
|
609
|
-
|
623
|
+
from topologicpy.Vertex import Vertex
|
624
|
+
from topologicpy.Topology import Topology
|
625
|
+
|
626
|
+
if not Topology.IsInstance(edgeA, "Edge"):
|
610
627
|
print("Edge.IsCollinear - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
|
611
628
|
return None
|
612
|
-
if not
|
629
|
+
if not Topology.IsInstance(edgeB, "Edge"):
|
613
630
|
print("Edge.IsCollinear - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
|
614
631
|
return None
|
615
632
|
ang = Edge.Angle(edgeA, edgeB, mantissa=mantissa, bracket=True)
|
@@ -626,15 +643,15 @@ class Edge(Topology):
|
|
626
643
|
return False
|
627
644
|
|
628
645
|
@staticmethod
|
629
|
-
def IsParallel(edgeA
|
646
|
+
def IsParallel(edgeA, edgeB, mantissa: int = 6, angTolerance: float = 0.1) -> bool:
|
630
647
|
"""
|
631
648
|
Return True if the two input edges are parallel. Returns False otherwise.
|
632
649
|
|
633
650
|
Parameters
|
634
651
|
----------
|
635
|
-
edgeA :
|
652
|
+
edgeA : topologic_core.Edge
|
636
653
|
The first input edge.
|
637
|
-
edgeB :
|
654
|
+
edgeB : topologic_core.Edge
|
638
655
|
The second input edge.
|
639
656
|
mantissa : int , optional
|
640
657
|
The desired length of the mantissa. The default is 6.
|
@@ -647,10 +664,12 @@ class Edge(Topology):
|
|
647
664
|
True if the two edges are collinear. False otherwise.
|
648
665
|
|
649
666
|
"""
|
650
|
-
|
667
|
+
from topologicpy.Topology import Topology
|
668
|
+
|
669
|
+
if not Topology.IsInstance(edgeA, "Edge"):
|
651
670
|
print("Edge.IsParallel - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
|
652
671
|
return None
|
653
|
-
if not
|
672
|
+
if not Topology.IsInstance(edgeB, "Edge"):
|
654
673
|
print("Edge.IsParallel - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
|
655
674
|
return None
|
656
675
|
ang = Edge.Angle(edgeA, edgeB, mantissa=mantissa, bracket=True)
|
@@ -659,13 +678,13 @@ class Edge(Topology):
|
|
659
678
|
return False
|
660
679
|
|
661
680
|
@staticmethod
|
662
|
-
def Length(edge
|
681
|
+
def Length(edge, mantissa: int = 6) -> float:
|
663
682
|
"""
|
664
683
|
Returns the length of the input edge.
|
665
684
|
|
666
685
|
Parameters
|
667
686
|
----------
|
668
|
-
edge :
|
687
|
+
edge : topologic_core.Edge
|
669
688
|
The input edge.
|
670
689
|
mantissa : int , optional
|
671
690
|
The desired length of the mantissa. The default is 6.
|
@@ -676,12 +695,14 @@ class Edge(Topology):
|
|
676
695
|
The length of the input edge.
|
677
696
|
|
678
697
|
"""
|
679
|
-
|
698
|
+
from topologicpy.Topology import Topology
|
699
|
+
|
700
|
+
if not Topology.IsInstance(edge, "Edge"):
|
680
701
|
print("Edge.Length - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
681
702
|
return None
|
682
703
|
length = None
|
683
704
|
try:
|
684
|
-
length = round(topologic.EdgeUtility.Length(edge), mantissa)
|
705
|
+
length = round(topologic.EdgeUtility.Length(edge), mantissa) # Hook to Core
|
685
706
|
except:
|
686
707
|
length = None
|
687
708
|
if length == None:
|
@@ -689,13 +710,13 @@ class Edge(Topology):
|
|
689
710
|
return length
|
690
711
|
|
691
712
|
@staticmethod
|
692
|
-
def Line(origin
|
713
|
+
def Line(origin= None, length: float = 1, direction: list = [1,0,0], placement: str ="center", tolerance: float = 0.0001):
|
693
714
|
"""
|
694
715
|
Creates a straight edge (line) using the input parameters.
|
695
716
|
|
696
717
|
Parameters
|
697
718
|
----------
|
698
|
-
origin :
|
719
|
+
origin : topologic_core.Vertex , optional
|
699
720
|
The origin location of the box. The default is None which results in the edge being placed at (0, 0, 0).
|
700
721
|
length : float , optional
|
701
722
|
The desired length of the edge. The default is 1.0.
|
@@ -711,7 +732,7 @@ class Edge(Topology):
|
|
711
732
|
The desired tolerance. The default is 0.0001.
|
712
733
|
Returns
|
713
734
|
-------
|
714
|
-
|
735
|
+
topologic_core.Edge
|
715
736
|
The created edge
|
716
737
|
"""
|
717
738
|
|
@@ -721,7 +742,7 @@ class Edge(Topology):
|
|
721
742
|
|
722
743
|
if origin == None:
|
723
744
|
origin = Vertex.Origin()
|
724
|
-
if not
|
745
|
+
if not Topology.IsInstance(origin, "Vertex"):
|
725
746
|
print("Edge.Line - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
726
747
|
return None
|
727
748
|
if length <= 0:
|
@@ -751,13 +772,13 @@ class Edge(Topology):
|
|
751
772
|
return None
|
752
773
|
|
753
774
|
@staticmethod
|
754
|
-
def Normal(edge
|
775
|
+
def Normal(edge, angle: float = 0.0):
|
755
776
|
"""
|
756
777
|
Returns the normal (perpendicular) vector to the input edge.
|
757
778
|
|
758
779
|
Parameters
|
759
780
|
----------
|
760
|
-
edge :
|
781
|
+
edge : topologic_core.Edge
|
761
782
|
The input edge.
|
762
783
|
angle : float , optional
|
763
784
|
The desired rotational offset angle in degrees for the normal edge. This rotates the normal edge
|
@@ -769,20 +790,22 @@ class Edge(Topology):
|
|
769
790
|
The normal (perpendicular ) vector to the input edge.
|
770
791
|
|
771
792
|
"""
|
772
|
-
|
793
|
+
from topologicpy.Topology import Topology
|
794
|
+
|
795
|
+
if not Topology.IsInstance(edge, "Edge"):
|
773
796
|
print("Edge.Normal - Error: The input edge parameter is not a valid edge. Returning None.")
|
774
797
|
return None
|
775
798
|
normal_edge = Edge.NormalAsEdge(edge, length=1.0, u=0.5, angle=angle)
|
776
799
|
return Edge.Direction(normal_edge)
|
777
800
|
|
778
801
|
@staticmethod
|
779
|
-
def NormalAsEdge(edge
|
802
|
+
def NormalAsEdge(edge, length: float = 1.0, u: float = 0.5, angle: float = 0.0):
|
780
803
|
"""
|
781
804
|
Returns the normal (perpendicular) vector to the input edge as an edge.
|
782
805
|
|
783
806
|
Parameters
|
784
807
|
----------
|
785
|
-
edge :
|
808
|
+
edge : topologic_core.Edge
|
786
809
|
The input edge.
|
787
810
|
length : float , optional
|
788
811
|
The desired length of the normal edge. The default is 1.0.
|
@@ -797,7 +820,7 @@ class Edge(Topology):
|
|
797
820
|
|
798
821
|
Returns
|
799
822
|
-------
|
800
|
-
|
823
|
+
topologic_core.Edge
|
801
824
|
The normal (perpendicular) vector to the input edge as an edge.
|
802
825
|
|
803
826
|
"""
|
@@ -832,7 +855,7 @@ class Edge(Topology):
|
|
832
855
|
# Return the start and end vertices of the normal line
|
833
856
|
return start_vertex, list(normal_end_vertex)
|
834
857
|
|
835
|
-
if not
|
858
|
+
if not Topology.IsInstance(edge, "Edge"):
|
836
859
|
print("Edge.NormalAsEdge - Error: The input edge parameter is not a valid edge. Returning None.")
|
837
860
|
return None
|
838
861
|
if length <= 0.0:
|
@@ -853,13 +876,13 @@ class Edge(Topology):
|
|
853
876
|
return normal_edge
|
854
877
|
|
855
878
|
@staticmethod
|
856
|
-
def Normalize(edge
|
879
|
+
def Normalize(edge, useEndVertex: bool = False, tolerance: float = 0.0001):
|
857
880
|
"""
|
858
881
|
Creates a normalized edge that has the same direction as the input edge, but a length of 1.
|
859
882
|
|
860
883
|
Parameters
|
861
884
|
----------
|
862
|
-
edge :
|
885
|
+
edge : topologic_core.Edge
|
863
886
|
The input edge.
|
864
887
|
useEndVertex : bool , optional
|
865
888
|
If True the normalized edge end vertex will be placed at the end vertex of the input edge. Otherwise, the normalized edge start vertex will be placed at the start vertex of the input edge. The default is False.
|
@@ -868,11 +891,13 @@ class Edge(Topology):
|
|
868
891
|
|
869
892
|
Returns
|
870
893
|
-------
|
871
|
-
|
894
|
+
topologic_core.Edge
|
872
895
|
The normalized edge.
|
873
896
|
|
874
897
|
"""
|
875
|
-
|
898
|
+
from topologicpy.Topology import Topology
|
899
|
+
|
900
|
+
if not Topology.IsInstance(edge, "Edge"):
|
876
901
|
print("Edge.Normalize - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
877
902
|
return None
|
878
903
|
if not useEndVertex:
|
@@ -884,15 +909,15 @@ class Edge(Topology):
|
|
884
909
|
return Edge.ByVertices([sv, ev], tolerance=tolerance)
|
885
910
|
|
886
911
|
@staticmethod
|
887
|
-
def ParameterAtVertex(edge
|
912
|
+
def ParameterAtVertex(edge, vertex, mantissa: int = 6, silent: bool = False) -> float:
|
888
913
|
"""
|
889
914
|
Returns the *u* parameter along the input edge based on the location of the input vertex.
|
890
915
|
|
891
916
|
Parameters
|
892
917
|
----------
|
893
|
-
edge :
|
918
|
+
edge : topologic_core.Edge
|
894
919
|
The input edge.
|
895
|
-
vertex :
|
920
|
+
vertex : topologic_core.Vertex
|
896
921
|
The input vertex.
|
897
922
|
mantissa : int , optional
|
898
923
|
The desired length of the mantissa. The default is 6.
|
@@ -905,52 +930,56 @@ class Edge(Topology):
|
|
905
930
|
The *u* parameter along the input edge based on the location of the input vertex.
|
906
931
|
|
907
932
|
"""
|
908
|
-
|
933
|
+
from topologicpy.Topology import Topology
|
934
|
+
|
935
|
+
if not Topology.IsInstance(edge, "Edge"):
|
909
936
|
if not silent:
|
910
937
|
print("Edge.ParameterAtVertex - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
911
938
|
return None
|
912
|
-
if not
|
939
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
913
940
|
if not silent:
|
914
941
|
print("Edge.ParameterAtVertex - Error: The input vertex parameter is not a valid topologic vertex. Returning None.")
|
915
942
|
return None
|
916
943
|
parameter = None
|
917
944
|
try:
|
918
|
-
parameter = topologic.EdgeUtility.ParameterAtPoint(edge, vertex)
|
945
|
+
parameter = topologic.EdgeUtility.ParameterAtPoint(edge, vertex) # Hook to Core
|
919
946
|
except:
|
920
947
|
return None #Return silently because topologic C++ returns a runtime error if point is not on curve.
|
921
948
|
return round(parameter, mantissa)
|
922
949
|
|
923
950
|
@staticmethod
|
924
|
-
def Reverse(edge
|
951
|
+
def Reverse(edge, tolerance: float = 0.0001):
|
925
952
|
"""
|
926
953
|
Creates an edge that has the reverse direction of the input edge.
|
927
954
|
|
928
955
|
Parameters
|
929
956
|
----------
|
930
|
-
edge :
|
957
|
+
edge : topologic_core.Edge
|
931
958
|
The input edge.
|
932
959
|
tolerance : float , optional
|
933
960
|
The desired tolerance. The default is 0.0001.
|
934
961
|
|
935
962
|
Returns
|
936
963
|
-------
|
937
|
-
|
964
|
+
topologic_core.Edge
|
938
965
|
The reversed edge.
|
939
966
|
|
940
967
|
"""
|
941
|
-
|
968
|
+
from topologicpy.Topology import Topology
|
969
|
+
|
970
|
+
if not Topology.IsInstance(edge, "Edge"):
|
942
971
|
print("Edge.Reverse - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
943
972
|
return None
|
944
973
|
return Edge.ByVertices([edge.EndVertex(), edge.StartVertex()], tolerance=tolerance)
|
945
974
|
|
946
975
|
@staticmethod
|
947
|
-
def SetLength(edge
|
976
|
+
def SetLength(edge , length: float = 1.0, bothSides: bool = True, reverse: bool = False, tolerance: float = 0.0001):
|
948
977
|
"""
|
949
978
|
Returns an edge with the new length in the same direction as the input edge.
|
950
979
|
|
951
980
|
Parameters
|
952
981
|
----------
|
953
|
-
edge :
|
982
|
+
edge : topologic_core.Edge
|
954
983
|
The input edge.
|
955
984
|
length : float , optional
|
956
985
|
The desired length of the edge. The default is 1.
|
@@ -963,11 +992,13 @@ class Edge(Topology):
|
|
963
992
|
|
964
993
|
Returns
|
965
994
|
-------
|
966
|
-
|
995
|
+
topologic_core.Edge
|
967
996
|
The extended edge.
|
968
997
|
|
969
998
|
"""
|
970
|
-
|
999
|
+
from topologicpy.Topology import Topology
|
1000
|
+
|
1001
|
+
if not Topology.IsInstance(edge, "Edge"):
|
971
1002
|
print("Edge.SetLength - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
972
1003
|
return None
|
973
1004
|
distance = (length - Edge.Length(edge))
|
@@ -976,22 +1007,24 @@ class Edge(Topology):
|
|
976
1007
|
return Edge.Trim(edge=edge, distance=distance, bothSides=bothSides, reverse=reverse, tolerance=tolerance)
|
977
1008
|
|
978
1009
|
@staticmethod
|
979
|
-
def StartVertex(edge
|
1010
|
+
def StartVertex(edge):
|
980
1011
|
"""
|
981
1012
|
Returns the start vertex of the input edge.
|
982
1013
|
|
983
1014
|
Parameters
|
984
1015
|
----------
|
985
|
-
edge :
|
1016
|
+
edge : topologic_core.Edge
|
986
1017
|
The input edge.
|
987
1018
|
|
988
1019
|
Returns
|
989
1020
|
-------
|
990
|
-
|
1021
|
+
topologic_core.Vertex
|
991
1022
|
The start vertex of the input edge.
|
992
1023
|
|
993
1024
|
"""
|
994
|
-
|
1025
|
+
from topologicpy.Topology import Topology
|
1026
|
+
|
1027
|
+
if not Topology.IsInstance(edge, "Edge"):
|
995
1028
|
print("Edge.StartVertex - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
996
1029
|
return None
|
997
1030
|
vert = None
|
@@ -1002,13 +1035,13 @@ class Edge(Topology):
|
|
1002
1035
|
return vert
|
1003
1036
|
|
1004
1037
|
@staticmethod
|
1005
|
-
def Trim(edge
|
1038
|
+
def Trim(edge, distance: float = 0.0, bothSides: bool = True, reverse: bool = False, tolerance: float = 0.0001):
|
1006
1039
|
"""
|
1007
1040
|
Trims the input edge by the input distance.
|
1008
1041
|
|
1009
1042
|
Parameters
|
1010
1043
|
----------
|
1011
|
-
edge :
|
1044
|
+
edge : topologic_core.Edge
|
1012
1045
|
The input edge.
|
1013
1046
|
distance : float , optional
|
1014
1047
|
The offset distance. The default is 0.
|
@@ -1021,11 +1054,13 @@ class Edge(Topology):
|
|
1021
1054
|
|
1022
1055
|
Returns
|
1023
1056
|
-------
|
1024
|
-
|
1057
|
+
topologic_core.Edge
|
1025
1058
|
The trimmed edge.
|
1026
1059
|
|
1027
1060
|
"""
|
1028
|
-
|
1061
|
+
from topologicpy.Topology import Topology
|
1062
|
+
|
1063
|
+
if not Topology.IsInstance(edge, "Edge"):
|
1029
1064
|
print("Edge.Trim - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
1030
1065
|
return None
|
1031
1066
|
distance = abs(distance)
|
@@ -1048,30 +1083,32 @@ class Edge(Topology):
|
|
1048
1083
|
return Edge.ByVertices([sve, eve], tolerance=tolerance, silent=True)
|
1049
1084
|
|
1050
1085
|
@staticmethod
|
1051
|
-
def TrimByEdge2D(edgeA
|
1086
|
+
def TrimByEdge2D(edgeA, edgeB, reverse: bool = False, tolerance: float = 0.0001):
|
1052
1087
|
"""
|
1053
1088
|
Trims the first input edge by the second input edge. This works only in the XY plane. Z coordinates are ignored.
|
1054
1089
|
|
1055
1090
|
Parameters
|
1056
1091
|
----------
|
1057
|
-
edgeA :
|
1092
|
+
edgeA : topologic_core.Edge
|
1058
1093
|
The first input edge.
|
1059
|
-
edgeB :
|
1094
|
+
edgeB : topologic_core.Edge
|
1060
1095
|
The second input edge.
|
1061
1096
|
tolerance : float , optional
|
1062
1097
|
The desired tolerance. The default is 0.0001.
|
1063
1098
|
|
1064
1099
|
Returns
|
1065
1100
|
-------
|
1066
|
-
|
1101
|
+
topologic_core.Edge
|
1067
1102
|
The trimmed edge.
|
1068
1103
|
|
1069
1104
|
"""
|
1105
|
+
from topologicpy.Vertex import Vertex
|
1070
1106
|
from topologicpy.Topology import Topology
|
1071
|
-
|
1107
|
+
|
1108
|
+
if not Topology.IsInstance(edgeA, "Edge"):
|
1072
1109
|
print("Edge.TrimByEdge2D - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
|
1073
1110
|
return None
|
1074
|
-
if not
|
1111
|
+
if not Topology.IsInstance(edgeB, "Edge"):
|
1075
1112
|
print("Edge.TrimByEdge2D - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
|
1076
1113
|
return None
|
1077
1114
|
sva = Edge.StartVertex(edgeA)
|
@@ -1085,34 +1122,37 @@ class Edge(Topology):
|
|
1085
1122
|
return edgeA
|
1086
1123
|
|
1087
1124
|
@staticmethod
|
1088
|
-
def VertexByDistance(edge
|
1125
|
+
def VertexByDistance(edge, distance: float = 0.0, origin= None, tolerance: float = 0.0001):
|
1089
1126
|
"""
|
1090
1127
|
Creates a vertex along the input edge offset by the input distance from the input origin.
|
1091
1128
|
|
1092
1129
|
Parameters
|
1093
1130
|
----------
|
1094
|
-
edge :
|
1131
|
+
edge : topologic_core.Edge
|
1095
1132
|
The input edge.
|
1096
1133
|
distance : float , optional
|
1097
1134
|
The offset distance. The default is 0.
|
1098
|
-
origin :
|
1135
|
+
origin : topologic_core.Vertex , optional
|
1099
1136
|
The origin of the offset distance. If set to None, the origin will be set to the start vertex of the input edge. The default is None.
|
1100
1137
|
tolerance : float , optional
|
1101
1138
|
The desired tolerance. The default is 0.0001.
|
1102
1139
|
|
1103
1140
|
Returns
|
1104
1141
|
-------
|
1105
|
-
|
1142
|
+
topologic_core.Vertex
|
1106
1143
|
The created vertex.
|
1107
1144
|
|
1108
1145
|
"""
|
1146
|
+
from topologicpy.Vertex import Vertex
|
1147
|
+
from topologicpy.Vector import Vector
|
1148
|
+
from topologicpy.Topology import Topology
|
1109
1149
|
|
1110
|
-
if not
|
1150
|
+
if not Topology.IsInstance(edge, "Edge"):
|
1111
1151
|
print("Edge.TrimByEdge2D - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
1112
1152
|
return None
|
1113
1153
|
if not origin:
|
1114
1154
|
origin = edge.StartVertex()
|
1115
|
-
if not
|
1155
|
+
if not Topology.IsInstance(origin, "Vertex"):
|
1116
1156
|
print("Edge.TrimByEdge2D - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
|
1117
1157
|
return None
|
1118
1158
|
sv = edge.StartVertex()
|
@@ -1122,29 +1162,29 @@ class Edge(Topology):
|
|
1122
1162
|
vz = ev.Z() - sv.Z()
|
1123
1163
|
vector = Vector.Normalize([vx, vy, vz])
|
1124
1164
|
vector = Vector.Multiply(vector, distance, tolerance)
|
1125
|
-
return
|
1165
|
+
return Vertex.ByCoordinates(origin.X()+vector[0], origin.Y()+vector[1], origin.Z()+vector[2])
|
1126
1166
|
|
1127
1167
|
@staticmethod
|
1128
|
-
def VertexByParameter(edge
|
1168
|
+
def VertexByParameter(edge, u: float = 0.0):
|
1129
1169
|
"""
|
1130
1170
|
Creates a vertex along the input edge offset by the input *u* parameter.
|
1131
1171
|
|
1132
1172
|
Parameters
|
1133
1173
|
----------
|
1134
|
-
edge :
|
1174
|
+
edge : topologic_core.Edge
|
1135
1175
|
The input edge.
|
1136
1176
|
u : float , optional
|
1137
1177
|
The *u* parameter along the input topologic Edge. A parameter of 0 returns the start vertex. A parameter of 1 returns the end vertex. The default is 0.
|
1138
1178
|
|
1139
1179
|
Returns
|
1140
1180
|
-------
|
1141
|
-
|
1181
|
+
topologic_core.Vertex
|
1142
1182
|
The created vertex.
|
1143
1183
|
|
1144
1184
|
"""
|
1145
1185
|
from topologicpy.Topology import Topology
|
1146
1186
|
|
1147
|
-
if not
|
1187
|
+
if not Topology.IsInstance(edge, "Edge"):
|
1148
1188
|
print("Edge.VertexByParameter - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
1149
1189
|
return None
|
1150
1190
|
vertex = None
|
@@ -1157,21 +1197,16 @@ class Edge(Topology):
|
|
1157
1197
|
edge_length = Edge.Length(edge)
|
1158
1198
|
dist = edge_length*u
|
1159
1199
|
vertex = Topology.TranslateByDirectionDistance(Edge.StartVertex(edge), direction=dir, distance=dist)
|
1160
|
-
#try:
|
1161
|
-
#vertex = topologic.EdgeUtility.PointAtParameter(edge, u)
|
1162
|
-
#except:
|
1163
|
-
#print("Edge.VertexByParameter - Error: Could not create a vertex at the input parameter. Returning None.")
|
1164
|
-
#vertex = None
|
1165
1200
|
return vertex
|
1166
1201
|
|
1167
1202
|
@staticmethod
|
1168
|
-
def Vertices(edge
|
1203
|
+
def Vertices(edge) -> list:
|
1169
1204
|
"""
|
1170
1205
|
Returns the list of vertices of the input edge.
|
1171
1206
|
|
1172
1207
|
Parameters
|
1173
1208
|
----------
|
1174
|
-
edge :
|
1209
|
+
edge : topologic_core.Edge
|
1175
1210
|
The input edge.
|
1176
1211
|
|
1177
1212
|
Returns
|
@@ -1180,9 +1215,11 @@ class Edge(Topology):
|
|
1180
1215
|
The list of vertices.
|
1181
1216
|
|
1182
1217
|
"""
|
1183
|
-
|
1218
|
+
from topologicpy.Topology import Topology
|
1219
|
+
|
1220
|
+
if not Topology.IsInstance(edge, "Edge"):
|
1184
1221
|
print("Edge.Vertices - Error: The input edge parameter is not a valid topologic edge. Returning None.")
|
1185
1222
|
return None
|
1186
1223
|
vertices = []
|
1187
|
-
_ = edge.Vertices(None, vertices)
|
1224
|
+
_ = edge.Vertices(None, vertices) # Hook to Core
|
1188
1225
|
return vertices
|