topologicpy 0.7.15__py3-none-any.whl → 0.7.18__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
@@ -377,6 +377,8 @@ class Cell():
377
377
  If set to True, the last wire in the list of input wires will be connected to the first wire in the list of input wires. The default is False.
378
378
  triangulate : bool , optional
379
379
  If set to True, the faces will be triangulated. The default is True.
380
+ planarize : bool, optional
381
+ If set to True, the created faces are planarized before building the cell. Otherwise, they are not. The default is False.
380
382
  mantissa : int , optional
381
383
  The desired length of the mantissa. The default is 6.
382
384
  tolerance : float , optional
@@ -858,8 +860,7 @@ class Cell():
858
860
 
859
861
  baseWire = Wire.Circle(origin=circle_origin, radius=radius, sides=uSides, fromAngle=0, toAngle=360, close=True, direction=[0, 0, 1], placement="center", tolerance=tolerance)
860
862
  baseFace = Face.ByWire(baseWire, tolerance=tolerance)
861
- cylinder = Cell.ByThickenedFace(face=baseFace, thickness=height, bothSides=False, reverse=True,
862
- tolerance=tolerance)
863
+ cylinder = Cell.ByThickenedFace(face=baseFace, thickness=height, bothSides=False, tolerance=tolerance)
863
864
  if vSides > 1:
864
865
  cutting_planes = []
865
866
  baseX = Vertex.X(origin, mantissa=mantissa) + xOffset
@@ -909,7 +910,7 @@ class Cell():
909
910
  from topologicpy.Topology import Topology
910
911
 
911
912
  def angleCode(f, up, tiltAngle):
912
- dirA = Face.NormalAtParameters(f)
913
+ dirA = Face.Normal(f)
913
914
  ang = round(Vector.Angle(dirA, up), 2)
914
915
  if abs(ang - 90) < tiltAngle:
915
916
  code = 0
@@ -1032,14 +1033,14 @@ class Cell():
1032
1033
  cluster = Cluster.ByTopologies(pentagons)
1033
1034
 
1034
1035
  cluster2 = Topology.Rotate(cluster, origin=Vertex.Origin(), axis=[1, 0, 0], angle=180)
1035
- cluster2 = Topology.Rotate(cluster2, origin=Vertex.Origin(), axis=[0, 0, 1], angle=36)
1036
- vertices = Topology.Vertices(cluster2)
1036
+ #cluster2 = Topology.Rotate(cluster2, origin=Vertex.Origin(), axis=[0, 0, 1], angle=36)
1037
+ vertices = Topology.Vertices(cluster)
1037
1038
  zList = [Vertex.Z(v) for v in vertices]
1038
1039
  zList = list(set(zList))
1039
1040
  zList.sort()
1040
- zoffset1 = zList[-1] - zList[0]
1041
- zoffset2 = zList[1] - zList[0]
1042
- cluster2 = Topology.Translate(cluster2, 0, 0, -zoffset1-zoffset2)
1041
+ zoffset = zList[1] - zList[0]
1042
+ total_height = zList[-1] - zList[0]
1043
+ cluster2 = Topology.Translate(cluster2, 0, 0, total_height+zoffset)
1043
1044
  pentagons += Topology.Faces(cluster2)
1044
1045
  dodecahedron = Cell.ByFaces(pentagons, tolerance=tolerance)
1045
1046
  centroid = Topology.Centroid(dodecahedron)
@@ -1052,6 +1053,12 @@ class Cell():
1052
1053
  elif placement == "lowerleft":
1053
1054
  dodecahedron = Topology.Translate(dodecahedron, radius, radius, radius)
1054
1055
 
1056
+ geo = Topology.Geometry(dodecahedron)
1057
+ vertices = [Vertex.ByCoordinates(coords) for coords in geo['vertices']]
1058
+ vertices = Vertex.Fuse(vertices)
1059
+ coords = [Vertex.Coordinates(v) for v in vertices]
1060
+ dodecahedron = Topology.RemoveCoplanarFaces(Topology.SelfMerge(Topology.ByGeometry(vertices=coords, faces=geo['faces'])))
1061
+ print(dodecahedron)
1055
1062
  dodecahedron = Topology.Orient(dodecahedron, origin=Vertex.Origin(), dirA=[0, 0, 1], dirB=direction, tolerance=tolerance)
1056
1063
  dodecahedron = Topology.Place(dodecahedron, originA=Vertex.Origin(), originB=origin)
1057
1064
  return dodecahedron
@@ -1393,7 +1400,7 @@ class Cell():
1393
1400
 
1394
1401
  icosahedron = Cell.ByFaces([f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,
1395
1402
  f11,f12,f13,f14,f15,f16,f17,f18,f19,f20], tolerance=tolerance)
1396
- sf = 1.051*0.5 # To insribe it in a sphere of radius 0.5
1403
+ sf = 1.051*0.5 # To inscribe it in a sphere of radius 0.5
1397
1404
  icosahedron = Topology.Scale(icosahedron, origin=Vertex.Origin(), x=sf, y=sf, z=sf)
1398
1405
  sf = radius/0.5
1399
1406
  icosahedron = Topology.Scale(icosahedron, origin=Vertex.Origin(), x=sf, y=sf, z=sf)
@@ -1823,7 +1830,7 @@ class Cell():
1823
1830
  ----------
1824
1831
  face : topologic_core.Face
1825
1832
  The input face.
1826
- angle : float , optioal
1833
+ angle : float , optional
1827
1834
  The desired angle in degrees of the roof. The default is 45.
1828
1835
  epsilon : float , optional
1829
1836
  The desired epsilon (another form of tolerance for distance from plane). The default is 0.01. (This is set to a larger number as it was found to work better)
@@ -1865,7 +1872,7 @@ class Cell():
1865
1872
  Returns
1866
1873
  -------
1867
1874
  list
1868
- The classified list of input cells based on their encolsure within the input list of super cells.
1875
+ The classified list of input cells based on their enclosure within the input list of super cells.
1869
1876
 
1870
1877
  """
1871
1878
 
@@ -1972,7 +1979,7 @@ class Cell():
1972
1979
  if not Topology.IsInstance(origin, "Vertex"):
1973
1980
  print("Cell.Sphere - Error: The input origin parameter is not a valid topologic vertex. Returning None.")
1974
1981
  return None
1975
- c = Wire.Circle(origin=Vertex.Origin(), radius=radius, sides=vSides, fromAngle=-90, toAngle=90, close=False, direction=[0, 0, 1], placement="center")
1982
+ c = Wire.Circle(origin=Vertex.Origin(), radius=radius, sides=vSides, fromAngle=0, toAngle=180, close=False, direction=[0, 0, 1], placement="center")
1976
1983
  c = Topology.Rotate(c, origin=Vertex.Origin(), axis=[1, 0, 0], angle=90)
1977
1984
  sphere = Topology.Spin(c, origin=Vertex.Origin(), triangulate=False, direction=[0, 0, 1], angle=360, sides=uSides, tolerance=tolerance)
1978
1985
  if Topology.Type(sphere) == Topology.TypeID("CellComplex"):
@@ -467,7 +467,7 @@ class CellComplex():
467
467
  from topologicpy.Topology import Topology
468
468
 
469
469
  def angleCode(f, up, tiltAngle):
470
- dirA = Face.NormalAtParameters(f)
470
+ dirA = Face.Normal(f)
471
471
  ang = round(Vector.Angle(dirA, up), 2)
472
472
  if abs(ang - 90) < tiltAngle:
473
473
  code = 0
@@ -1132,9 +1132,9 @@ class CellComplex():
1132
1132
  vertices = Topology.Vertices(cell)
1133
1133
  else:
1134
1134
  vertices += Topology.Vertices(cell)
1135
- vertices = [v for v in vertices if (Vertex.IsInternal(v, cell) or not Vertex.Index(v, Topology.Vertices(cell)) == None)]
1135
+ vertices = [v for v in vertices if (Vertex.IsInternal(v, cell) or not Vertex.Index(v, Topology.Vertices(cell), tolerance=tolerance) == None)]
1136
1136
  if len(vertices) < 1:
1137
- print("CellComplex.Voronoi - Error: The input vertices parame ter does not contain any vertices that are inside the input cell parameter. Returning None.")
1137
+ print("CellComplex.Voronoi - Error: The input vertices parameter does not contain any vertices that are inside the input cell parameter. Returning None.")
1138
1138
  return None
1139
1139
  voronoi_points = np.array([Vertex.Coordinates(v) for v in vertices])
1140
1140
  cluster = fracture_with_voronoi(voronoi_points)
topologicpy/DGL.py CHANGED
@@ -92,7 +92,7 @@ except:
92
92
  from dgl import save_graphs, load_graphs
93
93
  print("DGL - dgl library installed correctly.")
94
94
  except:
95
- warnings.warn("DGL - Error: Could not import dgl. The installation of the correct version of the dgl library is not trivial and is highly dependent on your hardward and software configuration. Please consult the dgl installation instructions.")
95
+ warnings.warn("DGL - Error: Could not import dgl. The installation of the correct version of the dgl library is not trivial and is highly dependent on your hardware and software configuration. Please consult the dgl installation instructions.")
96
96
 
97
97
  try:
98
98
  from tqdm.auto import tqdm
topologicpy/Edge.py CHANGED
@@ -84,13 +84,39 @@ class Edge():
84
84
  The created bisecting edge.
85
85
 
86
86
  """
87
- import numpy as np
88
-
87
+ from topologicpy.Vertex import Vertex
89
88
  from topologicpy.Wire import Wire
90
89
  from topologicpy.Cluster import Cluster
91
90
  from topologicpy.Topology import Topology
92
91
  from topologicpy.Vector import Vector
92
+ import numpy as np
93
93
 
94
+
95
+ def process_edges(edge1, edge2, tolerance=0.0001):
96
+ start1 = Edge.StartVertex(edge1)
97
+ end1 = Edge.EndVertex(edge1)
98
+ start2 = Edge.StartVertex(edge2)
99
+ end2 = Edge.EndVertex(edge2)
100
+
101
+ shared_vertex = None
102
+
103
+ if Vertex.Distance(start1, start2) < tolerance:
104
+ shared_vertex = start1
105
+ elif Vertex.Distance(start1, end2) < tolerance:
106
+ shared_vertex = start1
107
+ edge2 = Edge.Reverse(edge2)
108
+ elif Vertex.Distance(end1, start2) < tolerance:
109
+ shared_vertex = start2
110
+ edge1 = Edge.Reverse(edge1)
111
+ elif Vertex.Distance(end1, end2) < tolerance:
112
+ shared_vertex = end1
113
+ edge1 = Edge.Reverse(edge1)
114
+ edge2 = Edge.Reverse(edge2)
115
+
116
+ if shared_vertex is None:
117
+ return [None, None]
118
+ return edge1, edge2
119
+
94
120
  if not Topology.IsInstance(edgeA, "Edge"):
95
121
  print("Edge.Bisect - Error: The input edgeA parameter is not a valid topologic edge. Returning None.")
96
122
  return None
@@ -104,21 +130,21 @@ class Edge():
104
130
  print("Edge.Bisect - Error: The input edgeB parameter is shorter than the input tolerance parameter. Returning None.")
105
131
  return None
106
132
 
107
- wire = Topology.SelfMerge(Cluster.ByTopologies([edgeA, edgeB]), tolerance=tolerance)
108
- if not Topology.IsInstance(wire, "Wire"):
133
+
134
+ edge1, edge2 = process_edges(edgeA, edgeB, tolerance=tolerance)
135
+ if edge1 == None or edge2 == None:
109
136
  print("Edge.Bisect - Error: The input edgeA and edgeB parameters do not share a vertex and thus cannot be bisected. Returning None.")
110
137
  return None
111
- edges = Topology.Edges(wire)
112
- edgeA = edges[0]
113
- edgeB = edges[1]
114
-
115
- sv = Wire.Vertices(wire)[1]
116
-
117
- dirA = Edge.Direction(edgeA)
118
- dirB = Edge.Direction(edgeB)
119
- bisecting_vector = Vector.Bisect(dirA, dirB)
138
+ sv = Edge.StartVertex(edge1)
139
+ dir1 = Edge.Direction(edge1)
140
+ dir2 = Edge.Direction(edge2)
141
+ bisecting_vector = Vector.Bisect(dir1, dir2)
120
142
  ev = Topology.TranslateByDirectionDistance(sv, bisecting_vector, length)
121
143
  bisecting_edge = Edge.ByVertices([sv, ev])
144
+ if placement == 0:
145
+ bisecting_edge = Topology.TranslateByDirectionDistance(bisecting_edge, Vector.Reverse(bisecting_vector), length*0.5)
146
+ elif placement == 2:
147
+ bisecting_edge = Topology.TranslateByDirectionDistance(bisecting_edge, Vector.Reverse(bisecting_vector), length)
122
148
  return bisecting_edge
123
149
 
124
150
  @staticmethod
@@ -130,7 +156,7 @@ class Edge():
130
156
  ----------
131
157
  face : topologic_core.Face
132
158
  The input face
133
- origin : toopologic.Vertex , optional
159
+ origin : topologic_core.Vertex , optional
134
160
  The desired origin of the edge. If set to None, the centroid of the face is chosen as the origin of the edge. The default is None.
135
161
  length : float , optional
136
162
  The desired length of the edge. The default is 1.
@@ -178,7 +204,7 @@ class Edge():
178
204
  The input edge.
179
205
  offset : float , optional
180
206
  The desired offset. The default is 1.
181
- tolerance : float , optiona
207
+ tolerance : float , optional
182
208
  The desired tolerance. The default is 0.0001.
183
209
 
184
210
  Returns
@@ -206,7 +232,7 @@ class Edge():
206
232
  ----------
207
233
  vertexA : topologic_core.Vertex
208
234
  The first input vertex. This is considered the start vertex.
209
- vertexB : toopologic.Vertex
235
+ vertexB : topologic_core.Vertex
210
236
  The second input vertex. This is considered the end vertex.
211
237
  tolerance : float , optional
212
238
  The desired tolerance to decide if an Edge can be created. The default is 0.0001.
@@ -481,7 +507,7 @@ class Edge():
481
507
  if not silent:
482
508
  print("Edge.ExtendToEdge - Error: The input edges are not coplanar. Returning the original edge.")
483
509
  return edgeA
484
- if not Edge.IsParallel(edgeA, edgeB, tolerance=tolerance):
510
+ if Edge.IsParallel(edgeA, edgeB, tolerance=tolerance):
485
511
  if not silent:
486
512
  print("Edge.ExtendToEdge - Error: The input edges are parallel. Returning the original edge.")
487
513
  return edgeA
@@ -789,8 +815,8 @@ class Edge():
789
815
 
790
816
  x1, y1, z1 = Vertex.Coordinates(Edge.StartVertex(edgeA), mantissa=mantissa)
791
817
  x2, y2, z2 = Vertex.Coordinates(Edge.EndVertex(edgeA), mantissa=mantissa)
792
- x3, y3, z3 = Vertex.Coordinates(Edge.StartVertex(edgeA), mantissa=mantissa)
793
- x4, y4, z4 = Vertex.Coordinates(Edge.EndVertex(edgeA), mantissa=mantissa)
818
+ x3, y3, z3 = Vertex.Coordinates(Edge.StartVertex(edgeB), mantissa=mantissa)
819
+ x4, y4, z4 = Vertex.Coordinates(Edge.EndVertex(edgeB), mantissa=mantissa)
794
820
  line1 = ((x1, y1, z1), (x2, y2, z2))
795
821
  line2 = ((x3, y3, z3), (x4, y4, z4))
796
822
  return are_lines_parallel(line1, line2, tolerance=tolerance)
@@ -1239,7 +1265,7 @@ class Edge():
1239
1265
  if not silent:
1240
1266
  print("Edge.TrimByEdge - Error: The input edges are not coplanar. Returning the original edge.")
1241
1267
  return edgeA
1242
- if not Edge.IsParallel(edgeA, edgeB, tolerance=tolerance):
1268
+ if Edge.IsParallel(edgeA, edgeB, tolerance=tolerance):
1243
1269
  if not silent:
1244
1270
  print("Edge.TrimByEdge - Error: The input edges are parallel. Returning the original edge.")
1245
1271
  return edgeA