topologicpy 0.8.9__py3-none-any.whl → 0.8.11__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/BVH.py CHANGED
@@ -282,7 +282,7 @@ class BVH:
282
282
  # Add an edge from the parent to this vertex (if a parent exists)
283
283
  if parent_vertex is not None:
284
284
  d = Vertex.Distance(parent_vertex, current_vertex)
285
- if d < tolerance:
285
+ if d <= tolerance:
286
286
  current_vertex = Topology.Translate(current_vertex, tolerance*random.uniform(2,50), tolerance*random.uniform(2,50), tolerance*random.uniform(2,50))
287
287
  edge = Edge.ByVertices(parent_vertex, current_vertex, tolerance=tolerance)
288
288
  graph = Graph.AddEdge(graph, edge, silent=True)
topologicpy/Cell.py CHANGED
@@ -998,14 +998,14 @@ class Cell():
998
998
  verticalFaces.append(aFace)
999
999
  verticalApertures += getApertures(aFace)
1000
1000
  elif aCode == 1:
1001
- if abs(Vertex.Z(Topology.Centroid(aFace)) - zMin) < tolerance:
1001
+ if abs(Vertex.Z(Topology.Centroid(aFace)) - zMin) <= tolerance:
1002
1002
  bottomHorizontalFaces.append(aFace)
1003
1003
  bottomHorizontalApertures += getApertures(aFace)
1004
1004
  else:
1005
1005
  topHorizontalFaces.append(aFace)
1006
1006
  topHorizontalApertures += getApertures(aFace)
1007
1007
  elif aCode == 2:
1008
- if abs(Vertex.Z(Topology.Centroid(aFace)) - zMax) < tolerance:
1008
+ if abs(Vertex.Z(Topology.Centroid(aFace)) - zMax) <= tolerance:
1009
1009
  topHorizontalFaces.append(aFace)
1010
1010
  topHorizontalApertures += getApertures(aFace)
1011
1011
  else:
@@ -546,7 +546,7 @@ class CellComplex():
546
546
  internalVerticalApertures += getApertures(aFace)
547
547
  elif aCode == 1:
548
548
  if n == 1:
549
- if abs(Vertex.Z(Topology.Centroid(aFace)) - zMin) < tolerance:
549
+ if abs(Vertex.Z(Topology.Centroid(aFace)) - zMin) <= tolerance:
550
550
  bottomHorizontalFaces.append(aFace)
551
551
  bottomHorizontalApertures += getApertures(aFace)
552
552
  else:
@@ -557,7 +557,7 @@ class CellComplex():
557
557
  internalHorizontalApertures += getApertures(aFace)
558
558
  elif aCode == 2:
559
559
  if n == 1:
560
- if abs(Vertex.Z(Topology.Centroid(aFace)) - zMax) < tolerance:
560
+ if abs(Vertex.Z(Topology.Centroid(aFace)) - zMax) <= tolerance:
561
561
  topHorizontalFaces.append(aFace)
562
562
  topHorizontalApertures += getApertures(aFace)
563
563
  else:
topologicpy/Edge.py CHANGED
@@ -153,15 +153,15 @@ class Edge():
153
153
 
154
154
  shared_vertex = None
155
155
 
156
- if Vertex.Distance(start1, start2) < tolerance:
156
+ if Vertex.Distance(start1, start2) <= tolerance:
157
157
  shared_vertex = start1
158
- elif Vertex.Distance(start1, end2) < tolerance:
158
+ elif Vertex.Distance(start1, end2) <= tolerance:
159
159
  shared_vertex = start1
160
160
  edge2 = Edge.Reverse(edge2)
161
- elif Vertex.Distance(end1, start2) < tolerance:
161
+ elif Vertex.Distance(end1, start2) <= tolerance:
162
162
  shared_vertex = start2
163
163
  edge1 = Edge.Reverse(edge1)
164
- elif Vertex.Distance(end1, end2) < tolerance:
164
+ elif Vertex.Distance(end1, end2) <= tolerance:
165
165
  shared_vertex = end1
166
166
  edge1 = Edge.Reverse(edge1)
167
167
  edge2 = Edge.Reverse(edge2)
@@ -176,10 +176,10 @@ class Edge():
176
176
  if not Topology.IsInstance(edgeB, "Edge"):
177
177
  print("Edge.Bisect - Error: The input edgeB parameter is not a valid topologic edge. Returning None.")
178
178
  return None
179
- if Edge.Length(edgeA) < tolerance:
179
+ if Edge.Length(edgeA) <= tolerance:
180
180
  print("Edge.Bisect - Error: The input edgeA parameter is shorter than the input tolerance parameter. Returning None.")
181
181
  return None
182
- if Edge.Length(edgeB) < tolerance:
182
+ if Edge.Length(edgeB) <= tolerance:
183
183
  print("Edge.Bisect - Error: The input edgeB parameter is shorter than the input tolerance parameter. Returning None.")
184
184
  return None
185
185
 
@@ -313,7 +313,7 @@ class Edge():
313
313
  if not silent:
314
314
  print("Edge.ByStartVertexEndVertex - Error: The input vertexA and vertexB parameters are the same vertex. Returning None.")
315
315
  return None
316
- if Vertex.Distance(vertexA, vertexB) < tolerance:
316
+ if Vertex.Distance(vertexA, vertexB) <= tolerance:
317
317
  if not silent:
318
318
  print("Edge.ByStartVertexEndVertex - Error: The distance between the input vertexA and vertexB parameters is less than the input tolerance. Returning None.")
319
319
  return None
@@ -360,7 +360,7 @@ class Edge():
360
360
  print("Edge.ByVertexDirectionLength - Error: The input vertex parameter is not a valid vertex. Returning None.")
361
361
  return None
362
362
 
363
- if length < tolerance:
363
+ if length <= tolerance:
364
364
  if not silent:
365
365
  print("Edge.ByVertexDirectionLength - Error: The input edge parameter must not be less than the input tolerance parameter. Returning None.")
366
366
  return None
@@ -646,7 +646,7 @@ class Edge():
646
646
  print("Edge.Extend - Error: The input edge parameter is not a valid topologic edge. Returning None.")
647
647
  return None
648
648
  distance = abs(distance)
649
- if distance < tolerance:
649
+ if distance <= tolerance:
650
650
  return edge
651
651
  sv = Edge.StartVertex(edge)
652
652
  ev = Edge.EndVertex(edge)
@@ -810,11 +810,11 @@ class Edge():
810
810
  evb = Edge.EndVertex(edges[i])
811
811
  dsvsv = Vertex.Distance(sva, svb)
812
812
  devev = Vertex.Distance(eva, evb)
813
- if dsvsv < tolerance and devev < tolerance:
813
+ if dsvsv <= tolerance and devev <= tolerance:
814
814
  return i
815
815
  dsvev = Vertex.Distance(sva, evb)
816
816
  devsv = Vertex.Distance(eva, svb)
817
- if dsvev < tolerance and devsv < tolerance:
817
+ if dsvev <= tolerance and devsv <= tolerance:
818
818
  return i
819
819
  return None
820
820
 
@@ -856,7 +856,7 @@ class Edge():
856
856
  distances.append(Vertex.Distance(pair[0], pair[1]))
857
857
  v_list = Helper.Sort(v_list, distances)
858
858
  closest_pair = v_list[0]
859
- if Vertex.Distance(closest_pair[0], closest_pair[1]) < tolerance:
859
+ if Vertex.Distance(closest_pair[0], closest_pair[1]) <= tolerance:
860
860
  return Topology.Centroid(Cluster.ByTopologies(closest_pair))
861
861
 
862
862
  if Edge.IsCollinear(edgeA, edgeB, tolerance=tolerance):
@@ -915,11 +915,11 @@ class Edge():
915
915
  if not Topology.IsInstance(edgeB, "Edge"):
916
916
  print("Edge.IsCollinear - Error: The input parameter edgeB is not a valid edge. Returning None")
917
917
  return None
918
- if Edge.Length(edgeA) < tolerance:
919
- print("Edge.IsCollinear - Error: The length of edgeA is less than the tolerance. Returning None")
918
+ if Edge.Length(edgeA) <= tolerance:
919
+ print("Edge.IsCollinear - Error: The length of edgeA is less than or equal the tolerance. Returning None")
920
920
  return None
921
- if Edge.Length(edgeB) < tolerance:
922
- print("Edge.IsCollinear - Error: The length of edgeB is less than the tolerance. Returning None")
921
+ if Edge.Length(edgeB) <= tolerance:
922
+ print("Edge.IsCollinear - Error: The length of edgeB is less than or equal to the tolerance. Returning None")
923
923
  return None
924
924
 
925
925
  # Get start and end points of the first edge
@@ -962,7 +962,7 @@ class Edge():
962
962
  distance_end = distance_from_line(end_b, start_a_coords, direction_a)
963
963
 
964
964
  # Check if both distances are within tolerance
965
- return bool(distance_start < tolerance) and bool(distance_end < tolerance)
965
+ return bool(distance_start <= tolerance) and bool(distance_end <= tolerance)
966
966
 
967
967
  @staticmethod
968
968
  def IsCoplanar(edgeA, edgeB, mantissa: int = 6, tolerance: float = 0.0001):
@@ -996,11 +996,11 @@ class Edge():
996
996
  if not Topology.IsInstance(edgeB, "Edge"):
997
997
  print("Edge.IsCoplanar - Error: The input parameter edgeB is not a valid edge. Returning None")
998
998
  return None
999
- if Edge.Length(edgeA) < tolerance:
1000
- print("Edge.IsCoplanar - Error: The length of edgeA is less than the tolerance. Returning None")
999
+ if Edge.Length(edgeA) <= tolerance:
1000
+ print("Edge.IsCoplanar - Error: The length of edgeA is less than or equal to the tolerance. Returning None")
1001
1001
  return None
1002
- if Edge.Length(edgeB) < tolerance:
1003
- print("Edge.IsCoplanar - Error: The length of edgeB is less than the tolerance. Returning None")
1002
+ if Edge.Length(edgeB) <= tolerance:
1003
+ print("Edge.IsCoplanar - Error: The length of edgeB is less than or equal to the tolerance. Returning None")
1004
1004
  return None
1005
1005
 
1006
1006
  # Extract points
@@ -1513,8 +1513,8 @@ class Edge():
1513
1513
  distance = abs(distance)
1514
1514
  if distance == 0:
1515
1515
  return edge
1516
- if distance < tolerance:
1517
- print("Edge.Trim - Warning: The input distance parameter is less than the input tolerance parameter. Returning the input edge.")
1516
+ if distance <= tolerance:
1517
+ print("Edge.Trim - Warning: The input distance parameter is less than or equal to the input tolerance parameter. Returning the input edge.")
1518
1518
  return edge
1519
1519
  sv = Edge.StartVertex(edge)
1520
1520
  ev = Edge.EndVertex(edge)
topologicpy/Face.py CHANGED
@@ -325,7 +325,7 @@ class Face():
325
325
  print("Face.ByOffset - Warning: The input face parameter is not a valid face. Returning None.")
326
326
  return None
327
327
 
328
- if abs(Face.Normal(face)[2] + 1) < tolerance:
328
+ if abs(Face.Normal(face)[2] + 1) <= tolerance:
329
329
  reverse = not(reverse)
330
330
  eb = Face.Wire(face)
331
331
 
@@ -494,7 +494,7 @@ class Face():
494
494
  # We want this difference to be as close to 0 as possible
495
495
  loss = (new_area - area) ** 2
496
496
  # If the loss is less than the tolerance, accept the result and return a loss of 0.
497
- if loss < tolerance:
497
+ if loss <= tolerance:
498
498
  return 0
499
499
  # Otherwise, return the actual loss value.
500
500
  return loss
@@ -1622,7 +1622,7 @@ class Face():
1622
1622
  dV = direction
1623
1623
  uV = Vector.Normalize(dV)
1624
1624
  dot = sum([i*j for (i, j) in zip(uV, faceNormal)])
1625
- if dot < tolerance:
1625
+ if dot <= tolerance:
1626
1626
  return False
1627
1627
  return True
1628
1628
 
@@ -2278,7 +2278,7 @@ class Face():
2278
2278
  def vertex_part_of_face(vertex, face, tolerance=0.0001):
2279
2279
  vertices = Topology.Vertices(face)
2280
2280
  for v in vertices:
2281
- if Vertex.Distance(vertex, v) < tolerance:
2281
+ if Vertex.Distance(vertex, v) <= tolerance:
2282
2282
  return True
2283
2283
  return False
2284
2284
 
@@ -3040,9 +3040,9 @@ class Face():
3040
3040
  if not silent:
3041
3041
  print("Face.NormalEdge - Error: The input face parameter is not a valid face. Retuning None.")
3042
3042
  return None
3043
- if length < tolerance:
3043
+ if length <= tolerance:
3044
3044
  if not silent:
3045
- print("Face.NormalEdge - Error: The input length parameter is less than the input tolerance. Retuning None.")
3045
+ print("Face.NormalEdge - Error: The input length parameter is less than or equal to the input tolerance. Retuning None.")
3046
3046
  return None
3047
3047
  iv = Face.InternalVertex(face)
3048
3048
  u, v = Face.VertexParameters(face, iv)
@@ -3411,6 +3411,61 @@ class Face():
3411
3411
  return None
3412
3412
  return Face.ByWire(wire, tolerance=tolerance)
3413
3413
 
3414
+
3415
+ @staticmethod
3416
+ def ThirdVertex(face, tolerance: float = 0.0001, silent: bool = False):
3417
+ """
3418
+ Returns a third vertex on the input face to enable rotation matrix creation.
3419
+
3420
+ Parameters
3421
+ ----------
3422
+ face : topologic_core.Face
3423
+ The input face.
3424
+ tolerance : float , optional
3425
+ The desired tolerance. The default is 0.0001.
3426
+ silent : bool , optional
3427
+ If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
3428
+
3429
+ Returns
3430
+ -------
3431
+ topologic_core.Face
3432
+ The created face.
3433
+
3434
+ """
3435
+ from topologicpy.Vector import Vector
3436
+ from topologicpy.Vertex import Vertex
3437
+ from topologicpy.Topology import Topology
3438
+
3439
+ if not Topology.IsInstance(face, "Face"):
3440
+ if not silent:
3441
+ print("Face.ThirdVertex - Error: The input face parameter is not a valid face. Returning None.")
3442
+ return None
3443
+ # Retrieve all vertices of the face
3444
+ vertices = Face.Vertices(face)
3445
+ centroid = Topology.Centroid(face)
3446
+ normal = Face.Normal(face)
3447
+ for vertex in vertices:
3448
+ # Skip the centroid itself
3449
+ if Vertex.Distance(centroid, vertex) <= tolerance:
3450
+ continue
3451
+
3452
+ # Vector from the centroid to the current vertex
3453
+ vector_to_vertex = Vector.ByVertices(centroid, vertex)
3454
+ vector_to_vertex_normalized = Vector.Normalize(vector_to_vertex)
3455
+
3456
+
3457
+ # Check if the vector_to_vertex is collinear with the normal direction
3458
+ if Vector.IsCollinear(vector_to_vertex_normalized, normal, tolerance):
3459
+ continue
3460
+
3461
+ # If not collinear, return this vertex
3462
+ return vertex
3463
+
3464
+ # No valid third vertex found
3465
+ if not silent:
3466
+ print("Face.ThirdVertex - Warning: No valid third vertex could be found. Returning None.")
3467
+ return None
3468
+
3414
3469
  @staticmethod
3415
3470
  def Trapezoid(origin= None, widthA: float = 1.0, widthB: float = 0.75, offsetA: float = 0.0, offsetB: float = 0.0, length: float = 1.0, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
3416
3471
  """