topologicpy 0.8.30__py3-none-any.whl → 0.8.33__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 +5 -3
- topologicpy/CSG.py +1 -1
- topologicpy/Cell.py +1105 -12
- topologicpy/CellComplex.py +213 -1
- topologicpy/Cluster.py +4 -2
- topologicpy/Edge.py +61 -28
- topologicpy/Face.py +384 -101
- topologicpy/Graph.py +149 -2
- topologicpy/Plotly.py +0 -1
- topologicpy/ShapeGrammar.py +65 -6
- topologicpy/Topology.py +56 -416
- topologicpy/Vertex.py +1 -1
- topologicpy/Wire.py +95 -45
- topologicpy/version.py +1 -1
- {topologicpy-0.8.30.dist-info → topologicpy-0.8.33.dist-info}/METADATA +1 -1
- {topologicpy-0.8.30.dist-info → topologicpy-0.8.33.dist-info}/RECORD +19 -19
- {topologicpy-0.8.30.dist-info → topologicpy-0.8.33.dist-info}/WHEEL +1 -1
- {topologicpy-0.8.30.dist-info → topologicpy-0.8.33.dist-info}/licenses/LICENSE +0 -0
- {topologicpy-0.8.30.dist-info → topologicpy-0.8.33.dist-info}/top_level.txt +0 -0
topologicpy/Face.py
CHANGED
@@ -571,6 +571,9 @@ class Face():
|
|
571
571
|
The desired angular tolerance. The default is 0.1.
|
572
572
|
tolerance : float , optional
|
573
573
|
The desired tolerance. The default is 0.0001.
|
574
|
+
silent : bool , optional
|
575
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
576
|
+
|
574
577
|
|
575
578
|
Returns
|
576
579
|
-------
|
@@ -604,8 +607,7 @@ class Face():
|
|
604
607
|
|
605
608
|
# Try the simple method first
|
606
609
|
face = None
|
607
|
-
ext_boundary = Wire.RemoveCollinearEdges(Shell.ExternalBoundary(shell))
|
608
|
-
#ext_boundary = Shell.ExternalBoundary(shell)
|
610
|
+
ext_boundary = Wire.RemoveCollinearEdges(Shell.ExternalBoundary(shell), tolerance=tolerance, silent=silent)
|
609
611
|
if Topology.IsInstance(ext_boundary, "Wire"):
|
610
612
|
face = Face.ByWire(ext_boundary, silent=silent)
|
611
613
|
elif Topology.IsInstance(ext_boundary, "Cluster"):
|
@@ -629,7 +631,7 @@ class Face():
|
|
629
631
|
new_vertices.append(new_v)
|
630
632
|
planar_shell = Topology.SelfMerge(Topology.ReplaceVertices(planar_shell, verticesA=vertices, verticesB=new_vertices), tolerance=tolerance)
|
631
633
|
ext_boundary = Shell.ExternalBoundary(planar_shell, tolerance=tolerance)
|
632
|
-
ext_boundary = Topology.RemoveCollinearEdges(ext_boundary, angTolerance)
|
634
|
+
ext_boundary = Topology.RemoveCollinearEdges(ext_boundary, angTolerance=angTolerance, tolerance=tolerance, silent=silent)
|
633
635
|
if not Topology.IsInstance(ext_boundary, "Topology"):
|
634
636
|
print("Face.ByShell - Error: Could not derive the external boundary of the input shell parameter. Returning None.")
|
635
637
|
return None
|
@@ -637,9 +639,9 @@ class Face():
|
|
637
639
|
if Topology.IsInstance(ext_boundary, "Wire"):
|
638
640
|
if not Topology.IsPlanar(ext_boundary, tolerance=tolerance):
|
639
641
|
ext_boundary = Wire.Planarize(ext_boundary, origin=origin, tolerance=tolerance)
|
640
|
-
ext_boundary = Topology.RemoveCollinearEdges(ext_boundary, angTolerance)
|
642
|
+
ext_boundary = Topology.RemoveCollinearEdges(ext_boundary, angTolerance=angTolerance, tolerance=tolerance, silent=silent)
|
641
643
|
try:
|
642
|
-
face = Face.ByWire(ext_boundary)
|
644
|
+
face = Face.ByWire(ext_boundary, tolerance=tolerance, silent=silent)
|
643
645
|
face = Topology.Unflatten(face, origin=origin, direction=normal)
|
644
646
|
return face
|
645
647
|
except:
|
@@ -663,11 +665,11 @@ class Face():
|
|
663
665
|
int_wires = []
|
664
666
|
for int_boundary in int_boundaries:
|
665
667
|
temp_wires = Topology.Wires(int_boundary)
|
666
|
-
int_wires.append(Topology.RemoveCollinearEdges(temp_wires[0], angTolerance))
|
668
|
+
int_wires.append(Topology.RemoveCollinearEdges(temp_wires[0], angTolerance=angTolerance, tolerance=tolerance, silent=silent))
|
667
669
|
#int_wires.append(temp_wires[0])
|
668
670
|
|
669
671
|
temp_wires = Topology.Wires(ext_boundary)
|
670
|
-
ext_wire = Topology.RemoveCollinearEdges(temp_wires[0], angTolerance)
|
672
|
+
ext_wire = Topology.RemoveCollinearEdges(temp_wires[0], angTolerance=angTolerance, tolerance=tolerance, silent=silent)
|
671
673
|
#ext_wire = temp_wires[0]
|
672
674
|
face = Face.ByWires(ext_wire, int_wires)
|
673
675
|
face = Topology.Unflatten(face, origin=origin, direction=normal)
|
@@ -676,7 +678,7 @@ class Face():
|
|
676
678
|
return None
|
677
679
|
|
678
680
|
@staticmethod
|
679
|
-
def ByThickenedWire(wire, offsetA: float = 1.0, offsetB: float = 0.0, tolerance: float = 0.0001):
|
681
|
+
def ByThickenedWire(wire, offsetA: float = 1.0, offsetB: float = 0.0, tolerance: float = 0.0001, silent: bool = False):
|
680
682
|
"""
|
681
683
|
Creates a face by thickening the input wire. This method assumes the wire is manifold and planar.
|
682
684
|
|
@@ -690,6 +692,8 @@ class Face():
|
|
690
692
|
The desired offset to the interior of the wire. The default is 0.0.
|
691
693
|
tolerance : float , optional
|
692
694
|
The desired tolerance. The default is 0.0001.
|
695
|
+
silent : bool , optional
|
696
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
693
697
|
|
694
698
|
Returns
|
695
699
|
-------
|
@@ -710,7 +714,7 @@ class Face():
|
|
710
714
|
print("Face.ByThickenedWire - Error: The input wire parameter is not a manifold wire. Returning None.")
|
711
715
|
return None
|
712
716
|
three_vertices = Topology.Vertices(wire)[0:3]
|
713
|
-
temp_w = Wire.ByVertices(three_vertices, close=True)
|
717
|
+
temp_w = Wire.ByVertices(three_vertices, close=True, tolerance=tolerance, silent=silent)
|
714
718
|
flat_face = Face.ByWire(temp_w, tolerance=tolerance)
|
715
719
|
origin = Vertex.Origin()
|
716
720
|
normal = Face.Normal(flat_face)
|
@@ -733,7 +737,7 @@ class Face():
|
|
733
737
|
out_vertices = Topology.Vertices(outside_wire)[1:-1]
|
734
738
|
in_vertices = Topology.Vertices(inside_wire)[1:-1]
|
735
739
|
vertices = [sv2] + out_vertices + [ev2,ev1] + in_vertices + [sv1]
|
736
|
-
return_face = Face.ByWire(Wire.ByVertices(vertices))
|
740
|
+
return_face = Face.ByWire(Wire.ByVertices(vertices, close=True, tolerance=tolerance, silent=silent))
|
737
741
|
else:
|
738
742
|
return_face = Face.ByWires(outside_wire, [inside_wire])
|
739
743
|
return_face = Topology.Unflatten(return_face, origin=origin, direction=normal)
|
@@ -773,7 +777,7 @@ class Face():
|
|
773
777
|
print("Face.ByVertices - Error: The input vertices parameter does not contain at least three valid vertices. Returning None.")
|
774
778
|
return None
|
775
779
|
|
776
|
-
w = Wire.ByVertices(vertexList, tolerance=tolerance)
|
780
|
+
w = Wire.ByVertices(vertexList, close=True, tolerance=tolerance, silent=silent)
|
777
781
|
if not Topology.IsInstance(w, "Wire"):
|
778
782
|
if not silent:
|
779
783
|
print("Face.ByVertices - Error: Could not create the base wire. Returning None.")
|
@@ -782,8 +786,8 @@ class Face():
|
|
782
786
|
if not silent:
|
783
787
|
print("Face.ByVertices - Error: Could not create a closed base wire. Returning None.")
|
784
788
|
return None
|
785
|
-
f = Face.ByWire(w, tolerance=tolerance)
|
786
|
-
if not Topology.IsInstance(
|
789
|
+
f = Face.ByWire(w, tolerance=tolerance, silent=silent)
|
790
|
+
if not Topology.IsInstance(f, "Face"):
|
787
791
|
if not silent:
|
788
792
|
print("Face.ByVertices - Error: Could not create the face. Returning None.")
|
789
793
|
return None
|
@@ -851,7 +855,7 @@ class Face():
|
|
851
855
|
import inspect
|
852
856
|
|
853
857
|
def triangulateWire(wire):
|
854
|
-
wire = Topology.RemoveCollinearEdges(wire)
|
858
|
+
wire = Topology.RemoveCollinearEdges(wire, angTolerance=0.1, tolerance=tolerance, silent=silent)
|
855
859
|
vertices = Topology.Vertices(wire)
|
856
860
|
shell = Shell.Delaunay(vertices)
|
857
861
|
if Topology.IsInstance(shell, "Topology"):
|
@@ -1000,58 +1004,75 @@ class Face():
|
|
1000
1004
|
else:
|
1001
1005
|
internalBoundaries = Cluster.Wires(internalBoundariesCluster)
|
1002
1006
|
return Face.ByWires(externalBoundary, internalBoundaries, tolerance=tolerance, silent=silent)
|
1003
|
-
|
1007
|
+
|
1004
1008
|
@staticmethod
|
1005
|
-
def
|
1006
|
-
placement: str = "center", tolerance: float = 0.0001):
|
1009
|
+
def CHS(origin= None, radius: float = 0.5, thickness: float = 0.25, sides: int = 16, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001, silent: bool = False):
|
1007
1010
|
"""
|
1008
|
-
Creates a
|
1011
|
+
Creates a circular hollow section (CHS).
|
1009
1012
|
|
1010
1013
|
Parameters
|
1011
1014
|
----------
|
1012
1015
|
origin : topologic_core.Vertex, optional
|
1013
|
-
The location of the origin of the
|
1016
|
+
The location of the origin of the CHS. The default is None which results in the CHS being placed at (0, 0, 0).
|
1014
1017
|
radius : float , optional
|
1015
|
-
The radius of the
|
1016
|
-
|
1017
|
-
The
|
1018
|
+
The outer radius of the CHS. The default is 0.5.
|
1019
|
+
thickness : float , optional
|
1020
|
+
The thickness of the CHS. The default is 0.25.
|
1018
1021
|
direction : list , optional
|
1019
|
-
The vector representing the up direction of the
|
1020
|
-
northAngle : float , optional
|
1021
|
-
The angular offset in degrees from the positive Y axis direction. The angle is measured in a counter-clockwise fashion where 0 is positive Y, 90 is negative X, 180 is negative Y, and 270 is positive X.
|
1022
|
+
The vector representing the up direction of the CHS. The default is [0, 0, 1].
|
1022
1023
|
placement : str , optional
|
1023
|
-
The description of the placement of the origin of the
|
1024
|
+
The description of the placement of the origin of the CHS. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
|
1024
1025
|
tolerance : float , optional
|
1025
1026
|
The desired tolerance. The default is 0.0001.
|
1027
|
+
silent : bool , optional
|
1028
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
1026
1029
|
|
1027
1030
|
Returns
|
1028
1031
|
-------
|
1029
1032
|
topologic_core.Face
|
1030
|
-
The created
|
1033
|
+
The created face.
|
1031
1034
|
|
1032
1035
|
"""
|
1033
|
-
from topologicpy.Topology import Topology
|
1034
1036
|
from topologicpy.Vertex import Vertex
|
1035
|
-
|
1037
|
+
from topologicpy.Wire import Wire
|
1038
|
+
from topologicpy.Topology import Topology
|
1039
|
+
|
1040
|
+
if thickness >= radius:
|
1041
|
+
if not silent:
|
1042
|
+
print("Face.SHS - Error: The thickness value is larger than or equal to the outer radius value. Returning None.")
|
1043
|
+
return None
|
1044
|
+
if origin == None:
|
1036
1045
|
origin = Vertex.Origin()
|
1037
1046
|
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1047
|
+
outer_wire = Wire.Circle(origin=Vertex.Origin(), radius=radius, sides=sides, direction=[0,0,1], placement="center", tolerance=tolerance)
|
1048
|
+
inner_wire = Wire.Circle(origin=Vertex.Origin(), radius=radius-thickness, sides=sides, direction=[0,0,1], placement="center", tolerance=tolerance)
|
1049
|
+
return_face = Face.ByWires(outer_wire, [inner_wire])
|
1050
|
+
if not Topology.IsInstance(return_face, "face"):
|
1051
|
+
if not silent:
|
1052
|
+
print("Face.CHS - Error: Could not create the face for the CHS. Returning None.")
|
1053
|
+
return None
|
1054
|
+
|
1055
|
+
xOffset = 0
|
1056
|
+
yOffset = 0
|
1057
|
+
zOffset = 0
|
1043
1058
|
if placement.lower() == "lowerleft":
|
1044
|
-
|
1059
|
+
xOffset = radius
|
1060
|
+
yOffset = radius
|
1045
1061
|
elif placement.lower() == "upperleft":
|
1046
|
-
|
1062
|
+
xOffset = radius
|
1063
|
+
yOffset = -radius
|
1047
1064
|
elif placement.lower() == "lowerright":
|
1048
|
-
|
1065
|
+
xOffset = -radius
|
1066
|
+
yOffset = radius
|
1049
1067
|
elif placement.lower() == "upperright":
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1068
|
+
xOffset = -radius
|
1069
|
+
yOffset = -radius
|
1070
|
+
return_face = Topology.Translate(return_face, x=xOffset, y=yOffset, z=zOffset)
|
1071
|
+
return_face = Topology.Place(return_face, originA=Vertex.Origin(), originB=origin)
|
1072
|
+
if direction != [0, 0, 1]:
|
1073
|
+
return_face = Topology.Orient(return_face, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
1074
|
+
return return_face
|
1075
|
+
|
1055
1076
|
@staticmethod
|
1056
1077
|
def Circle(origin= None, radius: float = 0.5, sides: int = 16, fromAngle: float = 0.0, toAngle: float = 360.0, direction: list = [0, 0, 1],
|
1057
1078
|
placement: str = "center", tolerance: float = 0.0001):
|
@@ -1214,19 +1235,19 @@ class Face():
|
|
1214
1235
|
|
1215
1236
|
if not isinstance(width, int) and not isinstance(width, float):
|
1216
1237
|
if not silent:
|
1217
|
-
print("
|
1238
|
+
print("Face.CrossShape - Error: The width input parameter is not a valid number. Returning None.")
|
1218
1239
|
return None
|
1219
1240
|
if not isinstance(length, int) and not isinstance(length, float):
|
1220
1241
|
if not silent:
|
1221
|
-
print("
|
1242
|
+
print("Face.CrossShape - Error: The length input parameter is not a valid number. Returning None.")
|
1222
1243
|
return None
|
1223
1244
|
if not isinstance(a, int) and not isinstance(a, float):
|
1224
1245
|
if not silent:
|
1225
|
-
print("
|
1246
|
+
print("Face.CrossShape - Error: The a input parameter is not a valid number. Returning None.")
|
1226
1247
|
return None
|
1227
1248
|
if not isinstance(b, int) and not isinstance(b, float):
|
1228
1249
|
if not silent:
|
1229
|
-
print("
|
1250
|
+
print("Face.CrossShape - Error: The b input parameter is not a valid number. Returning None.")
|
1230
1251
|
return None
|
1231
1252
|
if c == None:
|
1232
1253
|
c = width/2
|
@@ -1234,72 +1255,72 @@ class Face():
|
|
1234
1255
|
d = length/2
|
1235
1256
|
if not isinstance(c, int) and not isinstance(c, float):
|
1236
1257
|
if not silent:
|
1237
|
-
print("
|
1258
|
+
print("Face.CrossShape - Error: The c input parameter is not a valid number. Returning None.")
|
1238
1259
|
return None
|
1239
1260
|
if not isinstance(d, int) and not isinstance(d, float):
|
1240
1261
|
if not silent:
|
1241
|
-
print("
|
1262
|
+
print("Face.CrossShape - Error: The d input parameter is not a valid number. Returning None.")
|
1242
1263
|
if width <= tolerance:
|
1243
1264
|
if not silent:
|
1244
|
-
print("
|
1265
|
+
print("Face.CrossShape - Error: The width input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
|
1245
1266
|
return None
|
1246
1267
|
if length <= tolerance:
|
1247
1268
|
if not silent:
|
1248
|
-
print("
|
1269
|
+
print("Face.CrossShape - Error: The length input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
|
1249
1270
|
return None
|
1250
1271
|
if a <= tolerance:
|
1251
1272
|
if not silent:
|
1252
|
-
print("
|
1273
|
+
print("Face.CrossShape - Error: The a input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
|
1253
1274
|
return None
|
1254
1275
|
if b <= tolerance:
|
1255
1276
|
if not silent:
|
1256
|
-
print("
|
1277
|
+
print("Face.CrossShape - Error: The b input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
|
1257
1278
|
return None
|
1258
1279
|
if c <= tolerance:
|
1259
1280
|
if not silent:
|
1260
|
-
print("
|
1281
|
+
print("Face.CrossShape - Error: The c input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
|
1261
1282
|
return None
|
1262
1283
|
if d <= tolerance:
|
1263
1284
|
if not silent:
|
1264
|
-
print("
|
1285
|
+
print("Face.CrossShape - Error: The d input parameter must be a positive number greater than the tolerance input parameter. Returning None.")
|
1265
1286
|
return None
|
1266
1287
|
if a >= (width - tolerance*2):
|
1267
1288
|
if not silent:
|
1268
|
-
print("
|
1289
|
+
print("Face.CrossShape - Error: The a input parameter must be less than the width input parameter. Returning None.")
|
1269
1290
|
return None
|
1270
1291
|
if b >= (length - tolerance*2):
|
1271
1292
|
if not silent:
|
1272
|
-
print("
|
1293
|
+
print("Face.CrossShape - Error: The b input parameter must be less than the length input parameter. Returning None.")
|
1273
1294
|
return None
|
1274
1295
|
if c <= (tolerance + a/2):
|
1275
1296
|
if not silent:
|
1276
|
-
print("
|
1297
|
+
print("Face.CrossShape - Error: The c input parameter must be more than half the a input parameter. Returning None.")
|
1277
1298
|
return None
|
1278
1299
|
if d <= (tolerance + b/2):
|
1279
1300
|
if not silent:
|
1280
|
-
print("
|
1301
|
+
print("Face.CrossShape - Error: The c input parameter must be more than half the b input parameter. Returning None.")
|
1281
1302
|
return None
|
1282
1303
|
if c >= (width - tolerance - a/2):
|
1283
1304
|
if not silent:
|
1284
|
-
print("
|
1305
|
+
print("Face.CrossShape - Error: The c input parameter must be less than the width minus half the a input parameter. Returning None.")
|
1285
1306
|
return None
|
1286
1307
|
if d >= (length - tolerance - b/2):
|
1287
1308
|
if not silent:
|
1288
|
-
print("
|
1309
|
+
print("Face.CrossShape - Error: The c input parameter must be less than the width minus half the b input parameter. Returning None.")
|
1289
1310
|
return None
|
1290
1311
|
if origin == None:
|
1291
1312
|
origin = Vertex.Origin()
|
1292
1313
|
if not Topology.IsInstance(origin, "vertex"):
|
1293
1314
|
if not silent:
|
1294
|
-
print("
|
1315
|
+
print("Face.CrossShape - Error: The origin input parameter is not a valid topologic vertex. Returning None.")
|
1295
1316
|
return None
|
1296
1317
|
if not isinstance(direction, list):
|
1297
1318
|
if not silent:
|
1298
|
-
print("
|
1319
|
+
print("Face.CrossShape - Error: The direction input parameter is not a valid list. Returning None.")
|
1299
1320
|
return None
|
1300
1321
|
if not len(direction) == 3:
|
1301
1322
|
if not silent:
|
1302
|
-
print("
|
1323
|
+
print("Face.CrossShape - Error: The direction input parameter is not a valid vector. Returning None.")
|
1303
1324
|
return None
|
1304
1325
|
cross_shape_wire = Wire.CrossShape(origin=origin,
|
1305
1326
|
width=width,
|
@@ -1663,7 +1684,7 @@ class Face():
|
|
1663
1684
|
return True
|
1664
1685
|
|
1665
1686
|
@staticmethod
|
1666
|
-
def Fillet(face, radius: float = 0, radiusKey: str = None, tolerance: float = 0.0001, silent: bool = False):
|
1687
|
+
def Fillet(face, radius: float = 0, sides: int = 16, radiusKey: str = None, tolerance: float = 0.0001, silent: bool = False):
|
1667
1688
|
"""
|
1668
1689
|
Fillets (rounds) the interior and exterior corners of the input face given the input radius. See https://en.wikipedia.org/wiki/Fillet_(mechanics)
|
1669
1690
|
|
@@ -1671,8 +1692,10 @@ class Face():
|
|
1671
1692
|
----------
|
1672
1693
|
face : topologic_core.Face
|
1673
1694
|
The input face.
|
1674
|
-
radius : float
|
1675
|
-
The desired radius of the fillet.
|
1695
|
+
radius : float , optional
|
1696
|
+
The desired radius of the fillet. The default is 0.
|
1697
|
+
sides : int , optional
|
1698
|
+
The number of sides (segments) of the fillet. The default is 16.
|
1676
1699
|
radiusKey : str , optional
|
1677
1700
|
If specified, the dictionary of the vertices will be queried for this key to specify the desired fillet radius. The default is None.
|
1678
1701
|
tolerance : float , optional
|
@@ -1700,19 +1723,19 @@ class Face():
|
|
1700
1723
|
f_vertices = Topology.Vertices(face)
|
1701
1724
|
if isinstance(radiusKey, str):
|
1702
1725
|
eb = Topology.TransferDictionariesBySelectors(eb, selectors=f_vertices, tranVertices=True)
|
1703
|
-
eb = Wire.Fillet(eb, radius=radius, radiusKey=radiusKey, tolerance=tolerance)
|
1726
|
+
eb = Wire.Fillet(eb, radius=radius, sides=sides, radiusKey=radiusKey, tolerance=tolerance, silent=True)
|
1704
1727
|
if not Topology.IsInstance(eb, "Wire"):
|
1705
1728
|
if not silent:
|
1706
1729
|
print("Face.Fillet - Error: The operation failed. Returning None.")
|
1707
1730
|
return None
|
1708
1731
|
ib_wires = []
|
1709
1732
|
for ib in ib_list:
|
1710
|
-
ib = Wire.ByVertices(Topology.Vertices(ib))
|
1733
|
+
ib = Wire.ByVertices(Topology.Vertices(ib), close=True, tolerance=tolerance, silent=silent)
|
1711
1734
|
ib = Wire.Reverse(ib)
|
1712
1735
|
if isinstance(radiusKey, str):
|
1713
1736
|
ib = Topology.TransferDictionariesBySelectors(ib, selectors=f_vertices, tranVertices=True)
|
1714
1737
|
|
1715
|
-
ib_wire = Wire.Fillet(ib, radius=radius, radiusKey=radiusKey, tolerance=tolerance, silent=
|
1738
|
+
ib_wire = Wire.Fillet(ib, radius=radius, sides=sides, radiusKey=radiusKey, tolerance=tolerance, silent=True)
|
1716
1739
|
if Topology.IsInstance(ib, "Wire"):
|
1717
1740
|
ib_wires.append(ib_wire)
|
1718
1741
|
else:
|
@@ -1721,7 +1744,7 @@ class Face():
|
|
1721
1744
|
return Face.ByWires(eb, ib_wires)
|
1722
1745
|
|
1723
1746
|
@staticmethod
|
1724
|
-
def Harmonize(face, tolerance: float = 0.0001):
|
1747
|
+
def Harmonize(face, tolerance: float = 0.0001, silent: bool = False):
|
1725
1748
|
"""
|
1726
1749
|
Returns a harmonized version of the input face such that the *u* and *v* origins are always in the upperleft corner.
|
1727
1750
|
|
@@ -1731,6 +1754,8 @@ class Face():
|
|
1731
1754
|
The input face.
|
1732
1755
|
tolerance : float , optional
|
1733
1756
|
The desired tolerance. The default is 0.0001.
|
1757
|
+
silent : bool , optional
|
1758
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
1734
1759
|
|
1735
1760
|
Returns
|
1736
1761
|
-------
|
@@ -1744,19 +1769,20 @@ class Face():
|
|
1744
1769
|
from topologicpy.Dictionary import Dictionary
|
1745
1770
|
|
1746
1771
|
if not Topology.IsInstance(face, "Face"):
|
1747
|
-
|
1772
|
+
if not silent:
|
1773
|
+
print("Face.Harmonize - Error: The input face parameter is not a valid face. Returning None.")
|
1748
1774
|
return None
|
1749
1775
|
normal = Face.Normal(face)
|
1750
1776
|
origin = Topology.Centroid(face)
|
1751
1777
|
flatFace = Topology.Flatten(face, origin=origin, direction=normal)
|
1752
1778
|
world_origin = Vertex.Origin()
|
1753
1779
|
vertices = Topology.Vertices(Face.ExternalBoundary(flatFace))
|
1754
|
-
harmonizedEB = Wire.ByVertices(vertices)
|
1780
|
+
harmonizedEB = Wire.ByVertices(vertices, close=True, tolerance=tolerance, silent=silent)
|
1755
1781
|
internalBoundaries = Face.InternalBoundaries(flatFace)
|
1756
1782
|
harmonizedIB = []
|
1757
1783
|
for ib in internalBoundaries:
|
1758
1784
|
ibVertices = Topology.Vertices(ib)
|
1759
|
-
harmonizedIB.append(Wire.ByVertices(ibVertices))
|
1785
|
+
harmonizedIB.append(Wire.ByVertices(ibVertices, close=True, tolerance=tolerance, silent=silent))
|
1760
1786
|
harmonizedFace = Face.ByWires(harmonizedEB, harmonizedIB, tolerance=tolerance)
|
1761
1787
|
harmonizedFace = Topology.Unflatten(harmonizedFace, origin=origin, direction=normal)
|
1762
1788
|
return harmonizedFace
|
@@ -1895,7 +1921,7 @@ class Face():
|
|
1895
1921
|
return vert
|
1896
1922
|
|
1897
1923
|
@staticmethod
|
1898
|
-
def Invert(face, tolerance: float = 0.0001):
|
1924
|
+
def Invert(face, tolerance: float = 0.0001, silent: bool = False):
|
1899
1925
|
"""
|
1900
1926
|
Creates a face that is an inverse (mirror) of the input face.
|
1901
1927
|
|
@@ -1905,6 +1931,8 @@ class Face():
|
|
1905
1931
|
The input face.
|
1906
1932
|
tolerance : float , optional
|
1907
1933
|
The desired tolerance. The default is 0.0001.
|
1934
|
+
silent : bool , optional
|
1935
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
1908
1936
|
|
1909
1937
|
Returns
|
1910
1938
|
-------
|
@@ -1920,12 +1948,12 @@ class Face():
|
|
1920
1948
|
eb = Face.ExternalBoundary(face)
|
1921
1949
|
vertices = Topology.Vertices(eb)
|
1922
1950
|
vertices.reverse()
|
1923
|
-
inverted_wire = Wire.ByVertices(vertices)
|
1951
|
+
inverted_wire = Wire.ByVertices(vertices, close=Wire.IsClosed(eb), tolerance=tolerance, silent=silent)
|
1924
1952
|
internal_boundaries = Face.InternalBoundaries(face)
|
1925
1953
|
if not internal_boundaries:
|
1926
|
-
inverted_face = Face.ByWire(inverted_wire, tolerance=tolerance)
|
1954
|
+
inverted_face = Face.ByWire(inverted_wire, tolerance=tolerance, silent=silent)
|
1927
1955
|
else:
|
1928
|
-
inverted_face = Face.ByWires(inverted_wire, internal_boundaries, tolerance=tolerance)
|
1956
|
+
inverted_face = Face.ByWires(inverted_wire, internal_boundaries, tolerance=tolerance, silent=silent)
|
1929
1957
|
return inverted_face
|
1930
1958
|
@staticmethod
|
1931
1959
|
def IsConvex(face, mantissa: int = 6, silent: bool = False) -> bool:
|
@@ -2140,7 +2168,7 @@ class Face():
|
|
2140
2168
|
return Face.ByWire(i_shape_wire, tolerance=tolerance, silent=silent)
|
2141
2169
|
|
2142
2170
|
@staticmethod
|
2143
|
-
def Isovist(face, vertex, obstacles: list = [], direction: list = [0,1,0], fov: float = 360, transferDictionaries: bool = False, metrics: bool = False, triangles: bool = False, mantissa: int = 6, tolerance: float = 0.0001):
|
2171
|
+
def Isovist(face, vertex, obstacles: list = [], direction: list = [0,1,0], fov: float = 360, transferDictionaries: bool = False, metrics: bool = False, triangles: bool = False, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False):
|
2144
2172
|
"""
|
2145
2173
|
Returns the face representing the isovist projection from the input viewpoint.
|
2146
2174
|
This method assumes all input is in 2D. Z coordinates are ignored.
|
@@ -2199,6 +2227,8 @@ class Face():
|
|
2199
2227
|
The desired length of the mantissa. The default is 6.
|
2200
2228
|
tolerance : float , optional:
|
2201
2229
|
The desired tolerance. The default is 0.0001.
|
2230
|
+
silent : bool , optional
|
2231
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
2202
2232
|
|
2203
2233
|
Returns
|
2204
2234
|
-------
|
@@ -2481,7 +2511,7 @@ class Face():
|
|
2481
2511
|
vertices = Topology.Vertices(eb)
|
2482
2512
|
coords = [Vertex.Coordinates(v, outputType="xy") for v in vertices]
|
2483
2513
|
new_vertices = [Vertex.ByCoordinates(coord) for coord in coords]
|
2484
|
-
eb = Wire.ByVertices(new_vertices, close=True)
|
2514
|
+
eb = Wire.ByVertices(new_vertices, close=True, tolerance=tolerance, silent=silent)
|
2485
2515
|
|
2486
2516
|
ib_list = Face.InternalBoundaries(flat_face)
|
2487
2517
|
new_ib_list = []
|
@@ -2489,7 +2519,7 @@ class Face():
|
|
2489
2519
|
vertices = Topology.Vertices(ib)
|
2490
2520
|
coords = [Vertex.Coordinates(v, outputType="xy") for v in vertices]
|
2491
2521
|
new_vertices = [Vertex.ByCoordinates(coord) for coord in coords]
|
2492
|
-
new_ib_list.append(Wire.ByVertices(new_vertices, close=True))
|
2522
|
+
new_ib_list.append(Wire.ByVertices(new_vertices, close=True, tolerance=tolerance, silent=silent))
|
2493
2523
|
|
2494
2524
|
flat_face = Face.ByWires(eb, new_ib_list)
|
2495
2525
|
for obs in flat_obstacles:
|
@@ -2508,7 +2538,7 @@ class Face():
|
|
2508
2538
|
edges = []
|
2509
2539
|
for target in targets:
|
2510
2540
|
if Vertex.Distance(flat_vertex, target) > tolerance:
|
2511
|
-
e = Edge.ByVertices(flat_vertex, target, silent=True)
|
2541
|
+
e = Edge.ByVertices([flat_vertex, target], tolerance=tolerance, silent=True)
|
2512
2542
|
e = Edge.SetLength(e, length=max_d, bothSides=False, tolerance=tolerance)
|
2513
2543
|
edges.append(e)
|
2514
2544
|
shell = Topology.Slice(flat_face, Cluster.ByTopologies(edges))
|
@@ -2533,11 +2563,12 @@ class Face():
|
|
2533
2563
|
sv = vertices[Vertex.Index(Edge.StartVertex(edge), vertices, tolerance=0.01)]
|
2534
2564
|
ev = vertices[Vertex.Index(Edge.EndVertex(edge), vertices, tolerance=0.01)]
|
2535
2565
|
if Vertex.Distance(sv, ev) > tolerance:
|
2536
|
-
new_edges.append(Edge.ByVertices([sv,ev]))
|
2566
|
+
new_edges.append(Edge.ByVertices([sv,ev], tolerance=tolerance, silent=True))
|
2537
2567
|
w = Wire.ByEdges(new_edges, tolerance=0.01)
|
2538
2568
|
return_face = Face.ByWire(w)
|
2539
2569
|
if not Topology.IsInstance(return_face, "Face"):
|
2540
|
-
|
2570
|
+
if not silent:
|
2571
|
+
print("Face.Isovist - Error: Could not create isovist. Returning None.")
|
2541
2572
|
return None
|
2542
2573
|
compAngle = 0
|
2543
2574
|
if fov == 360:
|
@@ -2555,9 +2586,10 @@ class Face():
|
|
2555
2586
|
if not Topology.IsInstance(return_face, "face"):
|
2556
2587
|
return_face = Topology.SelfMerge(return_face)
|
2557
2588
|
if return_face == None:
|
2558
|
-
|
2589
|
+
if not silent:
|
2590
|
+
print("Face.Isovist - Error: Could not create isovist. Returning None.")
|
2559
2591
|
return None
|
2560
|
-
simpler_face = Face.RemoveCollinearEdges(return_face)
|
2592
|
+
simpler_face = Face.RemoveCollinearEdges(return_face, angTolerance=0.1, tolerance=tolerance, silent=silent)
|
2561
2593
|
if Topology.IsInstance(simpler_face, "face"):
|
2562
2594
|
if transferDictionaries == True or metrics == True:
|
2563
2595
|
j_edges = [Topology.Edges(t) for t in obstacles]
|
@@ -2729,10 +2761,10 @@ class Face():
|
|
2729
2761
|
edges = Topology.Edges(return_face)
|
2730
2762
|
for edge in edges:
|
2731
2763
|
d = Topology.Dictionary(edge)
|
2732
|
-
if Vertex.Distance(Edge.StartVertex(edge), v) >
|
2733
|
-
e1 = Edge.ByVertices(Edge.StartVertex(edge), v)
|
2734
|
-
if Vertex.Distance(Edge.EndVertex(edge), v) >
|
2735
|
-
e2 = Edge.ByVertices(Edge.EndVertex(edge), v)
|
2764
|
+
if Vertex.Distance(Edge.StartVertex(edge), v) > tolerance:
|
2765
|
+
e1 = Edge.ByVertices([Edge.StartVertex(edge), v], tolerance=tolerance, silent=True)
|
2766
|
+
if Vertex.Distance(Edge.EndVertex(edge), v) > tolerance:
|
2767
|
+
e2 = Edge.ByVertices([Edge.EndVertex(edge), v], tolerance=tolerance, silent=True)
|
2736
2768
|
triangle = Topology.SelfMerge(Cluster.ByTopologies(edge, e1, e2))
|
2737
2769
|
if Topology.IsInstance(triangle, "wire"):
|
2738
2770
|
if Wire.IsClosed(triangle):
|
@@ -2863,7 +2895,7 @@ class Face():
|
|
2863
2895
|
return Face.ByWire(l_shape_wire, tolerance=tolerance, silent=silent)
|
2864
2896
|
|
2865
2897
|
@staticmethod
|
2866
|
-
def MedialAxis(face, resolution: int = 0, externalVertices: bool = False, internalVertices: bool = False, toLeavesOnly: bool = False, angTolerance: float = 0.1, tolerance: float = 0.0001):
|
2898
|
+
def MedialAxis(face, resolution: int = 0, externalVertices: bool = False, internalVertices: bool = False, toLeavesOnly: bool = False, angTolerance: float = 0.1, tolerance: float = 0.0001, silent: bool = False):
|
2867
2899
|
"""
|
2868
2900
|
Returns a wire representing an approximation of the medial axis of the input topology. See https://en.wikipedia.org/wiki/Medial_axis.
|
2869
2901
|
|
@@ -2883,6 +2915,8 @@ class Face():
|
|
2883
2915
|
The desired angular tolerance in degrees for removing collinear edges. The default is 0.1.
|
2884
2916
|
tolerance : float , optional
|
2885
2917
|
The desired tolerance. The default is 0.0001.
|
2918
|
+
silent : bool , optional
|
2919
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
2886
2920
|
|
2887
2921
|
Returns
|
2888
2922
|
-------
|
@@ -2953,7 +2987,7 @@ class Face():
|
|
2953
2987
|
|
2954
2988
|
tempWire = Topology.SelfMerge(Cluster.ByTopologies(medialAxisEdges), tolerance=tolerance)
|
2955
2989
|
if Topology.IsInstance(tempWire, "Wire") and angTolerance > 0:
|
2956
|
-
tempWire = Wire.RemoveCollinearEdges(tempWire, angTolerance=angTolerance)
|
2990
|
+
tempWire = Wire.RemoveCollinearEdges(tempWire, angTolerance=angTolerance, tolerance=tolerance, silent=silent)
|
2957
2991
|
medialAxisEdges = Wire.Edges(tempWire)
|
2958
2992
|
for v in theVertices:
|
2959
2993
|
nv = Vertex.NearestVertex(v, tempWire, useKDTree=False)
|
@@ -2962,12 +2996,12 @@ class Face():
|
|
2962
2996
|
if toLeavesOnly:
|
2963
2997
|
adjVertices = Topology.AdjacentTopologies(nv, tempWire)
|
2964
2998
|
if len(adjVertices) < 2:
|
2965
|
-
medialAxisEdges.append(Edge.ByVertices([nv, v], tolerance=tolerance))
|
2999
|
+
medialAxisEdges.append(Edge.ByVertices([nv, v], tolerance=tolerance, silent=silent))
|
2966
3000
|
else:
|
2967
|
-
medialAxisEdges.append(Edge.ByVertices([nv, v], tolerance=tolerance))
|
3001
|
+
medialAxisEdges.append(Edge.ByVertices([nv, v], tolerance=tolerance, silent=silent))
|
2968
3002
|
medialAxis = Topology.SelfMerge(Cluster.ByTopologies(medialAxisEdges), tolerance=tolerance)
|
2969
3003
|
if Topology.IsInstance(medialAxis, "Wire") and angTolerance > 0:
|
2970
|
-
medialAxis = Topology.RemoveCollinearEdges(medialAxis, angTolerance=angTolerance)
|
3004
|
+
medialAxis = Topology.RemoveCollinearEdges(medialAxis, angTolerance=angTolerance, tolerance=tolerance, silent=silent)
|
2971
3005
|
medialAxis = Topology.Unflatten(medialAxis, origin=origin,direction=normal)
|
2972
3006
|
return medialAxis
|
2973
3007
|
|
@@ -3114,6 +3148,57 @@ class Face():
|
|
3114
3148
|
ev = Topology.TranslateByDirectionDistance(iv, vec, length)
|
3115
3149
|
return Edge.ByVertices([iv, ev], tolerance=tolerance, silent=silent)
|
3116
3150
|
|
3151
|
+
@staticmethod
|
3152
|
+
def NorthArrow(origin= None, radius: float = 0.5, sides: int = 16, direction: list = [0, 0, 1], northAngle: float = 0.0,
|
3153
|
+
placement: str = "center", tolerance: float = 0.0001):
|
3154
|
+
"""
|
3155
|
+
Creates a north arrow.
|
3156
|
+
|
3157
|
+
Parameters
|
3158
|
+
----------
|
3159
|
+
origin : topologic_core.Vertex, optional
|
3160
|
+
The location of the origin of the circle. The default is None which results in the circle being placed at (0, 0, 0).
|
3161
|
+
radius : float , optional
|
3162
|
+
The radius of the circle. The default is 1.
|
3163
|
+
sides : int , optional
|
3164
|
+
The number of sides of the circle. The default is 16.
|
3165
|
+
direction : list , optional
|
3166
|
+
The vector representing the up direction of the circle. The default is [0, 0, 1].
|
3167
|
+
northAngle : float , optional
|
3168
|
+
The angular offset in degrees from the positive Y axis direction. The angle is measured in a counter-clockwise fashion where 0 is positive Y, 90 is negative X, 180 is negative Y, and 270 is positive X.
|
3169
|
+
placement : str , optional
|
3170
|
+
The description of the placement of the origin of the circle. This can be "center", "lowerleft", "upperleft", "lowerright", or "upperright". It is case insensitive. The default is "center".
|
3171
|
+
tolerance : float , optional
|
3172
|
+
The desired tolerance. The default is 0.0001.
|
3173
|
+
|
3174
|
+
Returns
|
3175
|
+
-------
|
3176
|
+
topologic_core.Face
|
3177
|
+
The created circle.
|
3178
|
+
|
3179
|
+
"""
|
3180
|
+
from topologicpy.Topology import Topology
|
3181
|
+
from topologicpy.Vertex import Vertex
|
3182
|
+
if not Topology.IsInstance(origin, "Vertex"):
|
3183
|
+
origin = Vertex.Origin()
|
3184
|
+
|
3185
|
+
c = Face.Circle(origin=origin, radius=radius, sides=sides, direction=[0, 0, 1], placement="center", tolerance=tolerance)
|
3186
|
+
r = Face.Rectangle(origin=origin, width=radius*0.01,length=radius*1.2, placement="lowerleft")
|
3187
|
+
r = Topology.Translate(r, -0.005*radius,0,0)
|
3188
|
+
arrow = Topology.Difference(c, r, tolerance=tolerance)
|
3189
|
+
arrow = Topology.Rotate(arrow, origin=Vertex.Origin(), axis=[0, 0, 1], angle=northAngle)
|
3190
|
+
if placement.lower() == "lowerleft":
|
3191
|
+
arrow = Topology.Translate(arrow, radius, radius, 0)
|
3192
|
+
elif placement.lower() == "upperleft":
|
3193
|
+
arrow = Topology.Translate(arrow, radius, -radius, 0)
|
3194
|
+
elif placement.lower() == "lowerright":
|
3195
|
+
arrow = Topology.Translate(arrow, -radius, radius, 0)
|
3196
|
+
elif placement.lower() == "upperright":
|
3197
|
+
arrow = Topology.Translate(arrow, -radius, -radius, 0)
|
3198
|
+
arrow = Topology.Place(arrow, originA=Vertex.Origin(), originB=origin)
|
3199
|
+
arrow = Topology.Orient(arrow, origin=origin, dirA=[0,0,1], dirB=direction)
|
3200
|
+
return arrow
|
3201
|
+
|
3117
3202
|
@staticmethod
|
3118
3203
|
def PlaneEquation(face, mantissa: int = 6) -> dict:
|
3119
3204
|
"""
|
@@ -3281,7 +3366,7 @@ class Face():
|
|
3281
3366
|
return Face.ByWire(wire, tolerance=tolerance)
|
3282
3367
|
|
3283
3368
|
@staticmethod
|
3284
|
-
def RemoveCollinearEdges(face, angTolerance: float = 0.1, tolerance: float = 0.0001):
|
3369
|
+
def RemoveCollinearEdges(face, angTolerance: float = 0.1, tolerance: float = 0.0001, silent: bool = False):
|
3285
3370
|
"""
|
3286
3371
|
Removes any collinear edges in the input face.
|
3287
3372
|
|
@@ -3293,6 +3378,8 @@ class Face():
|
|
3293
3378
|
The desired angular tolerance. The default is 0.1.
|
3294
3379
|
tolerance : float , optional
|
3295
3380
|
The desired tolerance. The default is 0.0001.
|
3381
|
+
silent : bool , optional
|
3382
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
3296
3383
|
|
3297
3384
|
Returns
|
3298
3385
|
-------
|
@@ -3305,15 +3392,211 @@ class Face():
|
|
3305
3392
|
import inspect
|
3306
3393
|
|
3307
3394
|
if not Topology.IsInstance(face, "Face"):
|
3308
|
-
|
3309
|
-
|
3310
|
-
|
3311
|
-
|
3395
|
+
if not silent:
|
3396
|
+
print("Face.RemoveCollinearEdges - Error: The input face parameter is not a valid face. Returning None.")
|
3397
|
+
curframe = inspect.currentframe()
|
3398
|
+
calframe = inspect.getouterframes(curframe, 2)
|
3399
|
+
print('caller name:', calframe[1][3])
|
3312
3400
|
return None
|
3313
|
-
eb = Wire.RemoveCollinearEdges(Face.Wire(face), angTolerance=angTolerance, tolerance=tolerance)
|
3314
|
-
ib = [Wire.RemoveCollinearEdges(w, angTolerance=angTolerance, tolerance=tolerance) for w in Face.InternalBoundaries(face)]
|
3401
|
+
eb = Wire.RemoveCollinearEdges(Face.Wire(face), angTolerance=angTolerance, tolerance=tolerance, silent=silent)
|
3402
|
+
ib = [Wire.RemoveCollinearEdges(w, angTolerance=angTolerance, tolerance=tolerance, silent=silent) for w in Face.InternalBoundaries(face)]
|
3315
3403
|
return Face.ByWires(eb, ib)
|
3316
3404
|
|
3405
|
+
@staticmethod
|
3406
|
+
def RHS(origin= None, width: float = 1.0, length: float = 1.0, thickness: float = 0.25, outerFillet: float = 0.0, innerFillet: float = 0.0, sides: int = 16, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001, silent: bool = False):
|
3407
|
+
"""
|
3408
|
+
Creates a rectangluar hollow section (RHS).
|
3409
|
+
|
3410
|
+
Parameters
|
3411
|
+
----------
|
3412
|
+
origin : topologic_core.Vertex, optional
|
3413
|
+
The location of the origin of the RHS. The default is None which results in the RHS being placed at (0, 0, 0).
|
3414
|
+
width : float , optional
|
3415
|
+
The width of the RHS. The default is 1.0.
|
3416
|
+
length : float , optional
|
3417
|
+
The length of the RHS. The default is 1.0.
|
3418
|
+
thickness : float , optional
|
3419
|
+
The thickness of the RHS. The default is 0.25.
|
3420
|
+
outerFillet : float , optional
|
3421
|
+
The outer fillet multiplication factor based on the thickness (e.g. 1t). The default is 0.
|
3422
|
+
innerFillet : float , optional
|
3423
|
+
The inner fillet multiplication factor based on the thickness (e.g. 1.5t). The default is 0.
|
3424
|
+
sides : int , optional
|
3425
|
+
The desired number of sides of the fillets. The default is 16.
|
3426
|
+
direction : list , optional
|
3427
|
+
The vector representing the up direction of the RHS. The default is [0, 0, 1].
|
3428
|
+
placement : str , optional
|
3429
|
+
The description of the placement of the origin of the RHS. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
|
3430
|
+
tolerance : float , optional
|
3431
|
+
The desired tolerance. The default is 0.0001.
|
3432
|
+
silent : bool , optional
|
3433
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
3434
|
+
|
3435
|
+
Returns
|
3436
|
+
-------
|
3437
|
+
topologic_core.Face
|
3438
|
+
The created face.
|
3439
|
+
|
3440
|
+
"""
|
3441
|
+
from topologicpy.Vertex import Vertex
|
3442
|
+
from topologicpy.Wire import Wire
|
3443
|
+
from topologicpy.Topology import Topology
|
3444
|
+
|
3445
|
+
if 2*thickness >= width:
|
3446
|
+
if not silent:
|
3447
|
+
print("Face.RHS - Error: Twice the thickness value is larger than or equal to the width value. Returning None.")
|
3448
|
+
return None
|
3449
|
+
if 2*thickness >= width:
|
3450
|
+
if not silent:
|
3451
|
+
print("Face.RHS - Error: Twice the thickness value is larger than or equal to the length value. Returning None.")
|
3452
|
+
return None
|
3453
|
+
outer_dimension = min(width, length)
|
3454
|
+
fillet_dimension = 2*outerFillet*thickness
|
3455
|
+
if fillet_dimension > outer_dimension:
|
3456
|
+
if not silent:
|
3457
|
+
print("Face.RHS = Error: The outer fillet radius input value is too large given the desired dimensions of the RHS. Returning None.")
|
3458
|
+
return None
|
3459
|
+
inner_dimension = min(width, length) - 2*thickness
|
3460
|
+
fillet_dimension = 2*innerFillet*thickness
|
3461
|
+
if fillet_dimension > inner_dimension:
|
3462
|
+
if not silent:
|
3463
|
+
print("Face.RHS = Error: The inner fillet radius input value is too large given the desired dimensions of the RHS. Returning None.")
|
3464
|
+
return None
|
3465
|
+
if origin == None:
|
3466
|
+
origin = Vertex.Origin()
|
3467
|
+
|
3468
|
+
outer_wire = Wire.Rectangle(origin=Vertex.Origin(), width=width, length=length, direction=[0,0,1], placement="center", tolerance=tolerance, silent=silent)
|
3469
|
+
inner_wire = Wire.Rectangle(origin=Vertex.Origin(), width=width-thickness*2, length=length-thickness*2, direction=[0,0,1], placement="center", tolerance=tolerance, silent=silent)
|
3470
|
+
if outerFillet > 0:
|
3471
|
+
outer_wire = Wire.Fillet(outer_wire, radius=outerFillet*thickness, sides=sides, silent=silent)
|
3472
|
+
if innerFillet > 0:
|
3473
|
+
inner_wire = Wire.Fillet(inner_wire, radius=innerFillet*thickness, sides=sides, silent=silent)
|
3474
|
+
return_face = Face.ByWires(outer_wire, [inner_wire], silent=silent)
|
3475
|
+
if not Topology.IsInstance(return_face, "face"):
|
3476
|
+
if not silent:
|
3477
|
+
print("Face.RHS - Error: Could not create the face for the RHS. Returning None.")
|
3478
|
+
return None
|
3479
|
+
|
3480
|
+
xOffset = 0
|
3481
|
+
yOffset = 0
|
3482
|
+
zOffset = 0
|
3483
|
+
if placement.lower() == "lowerleft":
|
3484
|
+
xOffset = width*0.5
|
3485
|
+
yOffset = length*0.5
|
3486
|
+
elif placement.lower() == "upperleft":
|
3487
|
+
xOffset = width*0.5
|
3488
|
+
yOffset = -length*0.5
|
3489
|
+
elif placement.lower() == "lowerright":
|
3490
|
+
xOffset = -width*0.5
|
3491
|
+
yOffset = length*0.5
|
3492
|
+
elif placement.lower() == "upperright":
|
3493
|
+
xOffset = -width*0.5
|
3494
|
+
yOffset = -length*0.5
|
3495
|
+
return_face = Topology.Translate(return_face, x=xOffset, y=yOffset, z=zOffset)
|
3496
|
+
return_face = Topology.Place(return_face, originA=Vertex.Origin(), originB=origin)
|
3497
|
+
if direction != [0, 0, 1]:
|
3498
|
+
return_face = Topology.Orient(return_face, origin=origin, dirA=[0, 0, 1], dirB=direction)
|
3499
|
+
return return_face
|
3500
|
+
|
3501
|
+
@staticmethod
|
3502
|
+
def Ring(origin= None, radius: float = 0.5, thickness: float = 0.25, sides: int = 16, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001, silent: bool = False):
|
3503
|
+
"""
|
3504
|
+
Creates a circular ring. This is an alias method for creating a circular hollow section (CHS).
|
3505
|
+
|
3506
|
+
Parameters
|
3507
|
+
----------
|
3508
|
+
origin : topologic_core.Vertex, optional
|
3509
|
+
The location of the origin of the ring. The default is None which results in the ring being placed at (0, 0, 0).
|
3510
|
+
radius : float , optional
|
3511
|
+
The outer radius of the ring. The default is 0.5.
|
3512
|
+
thickness : float , optional
|
3513
|
+
The thickness of the ring. The default is 0.25.
|
3514
|
+
direction : list , optional
|
3515
|
+
The vector representing the up direction of the ring. The default is [0, 0, 1].
|
3516
|
+
placement : str , optional
|
3517
|
+
The description of the placement of the origin of the ring. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
|
3518
|
+
tolerance : float , optional
|
3519
|
+
The desired tolerance. The default is 0.0001.
|
3520
|
+
silent : bool , optional
|
3521
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
3522
|
+
|
3523
|
+
Returns
|
3524
|
+
-------
|
3525
|
+
topologic_core.Face
|
3526
|
+
The created face.
|
3527
|
+
|
3528
|
+
"""
|
3529
|
+
|
3530
|
+
if thickness >= radius:
|
3531
|
+
if not silent:
|
3532
|
+
print("Face.Ring - Error: The thickness value is larger than or equal to the outer radius value. Returning None.")
|
3533
|
+
return None
|
3534
|
+
return Face.CHS(origin=origin,
|
3535
|
+
radius=radius,
|
3536
|
+
thickness=thickness,
|
3537
|
+
sides=sides,
|
3538
|
+
direction=direction,
|
3539
|
+
placement=placement,
|
3540
|
+
tolerance=tolerance,
|
3541
|
+
silent=silent)
|
3542
|
+
@staticmethod
|
3543
|
+
def SHS(origin= None, size: float = 1.0, thickness: float = 0.25, outerFillet: float = 0.0, innerFillet: float = 0.0, sides: int = 16, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001, silent: bool = False):
|
3544
|
+
"""
|
3545
|
+
Creates a square hollow section (SHS).
|
3546
|
+
|
3547
|
+
Parameters
|
3548
|
+
----------
|
3549
|
+
origin : topologic_core.Vertex, optional
|
3550
|
+
The location of the origin of the SHS. The default is None which results in the SHS being placed at (0, 0, 0).
|
3551
|
+
size : float , optional
|
3552
|
+
The outer size of the SHS. The default is 1.0.
|
3553
|
+
thickness : float , optional
|
3554
|
+
The thickness of the SHS. The default is 0.25.
|
3555
|
+
outerFillet : float , optional
|
3556
|
+
The outer fillet multiplication factor based on the thickness (e.g. 1t). The default is 0.
|
3557
|
+
innerFillet : float , optional
|
3558
|
+
The inner fillet multiplication factor based on the thickness (e.g. 1.5t). The default is 0.
|
3559
|
+
sides : int , optional
|
3560
|
+
The desired number of sides of the fillets. The default is 16.
|
3561
|
+
direction : list , optional
|
3562
|
+
The vector representing the up direction of the SHS. The default is [0, 0, 1].
|
3563
|
+
placement : str , optional
|
3564
|
+
The description of the placement of the origin of the SHS. This can be "center", "lowerleft", "upperleft", "lowerright", "upperright". It is case insensitive. The default is "center".
|
3565
|
+
tolerance : float , optional
|
3566
|
+
The desired tolerance. The default is 0.0001.
|
3567
|
+
silent : bool , optional
|
3568
|
+
If set to True, no error and warning messages are printed. Otherwise, they are. The default is False.
|
3569
|
+
|
3570
|
+
Returns
|
3571
|
+
-------
|
3572
|
+
topologic_core.Face
|
3573
|
+
The created face.
|
3574
|
+
|
3575
|
+
"""
|
3576
|
+
from topologicpy.Vertex import Vertex
|
3577
|
+
from topologicpy.Wire import Wire
|
3578
|
+
from topologicpy.Topology import Topology
|
3579
|
+
|
3580
|
+
if 2*thickness >= size:
|
3581
|
+
if not silent:
|
3582
|
+
print("Face.SHS - Error: Twice the thickness value is larger than or equal to the outer size value. Returning None.")
|
3583
|
+
return None
|
3584
|
+
fillet_dimension = 2*outerFillet*thickness
|
3585
|
+
if fillet_dimension > size:
|
3586
|
+
if not silent:
|
3587
|
+
print("Face.RHS = Error: The outer fillet radius input value is too large given the desired dimensions of the RHS. Returning None.")
|
3588
|
+
return None
|
3589
|
+
inner_dimension = size - 2*thickness
|
3590
|
+
fillet_dimension = 2*innerFillet*thickness
|
3591
|
+
if fillet_dimension > inner_dimension:
|
3592
|
+
if not silent:
|
3593
|
+
print("Face.RHS = Error: The inner fillet radius input value is too large given the desired dimensions of the RHS. Returning None.")
|
3594
|
+
return None
|
3595
|
+
if origin == None:
|
3596
|
+
origin = Vertex.Origin()
|
3597
|
+
|
3598
|
+
return Face.RHS(origin = origin, width = size, length = size, thickness = thickness, outerFillet = outerFillet, innerFillet = innerFillet, sides = sides, direction = direction, placement = placement, tolerance = tolerance, silent = silent)
|
3599
|
+
|
3317
3600
|
@staticmethod
|
3318
3601
|
def Simplify(face, tolerance=0.0001):
|
3319
3602
|
"""
|