topologicpy 0.7.0__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/Edge.py CHANGED
@@ -597,9 +597,10 @@ class Edge():
597
597
 
598
598
 
599
599
  @staticmethod
600
- def IsCollinear(edgeA, edgeB, mantissa: int = 6, angTolerance: float = 0.1, tolerance: float = 0.0001) -> bool:
600
+ def IsCollinear(edgeA, edgeB, mantissa: int = 6, tolerance: float = 0.0001) -> bool:
601
601
  """
602
602
  Return True if the two input edges are collinear. Returns False otherwise.
603
+ This code is based on a contribution by https://github.com/gaoxipeng
603
604
 
604
605
  Parameters
605
606
  ----------
@@ -609,8 +610,6 @@ class Edge():
609
610
  The second input edge.
610
611
  mantissa : int , optional
611
612
  The desired length of the mantissa. The default is 6.
612
- angTolerance : float , optional
613
- The angular tolerance used for the test. The default is 0.1.
614
613
  tolerance : float , optional
615
614
  The desired tolerance. The default is 0.0001.
616
615
 
@@ -622,25 +621,42 @@ class Edge():
622
621
  """
623
622
  from topologicpy.Vertex import Vertex
624
623
  from topologicpy.Topology import Topology
624
+ import numpy as np
625
625
 
626
626
  if not Topology.IsInstance(edgeA, "Edge"):
627
- print("Edge.IsCollinear - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
627
+ print("Edge.IsCollinear - Error: The input parameter edgeA is not a valid edge. Returning None")
628
628
  return None
629
629
  if not Topology.IsInstance(edgeB, "Edge"):
630
- print("Edge.IsCollinear - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
630
+ print("Edge.IsCollinear - Error: The input parameter edgeB is not a valid edge. Returning None")
631
631
  return None
632
- ang = Edge.Angle(edgeA, edgeB, mantissa=mantissa, bracket=True)
633
- svA = Edge.StartVertex(edgeA)
634
- evA = Edge.EndVertex(edgeA)
635
- svB = Edge.StartVertex(edgeB)
636
- evB = Edge.EndVertex(edgeB)
637
- d1 = Vertex.Distance(svA, svB)
638
- d2 = Vertex.Distance(svA, evB)
639
- d3 = Vertex.Distance(evA, svB)
640
- d4 = Vertex.Distance(evA, evB)
641
- if (d1 < tolerance or d2 < tolerance or d3 < tolerance or d4 < tolerance) and (abs(ang) < angTolerance or (abs(180 - ang) < angTolerance)):
642
- return True
643
- return False
632
+ if Edge.Length(edgeA) < tolerance:
633
+ print("Edge.IsCollinear - Error: The length of edgeA is less than the tolerance. Returning None")
634
+ return None
635
+ if Edge.Length(edgeB) < tolerance:
636
+ print("Edge.IsCollinear - Error: The length of edgeB is less than the tolerance. Returning None")
637
+ return None
638
+ # Calculate coefficients A, B, C from edgeA
639
+ start_a = Edge.StartVertex(edgeA)
640
+ end_a = Edge.EndVertex(edgeA)
641
+ A = Vertex.Y(end_a, mantissa=mantissa) - Vertex.Y(start_a, mantissa=mantissa)
642
+ B = -(Vertex.X(end_a, mantissa=mantissa) - Vertex.X(start_a, mantissa=mantissa))
643
+ norm = np.sqrt(A ** 2 + B ** 2)
644
+ A /= norm
645
+ B /= norm
646
+ C = -(A * Vertex.X(start_a, mantissa=mantissa) + B * Vertex.Y(start_a, mantissa=mantissa))
647
+
648
+ # Calculate perpendicular distance for start vertex of edgeB
649
+ start_b = Edge.StartVertex(edgeB)
650
+ x0, y0 = Vertex.X(start_b, mantissa=mantissa), Vertex.Y(start_b, mantissa=mantissa)
651
+ distance_start = abs(A * x0 + B * y0 + C)
652
+
653
+ # Calculate perpendicular distance for end vertex of edgeB
654
+ end_b = Edge.EndVertex(edgeB)
655
+ x0, y0 = Vertex.X(end_b, mantissa=mantissa), Vertex.Y(end_b, mantissa=mantissa)
656
+ distance_end = abs(A * x0 + B * y0 + C)
657
+
658
+ # Check if both distances are within tolerance
659
+ return bool(distance_start < tolerance) and bool(distance_end < tolerance)
644
660
 
645
661
  @staticmethod
646
662
  def IsParallel(edgeA, edgeB, mantissa: int = 6, angTolerance: float = 0.1) -> bool:
topologicpy/Face.py CHANGED
@@ -927,7 +927,19 @@ class Face():
927
927
  The external boundary of the input face.
928
928
 
929
929
  """
930
- return face.ExternalBoundary()
930
+ from topologicpy.Vector import Vector
931
+ from topologicpy.Wire import Wire
932
+ from topologicpy.Topology import Topology
933
+
934
+ eb = face.ExternalBoundary()
935
+ f_dir = Face.Normal(face)
936
+ faceVertices = Topology.Vertices(eb)
937
+ temp_face = Face.ByWire(eb)
938
+ temp_dir = Face.Normal(temp_face)
939
+ if Vector.IsAntiParallel(f_dir, temp_dir):
940
+ faceVertices.reverse()
941
+ eb = Wire.ByVertices(faceVertices)
942
+ return eb
931
943
 
932
944
  @staticmethod
933
945
  def FacingToward(face, direction: list = [0,0,-1], asVertex: bool = False, tolerance: float = 0.0001) -> bool:
@@ -2313,7 +2325,7 @@ class Face():
2313
2325
  The external boundary of the input face.
2314
2326
 
2315
2327
  """
2316
- return face.ExternalBoundary()
2328
+ return Face.ExternalBoundary(face)
2317
2329
 
2318
2330
  @staticmethod
2319
2331
  def Wires(face) -> list:
topologicpy/Topology.py CHANGED
@@ -3979,6 +3979,8 @@ class Topology():
3979
3979
 
3980
3980
  """
3981
3981
  from topologicpy.Vertex import Vertex
3982
+ from topologicpy.Face import Face
3983
+ from topologicpy.Vector import Vector
3982
3984
 
3983
3985
  def getSubTopologies(topology, subTopologyClass):
3984
3986
  topologies = []
@@ -4053,6 +4055,7 @@ class Topology():
4053
4055
  elif (Topology.Type(topology) > Topology.TypeID("Face")):
4054
4056
  _ = topology.Faces(None, topFaces)
4055
4057
  for aFace in topFaces:
4058
+ f_dir = Face.Normal(aFace)
4056
4059
  ib = []
4057
4060
  _ = aFace.InternalBoundaries(ib)
4058
4061
  if(len(ib) > 0):
@@ -4060,6 +4063,10 @@ class Topology():
4060
4063
  for aTriFace in triFaces:
4061
4064
  wire = aTriFace.ExternalBoundary()
4062
4065
  faceVertices = getSubTopologies(wire, topologic.Vertex)
4066
+ temp_face = Face.ByWire(wire)
4067
+ temp_dir = Face.Normal(temp_face)
4068
+ if Vector.IsAntiParallel(f_dir, temp_dir):
4069
+ faceVertices.reverse()
4063
4070
  f = []
4064
4071
  for aVertex in faceVertices:
4065
4072
  try:
@@ -4073,6 +4080,10 @@ class Topology():
4073
4080
  wire = aFace.ExternalBoundary()
4074
4081
  #wire = topologic.WireUtility.RemoveCollinearEdges(wire, 0.1) #This is an angle Tolerance
4075
4082
  faceVertices = getSubTopologies(wire, topologic.Vertex)
4083
+ temp_face = Face.ByWire(wire)
4084
+ temp_dir = Face.Normal(temp_face)
4085
+ if Vector.IsAntiParallel(f_dir, temp_dir):
4086
+ faceVertices.reverse()
4076
4087
  f = []
4077
4088
  for aVertex in faceVertices:
4078
4089
  try:
topologicpy/Vector.py CHANGED
@@ -526,7 +526,6 @@ class Vector(list):
526
526
  if np.isclose(dot_product, 1.0) or np.isclose(dot_product, -1.0):
527
527
  return True
528
528
  else:
529
- # Compute bisecting vector
530
529
  return False
531
530
 
532
531
  @staticmethod
topologicpy/Wire.py CHANGED
@@ -485,7 +485,7 @@ class Wire(Topology):
485
485
  if len(st) > 1:
486
486
  e1 = st[0]
487
487
  e2 = st[1]
488
- if not Edge.IsCollinear(e1, e2, angTolerance=angTolerance, tolerance=tolerance):
488
+ if not Edge.IsCollinear(e1, e2, tolerance=tolerance):
489
489
  e1 = Edge.Reverse(e1, tolerance=tolerance)
490
490
  bisector = Edge.ByVertices([vertices[i], newVertices[i]], tolerance=tolerance)
491
491
  nv = Edge.VertexByDistance(bisector, distance=finalMiterThreshold, origin=Edge.StartVertex(bisector), tolerance=0.0001)
@@ -510,7 +510,7 @@ class Wire(Topology):
510
510
  for v in vertices:
511
511
  edges = Topology.SuperTopologies(v, c, topologyType="edge")
512
512
  if len(edges) == 2:
513
- if not Edge.IsCollinear(edges[0], edges[1], angTolerance=angTolerance, tolerance=tolerance):
513
+ if not Edge.IsCollinear(edges[0], edges[1], tolerance=tolerance):
514
514
  adjacentVertices = Topology.AdjacentTopologies(v, c)
515
515
  total = 0
516
516
  for adjV in adjacentVertices:
@@ -2210,7 +2210,7 @@ class Wire(Topology):
2210
2210
  edges = []
2211
2211
  _ = aVertex.Edges(wire, edges)
2212
2212
  if len(edges) > 1:
2213
- if not Edge.IsCollinear(edges[0], edges[1], angTolerance=angTolerance, tolerance=tolerance):
2213
+ if not Edge.IsCollinear(edges[0], edges[1], tolerance=tolerance):
2214
2214
  wire_verts.append(aVertex)
2215
2215
  else:
2216
2216
  wire_verts.append(aVertex)
topologicpy/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.7.0'
1
+ __version__ = '0.7.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: topologicpy
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: An Advanced Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
5
5
  Author-email: Wassim Jabi <wassim.jabi@gmail.com>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -6,9 +6,9 @@ topologicpy/Color.py,sha256=UlmRcCSOhqcM_OyMWz4t3Kr75KcgXDhz3uctAJ2n7Ic,18031
6
6
  topologicpy/Context.py,sha256=ppApYKngZZCQBFWaxIMi2z2dokY23c935IDCBosxDAE,3055
7
7
  topologicpy/DGL.py,sha256=RpkLnAzjg6arY7cEMs2pDFYzRdkerVg1Wbm9hcE3QaM,138991
8
8
  topologicpy/Dictionary.py,sha256=pMbfE2RYGCNpVr2x58qiHRc-aBWnp1jLlyzwS9nz6-w,25891
9
- topologicpy/Edge.py,sha256=1Kg1-xkz1_9SVF9M2UuSf04uMuearTfhXMhM9XD3poA,49477
9
+ topologicpy/Edge.py,sha256=ktCp2VgBj-QvrUQ0oagTZG2QErth9cilzaBhhHeYNB8,50321
10
10
  topologicpy/EnergyModel.py,sha256=UBLim01lZLikVQmJAHEeja-KvF4tgzTxsSxwNDaezz4,52500
11
- topologicpy/Face.py,sha256=AgCtQ96QRb5Vej1fpiYp4S_GSDtxu50SKV0XgTVgnqQ,96750
11
+ topologicpy/Face.py,sha256=BOU6hN-4uCaXW_lbvuOlntrz_Q0jEiL5tIHAFuqWw_U,97195
12
12
  topologicpy/Graph.py,sha256=GsWySXL-cTd7bl-QWpl3Aw9Hr0KyACzIa4iRenTB63s,368030
13
13
  topologicpy/Grid.py,sha256=XM0iQtQbMQoYHf7S0ppSe-dxy93Y9VpI_vUkElWqnYA,17050
14
14
  topologicpy/Helper.py,sha256=07V9IFu5ilMpvAdZVhIbdBOjBJSRTtJ0BfR1IoRaRXU,17743
@@ -20,14 +20,14 @@ topologicpy/Polyskel.py,sha256=MYHKFOQBlUNqoUhAdOcKRIHpSk0dWWVrZgXK34NkvFM,15936
20
20
  topologicpy/Shell.py,sha256=6hidTQ6MW5q_es-WbTeI_yt7Sd7BMxWU_qfoherVZhE,74343
21
21
  topologicpy/Speckle.py,sha256=rUS6PCaxIjEF5_fUruxvMH47FMKg-ohcoU0qAUb-yNM,14267
22
22
  topologicpy/Sun.py,sha256=3tYb8kssU882lE1gEWg2mxDvCCY_LAVElkyUT6wa-ZU,36935
23
- topologicpy/Topology.py,sha256=t8Zc25xRNsJWu2e4n_hQ08WjRFBVRm1ujuSueBYauiU,292372
24
- topologicpy/Vector.py,sha256=4mvvValXDCXFzLupjC_lpsr7LxKVXLmVZUe6H3Fo7f8,29604
23
+ topologicpy/Topology.py,sha256=oXZZGGklFeVMIcKorVXM5RFMbCnoYcjdrScTIodSQng,292911
24
+ topologicpy/Vector.py,sha256=FHbrCb9GVLOUV_kqcplh4D88CVxlID6qX_wEQOw4rD0,29565
25
25
  topologicpy/Vertex.py,sha256=YgbbCcqABvb97z2-yEytpp5T3yoZPlQplR_vMQkQ9OA,65180
26
- topologicpy/Wire.py,sha256=Q8jpH797oSkjso-ipAxsCs6ta2BxTHrYuBbSLewmV0w,138505
26
+ topologicpy/Wire.py,sha256=MUEboxo11kMgwnZySSkwiyzBG2wv0wPiinf2cW4UVv8,138424
27
27
  topologicpy/__init__.py,sha256=D7ky87CAQMiS2KE6YLvcTLkTgA2PY7rASe6Z23pjp9k,872
28
- topologicpy/version.py,sha256=09hol5ovL6ArILJIJZ-MiscnOjKa6RjaETmtdgJpW2c,22
29
- topologicpy-0.7.0.dist-info/LICENSE,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
30
- topologicpy-0.7.0.dist-info/METADATA,sha256=zHBR-EYUrl66gK-J54RV5KYBg_h2bxXX5tfQMXJ4El0,46950
31
- topologicpy-0.7.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
32
- topologicpy-0.7.0.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
33
- topologicpy-0.7.0.dist-info/RECORD,,
28
+ topologicpy/version.py,sha256=0eAFjnFVSWI6_301EfFzaXJIiwNScF9GpeINoCLd-XM,22
29
+ topologicpy-0.7.2.dist-info/LICENSE,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
30
+ topologicpy-0.7.2.dist-info/METADATA,sha256=mUXBHGbD8IpLymaCvTw5wyJmhssEstUU57P6bXuYFkk,46950
31
+ topologicpy-0.7.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
32
+ topologicpy-0.7.2.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
33
+ topologicpy-0.7.2.dist-info/RECORD,,