topologicpy 0.6.2__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 +439 -351
- topologicpy/Grid.py +40 -43
- topologicpy/Honeybee.py +1 -1
- topologicpy/Matrix.py +28 -27
- topologicpy/Neo4j.py +5 -5
- topologicpy/Plotly.py +169 -53
- topologicpy/Shell.py +160 -145
- topologicpy/Sun.py +17 -13
- topologicpy/Topology.py +534 -766
- topologicpy/Vector.py +4 -3
- topologicpy/Vertex.py +145 -126
- topologicpy/Wire.py +542 -325
- topologicpy/version.py +1 -1
- {topologicpy-0.6.2.dist-info → topologicpy-0.7.0.dist-info}/METADATA +1 -1
- topologicpy-0.7.0.dist-info/RECORD +33 -0
- topologicpy-0.6.2.dist-info/RECORD +0 -33
- {topologicpy-0.6.2.dist-info → topologicpy-0.7.0.dist-info}/LICENSE +0 -0
- {topologicpy-0.6.2.dist-info → topologicpy-0.7.0.dist-info}/WHEEL +0 -0
- {topologicpy-0.6.2.dist-info → topologicpy-0.7.0.dist-info}/top_level.txt +0 -0
topologicpy/Vertex.py
CHANGED
@@ -14,10 +14,7 @@
|
|
14
14
|
# You should have received a copy of the GNU Affero General Public License along with
|
15
15
|
# this program. If not, see <https://www.gnu.org/licenses/>.
|
16
16
|
|
17
|
-
import topologicpy
|
18
17
|
import topologic_core as topologic
|
19
|
-
from topologicpy.Face import Face
|
20
|
-
from topologicpy.Topology import Topology
|
21
18
|
import collections
|
22
19
|
import os
|
23
20
|
import warnings
|
@@ -36,7 +33,7 @@ except:
|
|
36
33
|
except:
|
37
34
|
warnings.warn("Vertex - Error: Could not import numpy.")
|
38
35
|
|
39
|
-
class Vertex(
|
36
|
+
class Vertex():
|
40
37
|
@staticmethod
|
41
38
|
def AreCollinear(vertices: list, tolerance: float = 0.0001):
|
42
39
|
"""
|
@@ -73,7 +70,7 @@ class Vertex(Topology):
|
|
73
70
|
if not isinstance(vertices, list):
|
74
71
|
print("Vertex.AreCollinear - Error: The input list of vertices is not a valid list. Returning None.")
|
75
72
|
return None
|
76
|
-
vertexList = [x for x in vertices if
|
73
|
+
vertexList = [x for x in vertices if Topology.IsInstance(x, "Vertex")]
|
77
74
|
if len(vertexList) < 2:
|
78
75
|
print("Vertex.AreCollinear - Error: The input list of vertices does not contain sufficient valid vertices. Returning None.")
|
79
76
|
return None
|
@@ -90,7 +87,7 @@ class Vertex(Topology):
|
|
90
87
|
return True
|
91
88
|
|
92
89
|
@staticmethod
|
93
|
-
def AreIpsilateral(vertices: list, face
|
90
|
+
def AreIpsilateral(vertices: list, face) -> bool:
|
94
91
|
"""
|
95
92
|
Returns True if the input list of vertices are on one side of a face. Returns False otherwise. If at least one of the vertices is on the face, this method return True.
|
96
93
|
|
@@ -98,7 +95,7 @@ class Vertex(Topology):
|
|
98
95
|
----------
|
99
96
|
vertices : list
|
100
97
|
The input list of vertices.
|
101
|
-
face :
|
98
|
+
face : topologic_core.Face
|
102
99
|
The input face
|
103
100
|
|
104
101
|
Returns
|
@@ -127,10 +124,11 @@ class Vertex(Topology):
|
|
127
124
|
|
128
125
|
from topologicpy.Vertex import Vertex
|
129
126
|
from topologicpy.Face import Face
|
127
|
+
from topologicpy.Topology import Topology
|
130
128
|
|
131
|
-
if not
|
129
|
+
if not Topology.IsInstance(face, "Face"):
|
132
130
|
return None
|
133
|
-
vertexList = [x for x in vertices if
|
131
|
+
vertexList = [x for x in vertices if Topology.IsInstance(x, "Vertex")]
|
134
132
|
if len(vertexList) < 2:
|
135
133
|
return None
|
136
134
|
pointA = Vertex.Coordinates(vertexList[0])
|
@@ -146,15 +144,15 @@ class Vertex(Topology):
|
|
146
144
|
return True
|
147
145
|
|
148
146
|
@staticmethod
|
149
|
-
def AreIpsilateralCluster(cluster
|
147
|
+
def AreIpsilateralCluster(cluster, face) -> bool:
|
150
148
|
"""
|
151
149
|
Returns True if the two input vertices are on the same side of the input face. Returns False otherwise. If at least one of the vertices is on the face, this method return True.
|
152
150
|
|
153
151
|
Parameters
|
154
152
|
----------
|
155
|
-
cluster :
|
153
|
+
cluster : topologic_core.Cluster
|
156
154
|
The input list of vertices.
|
157
|
-
face :
|
155
|
+
face : topologic_core.Face
|
158
156
|
The input face
|
159
157
|
|
160
158
|
Returns
|
@@ -164,13 +162,13 @@ class Vertex(Topology):
|
|
164
162
|
|
165
163
|
"""
|
166
164
|
from topologicpy.Topology import Topology
|
167
|
-
if not
|
165
|
+
if not Topology.IsInstance(cluster, "Topology"):
|
168
166
|
return None
|
169
167
|
vertices = Topology.SubTopologies(cluster, subTopologyType="vertex")
|
170
168
|
return Vertex.AreIpsilateral(vertices, face)
|
171
169
|
|
172
170
|
@staticmethod
|
173
|
-
def AreOnSameSide(vertices: list, face
|
171
|
+
def AreOnSameSide(vertices: list, face) -> bool:
|
174
172
|
"""
|
175
173
|
Returns True if the two input vertices are on the same side of the input face. Returns False otherwise. If at least one of the vertices is on the face, this method return True.
|
176
174
|
|
@@ -178,7 +176,7 @@ class Vertex(Topology):
|
|
178
176
|
----------
|
179
177
|
vertices : list
|
180
178
|
The input list of vertices.
|
181
|
-
face :
|
179
|
+
face : topologic_core.Face
|
182
180
|
The input face
|
183
181
|
|
184
182
|
Returns
|
@@ -190,15 +188,15 @@ class Vertex(Topology):
|
|
190
188
|
return Vertex.AreIpsilateral(vertices, face)
|
191
189
|
|
192
190
|
@staticmethod
|
193
|
-
def AreOnSameSideCluster(cluster
|
191
|
+
def AreOnSameSideCluster(cluster, face) -> bool:
|
194
192
|
"""
|
195
193
|
Returns True if the two input vertices are on the same side of the input face. Returns False otherwise. If at least one of the vertices is on the face, this method return True.
|
196
194
|
|
197
195
|
Parameters
|
198
196
|
----------
|
199
|
-
cluster :
|
197
|
+
cluster : topologic_core.Cluster
|
200
198
|
The input list of vertices.
|
201
|
-
face :
|
199
|
+
face : topologic_core.Face
|
202
200
|
The input face
|
203
201
|
|
204
202
|
Returns
|
@@ -208,13 +206,13 @@ class Vertex(Topology):
|
|
208
206
|
|
209
207
|
"""
|
210
208
|
from topologicpy.Topology import Topology
|
211
|
-
if not
|
209
|
+
if not Topology.IsInstance(cluster, "Topology"):
|
212
210
|
return None
|
213
211
|
vertices = Topology.SubTopologies(cluster, subTopologyType="vertex")
|
214
212
|
return Vertex.AreIpsilateral(vertices, face)
|
215
213
|
|
216
214
|
@staticmethod
|
217
|
-
def ByCoordinates(*args, **kwargs)
|
215
|
+
def ByCoordinates(*args, **kwargs):
|
218
216
|
"""
|
219
217
|
Creates a vertex at the coordinates specified by the x, y, z inputs. You can call this method using a list of coordinates or individually.
|
220
218
|
Examples:
|
@@ -233,7 +231,7 @@ class Vertex(Topology):
|
|
233
231
|
|
234
232
|
Returns
|
235
233
|
-------
|
236
|
-
|
234
|
+
topologic_core.Vertex
|
237
235
|
The created vertex.
|
238
236
|
|
239
237
|
"""
|
@@ -301,7 +299,7 @@ class Vertex(Topology):
|
|
301
299
|
|
302
300
|
vertex = None
|
303
301
|
try:
|
304
|
-
vertex = topologic.Vertex.ByCoordinates(x, y, z)
|
302
|
+
vertex = topologic.Vertex.ByCoordinates(x, y, z) # Hook to Core
|
305
303
|
except:
|
306
304
|
vertex = None
|
307
305
|
print("Vertex.ByCoordinates - Error: Could not create a topologic vertex. Returning None.")
|
@@ -319,14 +317,16 @@ class Vertex(Topology):
|
|
319
317
|
|
320
318
|
Return
|
321
319
|
----------
|
322
|
-
|
320
|
+
topologic_core.Vertex
|
323
321
|
The computed centroid of the input list of vertices
|
322
|
+
|
324
323
|
"""
|
324
|
+
from topologicpy.Topology import Topology
|
325
325
|
|
326
326
|
if not isinstance(vertices, list):
|
327
327
|
print("Vertex.Centroid - Error: The input vertices parameter is not a valid list. Returning None.")
|
328
328
|
return None
|
329
|
-
vertices = [v for v in vertices if
|
329
|
+
vertices = [v for v in vertices if Topology.IsInstance(v, "Vertex")]
|
330
330
|
if len(vertices) < 1:
|
331
331
|
print("Vertex.Centroid - Error: The input vertices parameter does not contain any valid vertices. Returning None.")
|
332
332
|
return None
|
@@ -356,13 +356,13 @@ class Vertex(Topology):
|
|
356
356
|
return list(reversed(Vertex.CounterClockwise2D(vertices)))
|
357
357
|
|
358
358
|
@staticmethod
|
359
|
-
def Coordinates(vertex
|
359
|
+
def Coordinates(vertex, outputType: str = "xyz", mantissa: int = 6) -> list:
|
360
360
|
"""
|
361
361
|
Returns the coordinates of the input vertex.
|
362
362
|
|
363
363
|
Parameters
|
364
364
|
----------
|
365
|
-
vertex :
|
365
|
+
vertex : topologic_core.Vertex
|
366
366
|
The input vertex.
|
367
367
|
outputType : string, optional
|
368
368
|
The desired output type. Could be any permutation or substring of "xyz" or the string "matrix". The default is "xyz". The input is case insensitive and the coordinates will be returned in the specified order.
|
@@ -375,7 +375,9 @@ class Vertex(Topology):
|
|
375
375
|
The coordinates of the input vertex.
|
376
376
|
|
377
377
|
"""
|
378
|
-
|
378
|
+
from topologicpy.Topology import Topology
|
379
|
+
|
380
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
379
381
|
return None
|
380
382
|
x = round(vertex.X(), mantissa)
|
381
383
|
y = round(vertex.Y(), mantissa)
|
@@ -425,15 +427,15 @@ class Vertex(Topology):
|
|
425
427
|
return vertices
|
426
428
|
|
427
429
|
@staticmethod
|
428
|
-
def Degree(vertex
|
430
|
+
def Degree(vertex, hostTopology, topologyType: str = "edge"):
|
429
431
|
"""
|
430
432
|
Returns the vertex degree (the number of super topologies connected to it). See https://en.wikipedia.org/wiki/Degree_(graph_theory).
|
431
433
|
|
432
434
|
Parameters
|
433
435
|
----------
|
434
|
-
vertex :
|
436
|
+
vertex : topologic_core.Vertex
|
435
437
|
The input vertex.
|
436
|
-
hostTopology :
|
438
|
+
hostTopology : topologic_core.Topology
|
437
439
|
The input host topology in which to search for the connected super topologies.
|
438
440
|
topologyType : str , optional
|
439
441
|
The topology type to search for. This can be any of "edge", "wire", "face", "shell", "cell", "cellcomplex", "cluster". It is case insensitive. If set to None, the immediate supertopology type is searched for. The default is None.
|
@@ -446,25 +448,25 @@ class Vertex(Topology):
|
|
446
448
|
"""
|
447
449
|
from topologicpy.Topology import Topology
|
448
450
|
|
449
|
-
if not
|
451
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
450
452
|
print("Vertex.Degree - Error: The input vertex parameter is not a valid topologic vertex. Returning None.")
|
451
|
-
if not
|
453
|
+
if not Topology.IsInstance(hostTopology, "Topology"):
|
452
454
|
print("Vertex.Degree - Error: The input hostTopology parameter is not a valid topologic topology. Returning None.")
|
453
455
|
superTopologies = Topology.SuperTopologies(topology=vertex, hostTopology=hostTopology, topologyType=topologyType)
|
454
456
|
return len(superTopologies)
|
455
457
|
|
456
458
|
|
457
459
|
@staticmethod
|
458
|
-
def Distance(vertex
|
460
|
+
def Distance(vertex, topology, includeCentroid: bool =True,
|
459
461
|
mantissa: int = 6) -> float:
|
460
462
|
"""
|
461
463
|
Returns the distance between the input vertex and the input topology. This method returns the distance to the closest sub-topology in the input topology, optionally including its centroid.
|
462
464
|
|
463
465
|
Parameters
|
464
466
|
----------
|
465
|
-
vertex :
|
467
|
+
vertex : topologic_core.Vertex
|
466
468
|
The input vertex.
|
467
|
-
topology :
|
469
|
+
topology : topologic_core.Topology
|
468
470
|
The input topology.
|
469
471
|
includeCentroid : bool
|
470
472
|
If set to True, the centroid of the input topology will be considered in finding the nearest subTopology to the input vertex. The default is True.
|
@@ -479,6 +481,7 @@ class Vertex(Topology):
|
|
479
481
|
"""
|
480
482
|
from topologicpy.Edge import Edge
|
481
483
|
from topologicpy.Face import Face
|
484
|
+
from topologicpy.Topology import Topology
|
482
485
|
import math
|
483
486
|
|
484
487
|
def distance_point_to_point(point1, point2):
|
@@ -557,13 +560,13 @@ class Vertex(Topology):
|
|
557
560
|
if e == 0:
|
558
561
|
return 0
|
559
562
|
return d/e
|
560
|
-
if not
|
563
|
+
if not Topology.IsInstance(vertex, "Vertex") or not Topology.IsInstance(topology, "Topology"):
|
561
564
|
return None
|
562
|
-
if
|
565
|
+
if Topology.IsInstance(topology, "Vertex"):
|
563
566
|
return round(distance_to_vertex(vertex,topology), mantissa)
|
564
|
-
elif
|
567
|
+
elif Topology.IsInstance(topology, "Edge"):
|
565
568
|
return round(distance_to_edge(vertex,topology), mantissa)
|
566
|
-
elif
|
569
|
+
elif Topology.IsInstance(topology, "Wire"):
|
567
570
|
vertices = Topology.Vertices(topology)
|
568
571
|
distances = [distance_to_vertex(vertex, v) for v in vertices]
|
569
572
|
edges = Topology.Edges(topology)
|
@@ -571,7 +574,7 @@ class Vertex(Topology):
|
|
571
574
|
if includeCentroid:
|
572
575
|
distances.append(distance_to_vertex(vertex, Topology.Centroid(topology)))
|
573
576
|
return round(min(distances), mantissa)
|
574
|
-
elif
|
577
|
+
elif Topology.IsInstance(topology, "Face"):
|
575
578
|
vertices = Topology.Vertices(topology)
|
576
579
|
distances = [distance_to_vertex(vertex, v) for v in vertices]
|
577
580
|
edges = Topology.Edges(topology)
|
@@ -580,7 +583,7 @@ class Vertex(Topology):
|
|
580
583
|
if includeCentroid:
|
581
584
|
distances.append(distance_to_vertex(vertex, Topology.Centroid(topology)))
|
582
585
|
return round(min(distances), mantissa)
|
583
|
-
elif
|
586
|
+
elif Topology.IsInstance(topology, "Shell") or Topology.IsInstance(topology, "Cell") or Topology.IsInstance(topology, "CellComplex") or Topology.IsInstance(topology, "Cluster"):
|
584
587
|
vertices = Topology.Vertices(topology)
|
585
588
|
distances = [distance_to_vertex(vertex, v) for v in vertices]
|
586
589
|
edges = Topology.Edges(topology)
|
@@ -595,15 +598,15 @@ class Vertex(Topology):
|
|
595
598
|
return None
|
596
599
|
|
597
600
|
@staticmethod
|
598
|
-
def EnclosingCell(vertex
|
601
|
+
def EnclosingCell(vertex, topology, exclusive: bool = True, tolerance: float = 0.0001) -> list:
|
599
602
|
"""
|
600
603
|
Returns the list of Cells found in the input topology that enclose the input vertex.
|
601
604
|
|
602
605
|
Parameters
|
603
606
|
----------
|
604
|
-
vertex :
|
607
|
+
vertex : topologic_core.Vertex
|
605
608
|
The input vertex.
|
606
|
-
topology :
|
609
|
+
topology : topologic_core.Topology
|
607
610
|
The input topology.
|
608
611
|
exclusive : bool , optional
|
609
612
|
If set to True, return only the first found enclosing cell. The default is True.
|
@@ -616,6 +619,8 @@ class Vertex(Topology):
|
|
616
619
|
The list of enclosing cells.
|
617
620
|
|
618
621
|
"""
|
622
|
+
from topologicpy.Cell import Cell
|
623
|
+
from topologicpy.Topology import Topology
|
619
624
|
|
620
625
|
def boundingBox(cell):
|
621
626
|
vertices = []
|
@@ -629,9 +634,9 @@ class Vertex(Topology):
|
|
629
634
|
z.append(aVertex.Z())
|
630
635
|
return ([min(x), min(y), min(z), max(x), max(y), max(z)])
|
631
636
|
|
632
|
-
if
|
637
|
+
if Topology.IsInstance(topology, "Cell"):
|
633
638
|
cells = [topology]
|
634
|
-
elif
|
639
|
+
elif Topology.IsInstance(topology, "Cluster") or Topology.IsInstance(topology, "CellComplex"):
|
635
640
|
cells = []
|
636
641
|
_ = topology.Cells(None, cells)
|
637
642
|
else:
|
@@ -642,7 +647,7 @@ class Vertex(Topology):
|
|
642
647
|
for i in range(len(cells)):
|
643
648
|
bbox = boundingBox(cells[i])
|
644
649
|
if ((vertex.X() < bbox[0]) or (vertex.Y() < bbox[1]) or (vertex.Z() < bbox[2]) or (vertex.X() > bbox[3]) or (vertex.Y() > bbox[4]) or (vertex.Z() > bbox[5])) == False:
|
645
|
-
if
|
650
|
+
if Vertex.IsInternal(vertex, cells[i], tolerance=tolerance):
|
646
651
|
if exclusive:
|
647
652
|
return([cells[i]])
|
648
653
|
else:
|
@@ -669,7 +674,7 @@ class Vertex(Topology):
|
|
669
674
|
The list of fused vertices. This list contains the same number of vertices and in the same order as the input list of vertices. However, the coordinates
|
670
675
|
of these vertices have now been modified so that they are exactly the same with other vertices that are within the tolerance distance.
|
671
676
|
"""
|
672
|
-
|
677
|
+
from topologicpy.Topology import Topology
|
673
678
|
import numpy as np
|
674
679
|
|
675
680
|
def fuse_vertices(vertices, tolerance):
|
@@ -714,7 +719,7 @@ class Vertex(Topology):
|
|
714
719
|
if not isinstance(vertices, list):
|
715
720
|
print("Vertex.Fuse - Error: The input vertices parameter is not a valid list. Returning None.")
|
716
721
|
return None
|
717
|
-
vertices = [v for v in vertices if
|
722
|
+
vertices = [v for v in vertices if Topology.IsInstance(v, "Vertex")]
|
718
723
|
if len(vertices) == 0:
|
719
724
|
print("Vertex.Fuse - Error: The input vertices parameter does not contain any valid topologic vertices. Returning None.")
|
720
725
|
return None
|
@@ -725,13 +730,13 @@ class Vertex(Topology):
|
|
725
730
|
return return_vertices
|
726
731
|
|
727
732
|
@staticmethod
|
728
|
-
def Index(vertex
|
733
|
+
def Index(vertex, vertices: list, strict: bool = False, tolerance: float = 0.0001) -> int:
|
729
734
|
"""
|
730
735
|
Returns index of the input vertex in the input list of vertices
|
731
736
|
|
732
737
|
Parameters
|
733
738
|
----------
|
734
|
-
vertex :
|
739
|
+
vertex : topologic_core.Vertex
|
735
740
|
The input vertex.
|
736
741
|
vertices : list
|
737
742
|
The input list of vertices.
|
@@ -747,11 +752,11 @@ class Vertex(Topology):
|
|
747
752
|
|
748
753
|
"""
|
749
754
|
from topologicpy.Topology import Topology
|
750
|
-
if not
|
755
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
751
756
|
return None
|
752
757
|
if not isinstance(vertices, list):
|
753
758
|
return None
|
754
|
-
vertices = [v for v in vertices if
|
759
|
+
vertices = [v for v in vertices if Topology.IsInstance(v, "Vertex")]
|
755
760
|
if len(vertices) == 0:
|
756
761
|
return None
|
757
762
|
for i in range(len(vertices)):
|
@@ -771,7 +776,7 @@ class Vertex(Topology):
|
|
771
776
|
|
772
777
|
Parameters
|
773
778
|
----------
|
774
|
-
vertex :
|
779
|
+
vertex : topologic_core.Vertex
|
775
780
|
The input vertex.
|
776
781
|
vertices : list
|
777
782
|
The input list of vertices.
|
@@ -784,7 +789,7 @@ class Vertex(Topology):
|
|
784
789
|
|
785
790
|
Returns
|
786
791
|
-------
|
787
|
-
|
792
|
+
topologic_core.vertex
|
788
793
|
The input vertex with the interpolated value stored in its dictionary at the key specified by the input key. Other keys and values in the dictionary are preserved.
|
789
794
|
|
790
795
|
"""
|
@@ -846,12 +851,12 @@ class Vertex(Topology):
|
|
846
851
|
from topologicpy.Topology import Topology
|
847
852
|
from topologicpy.Dictionary import Dictionary
|
848
853
|
|
849
|
-
if not
|
854
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
850
855
|
return None
|
851
856
|
if not isinstance(vertices, list):
|
852
857
|
return None
|
853
858
|
|
854
|
-
vertices = [v for v in vertices if
|
859
|
+
vertices = [v for v in vertices if Topology.IsInstance(v, "Vertex")]
|
855
860
|
if len(vertices) == 0:
|
856
861
|
return None
|
857
862
|
|
@@ -874,15 +879,15 @@ class Vertex(Topology):
|
|
874
879
|
return vertex
|
875
880
|
|
876
881
|
@staticmethod
|
877
|
-
def IsCoincident(vertexA
|
882
|
+
def IsCoincident(vertexA, vertexB, tolerance: float = 0.0001, silent: bool = False) -> bool:
|
878
883
|
"""
|
879
884
|
Returns True if the input vertexA is coincident with the input vertexB. Returns False otherwise.
|
880
885
|
|
881
886
|
Parameters
|
882
887
|
----------
|
883
|
-
vertexA :
|
888
|
+
vertexA : topologic_core.Vertex
|
884
889
|
The first input vertex.
|
885
|
-
vertexB :
|
890
|
+
vertexB : topologic_core.Vertex
|
886
891
|
The second input vertex.
|
887
892
|
tolerance : float , optional
|
888
893
|
The tolerance for computing if the input vertexA is coincident with the input vertexB. The default is 0.0001.
|
@@ -893,26 +898,28 @@ class Vertex(Topology):
|
|
893
898
|
True if the input vertexA is coincident with the input vertexB. False otherwise.
|
894
899
|
|
895
900
|
"""
|
896
|
-
|
901
|
+
from topologicpy.Topology import Topology
|
902
|
+
|
903
|
+
if not Topology.IsInstance(vertexA, "Vertex"):
|
897
904
|
if not silent:
|
898
905
|
print("Vertex.IsCoincident - Error: The input vertexA parameter is not a valid vertex. Returning None.")
|
899
906
|
return None
|
900
|
-
if not
|
907
|
+
if not Topology.IsInstance(vertexB, "Vertex"):
|
901
908
|
if not silent:
|
902
909
|
print("Vertex.IsICoincident - Error: The input vertexB parameter is not a valid vertex. Returning None.")
|
903
910
|
return None
|
904
911
|
return Vertex.IsInternal(vertexA, vertexB, tolerance=tolerance, silent=silent)
|
905
912
|
|
906
913
|
@staticmethod
|
907
|
-
def IsExternal(vertex
|
914
|
+
def IsExternal(vertex, topology, tolerance: float = 0.0001, silent: bool = False) -> bool:
|
908
915
|
"""
|
909
916
|
Returns True if the input vertex is external to the input topology. Returns False otherwise.
|
910
917
|
|
911
918
|
Parameters
|
912
919
|
----------
|
913
|
-
vertex :
|
920
|
+
vertex : topologic_core.Vertex
|
914
921
|
The input vertex.
|
915
|
-
topology :
|
922
|
+
topology : topologic_core.Topology
|
916
923
|
The input topology.
|
917
924
|
tolerance : float , optional
|
918
925
|
The tolerance for computing if the input vertex is external to the input topology. The default is 0.0001.
|
@@ -925,27 +932,28 @@ class Vertex(Topology):
|
|
925
932
|
True if the input vertex is external to the input topology. False otherwise.
|
926
933
|
|
927
934
|
"""
|
935
|
+
from topologicpy.Topology import Topology
|
928
936
|
|
929
|
-
if not
|
937
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
930
938
|
if not silent:
|
931
939
|
print("Vertex.IsExternal - Error: The input vertex parameter is not a valid vertex. Returning None.")
|
932
940
|
return None
|
933
|
-
if not
|
941
|
+
if not Topology.IsInstance(topology, "Topology"):
|
934
942
|
if not silent:
|
935
943
|
print("Vertex.IsExternal - Error: The input topology parameter is not a valid topology. Returning None.")
|
936
944
|
return None
|
937
945
|
return not (Vertex.IsPeripheral(vertex, topology, tolerance=tolerance, silent=silent) or Vertex.IsInternal(vertex, topology, tolerance=tolerance, silent=silent))
|
938
946
|
|
939
947
|
@staticmethod
|
940
|
-
def IsInternal(vertex
|
948
|
+
def IsInternal(vertex, topology, tolerance: float = 0.0001, silent: bool = False) -> bool:
|
941
949
|
"""
|
942
950
|
Returns True if the input vertex is inside the input topology. Returns False otherwise.
|
943
951
|
|
944
952
|
Parameters
|
945
953
|
----------
|
946
|
-
vertex :
|
954
|
+
vertex : topologic_core.Vertex
|
947
955
|
The input vertex.
|
948
|
-
topology :
|
956
|
+
topology : topologic_core.Topology
|
949
957
|
The input topology.
|
950
958
|
tolerance : float , optional
|
951
959
|
The tolerance for computing if the input vertex is internal to the input topology. The default is 0.0001.
|
@@ -961,28 +969,30 @@ class Vertex(Topology):
|
|
961
969
|
from topologicpy.Edge import Edge
|
962
970
|
from topologicpy.Wire import Wire
|
963
971
|
from topologicpy.Face import Face
|
964
|
-
from topologicpy.Shell import Shell
|
965
972
|
from topologicpy.CellComplex import CellComplex
|
966
973
|
from topologicpy.Cluster import Cluster
|
967
974
|
from topologicpy.Topology import Topology
|
968
|
-
|
975
|
+
|
976
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
969
977
|
if not silent:
|
970
978
|
print("Vertex.IsInternal - Error: The input vertex parameter is not a valid vertex. Returning None.")
|
971
979
|
return None
|
972
|
-
if not
|
980
|
+
if not Topology.IsInstance(topology, "Topology"):
|
973
981
|
if not silent:
|
974
982
|
print("Vertex.IsInternal - Error: The input topology parameter is not a valid topology. Returning None.")
|
975
983
|
return None
|
976
984
|
|
977
|
-
if
|
985
|
+
if Topology.IsInstance(topology, "Vertex"):
|
978
986
|
return Vertex.Distance(vertex, topology) < tolerance
|
979
|
-
elif
|
987
|
+
elif Topology.IsInstance(topology, "Edge"):
|
980
988
|
try:
|
981
|
-
parameter =
|
989
|
+
parameter = Edge.ParameterAtVertex(topology, vertex)
|
982
990
|
except:
|
983
991
|
parameter = 400 #aribtrary large number greater than 1
|
992
|
+
if parameter == None:
|
993
|
+
return False
|
984
994
|
return 0 <= parameter <= 1
|
985
|
-
elif
|
995
|
+
elif Topology.IsInstance(topology, "Wire"):
|
986
996
|
vertices = [v for v in Topology.Vertices(topology) if Vertex.Degree(v, topology) > 1]
|
987
997
|
edges = Wire.Edges(topology)
|
988
998
|
sub_list = vertices + edges
|
@@ -990,7 +1000,7 @@ class Vertex(Topology):
|
|
990
1000
|
if Vertex.IsInternal(vertex, sub, tolerance=tolerance, silent=silent):
|
991
1001
|
return True
|
992
1002
|
return False
|
993
|
-
elif
|
1003
|
+
elif Topology.IsInstance(topology, "Face"):
|
994
1004
|
# Test the distance first
|
995
1005
|
if Vertex.PerpendicularDistance(vertex, topology) > tolerance:
|
996
1006
|
return False
|
@@ -1005,7 +1015,7 @@ class Vertex(Topology):
|
|
1005
1015
|
if intersect == None:
|
1006
1016
|
return False
|
1007
1017
|
return True
|
1008
|
-
elif
|
1018
|
+
elif Topology.IsInstance(topology, "Shell"):
|
1009
1019
|
if Vertex.IsPeripheral(vertex, topology, tolerance=tolerance, silent=silent):
|
1010
1020
|
return False
|
1011
1021
|
else:
|
@@ -1018,12 +1028,12 @@ class Vertex(Topology):
|
|
1018
1028
|
if Vertex.IsInternal(vertex, face, tolerance=tolerance, silent=silent):
|
1019
1029
|
return True
|
1020
1030
|
return False
|
1021
|
-
elif
|
1022
|
-
return topologic.CellUtility.Contains(topology, vertex, tolerance) == 0
|
1023
|
-
elif
|
1031
|
+
elif Topology.IsInstance(topology, "Cell"):
|
1032
|
+
return topologic.CellUtility.Contains(topology, vertex, tolerance) == 0 # Hook to Core
|
1033
|
+
elif Topology.IsInstance(topology, "CellComplex"):
|
1024
1034
|
ext_boundary = CellComplex.ExternalBoundary(topology)
|
1025
1035
|
return Vertex.IsInternal(vertex, ext_boundary, tolerance=tolerance, silent=silent)
|
1026
|
-
elif
|
1036
|
+
elif Topology.IsInstance(topology, "Cluster"):
|
1027
1037
|
sub_list = Cluster.FreeTopologies(topology)
|
1028
1038
|
for sub in sub_list:
|
1029
1039
|
if Vertex.IsInternal(vertex, sub, tolerance=tolerance, silent=silent):
|
@@ -1033,7 +1043,7 @@ class Vertex(Topology):
|
|
1033
1043
|
|
1034
1044
|
|
1035
1045
|
@staticmethod
|
1036
|
-
def IsPeripheral(vertex
|
1046
|
+
def IsPeripheral(vertex, topology, tolerance: float = 0.0001, silent: bool = False) -> bool:
|
1037
1047
|
"""
|
1038
1048
|
Returns True if the input vertex is peripheral to the input topology. Returns False otherwise.
|
1039
1049
|
A vertex is said to be peripheral to the input topology if:
|
@@ -1050,9 +1060,9 @@ class Vertex(Topology):
|
|
1050
1060
|
|
1051
1061
|
Parameters
|
1052
1062
|
----------
|
1053
|
-
vertex :
|
1063
|
+
vertex : topologic_core.Vertex
|
1054
1064
|
The input vertex.
|
1055
|
-
topology :
|
1065
|
+
topology : topologic_core.Topology
|
1056
1066
|
The input topology.
|
1057
1067
|
tolerance : float , optional
|
1058
1068
|
The tolerance for computing if the input vertex is peripheral to the input topology. The default is 0.0001.
|
@@ -1073,24 +1083,24 @@ class Vertex(Topology):
|
|
1073
1083
|
from topologicpy.Cluster import Cluster
|
1074
1084
|
from topologicpy.Topology import Topology
|
1075
1085
|
|
1076
|
-
if not
|
1086
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
1077
1087
|
if not silent:
|
1078
1088
|
print("Vertex.IsPeripheral - Error: The input vertex parameter is not a valid vertex. Returning None.")
|
1079
1089
|
return None
|
1080
|
-
if not
|
1090
|
+
if not Topology.IsInstance(topology, "Topology"):
|
1081
1091
|
if not silent:
|
1082
1092
|
print("Vertex.IsPeripheral - Error: The input topology parameter is not a valid topology. Returning None.")
|
1083
1093
|
return None
|
1084
1094
|
|
1085
|
-
if
|
1095
|
+
if Topology.IsInstance(topology, "Vertex"):
|
1086
1096
|
return Vertex.IsInternal(vertex, topology, tolerance=tolerance, silent=silent)
|
1087
|
-
elif
|
1097
|
+
elif Topology.IsInstance(topology, "Edge"):
|
1088
1098
|
sv = Edge.StartVertex(topology)
|
1089
1099
|
ev = Edge.EndVertex(topology)
|
1090
1100
|
f1 = Vertex.IsInternal(vertex, sv, tolerance=tolerance, silent=silent)
|
1091
1101
|
f2 = Vertex.IsInternal(vertex, ev, tolerance=tolerance, silent=silent)
|
1092
1102
|
return f1 or f2
|
1093
|
-
elif
|
1103
|
+
elif Topology.IsInstance(topology, "Wire"):
|
1094
1104
|
if Wire.IsManifold(topology):
|
1095
1105
|
if not Wire.IsClosed(topology):
|
1096
1106
|
sv = Wire.StartVertex(topology)
|
@@ -1110,33 +1120,33 @@ class Vertex(Topology):
|
|
1110
1120
|
if Vertex.IsPeripheral(vertex, sub, tolerance=tolerance, silent=silent):
|
1111
1121
|
return True
|
1112
1122
|
return False
|
1113
|
-
elif
|
1123
|
+
elif Topology.IsInstance(topology, "Face"):
|
1114
1124
|
sub_list = Topology.Vertices(topology) + Topology.Edges(topology)
|
1115
1125
|
for sub in sub_list:
|
1116
1126
|
if Vertex.IsInternal(vertex, sub, tolerance=tolerance, silent=silent):
|
1117
1127
|
return True
|
1118
1128
|
return False
|
1119
|
-
elif
|
1129
|
+
elif Topology.IsInstance(topology, "Shell"):
|
1120
1130
|
ext_boundary = Shell.ExternalBoundary(topology)
|
1121
1131
|
sub_list = Topology.Vertices(ext_boundary) + Topology.Edges(ext_boundary)
|
1122
1132
|
for sub in sub_list:
|
1123
1133
|
if Vertex.IsInternal(vertex, sub, tolerance=tolerance, silent=silent):
|
1124
1134
|
return True
|
1125
1135
|
return False
|
1126
|
-
elif
|
1136
|
+
elif Topology.IsInstance(topology, "Cell"):
|
1127
1137
|
sub_list = Topology.Vertices(topology) + Topology.Edges(topology) + Topology.Faces(topology)
|
1128
1138
|
for sub in sub_list:
|
1129
1139
|
if Vertex.IsInternal(vertex, sub, tolerance=tolerance, silent=silent):
|
1130
1140
|
return True
|
1131
1141
|
return False
|
1132
|
-
elif
|
1142
|
+
elif Topology.IsInstance(topology, "CellComplex"):
|
1133
1143
|
ext_boundary = CellComplex.ExternalBoundary(topology)
|
1134
1144
|
sub_list = Topology.Vertices(ext_boundary) + Topology.Edges(ext_boundary) + Topology.Faces(ext_boundary)
|
1135
1145
|
for sub in sub_list:
|
1136
1146
|
if Vertex.IsInternal(vertex, sub, tolerance=tolerance, silent=silent):
|
1137
1147
|
return True
|
1138
1148
|
return False
|
1139
|
-
elif
|
1149
|
+
elif Topology.IsInstance(topology, "Cluster"):
|
1140
1150
|
sub_list = Cluster.FreeTopologies(topology)
|
1141
1151
|
for sub in sub_list:
|
1142
1152
|
if Vertex.IsPeripheral(vertex, sub, tolerance=tolerance, silent=silent):
|
@@ -1145,25 +1155,27 @@ class Vertex(Topology):
|
|
1145
1155
|
return False
|
1146
1156
|
|
1147
1157
|
@staticmethod
|
1148
|
-
def NearestVertex(vertex
|
1158
|
+
def NearestVertex(vertex, topology, useKDTree: bool = True):
|
1149
1159
|
"""
|
1150
1160
|
Returns the vertex found in the input topology that is the nearest to the input vertex.
|
1151
1161
|
|
1152
1162
|
Parameters
|
1153
1163
|
----------
|
1154
|
-
vertex :
|
1164
|
+
vertex : topologic_core.Vertex
|
1155
1165
|
The input vertex.
|
1156
|
-
topology :
|
1166
|
+
topology : topologic_core.Topology
|
1157
1167
|
The input topology to be searched for the nearest vertex.
|
1158
1168
|
useKDTree : bool , optional
|
1159
1169
|
if set to True, the algorithm will use a KDTree method to search for the nearest vertex. The default is True.
|
1160
1170
|
|
1161
1171
|
Returns
|
1162
1172
|
-------
|
1163
|
-
|
1173
|
+
topologic_core.Vertex
|
1164
1174
|
The nearest vertex.
|
1165
1175
|
|
1166
|
-
"""
|
1176
|
+
"""
|
1177
|
+
from topologicpy.Topology import Topology
|
1178
|
+
|
1167
1179
|
def SED(a, b):
|
1168
1180
|
"""Compute the squared Euclidean distance between X and Y."""
|
1169
1181
|
p1 = (a.X(), a.Y(), a.Z())
|
@@ -1200,7 +1212,7 @@ class Vertex(Topology):
|
|
1200
1212
|
return vertices
|
1201
1213
|
|
1202
1214
|
def kdtree(topology):
|
1203
|
-
assert
|
1215
|
+
assert Topology.IsInstance(topology, "Topology"), "Vertex.NearestVertex: The input is not a Topology."
|
1204
1216
|
vertices = []
|
1205
1217
|
_ = topology.Vertices(None, vertices)
|
1206
1218
|
assert (len(vertices) > 0), "Vertex.NearestVertex: Could not find any vertices in the input Topology"
|
@@ -1288,7 +1300,7 @@ class Vertex(Topology):
|
|
1288
1300
|
return vertices[sorted_indices[0]]
|
1289
1301
|
|
1290
1302
|
@staticmethod
|
1291
|
-
def Origin()
|
1303
|
+
def Origin():
|
1292
1304
|
"""
|
1293
1305
|
Returns a vertex with coordinates (0, 0, 0)
|
1294
1306
|
|
@@ -1297,20 +1309,20 @@ class Vertex(Topology):
|
|
1297
1309
|
|
1298
1310
|
Return
|
1299
1311
|
-----------
|
1300
|
-
|
1312
|
+
topologic_core.Vertex
|
1301
1313
|
"""
|
1302
1314
|
return Vertex.ByCoordinates(0, 0, 0)
|
1303
1315
|
|
1304
1316
|
@staticmethod
|
1305
|
-
def PerpendicularDistance(vertex
|
1317
|
+
def PerpendicularDistance(vertex, face, mantissa: int = 6):
|
1306
1318
|
"""
|
1307
1319
|
Returns the perpendicular distance between the input vertex and the input face. The face is considered to be infinite.
|
1308
1320
|
|
1309
1321
|
Parameters
|
1310
1322
|
----------
|
1311
|
-
vertex :
|
1323
|
+
vertex : topologic_core.Vertex
|
1312
1324
|
The input vertex.
|
1313
|
-
face :
|
1325
|
+
face : topologic_core.Face
|
1314
1326
|
The input face.
|
1315
1327
|
mantissa: int , optional
|
1316
1328
|
The desired length of the mantissa. The default is 6.
|
@@ -1322,6 +1334,7 @@ class Vertex(Topology):
|
|
1322
1334
|
|
1323
1335
|
"""
|
1324
1336
|
from topologicpy.Face import Face
|
1337
|
+
from topologicpy.Topology import Topology
|
1325
1338
|
import math
|
1326
1339
|
|
1327
1340
|
def distance_point_to_line(point, line_start, line_end):
|
@@ -1355,10 +1368,10 @@ class Vertex(Topology):
|
|
1355
1368
|
distance = np.linalg.norm(point - closest_point)
|
1356
1369
|
|
1357
1370
|
return distance
|
1358
|
-
if not
|
1371
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
1359
1372
|
print("Vertex.PerpendicularDistance - Error: The input vertex is not a valid topologic vertex. Returning None.")
|
1360
1373
|
return None
|
1361
|
-
if not
|
1374
|
+
if not Topology.IsInstance(face, "Face"):
|
1362
1375
|
print("Vertex.PerpendicularDistance - Error: The input face is not a valid topologic face. Returning None.")
|
1363
1376
|
return None
|
1364
1377
|
dic = Face.PlaneEquation(face)
|
@@ -1431,7 +1444,7 @@ class Vertex(Topology):
|
|
1431
1444
|
return {"a":a, "b":b, "c":c, "d":d}
|
1432
1445
|
|
1433
1446
|
@staticmethod
|
1434
|
-
def Point(x=0, y=0, z=0)
|
1447
|
+
def Point(x=0, y=0, z=0):
|
1435
1448
|
"""
|
1436
1449
|
Creates a point (vertex) using the input parameters
|
1437
1450
|
|
@@ -1446,21 +1459,21 @@ class Vertex(Topology):
|
|
1446
1459
|
|
1447
1460
|
Return
|
1448
1461
|
-----------
|
1449
|
-
|
1462
|
+
topologic_core.Vertex
|
1450
1463
|
"""
|
1451
1464
|
|
1452
1465
|
return Vertex.ByCoordinates(x, y, z)
|
1453
1466
|
|
1454
1467
|
@staticmethod
|
1455
|
-
def Project(vertex
|
1468
|
+
def Project(vertex, face, direction: bool = None, mantissa: int = 6):
|
1456
1469
|
"""
|
1457
1470
|
Returns a vertex that is the projection of the input vertex unto the input face.
|
1458
1471
|
|
1459
1472
|
Parameters
|
1460
1473
|
----------
|
1461
|
-
vertex :
|
1474
|
+
vertex : topologic_core.Vertex
|
1462
1475
|
The input vertex to project unto the input face.
|
1463
|
-
face :
|
1476
|
+
face : topologic_core.Face
|
1464
1477
|
The input face that receives the projection of the input vertex.
|
1465
1478
|
direction : vector, optional
|
1466
1479
|
The direction in which to project the input vertex unto the input face. If not specified, the direction of the projection is the normal of the input face. The default is None.
|
@@ -1471,11 +1484,12 @@ class Vertex(Topology):
|
|
1471
1484
|
|
1472
1485
|
Returns
|
1473
1486
|
-------
|
1474
|
-
|
1487
|
+
topologic_core.Vertex
|
1475
1488
|
The projected vertex.
|
1476
1489
|
|
1477
1490
|
"""
|
1478
1491
|
from topologicpy.Face import Face
|
1492
|
+
from topologicpy.Topology import Topology
|
1479
1493
|
|
1480
1494
|
def project_point_onto_plane(point, plane_coeffs, direction_vector):
|
1481
1495
|
"""
|
@@ -1508,9 +1522,9 @@ class Vertex(Topology):
|
|
1508
1522
|
|
1509
1523
|
return [x_proj, y_proj, z_proj]
|
1510
1524
|
|
1511
|
-
if not
|
1525
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
1512
1526
|
return None
|
1513
|
-
if not
|
1527
|
+
if not Topology.IsInstance(face, "Face"):
|
1514
1528
|
return None
|
1515
1529
|
eq = Face.PlaneEquation(face, mantissa= mantissa)
|
1516
1530
|
if direction == None or direction == []:
|
@@ -1519,13 +1533,13 @@ class Vertex(Topology):
|
|
1519
1533
|
return Vertex.ByCoordinates(pt[0], pt[1], pt[2])
|
1520
1534
|
|
1521
1535
|
@staticmethod
|
1522
|
-
def X(vertex
|
1536
|
+
def X(vertex, mantissa: int = 6) -> float:
|
1523
1537
|
"""
|
1524
1538
|
Returns the X coordinate of the input vertex.
|
1525
1539
|
|
1526
1540
|
Parameters
|
1527
1541
|
----------
|
1528
|
-
vertex :
|
1542
|
+
vertex : topologic_core.Vertex
|
1529
1543
|
The input vertex.
|
1530
1544
|
mantissa : int , optional
|
1531
1545
|
The desired length of the mantissa. The default is 6.
|
@@ -1536,18 +1550,20 @@ class Vertex(Topology):
|
|
1536
1550
|
The X coordinate of the input vertex.
|
1537
1551
|
|
1538
1552
|
"""
|
1539
|
-
|
1553
|
+
from topologicpy.Topology import Topology
|
1554
|
+
|
1555
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
1540
1556
|
return None
|
1541
1557
|
return round(vertex.X(), mantissa)
|
1542
1558
|
|
1543
1559
|
@staticmethod
|
1544
|
-
def Y(vertex
|
1560
|
+
def Y(vertex, mantissa: int = 6) -> float:
|
1545
1561
|
"""
|
1546
1562
|
Returns the Y coordinate of the input vertex.
|
1547
1563
|
|
1548
1564
|
Parameters
|
1549
1565
|
----------
|
1550
|
-
vertex :
|
1566
|
+
vertex : topologic_core.Vertex
|
1551
1567
|
The input vertex.
|
1552
1568
|
mantissa : int , optional
|
1553
1569
|
The desired length of the mantissa. The default is 6.
|
@@ -1558,18 +1574,19 @@ class Vertex(Topology):
|
|
1558
1574
|
The Y coordinate of the input vertex.
|
1559
1575
|
|
1560
1576
|
"""
|
1561
|
-
|
1577
|
+
from topologicpy.Topology import Topology
|
1578
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
1562
1579
|
return None
|
1563
1580
|
return round(vertex.Y(), mantissa)
|
1564
1581
|
|
1565
1582
|
@staticmethod
|
1566
|
-
def Z(vertex
|
1583
|
+
def Z(vertex, mantissa: int = 6) -> float:
|
1567
1584
|
"""
|
1568
1585
|
Returns the Z coordinate of the input vertex.
|
1569
1586
|
|
1570
1587
|
Parameters
|
1571
1588
|
----------
|
1572
|
-
vertex :
|
1589
|
+
vertex : topologic_core.Vertex
|
1573
1590
|
The input vertex.
|
1574
1591
|
mantissa : int , optional
|
1575
1592
|
The desired length of the mantissa. The default is 6.
|
@@ -1580,7 +1597,9 @@ class Vertex(Topology):
|
|
1580
1597
|
The Z coordinate of the input vertex.
|
1581
1598
|
|
1582
1599
|
"""
|
1583
|
-
|
1600
|
+
from topologicpy.Topology import Topology
|
1601
|
+
|
1602
|
+
if not Topology.IsInstance(vertex, "Vertex"):
|
1584
1603
|
return None
|
1585
1604
|
return round(vertex.Z(), mantissa)
|
1586
1605
|
|