topologicpy 0.8.59__py3-none-any.whl → 0.8.71__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 +478 -211
- topologicpy/Cell.py +5 -2
- topologicpy/Dictionary.py +17 -6
- topologicpy/Face.py +23 -50
- topologicpy/Graph.py +660 -42
- topologicpy/Kuzu.py +1 -1
- topologicpy/Shell.py +50 -14
- topologicpy/Topology.py +138 -108
- topologicpy/Vertex.py +333 -99
- topologicpy/version.py +1 -1
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/METADATA +1 -1
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/RECORD +15 -15
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/WHEEL +0 -0
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/licenses/LICENSE +0 -0
- {topologicpy-0.8.59.dist-info → topologicpy-0.8.71.dist-info}/top_level.txt +0 -0
topologicpy/Cell.py
CHANGED
@@ -226,7 +226,7 @@ class Cell():
|
|
226
226
|
return new_cell
|
227
227
|
|
228
228
|
@staticmethod
|
229
|
-
def ByShell(shell, planarize: bool = False, tolerance: float = 0.0001):
|
229
|
+
def ByShell(shell, planarize: bool = False, tolerance: float = 0.0001, silent: bool = False):
|
230
230
|
"""
|
231
231
|
Creates a cell from the input shell.
|
232
232
|
|
@@ -238,6 +238,8 @@ class Cell():
|
|
238
238
|
If set to True, the input faces of the input shell are planarized before building the cell. Otherwise, they are not. Default is False.
|
239
239
|
tolerance : float , optional
|
240
240
|
The desired tolerance. Default is 0.0001.
|
241
|
+
silent : bool , optional
|
242
|
+
If set to True, error and warning messages are suppressed. Default is False.
|
241
243
|
|
242
244
|
Returns
|
243
245
|
-------
|
@@ -248,7 +250,8 @@ class Cell():
|
|
248
250
|
from topologicpy.Topology import Topology
|
249
251
|
|
250
252
|
if not Topology.IsInstance(shell, "Shell"):
|
251
|
-
|
253
|
+
if not silent:
|
254
|
+
print("Cell.ByShell - Error: The input shell parameter is not a valid topologic shell. Returning None.")
|
252
255
|
return None
|
253
256
|
faces = Topology.SubTopologies(shell, subTopologyType="face")
|
254
257
|
return Cell.ByFaces(faces, planarize=planarize, tolerance=tolerance)
|
topologicpy/Dictionary.py
CHANGED
@@ -885,7 +885,10 @@ class Dictionary():
|
|
885
885
|
temp_value = attr.StringValue()
|
886
886
|
topologies = None
|
887
887
|
try:
|
888
|
-
|
888
|
+
if is_json_string(temp_value):
|
889
|
+
topologies = Topology.ByJSONString(temp_value)
|
890
|
+
else:
|
891
|
+
topologies = None
|
889
892
|
except:
|
890
893
|
topologies = None
|
891
894
|
if isinstance(topologies, list):
|
@@ -910,13 +913,21 @@ class Dictionary():
|
|
910
913
|
elif isinstance(attr, float) or isinstance(attr, int):
|
911
914
|
return attr
|
912
915
|
elif isinstance(attr, str):
|
913
|
-
topologies = Topology.ByJSONString(attr)
|
914
916
|
if attr == "__NONE__":
|
915
917
|
return None
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
918
|
+
topologies = None
|
919
|
+
try:
|
920
|
+
if is_json_string(attr):
|
921
|
+
topologies = Topology.ByJSONString(attr)
|
922
|
+
else:
|
923
|
+
topologies = None
|
924
|
+
except:
|
925
|
+
topologies = None
|
926
|
+
if isinstance(topologies, list):
|
927
|
+
if len(topologies) > 1:
|
928
|
+
return topologies
|
929
|
+
elif len(topologies) == 1:
|
930
|
+
return topologies[0]
|
920
931
|
elif is_json_string(attr):
|
921
932
|
return json_to_dict(attr)
|
922
933
|
else:
|
topologicpy/Face.py
CHANGED
@@ -870,12 +870,14 @@ class Face():
|
|
870
870
|
print('caller name:', calframe[1][3])
|
871
871
|
return None
|
872
872
|
if not Wire.IsClosed(wire):
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
873
|
+
wire = Wire.Close(wire, tolerance=tolerance)
|
874
|
+
if not Wire.IsClosed(wire):
|
875
|
+
if not silent:
|
876
|
+
print("Face.ByWire - Error: The input wire parameter is not a closed topologic wire. Returning None.")
|
877
|
+
curframe = inspect.currentframe()
|
878
|
+
calframe = inspect.getouterframes(curframe, 2)
|
879
|
+
print('caller name:', calframe[1][3])
|
880
|
+
return None
|
879
881
|
|
880
882
|
edges = Wire.Edges(wire)
|
881
883
|
wire = Topology.SelfMerge(Cluster.ByTopologies(edges), tolerance=tolerance)
|
@@ -1882,53 +1884,24 @@ class Face():
|
|
1882
1884
|
The created vertex.
|
1883
1885
|
|
1884
1886
|
"""
|
1885
|
-
def get_uv_radially():
|
1886
|
-
"""
|
1887
|
-
Generate the points of a grid with a given size n, sorted radially from the center to the periphery.
|
1888
|
-
n should be an odd number, ensuring that there's a center point (0, 0).
|
1889
|
-
|
1890
|
-
Args:
|
1891
|
-
n (int): The size of the grid. It should be odd for a clear center point.
|
1892
|
-
|
1893
|
-
Returns:
|
1894
|
-
list: A list of tuples (x, y) sorted by radial distance from the center (0, 0).
|
1895
|
-
"""
|
1896
|
-
import math
|
1897
|
-
|
1898
|
-
points = []
|
1899
|
-
n = 100
|
1900
|
-
# Iterate over the grid, ranging from -n//2 to n//2
|
1901
|
-
for x in range(-n//2, n//2 + 1):
|
1902
|
-
for y in range(-n//2, n//2 + 1):
|
1903
|
-
points.append((x, y))
|
1904
|
-
|
1905
|
-
# Sort points by their Euclidean distance from the center (0, 0)
|
1906
|
-
points.sort(key=lambda point: math.sqrt(point[0]**2 + point[1]**2))
|
1907
|
-
return_points = []
|
1908
|
-
for p in points:
|
1909
|
-
new_p = ((p[0]+50)*0.01, (p[1]+50)*0.01)
|
1910
|
-
return_points.append(new_p)
|
1911
|
-
return return_points
|
1912
|
-
|
1913
1887
|
from topologicpy.Vertex import Vertex
|
1888
|
+
from topologicpy.Shell import Shell
|
1889
|
+
from topologicpy.Cluster import Cluster
|
1890
|
+
from topologicpy.BVH import BVH
|
1914
1891
|
from topologicpy.Topology import Topology
|
1915
1892
|
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
print("Face.InternalVertex - Warning: Could not find an internal vertex. Returning the first vertex of the face.")
|
1929
|
-
vert = Topology.Vertices(face)[0]
|
1930
|
-
#v = topologic.FaceUtility.InternalVertex(face, tolerance) # Hook to Core
|
1931
|
-
return vert
|
1893
|
+
centroid = Topology.Centroid(face)
|
1894
|
+
if Vertex.IsInternal(centroid, face):
|
1895
|
+
return centroid
|
1896
|
+
|
1897
|
+
shell = Topology.Triangulate(face)
|
1898
|
+
ib = Shell.InternalBoundaries(shell)
|
1899
|
+
cluster = Cluster.ByTopologies(ib)
|
1900
|
+
edges = Topology.Edges(cluster)
|
1901
|
+
bvh = BVH.ByTopologies(edges, tolerance=tolerance, silent=True)
|
1902
|
+
nearest_edge = BVH.Nearest(bvh, centroid)
|
1903
|
+
return Topology.Centroid(nearest_edge)
|
1904
|
+
|
1932
1905
|
|
1933
1906
|
@staticmethod
|
1934
1907
|
def Invert(face, tolerance: float = 0.0001, silent: bool = False):
|