topologicpy 0.4.94__py3-none-any.whl → 0.4.96__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/Shell.py CHANGED
@@ -146,7 +146,7 @@ class Shell(Topology):
146
146
  iv = Topology.InternalVertex(w1, tolerance=tolerance)
147
147
  flag = False
148
148
  for w2 in faces:
149
- if Face.IsInternal(w2, iv):
149
+ if Vertex.IsInternal(iv, w2):
150
150
  flag = True
151
151
  break;
152
152
  if flag == False:
@@ -285,7 +285,7 @@ class Shell(Topology):
285
285
  return None
286
286
  shell = topologic.Shell.ByFaces(faceList, tolerance)
287
287
  if not isinstance(shell, topologic.Shell):
288
- shell = Topology.SelfMerge(shell)
288
+ shell = Topology.SelfMerge(shell, tolerance=tolerance)
289
289
  if isinstance(shell, topologic.Shell):
290
290
  return shell
291
291
  else:
@@ -520,29 +520,17 @@ class Shell(Topology):
520
520
  flatFace = Topology.Flatten(face, origin=origin, direction=normal)
521
521
  faceVertices = Face.Vertices(face)
522
522
  vertices += faceVertices
523
- # Retrieve the needed transformations
524
- dictionary = Topology.Dictionary(flatFace)
525
- xTran = Dictionary.ValueAtKey(dictionary,"x")
526
- yTran = Dictionary.ValueAtKey(dictionary,"y")
527
- zTran = Dictionary.ValueAtKey(dictionary,"z")
528
- phi = Dictionary.ValueAtKey(dictionary,"phi")
529
- theta = Dictionary.ValueAtKey(dictionary,"theta")
530
523
 
531
524
  # Create a cluster of the input vertices
532
525
  verticesCluster = Cluster.ByTopologies(vertices)
533
526
 
534
527
  # Flatten the cluster using the same transformations
535
- verticesCluster = Topology.Translate(verticesCluster, -xTran, -yTran, -zTran)
536
- verticesCluster = Topology.Rotate(verticesCluster, origin=world_origin, x=0, y=0, z=1, degree=-phi)
537
- verticesCluster = Topology.Rotate(verticesCluster, origin=world_origin, x=0, y=1, z=0, degree=-theta)
528
+ verticesCluster = Topology.Flatten(verticesCluster, origin=origin, direction=normal)
538
529
 
539
530
  vertices = Cluster.Vertices(verticesCluster)
540
- tempFlatVertices = []
541
531
  points = []
542
532
  for v in vertices:
543
- tempFlatVertices.append(Vertex.ByCoordinates(Vertex.X(v), Vertex.Y(v), 0))
544
533
  points.append([Vertex.X(v), Vertex.Y(v)])
545
- #flatVertices = tempFlatVertices
546
534
  delaunay = SCIDelaunay(points)
547
535
  simplices = delaunay.simplices
548
536
 
@@ -569,9 +557,7 @@ class Shell(Topology):
569
557
  ibList = [Face.ByWire(w) for w in wires]
570
558
  cluster = Cluster.ByTopologies(ibList)
571
559
  shell = Topology.Difference(shell, cluster)
572
- shell = Topology.Rotate(shell, origin=world_origin, x=0, y=1, z=0, degree=theta)
573
- shell = Topology.Rotate(shell, origin=world_origin, x=0, y=0, z=1, degree=phi)
574
- shell = Topology.Translate(shell, xTran, yTran, zTran)
560
+ shell = Topology.Unflatten(shell, origin=origin, direction=normal)
575
561
  return shell
576
562
 
577
563
  @staticmethod
@@ -652,47 +638,6 @@ class Shell(Topology):
652
638
  _ = shell.Faces(None, faces)
653
639
  return faces
654
640
 
655
- @staticmethod
656
- def IsInside(shell: topologic.Shell, vertex: topologic.Vertex, tolerance: float = 0.0001) -> bool:
657
- """
658
- DEPRECATED METHOD. DO NOT USE. INSTEAD USE Shell.IsInternal.
659
- """
660
- print("Shell.IsInside - Warning: Deprecated method. This method will be removed in the future. Instead, use Cell.IsInternal.")
661
- return Shell.IsInternal(shell=shell, vertex=vertex, tolerance=tolerance)
662
-
663
- @staticmethod
664
-
665
- def IsInternal(shell: topologic.Shell, vertex: topologic.Vertex, tolerance: float = 0.0001) -> bool:
666
- """
667
- Returns True if the input vertex is an internal vertex of the input shell. Returns False otherwise. Intenral is defined as being inside one of the shell's faces.
668
-
669
- Parameters
670
- ----------
671
- shell : topologic.Shell
672
- The input shell.
673
- vertex : topologic.Vertex
674
- The input vertex.
675
- tolerance : float , optional
676
- The desired tolerance. The default is 0.0001.
677
-
678
- Returns
679
- -------
680
- bool
681
- Returns True if the input vertex is inside the input shell. Returns False otherwise.
682
-
683
- """
684
-
685
- from topologicpy.Face import Face
686
- if not isinstance(shell, topologic.Shell):
687
- return None
688
- if not isinstance(vertex, topologic.Vertex):
689
- return None
690
- faces = Shell.Faces(shell)
691
- for f in faces:
692
- if Face.IsInternal(face=f, vertex=vertex, tolerance=tolerance):
693
- return True
694
- return False
695
-
696
641
  @staticmethod
697
642
  def IsOnBoundary(shell: topologic.Shell, vertex: topologic.Vertex, tolerance: float = 0.0001) -> bool:
698
643
  """
@@ -729,32 +674,6 @@ class Shell(Topology):
729
674
  return True
730
675
  return False
731
676
 
732
- @staticmethod
733
- def IsOutside(shell: topologic.Shell, vertex: topologic.Vertex, tolerance: float = 0.0001) -> bool:
734
- """
735
- Returns True if the input vertex is outside the input shell. Returns False otherwise. Outside is defined as being outside all of the shell's faces
736
-
737
- Parameters
738
- ----------
739
- shell : topologic.Shell
740
- The input shell.
741
- vertex : topologic.Vertex
742
- The input vertex.
743
- tolerance : float , optional
744
- The desired tolerance. The default is 0.0001.
745
-
746
- Returns
747
- -------
748
- bool
749
- Returns True if the input vertex is inside the input shell. Returns False otherwise.
750
-
751
- """
752
- if not isinstance(shell, topologic.Shell):
753
- return None
754
- if not isinstance(vertex, topologic.Vertex):
755
- return None
756
- return not Shell.IsInternal(shell=shell, vertex=vertex, tolerance=tolerance)
757
-
758
677
  @staticmethod
759
678
  def HyperbolicParaboloidRectangularDomain(origin: topologic.Vertex = None, llVertex: topologic.Vertex = None, lrVertex: topologic.Vertex =None, ulVertex: topologic.Vertex =None, urVertex: topologic.Vertex = None,
760
679
  uSides: int = 10, vSides: int = 10, direction: list = [0,0,1], placement: str = "center", tolerance: float = 0.0001) -> topologic.Shell:
@@ -1372,13 +1291,13 @@ class Shell(Topology):
1372
1291
  origin = Topology.Centroid(face)
1373
1292
  normal = Face.Normal(face)
1374
1293
  flat_face = Topology.Flatten(face, origin=origin, direction=normal)
1375
- d = Topology.Dictionary(flat_face)
1376
1294
  roof = Wire.Roof(flat_face, degree=degree, tolerance=tolerance)
1377
1295
  if not roof:
1378
1296
  return None
1379
1297
  shell = Shell.Skeleton(flat_face, tolerance=tolerance)
1298
+ print(shell)
1380
1299
  faces = Shell.Faces(shell)
1381
-
1300
+ Topology.Show(shell)
1382
1301
  if not faces:
1383
1302
  return None
1384
1303
  triangles = []
@@ -1423,14 +1342,7 @@ class Shell(Topology):
1423
1342
  shell = Topology.RemoveCoplanarFaces(shell, epsilon=epsilon, tolerance=tolerance)
1424
1343
  except:
1425
1344
  pass
1426
- xTran = Dictionary.ValueAtKey(d,"x")
1427
- yTran = Dictionary.ValueAtKey(d,"y")
1428
- zTran = Dictionary.ValueAtKey(d,"z")
1429
- phi = Dictionary.ValueAtKey(d,"phi")
1430
- theta = Dictionary.ValueAtKey(d,"theta")
1431
- shell = Topology.Rotate(shell, origin=Vertex.Origin(), x=0, y=1, z=0, degree=theta)
1432
- shell = Topology.Rotate(shell, origin=Vertex.Origin(), x=0, y=0, z=1, degree=phi)
1433
- shell = Topology.Translate(shell, xTran, yTran, zTran)
1345
+ #shell = Topology.Unflatten(shell, origin=origin, direction=normal)
1434
1346
  return shell
1435
1347
 
1436
1348
  @staticmethod
@@ -1689,7 +1601,7 @@ class Shell(Topology):
1689
1601
  faces = Topology.Faces(result)
1690
1602
  final_faces = []
1691
1603
  for face in faces:
1692
- if not Face.IsInternal(face, v, tolerance=0.01):
1604
+ if not Vertex.IsInternal(v, face, tolerance=0.01):
1693
1605
  final_faces.append(face)
1694
1606
  final_result = Shell.ByFaces(final_faces, tolerance=tolerance)
1695
1607
  return final_result
@@ -1759,26 +1671,25 @@ class Shell(Topology):
1759
1671
  origin = Topology.Centroid(face)
1760
1672
  normal = Face.Normal(face)
1761
1673
  flatFace = Topology.Flatten(face, origin=origin, direction=normal)
1762
- # Retrieve the needed transformations
1763
- dictionary = Topology.Dictionary(flatFace)
1764
- xTran = Dictionary.ValueAtKey(dictionary,"x")
1765
- yTran = Dictionary.ValueAtKey(dictionary,"y")
1766
- zTran = Dictionary.ValueAtKey(dictionary,"z")
1767
- phi = Dictionary.ValueAtKey(dictionary,"phi")
1768
- theta = Dictionary.ValueAtKey(dictionary,"theta")
1769
-
1770
- # Create a Vertex at the world's origin (0,0,0)
1771
- world_origin = Vertex.ByCoordinates(0,0,0)
1674
+ eb = Face.ExternalBoundary(flatFace)
1675
+ ibList = Face.InternalBoundaries(flatFace)
1676
+ temp_verts = Topology.Vertices(eb)
1677
+ new_verts = [Vertex.ByCoordinates(Vertex.X(v), Vertex.Y(v), 0) for v in temp_verts]
1678
+ eb = Wire.ByVertices(new_verts, close=True)
1679
+ new_ibList = []
1680
+ for ib in ibList:
1681
+ temp_verts = Topology.Vertices(ib)
1682
+ new_verts = [Vertex.ByCoordinates(Vertex.X(v), Vertex.Y(v), 0) for v in temp_verts]
1683
+ new_ibList.append(Wire.ByVertices(new_verts, close=True))
1684
+ flatFace = Face.ByWires(eb, new_ibList)
1772
1685
 
1773
1686
  # Create a cluster of the input vertices
1774
1687
  verticesCluster = Cluster.ByTopologies(vertices)
1775
1688
 
1776
1689
  # Flatten the cluster using the same transformations
1777
- verticesCluster = Topology.Translate(verticesCluster, -xTran, -yTran, -zTran)
1778
- verticesCluster = Topology.Rotate(verticesCluster, origin=world_origin, x=0, y=0, z=1, degree=-phi)
1779
- verticesCluster = Topology.Rotate(verticesCluster, origin=world_origin, x=0, y=1, z=0, degree=-theta)
1780
-
1781
- flatVertices = Cluster.Vertices(verticesCluster)
1690
+ verticesCluster = Topology.Flatten(verticesCluster, origin=origin, direction=normal)
1691
+ flatVertices = Topology.Vertices(verticesCluster)
1692
+ flatVertices = [Vertex.ByCoordinates(Vertex.X(v), Vertex.Y(v), 0) for v in flatVertices]
1782
1693
  points = []
1783
1694
  for flatVertex in flatVertices:
1784
1695
  points.append([flatVertex.X(), flatVertex.Y()])
@@ -1814,14 +1725,20 @@ class Shell(Topology):
1814
1725
  if len(region) > 1 and not -1 in region:
1815
1726
  for v in region:
1816
1727
  tempWire.append(Vertex.ByCoordinates(voronoiVertices[v].X(), voronoiVertices[v].Y(),0))
1728
+ temp_verts = []
1729
+ for v in tempWire:
1730
+ if len(temp_verts) == 0:
1731
+ temp_verts.append(v)
1732
+ elif Vertex.Index(v, temp_verts) == None:
1733
+ temp_verts.append(v)
1734
+ tempWire = temp_verts
1735
+ temp_w = Wire.ByVertices(tempWire, close=True)
1817
1736
  faces.append(Face.ByWire(Wire.ByVertices(tempWire, close=True), tolerance=tolerance))
1818
1737
  shell = Shell.ByFaces(faces, tolerance=tolerance)
1819
1738
  edges = Shell.Edges(shell)
1820
1739
  edgesCluster = Cluster.ByTopologies(edges)
1821
- shell = Topology.Boolean(flatFace,edgesCluster, operation="slice", tolerance=tolerance)
1822
- shell = Topology.Rotate(shell, origin=world_origin, x=0, y=1, z=0, degree=theta)
1823
- shell = Topology.Rotate(shell, origin=world_origin, x=0, y=0, z=1, degree=phi)
1824
- shell = Topology.Translate(shell, xTran, yTran, zTran)
1740
+ shell = Topology.Slice(flatFace,edgesCluster, tolerance=tolerance)
1741
+ shell = Topology.Unflatten(shell, origin=origin, direction=normal)
1825
1742
  return shell
1826
1743
 
1827
1744
  @staticmethod