topologicpy 0.7.83__py3-none-any.whl → 0.7.85__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 +10 -6
- topologicpy/CellComplex.py +10 -5
- topologicpy/Cluster.py +8 -8
- topologicpy/Dictionary.py +34 -1
- topologicpy/Edge.py +3 -3
- topologicpy/Face.py +11 -3
- topologicpy/Graph.py +91 -49
- topologicpy/Grid.py +4 -4
- topologicpy/Helper.py +42 -1
- topologicpy/Plotly.py +21 -22
- topologicpy/Shell.py +10 -6
- topologicpy/Topology.py +160 -54
- topologicpy/Vertex.py +8 -3
- topologicpy/Wire.py +111 -18
- topologicpy/version.py +1 -1
- {topologicpy-0.7.83.dist-info → topologicpy-0.7.85.dist-info}/METADATA +1 -1
- topologicpy-0.7.85.dist-info/RECORD +36 -0
- topologicpy-0.7.83.dist-info/RECORD +0 -36
- {topologicpy-0.7.83.dist-info → topologicpy-0.7.85.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.83.dist-info → topologicpy-0.7.85.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.83.dist-info → topologicpy-0.7.85.dist-info}/top_level.txt +0 -0
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
|
@@ -1967,9 +1967,13 @@ class Cell():
|
|
1967
1967
|
"""
|
1968
1968
|
from topologicpy.Face import Face
|
1969
1969
|
from topologicpy.Topology import Topology
|
1970
|
-
|
1970
|
+
import inspect
|
1971
|
+
|
1971
1972
|
if not Topology.IsInstance(cell, "Cell"):
|
1972
1973
|
print("Cell.RemoveCollinearEdges - Error: The input cell parameter is not a valid cell. Returning None.")
|
1974
|
+
curframe = inspect.currentframe()
|
1975
|
+
calframe = inspect.getouterframes(curframe, 2)
|
1976
|
+
print('caller name:', calframe[1][3])
|
1973
1977
|
return None
|
1974
1978
|
faces = Cell.Faces(cell)
|
1975
1979
|
clean_faces = []
|
@@ -2070,7 +2074,7 @@ class Cell():
|
|
2070
2074
|
if unused[i]:
|
2071
2075
|
iv = Topology.InternalVertex(cells[i], tolerance=tolerance)
|
2072
2076
|
for j in range(len(superCells)):
|
2073
|
-
if (Vertex.IsInternal(iv, superCells[j], tolerance)):
|
2077
|
+
if (Vertex.IsInternal(iv, superCells[j], tolerance=tolerance)):
|
2074
2078
|
sets[j].append(cells[i])
|
2075
2079
|
unused[i] = False
|
2076
2080
|
return sets
|
topologicpy/CellComplex.py
CHANGED
@@ -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):
|
@@ -972,9 +972,14 @@ class CellComplex():
|
|
972
972
|
"""
|
973
973
|
from topologicpy.Cell import Cell
|
974
974
|
from topologicpy.Topology import Topology
|
975
|
-
|
975
|
+
import inspect
|
976
|
+
|
976
977
|
if not Topology.IsInstance(cellComplex, "CellComplex"):
|
977
978
|
print("CellComplex.RemoveCollinearEdges - Error: The input cellComplex parameter is not a valid cellComplex. Returning None.")
|
979
|
+
print("CellComplex.RemoveCollinearEdges - Inspection:")
|
980
|
+
curframe = inspect.currentframe()
|
981
|
+
calframe = inspect.getouterframes(curframe, 2)
|
982
|
+
print('caller name:', calframe[1][3])
|
978
983
|
return None
|
979
984
|
cells = CellComplex.Cells(cellComplex)
|
980
985
|
clean_cells = []
|
topologicpy/Cluster.py
CHANGED
@@ -143,14 +143,14 @@ class Cluster():
|
|
143
143
|
return Cluster.ByTopologies(vertices)
|
144
144
|
|
145
145
|
@staticmethod
|
146
|
-
def ByTopologies(*
|
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 :
|
153
|
-
|
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(
|
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(
|
178
|
-
topologies =
|
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(
|
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(
|
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/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
|
|
@@ -1477,7 +1477,7 @@ class Edge():
|
|
1477
1477
|
svb = Edge.StartVertex(edgeB)
|
1478
1478
|
evb = Edge.EndVertex(edgeB)
|
1479
1479
|
intVertex = None
|
1480
|
-
if Edge.IsCollinear(edgeA, edgeB):
|
1480
|
+
if Edge.IsCollinear(edgeA, edgeB, tolerance=tolerance):
|
1481
1481
|
if Vertex.IsInternal(svb, edgeA):
|
1482
1482
|
intVertex = svb
|
1483
1483
|
elif Vertex.IsInternal(evb, edgeA):
|
@@ -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
@@ -594,6 +594,7 @@ class Face():
|
|
594
594
|
# Try the simple method first
|
595
595
|
face = None
|
596
596
|
ext_boundary = Wire.RemoveCollinearEdges(Shell.ExternalBoundary(shell))
|
597
|
+
#ext_boundary = Shell.ExternalBoundary(shell)
|
597
598
|
if Topology.IsInstance(ext_boundary, "Wire"):
|
598
599
|
face = Face.ByWire(ext_boundary, silent=silent)
|
599
600
|
elif Topology.IsInstance(ext_boundary, "Cluster"):
|
@@ -652,8 +653,11 @@ class Face():
|
|
652
653
|
for int_boundary in int_boundaries:
|
653
654
|
temp_wires = Topology.Wires(int_boundary)
|
654
655
|
int_wires.append(Topology.RemoveCollinearEdges(temp_wires[0], angTolerance))
|
656
|
+
#int_wires.append(temp_wires[0])
|
657
|
+
|
655
658
|
temp_wires = Topology.Wires(ext_boundary)
|
656
659
|
ext_wire = Topology.RemoveCollinearEdges(temp_wires[0], angTolerance)
|
660
|
+
#ext_wire = temp_wires[0]
|
657
661
|
face = Face.ByWires(ext_wire, int_wires)
|
658
662
|
face = Topology.Unflatten(face, origin=origin, direction=normal)
|
659
663
|
return face
|
@@ -1635,7 +1639,7 @@ class Face():
|
|
1635
1639
|
return plane
|
1636
1640
|
return [coef / norm for coef in plane]
|
1637
1641
|
|
1638
|
-
def are_planes_coplanar(plane1, plane2, tolerance):
|
1642
|
+
def are_planes_coplanar(plane1, plane2, tolerance=0.0001):
|
1639
1643
|
normalized_plane1 = normalize_plane_coefficients(plane1)
|
1640
1644
|
normalized_plane2 = normalize_plane_coefficients(plane2)
|
1641
1645
|
return np.allclose(normalized_plane1, normalized_plane2, atol=tolerance)
|
@@ -1840,7 +1844,7 @@ class Face():
|
|
1840
1844
|
# Return the average angle
|
1841
1845
|
return np.mean(angles)
|
1842
1846
|
|
1843
|
-
def vertex_part_of_face(vertex, face, tolerance):
|
1847
|
+
def vertex_part_of_face(vertex, face, tolerance=0.0001):
|
1844
1848
|
vertices = Topology.Vertices(face)
|
1845
1849
|
for v in vertices:
|
1846
1850
|
if Vertex.Distance(vertex, v) < tolerance:
|
@@ -2573,9 +2577,13 @@ class Face():
|
|
2573
2577
|
"""
|
2574
2578
|
from topologicpy.Wire import Wire
|
2575
2579
|
from topologicpy.Topology import Topology
|
2576
|
-
|
2580
|
+
import inspect
|
2581
|
+
|
2577
2582
|
if not Topology.IsInstance(face, "Face"):
|
2578
2583
|
print("Face.RemoveCollinearEdges - Error: The input face parameter is not a valid face. Returning None.")
|
2584
|
+
curframe = inspect.currentframe()
|
2585
|
+
calframe = inspect.getouterframes(curframe, 2)
|
2586
|
+
print('caller name:', calframe[1][3])
|
2579
2587
|
return None
|
2580
2588
|
eb = Wire.RemoveCollinearEdges(Face.Wire(face), angTolerance=angTolerance, tolerance=tolerance)
|
2581
2589
|
ib = [Wire.RemoveCollinearEdges(w, angTolerance=angTolerance, tolerance=tolerance) for w in Face.InternalBoundaries(face)]
|