topologicpy 0.6.3__py3-none-any.whl → 0.7.2__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 +217 -164
- topologicpy/EnergyModel.py +23 -24
- topologicpy/Face.py +526 -315
- 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 +544 -765
- topologicpy/Vector.py +4 -4
- topologicpy/Vertex.py +145 -126
- topologicpy/Wire.py +545 -328
- topologicpy/version.py +1 -1
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.2.dist-info}/METADATA +1 -1
- topologicpy-0.7.2.dist-info/RECORD +33 -0
- topologicpy-0.6.3.dist-info/RECORD +0 -33
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.2.dist-info}/LICENSE +0 -0
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.2.dist-info}/WHEEL +0 -0
- {topologicpy-0.6.3.dist-info → topologicpy-0.7.2.dist-info}/top_level.txt +0 -0
topologicpy/Cluster.py
CHANGED
@@ -14,7 +14,6 @@
|
|
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
|
-
from topologicpy.Topology import Topology
|
18
17
|
import topologic_core as topologic
|
19
18
|
import os
|
20
19
|
import warnings
|
@@ -47,7 +46,7 @@ except:
|
|
47
46
|
except:
|
48
47
|
warnings.warn("Cluster - Error: Could not import scipy.")
|
49
48
|
|
50
|
-
class Cluster(
|
49
|
+
class Cluster():
|
51
50
|
@staticmethod
|
52
51
|
def ByFormula(formula, xRange=None, yRange=None, xString="X", yString="Y"):
|
53
52
|
"""
|
@@ -82,7 +81,7 @@ class Cluster(Topology):
|
|
82
81
|
The string used to represent the Y independent variable. The default is 'Y' (uppercase).
|
83
82
|
|
84
83
|
Returns:
|
85
|
-
|
84
|
+
topologic_core.Cluster
|
86
85
|
The created cluster of vertices.
|
87
86
|
"""
|
88
87
|
from topologicpy.Vertex import Vertex
|
@@ -144,7 +143,7 @@ class Cluster(Topology):
|
|
144
143
|
return Cluster.ByTopologies(vertices)
|
145
144
|
|
146
145
|
@staticmethod
|
147
|
-
def ByTopologies(*args, transferDictionaries: bool = False)
|
146
|
+
def ByTopologies(*args, transferDictionaries: bool = False):
|
148
147
|
"""
|
149
148
|
Creates a topologic Cluster from the input list of topologies. The input can be individual topologies each as an input argument or a list of topologies stored in one input argument.
|
150
149
|
|
@@ -157,7 +156,7 @@ class Cluster(Topology):
|
|
157
156
|
|
158
157
|
Returns
|
159
158
|
-------
|
160
|
-
|
159
|
+
topologic_core.Cluster
|
161
160
|
The created topologic Cluster.
|
162
161
|
|
163
162
|
"""
|
@@ -175,7 +174,7 @@ class Cluster(Topology):
|
|
175
174
|
print("Cluster.ByTopologies - Error: The input topologies parameter is an empty list. Returning None.")
|
176
175
|
return None
|
177
176
|
else:
|
178
|
-
topologyList = [x for x in topologies if
|
177
|
+
topologyList = [x for x in topologies if Topology.IsInstance(x, "Topology")]
|
179
178
|
if len(topologies) == 0:
|
180
179
|
print("Cluster.ByTopologies - Error: The input topologies parameter does not contain any valid topologies. Returning None.")
|
181
180
|
return None
|
@@ -184,11 +183,11 @@ class Cluster(Topology):
|
|
184
183
|
return topologies
|
185
184
|
else:
|
186
185
|
topologyList = Helper.Flatten(list(args))
|
187
|
-
topologyList = [x for x in topologyList if
|
186
|
+
topologyList = [x for x in topologyList if Topology.IsInstance(x, "Topology")]
|
188
187
|
if len(topologyList) == 0:
|
189
188
|
print("Cluster.ByTopologies - Error: The input parameters do not contain any valid topologies. Returning None.")
|
190
189
|
return None
|
191
|
-
cluster = topologic.Cluster.ByTopologies(topologyList, False)
|
190
|
+
cluster = topologic.Cluster.ByTopologies(topologyList, False) # Hook to Core
|
192
191
|
dictionaries = []
|
193
192
|
for t in topologyList:
|
194
193
|
d = Topology.Dictionary(t)
|
@@ -205,13 +204,13 @@ class Cluster(Topology):
|
|
205
204
|
return cluster
|
206
205
|
|
207
206
|
@staticmethod
|
208
|
-
def CellComplexes(cluster
|
207
|
+
def CellComplexes(cluster) -> list:
|
209
208
|
"""
|
210
209
|
Returns the cellComplexes of the input cluster.
|
211
210
|
|
212
211
|
Parameters
|
213
212
|
----------
|
214
|
-
cluster :
|
213
|
+
cluster : topologic_core.Cluster
|
215
214
|
The input cluster.
|
216
215
|
|
217
216
|
Returns
|
@@ -220,7 +219,9 @@ class Cluster(Topology):
|
|
220
219
|
The list of cellComplexes.
|
221
220
|
|
222
221
|
"""
|
223
|
-
|
222
|
+
from topologicpy.Topology import Topology
|
223
|
+
|
224
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
224
225
|
print("Cluster.CellComplexes - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
225
226
|
return None
|
226
227
|
cellComplexes = []
|
@@ -228,13 +229,13 @@ class Cluster(Topology):
|
|
228
229
|
return cellComplexes
|
229
230
|
|
230
231
|
@staticmethod
|
231
|
-
def Cells(cluster
|
232
|
+
def Cells(cluster) -> list:
|
232
233
|
"""
|
233
234
|
Returns the cells of the input cluster.
|
234
235
|
|
235
236
|
Parameters
|
236
237
|
----------
|
237
|
-
cluster :
|
238
|
+
cluster : topologic_core.Cluster
|
238
239
|
The input cluster.
|
239
240
|
|
240
241
|
Returns
|
@@ -243,7 +244,9 @@ class Cluster(Topology):
|
|
243
244
|
The list of cells.
|
244
245
|
|
245
246
|
"""
|
246
|
-
|
247
|
+
from topologicpy.Topology import Topology
|
248
|
+
|
249
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
247
250
|
print("Cluster.Cells - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
248
251
|
return None
|
249
252
|
cells = []
|
@@ -358,7 +361,7 @@ class Cluster(Topology):
|
|
358
361
|
if not isinstance(topologies, list):
|
359
362
|
print("Cluster.DBSCAN - Error: The input vertices parameter is not a valid list. Returning None.")
|
360
363
|
return None, None
|
361
|
-
topologyList = [t for t in topologies if
|
364
|
+
topologyList = [t for t in topologies if Topology.IsInstance(t, "Topology")]
|
362
365
|
if len(topologyList) < 1:
|
363
366
|
print("Cluster.DBSCAN - Error: The input vertices parameter does not contain any valid vertices. Returning None.")
|
364
367
|
return None, None
|
@@ -367,16 +370,16 @@ class Cluster(Topology):
|
|
367
370
|
return None, None
|
368
371
|
|
369
372
|
if not isinstance(selectors, list):
|
370
|
-
check_vertices = [t for t in topologyList if not
|
373
|
+
check_vertices = [t for t in topologyList if not Topology.IsInstance(t, "Vertex")]
|
371
374
|
if len(check_vertices) > 0:
|
372
|
-
print("Cluster.DBSCAN - Error: The input selectors parameter is not a valid list and this is needed since the list of topologies contains objects of type other than a
|
375
|
+
print("Cluster.DBSCAN - Error: The input selectors parameter is not a valid list and this is needed since the list of topologies contains objects of type other than a topologic_core.Vertex. Returning None.")
|
373
376
|
return None, None
|
374
377
|
else:
|
375
|
-
selectors = [s for s in selectors if
|
378
|
+
selectors = [s for s in selectors if Topology.IsInstance(s, "Vertex")]
|
376
379
|
if len(selectors) < 1:
|
377
|
-
check_vertices = [t for t in topologyList if not
|
380
|
+
check_vertices = [t for t in topologyList if not Topology.IsInstance(t, "Vertex")]
|
378
381
|
if len(check_vertices) > 0:
|
379
|
-
print("Cluster.DBSCAN - Error: The input selectors parameter does not contain any valid vertices and this is needed since the list of topologies contains objects of type other than a
|
382
|
+
print("Cluster.DBSCAN - Error: The input selectors parameter does not contain any valid vertices and this is needed since the list of topologies contains objects of type other than a topologic_core.Vertex. Returning None.")
|
380
383
|
return None, None
|
381
384
|
if not len(selectors) == len(topologyList):
|
382
385
|
print("Cluster.DBSCAN - Error: The input topologies and selectors parameters do not have the same length. Returning None.")
|
@@ -433,13 +436,13 @@ class Cluster(Topology):
|
|
433
436
|
return tp_clusters, tp_noise
|
434
437
|
|
435
438
|
@staticmethod
|
436
|
-
def Edges(cluster
|
439
|
+
def Edges(cluster) -> list:
|
437
440
|
"""
|
438
441
|
Returns the edges of the input cluster.
|
439
442
|
|
440
443
|
Parameters
|
441
444
|
----------
|
442
|
-
cluster :
|
445
|
+
cluster : topologic_core.Cluster
|
443
446
|
The input cluster.
|
444
447
|
|
445
448
|
Returns
|
@@ -447,8 +450,10 @@ class Cluster(Topology):
|
|
447
450
|
list
|
448
451
|
The list of edges.
|
449
452
|
|
450
|
-
"""
|
451
|
-
|
453
|
+
"""
|
454
|
+
from topologicpy.Topology import Topology
|
455
|
+
|
456
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
452
457
|
print("Cluster.Edges - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
453
458
|
return None
|
454
459
|
edges = []
|
@@ -456,13 +461,13 @@ class Cluster(Topology):
|
|
456
461
|
return edges
|
457
462
|
|
458
463
|
@staticmethod
|
459
|
-
def Faces(cluster
|
464
|
+
def Faces(cluster) -> list:
|
460
465
|
"""
|
461
466
|
Returns the faces of the input cluster.
|
462
467
|
|
463
468
|
Parameters
|
464
469
|
----------
|
465
|
-
cluster :
|
470
|
+
cluster : topologic_core.Cluster
|
466
471
|
The input cluster.
|
467
472
|
|
468
473
|
Returns
|
@@ -471,7 +476,9 @@ class Cluster(Topology):
|
|
471
476
|
The list of faces.
|
472
477
|
|
473
478
|
"""
|
474
|
-
|
479
|
+
from topologicpy.Topology import Topology
|
480
|
+
|
481
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
475
482
|
print("Cluster.Faces - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
476
483
|
return None
|
477
484
|
faces = []
|
@@ -479,13 +486,13 @@ class Cluster(Topology):
|
|
479
486
|
return faces
|
480
487
|
|
481
488
|
@staticmethod
|
482
|
-
def FreeCells(cluster
|
489
|
+
def FreeCells(cluster, tolerance: float = 0.0001) -> list:
|
483
490
|
"""
|
484
491
|
Returns the free cells of the input cluster that are not part of a higher topology.
|
485
492
|
|
486
493
|
Parameters
|
487
494
|
----------
|
488
|
-
cluster :
|
495
|
+
cluster : topologic_core.Cluster
|
489
496
|
The input cluster.
|
490
497
|
tolerance : float , optional
|
491
498
|
The desired tolerance. The default is 0.0001.
|
@@ -499,7 +506,7 @@ class Cluster(Topology):
|
|
499
506
|
from topologicpy.CellComplex import CellComplex
|
500
507
|
from topologicpy.Topology import Topology
|
501
508
|
|
502
|
-
if not
|
509
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
503
510
|
print("Cluster.FreeCells - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
504
511
|
return None
|
505
512
|
allCells = []
|
@@ -520,7 +527,7 @@ class Cluster(Topology):
|
|
520
527
|
resultingCluster = Topology.Boolean(allCellsCluster, cellComplexesCluster, operation="difference", tolerance=tolerance)
|
521
528
|
if resultingCluster == None:
|
522
529
|
return []
|
523
|
-
if
|
530
|
+
if Topology.IsInstance(resultingCluster, "Cell"):
|
524
531
|
return [resultingCluster]
|
525
532
|
result = Topology.SubTopologies(resultingCluster, subTopologyType="cell")
|
526
533
|
if result == None:
|
@@ -528,13 +535,13 @@ class Cluster(Topology):
|
|
528
535
|
return result
|
529
536
|
|
530
537
|
@staticmethod
|
531
|
-
def FreeShells(cluster
|
538
|
+
def FreeShells(cluster, tolerance: float = 0.0001) -> list:
|
532
539
|
"""
|
533
540
|
Returns the free shells of the input cluster that are not part of a higher topology.
|
534
541
|
|
535
542
|
Parameters
|
536
543
|
----------
|
537
|
-
cluster :
|
544
|
+
cluster : topologic_core.Cluster
|
538
545
|
The input cluster.
|
539
546
|
tolerance : float, optional
|
540
547
|
The desired tolerance. The default is 0.0001.
|
@@ -548,7 +555,7 @@ class Cluster(Topology):
|
|
548
555
|
from topologicpy.Cell import Cell
|
549
556
|
from topologicpy.Topology import Topology
|
550
557
|
|
551
|
-
if not
|
558
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
552
559
|
print("Cluster.FreeShells - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
553
560
|
return None
|
554
561
|
allShells = []
|
@@ -568,7 +575,7 @@ class Cluster(Topology):
|
|
568
575
|
resultingCluster = Topology.Boolean(allShellsCluster, cellsCluster, operation="difference", tolerance=tolerance)
|
569
576
|
if resultingCluster == None:
|
570
577
|
return []
|
571
|
-
if
|
578
|
+
if Topology.IsInstance(resultingCluster, "Shell"):
|
572
579
|
return [resultingCluster]
|
573
580
|
result = Topology.SubTopologies(resultingCluster, subTopologyType="shell")
|
574
581
|
if result == None:
|
@@ -576,13 +583,13 @@ class Cluster(Topology):
|
|
576
583
|
return result
|
577
584
|
|
578
585
|
@staticmethod
|
579
|
-
def FreeFaces(cluster
|
586
|
+
def FreeFaces(cluster, tolerance: float = 0.0001) -> list:
|
580
587
|
"""
|
581
588
|
Returns the free faces of the input cluster that are not part of a higher topology.
|
582
589
|
|
583
590
|
Parameters
|
584
591
|
----------
|
585
|
-
cluster :
|
592
|
+
cluster : topologic_core.Cluster
|
586
593
|
The input cluster.
|
587
594
|
tolerance : float , optional
|
588
595
|
The desired tolerance. The default is 0.0001.
|
@@ -596,7 +603,7 @@ class Cluster(Topology):
|
|
596
603
|
from topologicpy.Shell import Shell
|
597
604
|
from topologicpy.Topology import Topology
|
598
605
|
|
599
|
-
if not
|
606
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
600
607
|
print("Cluster.FreeFaces - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
601
608
|
return None
|
602
609
|
allFaces = []
|
@@ -616,7 +623,7 @@ class Cluster(Topology):
|
|
616
623
|
resultingCluster = Topology.Boolean(allFacesCluster, shellCluster, operation="difference", tolerance=tolerance)
|
617
624
|
if resultingCluster == None:
|
618
625
|
return []
|
619
|
-
if
|
626
|
+
if Topology.IsInstance(resultingCluster, "Face"):
|
620
627
|
return [resultingCluster]
|
621
628
|
result = Topology.SubTopologies(resultingCluster, subTopologyType="face")
|
622
629
|
if result == None:
|
@@ -624,13 +631,13 @@ class Cluster(Topology):
|
|
624
631
|
return result
|
625
632
|
|
626
633
|
@staticmethod
|
627
|
-
def FreeWires(cluster
|
634
|
+
def FreeWires(cluster, tolerance: float = 0.0001) -> list:
|
628
635
|
"""
|
629
636
|
Returns the free wires of the input cluster that are not part of a higher topology.
|
630
637
|
|
631
638
|
Parameters
|
632
639
|
----------
|
633
|
-
cluster :
|
640
|
+
cluster : topologic_core.Cluster
|
634
641
|
The input cluster.
|
635
642
|
tolerance : float , optional
|
636
643
|
The desired tolerance. The default is 0.0001.
|
@@ -644,7 +651,7 @@ class Cluster(Topology):
|
|
644
651
|
from topologicpy.Face import Face
|
645
652
|
from topologicpy.Topology import Topology
|
646
653
|
|
647
|
-
if not
|
654
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
648
655
|
print("Cluster.FreeWires - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
649
656
|
return None
|
650
657
|
allWires = []
|
@@ -664,7 +671,7 @@ class Cluster(Topology):
|
|
664
671
|
resultingCluster = Topology.Boolean(allWiresCluster, facesCluster, operation="difference", tolerance=tolerance)
|
665
672
|
if resultingCluster == None:
|
666
673
|
return []
|
667
|
-
if
|
674
|
+
if Topology.IsInstance(resultingCluster, "Wire"):
|
668
675
|
return [resultingCluster]
|
669
676
|
result = Topology.SubTopologies(resultingCluster, subTopologyType="wire")
|
670
677
|
if not result:
|
@@ -672,13 +679,13 @@ class Cluster(Topology):
|
|
672
679
|
return result
|
673
680
|
|
674
681
|
@staticmethod
|
675
|
-
def FreeEdges(cluster
|
682
|
+
def FreeEdges(cluster, tolerance: float = 0.0001) -> list:
|
676
683
|
"""
|
677
684
|
Returns the free edges of the input cluster that are not part of a higher topology.
|
678
685
|
|
679
686
|
Parameters
|
680
687
|
----------
|
681
|
-
cluster :
|
688
|
+
cluster : topologic_core.Cluster
|
682
689
|
The input cluster.
|
683
690
|
tolerance : float, optional
|
684
691
|
The desired tolerance. The default is 0.0001.
|
@@ -692,7 +699,7 @@ class Cluster(Topology):
|
|
692
699
|
from topologicpy.Wire import Wire
|
693
700
|
from topologicpy.Topology import Topology
|
694
701
|
|
695
|
-
if not
|
702
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
696
703
|
print("Cluster.FreeEdges - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
697
704
|
return None
|
698
705
|
allEdges = []
|
@@ -712,7 +719,7 @@ class Cluster(Topology):
|
|
712
719
|
resultingCluster = Topology.Boolean(allEdgesCluster, wireCluster, operation="difference", tolerance=tolerance)
|
713
720
|
if resultingCluster == None:
|
714
721
|
return []
|
715
|
-
if
|
722
|
+
if Topology.IsInstance(resultingCluster, "Edge"):
|
716
723
|
return [resultingCluster]
|
717
724
|
result = Topology.SubTopologies(resultingCluster, subTopologyType="edge")
|
718
725
|
if result == None:
|
@@ -720,13 +727,13 @@ class Cluster(Topology):
|
|
720
727
|
return result
|
721
728
|
|
722
729
|
@staticmethod
|
723
|
-
def FreeVertices(cluster
|
730
|
+
def FreeVertices(cluster, tolerance: float = 0.0001) -> list:
|
724
731
|
"""
|
725
732
|
Returns the free vertices of the input cluster that are not part of a higher topology.
|
726
733
|
|
727
734
|
Parameters
|
728
735
|
----------
|
729
|
-
cluster :
|
736
|
+
cluster : topologic_core.Cluster
|
730
737
|
The input cluster.
|
731
738
|
tolerance : float , optional
|
732
739
|
The desired tolerance. The default is 0.0001.
|
@@ -740,7 +747,7 @@ class Cluster(Topology):
|
|
740
747
|
from topologicpy.Edge import Edge
|
741
748
|
from topologicpy.Topology import Topology
|
742
749
|
|
743
|
-
if not
|
750
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
744
751
|
print("Cluster.FreeVertices - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
745
752
|
return None
|
746
753
|
allVertices = []
|
@@ -758,7 +765,7 @@ class Cluster(Topology):
|
|
758
765
|
return allVertices
|
759
766
|
edgesCluster = Cluster.ByTopologies(edgesVertices)
|
760
767
|
resultingCluster = Topology.Boolean(allVerticesCluster, edgesCluster, operation="difference", tolerance=tolerance)
|
761
|
-
if
|
768
|
+
if Topology.IsInstance(resultingCluster, "Vertex"):
|
762
769
|
return [resultingCluster]
|
763
770
|
if resultingCluster == None:
|
764
771
|
return []
|
@@ -768,13 +775,13 @@ class Cluster(Topology):
|
|
768
775
|
return result
|
769
776
|
|
770
777
|
@staticmethod
|
771
|
-
def FreeTopologies(cluster
|
778
|
+
def FreeTopologies(cluster, tolerance: float = 0.0001) -> list:
|
772
779
|
"""
|
773
780
|
Returns the free topologies of the input cluster that are not part of a higher topology.
|
774
781
|
|
775
782
|
Parameters
|
776
783
|
----------
|
777
|
-
cluster :
|
784
|
+
cluster : topologic_core.Cluster
|
778
785
|
The input cluster.
|
779
786
|
tolerance : float , optional
|
780
787
|
The desired tolerance. The default is 0.0001.
|
@@ -796,13 +803,13 @@ class Cluster(Topology):
|
|
796
803
|
return topologies
|
797
804
|
|
798
805
|
@staticmethod
|
799
|
-
def HighestType(cluster
|
806
|
+
def HighestType(cluster) -> int:
|
800
807
|
"""
|
801
808
|
Returns the type of the highest dimension subtopology found in the input cluster.
|
802
809
|
|
803
810
|
Parameters
|
804
811
|
----------
|
805
|
-
cluster :
|
812
|
+
cluster : topologic_core.Cluster
|
806
813
|
The input cluster.
|
807
814
|
|
808
815
|
Returns
|
@@ -811,30 +818,32 @@ class Cluster(Topology):
|
|
811
818
|
The type of the highest dimension subtopology found in the input cluster.
|
812
819
|
|
813
820
|
"""
|
814
|
-
|
821
|
+
from topologicpy.Topology import Topology
|
822
|
+
|
823
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
815
824
|
print("Cluster.HighestType - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
816
825
|
return None
|
817
826
|
cellComplexes = Cluster.CellComplexes(cluster)
|
818
827
|
if len(cellComplexes) > 0:
|
819
|
-
return
|
828
|
+
return Topology.TypeID("CellComplex")
|
820
829
|
cells = Cluster.Cells(cluster)
|
821
830
|
if len(cells) > 0:
|
822
|
-
return
|
831
|
+
return Topology.TypeID("Cell")
|
823
832
|
shells = Cluster.Shells(cluster)
|
824
833
|
if len(shells) > 0:
|
825
|
-
return
|
834
|
+
return Topology.TypeID("Shell")
|
826
835
|
faces = Cluster.Faces(cluster)
|
827
836
|
if len(faces) > 0:
|
828
|
-
return
|
837
|
+
return Topology.TypeID("Face")
|
829
838
|
wires = Cluster.Wires(cluster)
|
830
839
|
if len(wires) > 0:
|
831
|
-
return
|
840
|
+
return Topology.TypeID("Wire")
|
832
841
|
edges = Cluster.Edges(cluster)
|
833
842
|
if len(edges) > 0:
|
834
|
-
return
|
843
|
+
return Topology.TypeID("Edge")
|
835
844
|
vertices = Cluster.Vertices(cluster)
|
836
845
|
if len(vertices) > 0:
|
837
|
-
return
|
846
|
+
return Topology.TypeID("Vertex")
|
838
847
|
|
839
848
|
@staticmethod
|
840
849
|
def K_Means(topologies, selectors=None, keys=["x", "y", "z"], k=4, maxIterations=100, centroidKey="k_centroid"):
|
@@ -910,21 +919,21 @@ class Cluster(Topology):
|
|
910
919
|
if not isinstance(topologies, list):
|
911
920
|
print("Cluster.K_Means - Error: The input topologies parameter is not a valid list. Returning None.")
|
912
921
|
return None
|
913
|
-
topologies = [t for t in topologies if
|
922
|
+
topologies = [t for t in topologies if Topology.IsInstance(t, "Topology")]
|
914
923
|
if len(topologies) < 1:
|
915
924
|
print("Cluster.K_Means - Error: The input topologies parameter does not contain any valid topologies. Returning None.")
|
916
925
|
return None
|
917
926
|
if not isinstance(selectors, list):
|
918
|
-
check_vertices = [v for v in topologies if not
|
927
|
+
check_vertices = [v for v in topologies if not Topology.IsInstance(v, "Vertex")]
|
919
928
|
if len(check_vertices) > 0:
|
920
|
-
print("Cluster.K_Means - Error: The input selectors parameter is not a valid list and this is needed since the list of topologies contains objects of type other than a
|
929
|
+
print("Cluster.K_Means - Error: The input selectors parameter is not a valid list and this is needed since the list of topologies contains objects of type other than a topologic_core.Vertex. Returning None.")
|
921
930
|
return None
|
922
931
|
else:
|
923
|
-
selectors = [s for s in selectors if
|
932
|
+
selectors = [s for s in selectors if Topology.IsInstance(s, "Vertex")]
|
924
933
|
if len(selectors) < 1:
|
925
|
-
check_vertices = [v for v in topologies if not
|
934
|
+
check_vertices = [v for v in topologies if not Topology.IsInstance(v, "Vertex")]
|
926
935
|
if len(check_vertices) > 0:
|
927
|
-
print("Cluster.K_Means - Error: The input selectors parameter does not contain any valid vertices and this is needed since the list of topologies contains objects of type other than a
|
936
|
+
print("Cluster.K_Means - Error: The input selectors parameter does not contain any valid vertices and this is needed since the list of topologies contains objects of type other than a topologic_core.Vertex. Returning None.")
|
928
937
|
return None
|
929
938
|
if not len(selectors) == len(topologies):
|
930
939
|
print("Cluster.K_Means - Error: The input topologies and selectors parameters do not have the same length. Returning None.")
|
@@ -1034,7 +1043,7 @@ class Cluster(Topology):
|
|
1034
1043
|
|
1035
1044
|
Returns
|
1036
1045
|
-------
|
1037
|
-
|
1046
|
+
topologic_core.Cluster
|
1038
1047
|
The created cluster with merged cells as possible.
|
1039
1048
|
|
1040
1049
|
"""
|
@@ -1064,12 +1073,12 @@ class Cluster(Topology):
|
|
1064
1073
|
|
1065
1074
|
# Example adjacency test function (replace this with your actual implementation)
|
1066
1075
|
def adjacency_test(cell1, cell2, tolerance=0.0001):
|
1067
|
-
return
|
1076
|
+
return Topology.IsInstance(Topology.Merge(cell1, cell2, tolerance=tolerance), "CellComplex")
|
1068
1077
|
|
1069
1078
|
if not isinstance(cells, list):
|
1070
1079
|
print("Cluster.MergeCells - Error: The input cells parameter is not a valid list of cells. Returning None.")
|
1071
1080
|
return None
|
1072
|
-
#cells = [cell for cell in cells if
|
1081
|
+
#cells = [cell for cell in cells if Topology.IsInstance(cell, "Cell")]
|
1073
1082
|
if len(cells) < 1:
|
1074
1083
|
print("Cluster.MergeCells - Error: The input cells parameter does not contain any valid cells. Returning None.")
|
1075
1084
|
return None
|
@@ -1081,23 +1090,23 @@ class Cluster(Topology):
|
|
1081
1090
|
aComplex = list(aComplex)
|
1082
1091
|
if len(aComplex) > 1:
|
1083
1092
|
cc = CellComplex.ByCells(aComplex, silent=True)
|
1084
|
-
if
|
1093
|
+
if Topology.IsInstance(cc, "CellComplex"):
|
1085
1094
|
cellComplexes.append(cc)
|
1086
1095
|
elif len(aComplex) == 1:
|
1087
|
-
if
|
1096
|
+
if Topology.IsInstance(aComplex[0], "Cell"):
|
1088
1097
|
cells.append(aComplex[0])
|
1089
1098
|
return Cluster.ByTopologies(cellComplexes+cells)
|
1090
1099
|
|
1091
1100
|
@staticmethod
|
1092
|
-
def MysticRose(wire
|
1101
|
+
def MysticRose(wire= None, origin= None, radius: float = 0.5, sides: int = 16, perimeter: bool = True, direction: list = [0, 0, 1], placement:str = "center", tolerance: float = 0.0001):
|
1093
1102
|
"""
|
1094
1103
|
Creates a mystic rose.
|
1095
1104
|
|
1096
1105
|
Parameters
|
1097
1106
|
----------
|
1098
|
-
wire :
|
1107
|
+
wire : topologic_core.Wire , optional
|
1099
1108
|
The input Wire. if set to None, a circle with the input parameters is created. Otherwise, the input parameters are ignored.
|
1100
|
-
origin :
|
1109
|
+
origin : topologic_core.Vertex , optional
|
1101
1110
|
The location of the origin of the circle. The default is None which results in the circle being placed at (0, 0, 0).
|
1102
1111
|
radius : float , optional
|
1103
1112
|
The radius of the mystic rose. The default is 1.
|
@@ -1114,7 +1123,7 @@ class Cluster(Topology):
|
|
1114
1123
|
|
1115
1124
|
Returns
|
1116
1125
|
-------
|
1117
|
-
|
1126
|
+
topologic_core.Cluster
|
1118
1127
|
The created mystic rose (cluster of edges).
|
1119
1128
|
|
1120
1129
|
"""
|
@@ -1141,13 +1150,13 @@ class Cluster(Topology):
|
|
1141
1150
|
return Cluster.ByTopologies(edges)
|
1142
1151
|
|
1143
1152
|
@staticmethod
|
1144
|
-
def Shells(cluster
|
1153
|
+
def Shells(cluster) -> list:
|
1145
1154
|
"""
|
1146
1155
|
Returns the shells of the input cluster.
|
1147
1156
|
|
1148
1157
|
Parameters
|
1149
1158
|
----------
|
1150
|
-
cluster :
|
1159
|
+
cluster : topologic_core.Cluster
|
1151
1160
|
The input cluster.
|
1152
1161
|
|
1153
1162
|
Returns
|
@@ -1156,7 +1165,9 @@ class Cluster(Topology):
|
|
1156
1165
|
The list of shells.
|
1157
1166
|
|
1158
1167
|
"""
|
1159
|
-
|
1168
|
+
from topologicpy.Topology import Topology
|
1169
|
+
|
1170
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
1160
1171
|
print("Cluster.Shells - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
1161
1172
|
return None
|
1162
1173
|
shells = []
|
@@ -1164,22 +1175,24 @@ class Cluster(Topology):
|
|
1164
1175
|
return shells
|
1165
1176
|
|
1166
1177
|
@staticmethod
|
1167
|
-
def Simplify(cluster
|
1178
|
+
def Simplify(cluster):
|
1168
1179
|
"""
|
1169
1180
|
Simplifies the input cluster if possible. For example, if the cluster contains only one cell, that cell is returned.
|
1170
1181
|
|
1171
1182
|
Parameters
|
1172
1183
|
----------
|
1173
|
-
cluster :
|
1184
|
+
cluster : topologic_core.Cluster
|
1174
1185
|
The input cluster.
|
1175
1186
|
|
1176
1187
|
Returns
|
1177
1188
|
-------
|
1178
|
-
|
1189
|
+
topologic_core.Topology or list
|
1179
1190
|
The simplification of the cluster.
|
1180
1191
|
|
1181
1192
|
"""
|
1182
|
-
|
1193
|
+
from topologicpy.Topology import Topology
|
1194
|
+
|
1195
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
1183
1196
|
print("Cluster.Simplify - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
1184
1197
|
return None
|
1185
1198
|
resultingTopologies = []
|
@@ -1241,13 +1254,13 @@ class Cluster(Topology):
|
|
1241
1254
|
return cluster
|
1242
1255
|
|
1243
1256
|
@staticmethod
|
1244
|
-
def Vertices(cluster
|
1257
|
+
def Vertices(cluster) -> list:
|
1245
1258
|
"""
|
1246
1259
|
Returns the vertices of the input cluster.
|
1247
1260
|
|
1248
1261
|
Parameters
|
1249
1262
|
----------
|
1250
|
-
cluster :
|
1263
|
+
cluster : topologic_core.Cluster
|
1251
1264
|
The input cluster.
|
1252
1265
|
|
1253
1266
|
Returns
|
@@ -1256,7 +1269,9 @@ class Cluster(Topology):
|
|
1256
1269
|
The list of vertices.
|
1257
1270
|
|
1258
1271
|
"""
|
1259
|
-
|
1272
|
+
from topologicpy.Topology import Topology
|
1273
|
+
|
1274
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
1260
1275
|
print("Cluster.Vertices - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
1261
1276
|
return None
|
1262
1277
|
vertices = []
|
@@ -1264,13 +1279,13 @@ class Cluster(Topology):
|
|
1264
1279
|
return vertices
|
1265
1280
|
|
1266
1281
|
@staticmethod
|
1267
|
-
def Wires(cluster
|
1282
|
+
def Wires(cluster) -> list:
|
1268
1283
|
"""
|
1269
1284
|
Returns the wires of the input cluster.
|
1270
1285
|
|
1271
1286
|
Parameters
|
1272
1287
|
----------
|
1273
|
-
cluster :
|
1288
|
+
cluster : topologic_core.Cluster
|
1274
1289
|
The input cluster.
|
1275
1290
|
|
1276
1291
|
Returns
|
@@ -1279,7 +1294,9 @@ class Cluster(Topology):
|
|
1279
1294
|
The list of wires.
|
1280
1295
|
|
1281
1296
|
"""
|
1282
|
-
|
1297
|
+
from topologicpy.Topology import Topology
|
1298
|
+
|
1299
|
+
if not Topology.IsInstance(cluster, "Cluster"):
|
1283
1300
|
print("Cluster.Wires - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
|
1284
1301
|
return None
|
1285
1302
|
wires = []
|