topologicpy 0.7.4__py3-none-any.whl → 0.7.6__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/Plotly.py CHANGED
@@ -272,7 +272,23 @@ class Plotly:
272
272
  return df
273
273
 
274
274
  @staticmethod
275
- def DataByGraph(graph, vertexColor="black", vertexSize=6, vertexLabelKey=None, vertexGroupKey=None, vertexGroups=[], showVertices=True, showVertexLegend=False, edgeColor="black", edgeWidth=1, edgeLabelKey=None, edgeGroupKey=None, edgeGroups=[], showEdges=True, showEdgeLegend=False, colorScale="viridis"):
275
+ def DataByGraph(graph,
276
+ vertexColor: str = "black",
277
+ vertexSize: float = 6,
278
+ vertexLabelKey: str = None,
279
+ vertexGroupKey: str = None,
280
+ vertexGroups: list = [],
281
+ showVertices: bool = True,
282
+ showVertexLegend: bool = False,
283
+ edgeColor: str = "black",
284
+ edgeWidth: float = 1,
285
+ edgeLabelKey: str = None,
286
+ edgeGroupKey: str = None,
287
+ edgeGroups: list = [],
288
+ showEdges: bool = True,
289
+ showEdgeLegend: bool = False,
290
+ colorScale: str = "viridis",
291
+ mantissa: int = 6):
276
292
  """
277
293
  Creates plotly vertex and edge data from the input graph.
278
294
 
@@ -344,9 +360,9 @@ class Plotly:
344
360
  vertices = Graph.Vertices(graph)
345
361
  if vertexLabelKey or vertexGroupKey:
346
362
  for v in vertices:
347
- Xn=[round(Vertex.X(v), 4) for v in vertices] # x-coordinates of nodes
348
- Yn=[round(Vertex.Y(v), 4) for v in vertices] # y-coordinates of nodes
349
- Zn=[round(Vertex.Z(v), 4) for v in vertices] # x-coordinates of nodes
363
+ Xn=[Vertex.X(v, mantissa=mantissa) for v in vertices] # x-coordinates of nodes
364
+ Yn=[Vertex.Y(v, mantissa=mantissa) for v in vertices] # y-coordinates of nodes
365
+ Zn=[Vertex.Z(v, mantissa=mantissa) for v in vertices] # x-coordinates of nodes
350
366
  v_label = ""
351
367
  v_group = ""
352
368
  d = Topology.Dictionary(v)
@@ -371,9 +387,9 @@ class Plotly:
371
387
  v_labels.append(v_label)
372
388
  else:
373
389
  for v in vertices:
374
- Xn=[round(Vertex.X(v), 4) for v in vertices] # x-coordinates of nodes
375
- Yn=[round(Vertex.Y(v), 4) for v in vertices] # y-coordinates of nodes
376
- Zn=[round(Vertex.Z(v), 4) for v in vertices] # x-coordinates of nodes
390
+ Xn=[Vertex.X(v, mantissa=mantissa) for v in vertices] # x-coordinates of nodes
391
+ Yn=[Vertex.Y(v, mantissa=mantissa) for v in vertices] # y-coordinates of nodes
392
+ Zn=[Vertex.Z(v, mantissa=mantissa) for v in vertices] # x-coordinates of nodes
377
393
  if len(list(set(v_groupList))) < 2:
378
394
  v_groupList = vertexColor
379
395
  if len(v_labels) < 1:
@@ -409,9 +425,9 @@ class Plotly:
409
425
  for e in edges:
410
426
  sv = Edge.StartVertex(e)
411
427
  ev = Edge.EndVertex(e)
412
- Xe+=[round(Vertex.X(sv), 4), round(Vertex.X(ev), 4), None] # x-coordinates of edge ends
413
- Ye+=[round(Vertex.Y(sv), 4), round(Vertex.Y(ev), 4), None] # y-coordinates of edge ends
414
- Ze+=[round(Vertex.Z(sv), 4), round(Vertex.Z(ev), 4), None] # z-coordinates of edge ends
428
+ Xe+=[Vertex.X(sv, mantissa=mantissa), Vertex.X(ev, mantissa=mantissa), None] # x-coordinates of edge ends
429
+ Ye+=[Vertex.Y(sv, mantissa=mantissa), Vertex.Y(ev, mantissa=mantissa), None] # y-coordinates of edge ends
430
+ Ze+=[Vertex.Z(sv, mantissa=mantissa), Vertex.Z(ev, mantissa=mantissa), None] # z-coordinates of edge ends
415
431
  e_label = ""
416
432
  e_group = ""
417
433
  d = Topology.Dictionary(e)
@@ -435,9 +451,9 @@ class Plotly:
435
451
  for e in edges:
436
452
  sv = Edge.StartVertex(e)
437
453
  ev = Edge.EndVertex(e)
438
- Xe+=[round(Vertex.X(sv), 4), round(Vertex.X(ev), 4), None] # x-coordinates of edge ends
439
- Ye+=[round(Vertex.Y(sv), 4), round(Vertex.Y(ev), 4), None] # y-coordinates of edge ends
440
- Ze+=[round(Vertex.Z(sv), 4), round(Vertex.Z(ev), 4), None] # z-coordinates of edge ends
454
+ Xe+=[Vertex.X(sv, mantissa=mantissa), Vertex.X(ev, mantissa=mantissa), None] # x-coordinates of edge ends
455
+ Ye+=[Vertex.Y(sv, mantissa=mantissa), Vertex.Y(ev, mantissa=mantissa), None] # y-coordinates of edge ends
456
+ Ze+=[Vertex.Z(sv, mantissa=mantissa), Vertex.Z(ev, mantissa=mantissa), None] # z-coordinates of edge ends
441
457
 
442
458
  if len(list(set(e_groupList))) < 2:
443
459
  e_groupList = edgeColor
@@ -460,14 +476,6 @@ class Plotly:
460
476
 
461
477
  return data
462
478
 
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
479
  @staticmethod
472
480
  def DataByTopology(topology,
473
481
  showVertices=True, vertexSize=1.1, vertexColor="black",
@@ -603,6 +611,9 @@ class Plotly:
603
611
  The vertex, edge, and face data list.
604
612
 
605
613
  """
614
+ from topologicpy.Vertex import Vertex
615
+ from topologicpy.Face import Face
616
+ from topologicpy.Cluster import Cluster
606
617
  from topologicpy.Topology import Topology
607
618
  from topologicpy.Dictionary import Dictionary
608
619
  from topologicpy.Color import Color
@@ -634,9 +645,9 @@ class Plotly:
634
645
  minGroup = 0
635
646
  maxGroup = 1
636
647
  for m, v in enumerate(vertices):
637
- x.append(round(v[0], mantissa))
638
- y.append(round(v[1], mantissa))
639
- z.append(round(v[2], mantissa))
648
+ x.append(v[0])
649
+ y.append(v[1])
650
+ z.append(v[2])
640
651
  label = ""
641
652
  group = ""
642
653
  if len(dictionaries) > 0:
@@ -666,9 +677,9 @@ class Plotly:
666
677
  labels.append(label)
667
678
  else:
668
679
  for v in vertices:
669
- x.append(round(v[0], mantissa))
670
- y.append(round(v[1], mantissa))
671
- z.append(round(v[2], mantissa))
680
+ x.append(v[0])
681
+ y.append(v[1])
682
+ z.append(v[2])
672
683
 
673
684
  if len(list(set(groupList))) < 2:
674
685
  groupList = color
@@ -714,9 +725,9 @@ class Plotly:
714
725
  for m, e in enumerate(edges):
715
726
  sv = vertices[e[0]]
716
727
  ev = vertices[e[1]]
717
- x+=[round(sv[0], mantissa),round(ev[0], mantissa), None] # x-coordinates of edge ends
718
- y+=[round(sv[1], mantissa),round(ev[1], mantissa), None] # y-coordinates of edge ends
719
- z+=[round(sv[2], mantissa),round(ev[2], mantissa), None] # z-coordinates of edge ends
728
+ x+=[sv[0], ev[0], None] # x-coordinates of edge ends
729
+ y+=[sv[1], ev[1], None] # y-coordinates of edge ends
730
+ z+=[sv[2], ev[2], None] # z-coordinates of edge ends
720
731
  label = ""
721
732
  group = ""
722
733
  if len(dictionaries) > 0:
@@ -748,9 +759,9 @@ class Plotly:
748
759
  for e in edges:
749
760
  sv = vertices[e[0]]
750
761
  ev = vertices[e[1]]
751
- x+=[round(sv[0],mantissa),round(ev[0],mantissa), None] # x-coordinates of edge ends
752
- y+=[round(sv[1],mantissa),round(ev[1],mantissa), None] # y-coordinates of edge ends
753
- z+=[round(sv[2],mantissa),round(ev[2],mantissa), None] # z-coordinates of edge ends
762
+ x+=[sv[0], ev[0], None] # x-coordinates of edge ends
763
+ y+=[sv[1], ev[1], None] # y-coordinates of edge ends
764
+ z+=[sv[2], ev[2], None] # z-coordinates of edge ends
754
765
 
755
766
  if len(list(set(groupList))) < 2:
756
767
  groupList = color
@@ -779,9 +790,9 @@ class Plotly:
779
790
  y = []
780
791
  z = []
781
792
  for v in vertices:
782
- x.append(round(v[0], mantissa))
783
- y.append(round(v[1], mantissa))
784
- z.append(round(v[2], mantissa))
793
+ x.append(v[0])
794
+ y.append(v[1])
795
+ z.append(v[2])
785
796
  i = []
786
797
  j = []
787
798
  k = []
@@ -870,12 +881,6 @@ class Plotly:
870
881
  lighting = {"facenormalsepsilon": 0},
871
882
  )
872
883
  return fData
873
-
874
- from topologicpy.Face import Face
875
- from topologicpy.Cluster import Cluster
876
- from topologicpy.Topology import Topology
877
- from topologicpy.Dictionary import Dictionary
878
- from time import time
879
884
 
880
885
  if not Topology.IsInstance(topology, "Topology"):
881
886
  return None
@@ -901,7 +906,7 @@ class Plotly:
901
906
 
902
907
  if intensityKey:
903
908
  for i, tp_v in enumerate(tp_vertices):
904
- vertices.append([tp_v.X(), tp_v.Y(), tp_v.Z()])
909
+ vertices.append([Vertex.X(tp_v, mantissa=mantissa), Vertex.Y(tp_v, mantissa=mantissa), Vertex.Z(tp_v, mantissa=mantissa)])
905
910
  d = Topology.Dictionary(tp_v)
906
911
  if d:
907
912
  v = Dictionary.ValueAtKey(d, key=intensityKey)
@@ -938,7 +943,7 @@ class Plotly:
938
943
  if vertexLabelKey or vertexGroupKey:
939
944
  d = Topology.Dictionary(tp_v)
940
945
  v_dictionaries.append(d)
941
- vertices.append([tp_v.X(), tp_v.Y(), tp_v.Z()])
946
+ vertices.append([Vertex.X(tp_v, mantissa=mantissa), Vertex.Y(tp_v, mantissa=mantissa), Vertex.Z(tp_v, mantissa=mantissa)])
942
947
  data.append(vertexData(vertices, dictionaries=v_dictionaries, color=vertexColor, size=vertexSize, labelKey=vertexLabelKey, groupKey=vertexGroupKey, minGroup=vertexMinGroup, maxGroup=vertexMaxGroup, groups=vertexGroups, legendLabel=vertexLegendLabel, legendGroup=vertexLegendGroup, legendRank=vertexLegendRank, showLegend=showVertexLegend, colorScale=colorScale))
943
948
 
944
949
  if showEdges and Topology.Type(topology) > Topology.TypeID("Vertex"):
@@ -963,24 +968,6 @@ class Plotly:
963
968
  else:
964
969
  tp_faces = Topology.Faces(topology)
965
970
  if not(tp_faces == None or tp_faces == []):
966
- # rebuild faces to remove any degenerate faces
967
- #new_faces = []
968
- #for i, f in enumerate(tp_faces):
969
- #eb = Face.ExternalBoundary(f)
970
- #eb = Topology.RemoveCollinearEdges(eb)
971
- #if not eb == None:
972
- #ibList = Face.InternalBoundaries(f)
973
- #ibList = [Wire.RemoveCollinearEdges(ib) for ib in ibList]
974
- #ibList = [ib for ib in ibList if not ib == None]
975
- #new_f = Face.ByWires(eb, ibList, silent=False)
976
- #if Topology.IsInstance(new_f, "Face"):
977
- #if faceLabelKey or faceGroupKey:
978
- #d = Topology.Dictionary(tp_faces[i])
979
- #keys = Dictionary.Keys(d)
980
- #if len(keys) > 0:
981
- #new_f = Topology.SetDictionary(new_f, d)
982
- #new_faces.append(new_f)
983
-
984
971
  f_dictionaries = []
985
972
  all_triangles = []
986
973
  for tp_face in tp_faces:
topologicpy/Shell.py CHANGED
@@ -50,7 +50,16 @@ except:
50
50
 
51
51
  class Shell():
52
52
  @staticmethod
53
- def ByDisjointFaces(externalBoundary, faces, maximumGap=0.5, mergeJunctions=False, threshold=0.5, uSides=1, vSides=1, transferDictionaries=False, tolerance=0.0001):
53
+ def ByDisjointFaces(externalBoundary,
54
+ faces,
55
+ maximumGap: float = 0.5,
56
+ mergeJunctions: bool = False,
57
+ threshold: float = 0.5,
58
+ uSides: int = 1,
59
+ vSides: int = 1,
60
+ transferDictionaries: bool = False,
61
+ mantissa: int = 6,
62
+ tolerance: float = 0.0001):
54
63
  """
55
64
  Creates a shell from an input list of disjointed faces. THIS IS STILL EXPERIMENTAL
56
65
 
@@ -72,6 +81,8 @@ class Shell():
72
81
  The desired number of sides along the Y axis for the grid that subdivides the input faces to aid in processing. The default is 1.
73
82
  transferDictionaries : bool, optional.
74
83
  If set to True, the dictionaries in the input list of faces are transfered to the faces of the resulting shell. The default is False.
84
+ mantissa : int , optional
85
+ The desired length of the mantissa. The default is 6.
75
86
  tolerance : float , optional
76
87
  The desired tolerance. The default is 0.0001.
77
88
 
@@ -177,7 +188,7 @@ class Shell():
177
188
  for v in vertices:
178
189
  for w in vertices:
179
190
  if not Topology.IsSame(v, w) and not w in used:
180
- if Vertex.Distance(v, w) < threshold:
191
+ if Vertex.Distance(v, w, mantissa=mantissa) < threshold:
181
192
  centers.append(v)
182
193
  used.append(w)
183
194
  edges = Shell.Edges(shell)
@@ -186,9 +197,9 @@ class Shell():
186
197
  sv = Edge.StartVertex(e)
187
198
  ev = Edge.EndVertex(e)
188
199
  for v in centers:
189
- if Vertex.Distance(sv, v) < threshold:
200
+ if Vertex.Distance(sv, v, mantissa=mantissa) < threshold:
190
201
  sv = v
191
- if Vertex.Distance(ev, v) < threshold:
202
+ if Vertex.Distance(ev, v, mantissa=mantissa) < threshold:
192
203
  ev = v
193
204
  new_edges.append(Edge.ByVertices([sv,ev], tolerance=tolerance))
194
205
  cluster = Cluster.ByTopologies(new_edges)
@@ -196,10 +207,10 @@ class Shell():
196
207
  vertices = Topology.Vertices(cluster)
197
208
  edges = Topology.Edges(shell)
198
209
 
199
- xList = list(set([Vertex.X(v) for v in vertices]))
210
+ xList = list(set([Vertex.X(v, mantissa=mantissa) for v in vertices]))
200
211
  xList.sort()
201
212
  xList = Helper.MergeByThreshold(xList, 0.5)
202
- yList = list(set([Vertex.Y(v) for v in vertices]))
213
+ yList = list(set([Vertex.Y(v, mantissa=mantissa) for v in vertices]))
203
214
  yList.sort()
204
215
  yList = Helper.MergeByThreshold(yList, 0.5)
205
216
  yList.sort()
@@ -211,10 +222,10 @@ class Shell():
211
222
  for e in edges:
212
223
  sv = Edge.StartVertex(e)
213
224
  ev = Edge.EndVertex(e)
214
- svx = Vertex.X(sv)
215
- svy = Vertex.Y(sv)
216
- evx = Vertex.X(ev)
217
- evy = Vertex.Y(ev)
225
+ svx = Vertex.X(sv, mantissa=mantissa)
226
+ svy = Vertex.Y(sv, mantissa=mantissa)
227
+ evx = Vertex.X(ev, mantissa=mantissa)
228
+ evy = Vertex.Y(ev, mantissa=mantissa)
218
229
  for x in xList:
219
230
  if abs(svx-x) < threshold:
220
231
  svx = x
@@ -479,7 +490,7 @@ class Shell():
479
490
  return Shell.Pie(origin=origin, radiusA=radius, radiusB=0, sides=sides, rings=1, fromAngle=fromAngle, toAngle=toAngle, direction=direction, placement=placement, tolerance=tolerance)
480
491
 
481
492
  @staticmethod
482
- def Delaunay(vertices: list, face= None, tolerance: float = 0.0001):
493
+ def Delaunay(vertices: list, face= None, mantissa: int = 6, tolerance: float = 0.0001):
483
494
  """
484
495
  Returns a delaunay partitioning of the input vertices. The vertices must be coplanar. See https://en.wikipedia.org/wiki/Delaunay_triangulation.
485
496
 
@@ -489,6 +500,8 @@ class Shell():
489
500
  The input list of vertices.
490
501
  face : topologic_core.Face , optional
491
502
  The input face. If specified, the delaunay triangulation is clipped to the face.
503
+ mantissa : int , optional
504
+ The desired length of the mantissa. The default is 6.
492
505
  tolerance : float , optional
493
506
  The desired tolerance. The default is 0.0001.
494
507
 
@@ -503,10 +516,8 @@ class Shell():
503
516
  from topologicpy.Face import Face
504
517
  from topologicpy.Cluster import Cluster
505
518
  from topologicpy.Topology import Topology
506
- from topologicpy.Dictionary import Dictionary
507
519
  from random import sample
508
520
  from scipy.spatial import Delaunay as SCIDelaunay
509
- import numpy as np
510
521
 
511
522
  if not isinstance(vertices, list):
512
523
  return None
@@ -514,13 +525,11 @@ class Shell():
514
525
  if len(vertices) < 3:
515
526
  return None
516
527
 
517
- # Create a Vertex at the world's origin (0, 0, 0)
518
- world_origin = Vertex.Origin()
519
528
 
520
529
  if Topology.IsInstance(face, "Face"):
521
530
  # Flatten the face
522
531
  origin = Topology.Centroid(face)
523
- normal = Face.Normal(face)
532
+ normal = Face.Normal(face, mantissa=mantissa)
524
533
  flatFace = Topology.Flatten(face, origin=origin, direction=normal)
525
534
  faceVertices = Face.Vertices(face)
526
535
  vertices += faceVertices
@@ -534,7 +543,7 @@ class Shell():
534
543
  vertices = Cluster.Vertices(verticesCluster)
535
544
  points = []
536
545
  for v in vertices:
537
- points.append([Vertex.X(v), Vertex.Y(v)])
546
+ points.append([Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa)])
538
547
  delaunay = SCIDelaunay(points)
539
548
  simplices = delaunay.simplices
540
549
 
@@ -682,8 +691,17 @@ class Shell():
682
691
  return False
683
692
 
684
693
  @staticmethod
685
- def HyperbolicParaboloidRectangularDomain(origin= None, llVertex= None, lrVertex= None, ulVertex= None, urVertex= None,
686
- uSides: int = 10, vSides: int = 10, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
694
+ def HyperbolicParaboloidRectangularDomain(origin= None,
695
+ llVertex= None,
696
+ lrVertex= None,
697
+ ulVertex= None,
698
+ urVertex= None,
699
+ uSides: int = 10,
700
+ vSides: int = 10,
701
+ direction: list = [0, 0, 1],
702
+ placement: str = "center",
703
+ mantissa: int = 6,
704
+ tolerance: float = 0.0001):
687
705
  """
688
706
  Creates a hyperbolic paraboloid with a rectangular domain.
689
707
 
@@ -707,6 +725,8 @@ class Shell():
707
725
  The vector representing the up direction of the hyperbolic parabolid. The default is [0, 0, 1].
708
726
  placement : str , optional
709
727
  The description of the placement of the origin of the hyperbolic parabolid. This can be "center", "lowerleft", "bottom". It is case insensitive. The default is "center".
728
+ mantissa : int , optional
729
+ The desired length of the mantissa. The default is 6.
710
730
  tolerance : float , optional
711
731
  The desired tolerance. The default is 0.0001.
712
732
  Returns
@@ -751,12 +771,13 @@ class Shell():
751
771
  xOffset = 0
752
772
  yOffset = 0
753
773
  zOffset = 0
754
- minX = min([llVertex.X(), lrVertex.X(), ulVertex.X(), urVertex.X()])
755
- maxX = max([llVertex.X(), lrVertex.X(), ulVertex.X(), urVertex.X()])
756
- minY = min([llVertex.Y(), lrVertex.Y(), ulVertex.Y(), urVertex.Y()])
757
- maxY = max([llVertex.Y(), lrVertex.Y(), ulVertex.Y(), urVertex.Y()])
758
- minZ = min([llVertex.Z(), lrVertex.Z(), ulVertex.Z(), urVertex.Z()])
759
- maxZ = max([llVertex.Z(), lrVertex.Z(), ulVertex.Z(), urVertex.Z()])
774
+ minX = min([Vertex.X(llVertex, mantissa=mantissa), Vertex.X(lrVertex, mantissa=mantissa), Vertex.X(ulVertex, mantissa=mantissa), Vertex.X(urVertex, mantissa=mantissa)])
775
+ maxX = max([Vertex.X(llVertex, mantissa=mantissa), Vertex.X(lrVertex, mantissa=mantissa), Vertex.X(ulVertex, mantissa=mantissa), Vertex.X(urVertex, mantissa=mantissa)])
776
+ minY = min([Vertex.Y(llVertex, mantissa=mantissa), Vertex.Y(lrVertex, mantissa=mantissa), Vertex.Y(ulVertex, mantissa=mantissa), Vertex.Y(urVertex, mantissa=mantissa)])
777
+ maxY = max([Vertex.Y(llVertex, mantissa=mantissa), Vertex.Y(lrVertex, mantissa=mantissa), Vertex.Y(ulVertex, mantissa=mantissa), Vertex.Y(urVertex, mantissa=mantissa)])
778
+ minZ = min([Vertex.Z(llVertex, mantissa=mantissa), Vertex.Z(lrVertex, mantissa=mantissa), Vertex.Z(ulVertex, mantissa=mantissa), Vertex.Z(urVertex, mantissa=mantissa)])
779
+ maxZ = max([Vertex.Z(llVertex, mantissa=mantissa), Vertex.Z(lrVertex, mantissa=mantissa), Vertex.Z(ulVertex, mantissa=mantissa), Vertex.Z(urVertex, mantissa=mantissa)])
780
+
760
781
  if placement.lower() == "lowerleft":
761
782
  xOffset = -minX
762
783
  yOffset = -minY
@@ -777,7 +798,7 @@ class Shell():
777
798
  @staticmethod
778
799
  def HyperbolicParaboloidCircularDomain(origin= None, radius: float = 0.5, sides: int = 36, rings: int = 10,
779
800
  A: float = 2.0, B: float = -2.0, direction: list = [0, 0, 1],
780
- placement: str = "center", tolerance: float = 0.0001):
801
+ placement: str = "center", mantissa: int = 6, tolerance: float = 0.0001):
781
802
  """
782
803
  Creates a hyperbolic paraboloid with a circular domain. See https://en.wikipedia.org/wiki/Compactness_measure_of_a_shape
783
804
 
@@ -799,6 +820,8 @@ class Shell():
799
820
  The vector representing the up direction of the hyperbolic paraboloid. The default is [0, 0, 1].
800
821
  placement : str , optional
801
822
  The description of the placement of the origin of the circle. This can be "center", "lowerleft", "bottom". It is case insensitive. The default is "center".
823
+ mantissa : int , optional
824
+ The desired length of the mantissa. The default is 6
802
825
  tolerance : float , optional
803
826
  The desired tolerance. The default is 0.0001.
804
827
  Returns
@@ -907,9 +930,9 @@ class Shell():
907
930
  yList = []
908
931
  zList = []
909
932
  for aVertex in vertices:
910
- xList.append(aVertex.X())
911
- yList.append(aVertex.Y())
912
- zList.append(aVertex.Z())
933
+ xList.append(Vertex.X(aVertex, mantissa=mantissa))
934
+ yList.append(Vertex.Y(aVertex, mantissa=mantissa))
935
+ zList.append(Vertex.Z(aVertex, mantissa=mantissa))
913
936
  minX = min(xList)
914
937
  maxX = max(xList)
915
938
  minY = min(yList)
@@ -1251,7 +1274,7 @@ class Shell():
1251
1274
  return Shell.ByFaces(clean_faces, tolerance=tolerance)
1252
1275
 
1253
1276
  @staticmethod
1254
- def Roof(face, angle: float = 45, epsilon: float = 0.01, tolerance: float = 0.001):
1277
+ def Roof(face, angle: float = 45, epsilon: float = 0.01, mantissa: int = 6, tolerance: float = 0.001):
1255
1278
  """
1256
1279
  Creates a hipped roof through a straight skeleton. This method is contributed by 高熙鹏 xipeng gao <gaoxipeng1998@gmail.com>
1257
1280
  This algorithm depends on the polyskel code which is included in the library. Polyskel code is found at: https://github.com/Botffy/polyskel
@@ -1264,6 +1287,8 @@ class Shell():
1264
1287
  The desired angle in degrees of the roof. The default is 45.
1265
1288
  epsilon : float , optional
1266
1289
  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)
1290
+ manitssa : int , optional
1291
+ The desired length of the mantissa. The default is 6.
1267
1292
  tolerance : float , optional
1268
1293
  The desired tolerance. The default is 0.001. (This is set to a larger number as it was found to work better)
1269
1294
 
@@ -1277,19 +1302,15 @@ class Shell():
1277
1302
  from topologicpy.Wire import Wire
1278
1303
  from topologicpy.Face import Face
1279
1304
  from topologicpy.Shell import Shell
1280
- from topologicpy.Cell import Cell
1281
1305
  from topologicpy.Cluster import Cluster
1282
1306
  from topologicpy.Topology import Topology
1283
- from topologicpy.Dictionary import Dictionary
1284
- import topologic_core as topologic
1285
- import math
1286
1307
 
1287
1308
  def nearest_vertex_2d(v, vertices, tolerance=0.001):
1288
1309
  for vertex in vertices:
1289
- x2 = Vertex.X(vertex)
1290
- y2 = Vertex.Y(vertex)
1291
- temp_v = Vertex.ByCoordinates(x2, y2, Vertex.Z(v))
1292
- if Vertex.Distance(v, temp_v) <= tolerance:
1310
+ x2 = Vertex.X(vertex, mantissa=mantissa)
1311
+ y2 = Vertex.Y(vertex, mantissa=mantissa)
1312
+ temp_v = Vertex.ByCoordinates(x2, y2, Vertex.Z(v, mantissa=mantissa))
1313
+ if Vertex.Distance(v, temp_v, mantissa=mantissa) <= tolerance:
1293
1314
  return vertex
1294
1315
  return None
1295
1316
 
@@ -1301,7 +1322,7 @@ class Shell():
1301
1322
  if angle < tolerance:
1302
1323
  return None
1303
1324
  origin = Topology.Centroid(face)
1304
- normal = Face.Normal(face)
1325
+ normal = Face.Normal(face, mantissa=mantissa)
1305
1326
  flat_face = Topology.Flatten(face, origin=origin, direction=normal)
1306
1327
  roof = Wire.Roof(flat_face, angle=angle, tolerance=tolerance)
1307
1328
  if not roof:
@@ -1323,7 +1344,7 @@ class Shell():
1323
1344
  roof_vertices = Topology.Vertices(roof)
1324
1345
  flat_vertices = []
1325
1346
  for rv in roof_vertices:
1326
- flat_vertices.append(Vertex.ByCoordinates(Vertex.X(rv), Vertex.Y(rv), 0))
1347
+ flat_vertices.append(Vertex.ByCoordinates(Vertex.X(rv, mantissa=mantissa), Vertex.Y(rv, mantissa=mantissa), 0))
1327
1348
 
1328
1349
  final_triangles = []
1329
1350
  for triangle in triangles:
@@ -1473,7 +1494,7 @@ class Shell():
1473
1494
  return shell
1474
1495
 
1475
1496
  @staticmethod
1476
- def Simplify(shell, simplifyBoundary=True, tolerance=0.0001):
1497
+ def Simplify(shell, simplifyBoundary: bool = True, mantissa: int = 6, tolerance: float = 0.0001):
1477
1498
  """
1478
1499
  Simplifies the input shell edges based on the Douglas Peucker algorthim. See https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
1479
1500
  Part of this code was contributed by gaoxipeng. See https://github.com/wassimj/topologicpy/issues/35
@@ -1484,6 +1505,8 @@ class Shell():
1484
1505
  The input shell.
1485
1506
  simplifyBoundary : bool , optional
1486
1507
  If set to True, the external boundary of the shell will be simplified as well. Otherwise, it will not be simplified. The default is True.
1508
+ mantissa : int , optional
1509
+ The desired length of the mantissa. The default is 6
1487
1510
  tolerance : float , optional
1488
1511
  The desired tolerance. The default is 0.0001. Edges shorter than this length will be removed.
1489
1512
 
@@ -1503,12 +1526,12 @@ class Shell():
1503
1526
 
1504
1527
  def perpendicular_distance(point, line_start, line_end):
1505
1528
  # Calculate the perpendicular distance from a point to a line segment
1506
- x0 = point.X()
1507
- y0 = point.Y()
1508
- x1 = line_start.X()
1509
- y1 = line_start.Y()
1510
- x2 = line_end.X()
1511
- y2 = line_end.Y()
1529
+ x0 = Vertex.X(point, mantissa=mantissa)
1530
+ y0 = Vertex.Y(point, mantissa=mantissa)
1531
+ x1 = Vertex.X(line_start, mantissa=mantissa)
1532
+ y1 = Vertex.Y(line_start, mantissa=mantissa)
1533
+ x2 = Vertex.X(line_end, mantissa=mantissa)
1534
+ y2 = Vertex.Y(line_end, mantissa=mantissa)
1512
1535
 
1513
1536
  numerator = abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1)
1514
1537
  denominator = Vertex.Distance(line_start, line_end)
@@ -1642,7 +1665,7 @@ class Shell():
1642
1665
  return vertices
1643
1666
 
1644
1667
  @staticmethod
1645
- def Voronoi(vertices: list, face= None, tolerance: float = 0.0001):
1668
+ def Voronoi(vertices: list, face= None, mantissa: int = 6, tolerance: float = 0.0001):
1646
1669
  """
1647
1670
  Returns a voronoi partitioning of the input face based on the input vertices. The vertices must be coplanar and within the face. See https://en.wikipedia.org/wiki/Voronoi_diagram.
1648
1671
 
@@ -1652,6 +1675,8 @@ class Shell():
1652
1675
  The input list of vertices.
1653
1676
  face : topologic_core.Face , optional
1654
1677
  The input face. If the face is not set an optimised bounding rectangle of the input vertices is used instead. The default is None.
1678
+ mantissa : int , optional
1679
+ The desired length of the mantissa. The default is 6
1655
1680
  tolerance : float , optional
1656
1681
  The desired tolerance. The default is 0.0001.
1657
1682
 
@@ -1681,17 +1706,17 @@ class Shell():
1681
1706
 
1682
1707
  # Flatten the input face
1683
1708
  origin = Topology.Centroid(face)
1684
- normal = Face.Normal(face)
1709
+ normal = Face.Normal(face, mantissa=mantissa)
1685
1710
  flatFace = Topology.Flatten(face, origin=origin, direction=normal)
1686
1711
  eb = Face.ExternalBoundary(flatFace)
1687
1712
  ibList = Face.InternalBoundaries(flatFace)
1688
1713
  temp_verts = Topology.Vertices(eb)
1689
- new_verts = [Vertex.ByCoordinates(Vertex.X(v), Vertex.Y(v), 0) for v in temp_verts]
1714
+ new_verts = [Vertex.ByCoordinates(Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa), 0) for v in temp_verts]
1690
1715
  eb = Wire.ByVertices(new_verts, close=True)
1691
1716
  new_ibList = []
1692
1717
  for ib in ibList:
1693
1718
  temp_verts = Topology.Vertices(ib)
1694
- new_verts = [Vertex.ByCoordinates(Vertex.X(v), Vertex.Y(v), 0) for v in temp_verts]
1719
+ new_verts = [Vertex.ByCoordinates(Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa), 0) for v in temp_verts]
1695
1720
  new_ibList.append(Wire.ByVertices(new_verts, close=True))
1696
1721
  flatFace = Face.ByWires(eb, new_ibList)
1697
1722
 
@@ -1701,10 +1726,10 @@ class Shell():
1701
1726
  # Flatten the cluster using the same transformations
1702
1727
  verticesCluster = Topology.Flatten(verticesCluster, origin=origin, direction=normal)
1703
1728
  flatVertices = Topology.Vertices(verticesCluster)
1704
- flatVertices = [Vertex.ByCoordinates(Vertex.X(v), Vertex.Y(v), 0) for v in flatVertices]
1729
+ flatVertices = [Vertex.ByCoordinates(Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa), 0) for v in flatVertices]
1705
1730
  points = []
1706
1731
  for flatVertex in flatVertices:
1707
- points.append([flatVertex.X(), flatVertex.Y()])
1732
+ points.append([Vertex.X(flatVertex, mantissa=mantissa), Vertex.Y(flatVertex, mantissa=mantissa)])
1708
1733
 
1709
1734
  br = Wire.BoundingRectangle(flatFace)
1710
1735
  br_vertices = Wire.Vertices(br)
@@ -1736,7 +1761,7 @@ class Shell():
1736
1761
  tempWire = []
1737
1762
  if len(region) > 1 and not -1 in region:
1738
1763
  for v in region:
1739
- tempWire.append(Vertex.ByCoordinates(voronoiVertices[v].X(), voronoiVertices[v].Y(), 0))
1764
+ tempWire.append(Vertex.ByCoordinates(Vertex.X(voronoiVertices[v], mantissa=mantissa), Vertex.Y(voronoiVertices[v], mantissa=mantissa), 0))
1740
1765
  temp_verts = []
1741
1766
  for v in tempWire:
1742
1767
  if len(temp_verts) == 0: