topologicpy 0.7.84__py3-none-any.whl → 0.7.86__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/Cell.py CHANGED
@@ -726,7 +726,7 @@ class Cell():
726
726
  from topologicpy.Topology import Topology
727
727
  import math
728
728
 
729
- def createCone(baseWire, topWire, baseVertex, topVertex, tolerance):
729
+ def createCone(baseWire, topWire, baseVertex, topVertex, tolerance=0.0001):
730
730
  if baseWire == None and topWire == None:
731
731
  raise Exception("Cell.Cone - Error: Both radii of the cone cannot be zero at the same time")
732
732
  elif baseWire == None:
@@ -789,7 +789,7 @@ class Cell():
789
789
  topWire = None
790
790
  baseVertex = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+xOffset, Vertex.Y(origin, mantissa=mantissa)+yOffset, Vertex.Z(origin, mantissa=mantissa)+zOffset)
791
791
  topVertex = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+xOffset, Vertex.Y(origin, mantissa=mantissa)+yOffset, Vertex.Z(origin, mantissa=mantissa)+zOffset+height)
792
- cone = createCone(baseWire, topWire, baseVertex, topVertex, tolerance)
792
+ cone = createCone(baseWire, topWire, baseVertex, topVertex, tolerance=tolerance)
793
793
  if cone == None:
794
794
  print("Cell.Cone - Error: Could not create a cone. Returning None.")
795
795
  return None
@@ -1304,7 +1304,7 @@ class Cell():
1304
1304
  from topologicpy.Topology import Topology
1305
1305
  import math
1306
1306
 
1307
- def createHyperboloid(baseVertices, topVertices, tolerance):
1307
+ def createHyperboloid(baseVertices, topVertices, tolerance=0.0001):
1308
1308
  baseWire = Wire.ByVertices(baseVertices, close=True)
1309
1309
  topWire = Wire.ByVertices(topVertices, close=True)
1310
1310
  baseFace = Face.ByWire(baseWire, tolerance=tolerance)
@@ -1358,7 +1358,7 @@ class Cell():
1358
1358
  topY = math.cos(angle-math.radians(twist))*topRadius + Vertex.Y(w_origin, mantissa=mantissa) + yOffset
1359
1359
  topV.append(Vertex.ByCoordinates(topX,topY,topZ))
1360
1360
 
1361
- hyperboloid = createHyperboloid(baseV, topV, tolerance)
1361
+ hyperboloid = createHyperboloid(baseV, topV, tolerance=tolerance)
1362
1362
  if hyperboloid == None:
1363
1363
  print("Cell.Hyperboloid - Error: Could not create a hyperboloid. Returning None.")
1364
1364
  return None
@@ -2074,7 +2074,7 @@ class Cell():
2074
2074
  if unused[i]:
2075
2075
  iv = Topology.InternalVertex(cells[i], tolerance=tolerance)
2076
2076
  for j in range(len(superCells)):
2077
- if (Vertex.IsInternal(iv, superCells[j], tolerance)):
2077
+ if (Vertex.IsInternal(iv, superCells[j], tolerance=tolerance)):
2078
2078
  sets[j].append(cells[i])
2079
2079
  unused[i] = False
2080
2080
  return sets
@@ -158,7 +158,7 @@ class CellComplex():
158
158
  return(temp_cells[0])
159
159
  if transferDictionaries == True:
160
160
  for temp_cell in temp_cells:
161
- v = Topology.InternalVertex(temp_cell)
161
+ v = Topology.InternalVertex(temp_cell, tolerance=tolerance)
162
162
  enclosing_cells = Vertex.EnclosingCell(v, cluster)
163
163
  dictionaries = [Topology.Dictionary(ec) for ec in enclosing_cells]
164
164
  d = Dictionary.ByMergedDictionaries(dictionaries, silent=silent)
@@ -191,7 +191,7 @@ class CellComplex():
191
191
  print("CellComplex.ByCellsCluster - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
192
192
  return None
193
193
  cells = Topology.Cells(cluster)
194
- return CellComplex.ByCells(cells, tolerance)
194
+ return CellComplex.ByCells(cells, tolerance=tolerance)
195
195
 
196
196
  @staticmethod
197
197
  def ByFaces(faces: list, tolerance: float = 0.0001, silent: bool = False):
@@ -236,7 +236,7 @@ class CellComplex():
236
236
  for i in range(1,len(faces)):
237
237
  newCellComplex = None
238
238
  try:
239
- newCellComplex = cellComplex.Merge(faces[i], False, tolerance)
239
+ newCellComplex = cellComplex.Merge(faces[i], False, tolerance) # Hook to Core
240
240
  except:
241
241
  if not silent:
242
242
  print("CellComplex.ByFaces - Warning: Failed to merge face #"+str(i)+". Skipping.")
@@ -284,7 +284,7 @@ class CellComplex():
284
284
  print("CellComplex.ByFacesCluster - Error: The input cluster parameter is not a valid topologic cluster. Returning None.")
285
285
  return None
286
286
  faces = Topology.Faces(cluster)
287
- return CellComplex.ByFaces(faces, tolerance)
287
+ return CellComplex.ByFaces(faces, tolerance=tolerance)
288
288
 
289
289
  @staticmethod
290
290
  def ByWires(wires: list, triangulate: bool = True, tolerance: float = 0.0001):
topologicpy/Cluster.py CHANGED
@@ -143,14 +143,14 @@ class Cluster():
143
143
  return Cluster.ByTopologies(vertices)
144
144
 
145
145
  @staticmethod
146
- def ByTopologies(*args, transferDictionaries: bool = False, silent=False):
146
+ def ByTopologies(*topologies, transferDictionaries: bool = False, silent=False):
147
147
  """
148
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.
149
149
 
150
150
  Parameters
151
151
  ----------
152
- topologies : list
153
- The list of topologies.
152
+ *topologies : topologic_core.Topology
153
+ One or more instances of `topologic_core.Topology` to be processed.
154
154
  transferDictionaries : bool , optional
155
155
  If set to True, the dictionaries from the input topologies are merged and transferred to the cluster. Otherwise they are not. The default is False.
156
156
  silent : bool , optional
@@ -167,15 +167,15 @@ class Cluster():
167
167
  from topologicpy.Helper import Helper
168
168
  import inspect
169
169
 
170
- if len(args) == 0:
170
+ if len(topologies) == 0:
171
171
  if not silent:
172
172
  print("Cluster.ByTopologies - Error: The input topologies parameter is an empty list. Returning None.")
173
173
  curframe = inspect.currentframe()
174
174
  calframe = inspect.getouterframes(curframe, 2)
175
175
  print('caller name:', calframe[1][3])
176
176
  return None
177
- if len(args) == 1:
178
- topologies = args[0]
177
+ if len(topologies) == 1:
178
+ topologies = topologies[0]
179
179
  if isinstance(topologies, list):
180
180
  if len(topologies) == 0:
181
181
  if not silent:
@@ -186,7 +186,7 @@ class Cluster():
186
186
  return None
187
187
  else:
188
188
  topologyList = [x for x in topologies if Topology.IsInstance(x, "Topology")]
189
- if len(topologies) == 0:
189
+ if len(topologyList) == 0:
190
190
  if not silent:
191
191
  print("Cluster.ByTopologies - Error: The input topologies parameter does not contain any valid topologies. Returning None.")
192
192
  curframe = inspect.currentframe()
@@ -201,7 +201,7 @@ class Cluster():
201
201
  print('caller name:', calframe[1][3])
202
202
  return topologies
203
203
  else:
204
- topologyList = Helper.Flatten(list(args))
204
+ topologyList = Helper.Flatten(list(topologies))
205
205
  topologyList = [x for x in topologyList if Topology.IsInstance(x, "Topology")]
206
206
  if len(topologyList) == 0:
207
207
  if not silent:
topologicpy/Color.py CHANGED
@@ -483,6 +483,9 @@ class Color:
483
483
  print("Color.RGBToHex - Error: The input rgb parameter is not a valid list. Returning None.")
484
484
  return None
485
485
  r, g, b = rgb
486
+ r = int(r)
487
+ g = int(g)
488
+ b = int(b)
486
489
  hex_value = "#{:02x}{:02x}{:02x}".format(r, g, b)
487
490
  return hex_value.upper()
488
491
 
topologicpy/Dictionary.py CHANGED
@@ -637,7 +637,40 @@ class Dictionary():
637
637
  return processTopologicDictionary(dictionary, key, value)
638
638
  else:
639
639
  return None
640
-
640
+
641
+ @staticmethod
642
+ def SetValuesAtKeys(dictionary, keys, values):
643
+ """
644
+ Creates a key/value pair in the input dictionary.
645
+
646
+ Parameters
647
+ ----------
648
+ keys : list
649
+ A list of strings representing the keys of the dictionary.
650
+ values : list
651
+ A list of values corresponding to the list of keys. Values can be integers, floats, strings, or lists
652
+
653
+ Returns
654
+ -------
655
+ topologic_core.Dictionary
656
+ The created dictionary.
657
+
658
+ """
659
+
660
+ if not isinstance(keys, list):
661
+ print("Dictionary.SetValuesAtKeys - Error: The input keys parameter is not a valid list. Returning None.")
662
+ return None
663
+ if not isinstance(values, list):
664
+ print("Dictionary.SetValuesAtkeys - Error: The input values parameter is not a valid list. Returning None.")
665
+ return None
666
+ if len(keys) != len(values):
667
+ print("Dictionary.SetValuesAtKeys - Error: The input keys and values parameters are not of equal length. Returning None.")
668
+ return None
669
+
670
+ for i, key in enumerate(keys):
671
+ dictionary = Dictionary.SetValueAtKey(dictionary, key, values[i])
672
+ return dictionary
673
+
641
674
  @staticmethod
642
675
  def _ConvertAttribute(attr):
643
676
  """
topologicpy/Edge.py CHANGED
@@ -214,7 +214,7 @@ class Edge():
214
214
 
215
215
  n = Edge.Normal(edge)
216
216
  n = Vector.Normalize(n)
217
- n = Vector.Multiply(n, offset, tolerance)
217
+ n = Vector.Multiply(n, offset, tolerance=tolerance)
218
218
  edge = Topology.Translate(edge, n[0], n[1], n[2])
219
219
  return edge
220
220
 
@@ -1544,7 +1544,7 @@ class Edge():
1544
1544
  vy = Vertex.Y(ev, mantissa=mantissa) - Vertex.Y(sv, mantissa=mantissa)
1545
1545
  vz = Vertex.Z(ev, mantissa=mantissa) - Vertex.Z(sv, mantissa=mantissa)
1546
1546
  vector = Vector.Normalize([vx, vy, vz])
1547
- vector = Vector.Multiply(vector, distance, tolerance)
1547
+ vector = Vector.Multiply(vector, distance, tolerance=tolerance)
1548
1548
  return Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+vector[0], Vertex.Y(origin, mantissa=mantissa)+vector[1], Vertex.Z(origin, mantissa=mantissa)+vector[2])
1549
1549
 
1550
1550
  @staticmethod
topologicpy/Face.py CHANGED
@@ -1639,7 +1639,7 @@ class Face():
1639
1639
  return plane
1640
1640
  return [coef / norm for coef in plane]
1641
1641
 
1642
- def are_planes_coplanar(plane1, plane2, tolerance):
1642
+ def are_planes_coplanar(plane1, plane2, tolerance=0.0001):
1643
1643
  normalized_plane1 = normalize_plane_coefficients(plane1)
1644
1644
  normalized_plane2 = normalize_plane_coefficients(plane2)
1645
1645
  return np.allclose(normalized_plane1, normalized_plane2, atol=tolerance)
@@ -1844,7 +1844,7 @@ class Face():
1844
1844
  # Return the average angle
1845
1845
  return np.mean(angles)
1846
1846
 
1847
- def vertex_part_of_face(vertex, face, tolerance):
1847
+ def vertex_part_of_face(vertex, face, tolerance=0.0001):
1848
1848
  vertices = Topology.Vertices(face)
1849
1849
  for v in vertices:
1850
1850
  if Vertex.Distance(vertex, v) < tolerance: