topologicpy 0.7.5__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/Cell.py CHANGED
@@ -638,7 +638,7 @@ class Cell():
638
638
 
639
639
  @staticmethod
640
640
  def Cone(origin = None, baseRadius: float = 0.5, topRadius: float = 0, height: float = 1, uSides: int = 16, vSides: int = 1, direction: list = [0, 0, 1],
641
- dirZ: float = 1, placement: str = "center", tolerance: float = 0.0001):
641
+ dirZ: float = 1, placement: str = "center", mantissa: int = 6, tolerance: float = 0.0001):
642
642
  """
643
643
  Creates a cone.
644
644
 
@@ -658,6 +658,8 @@ class Cell():
658
658
  The vector representing the up direction of the cone. The default is [0, 0, 1].
659
659
  placement : str , optional
660
660
  The description of the placement of the origin of the cone. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
661
+ mantissa : int , optional
662
+ The desired length of the mantissa. The default is 6
661
663
  tolerance : float , optional
662
664
  The desired tolerance. The default is 0.0001.
663
665
 
@@ -719,13 +721,13 @@ class Cell():
719
721
  for i in range(uSides):
720
722
  angle = math.radians(360/uSides)*i
721
723
  if baseRadius > 0:
722
- baseX = math.cos(angle)*baseRadius + origin.X() + xOffset
723
- baseY = math.sin(angle)*baseRadius + origin.Y() + yOffset
724
- baseZ = origin.Z() + zOffset
724
+ baseX = math.cos(angle)*baseRadius + Vertex.X(origin, mantissa=mantissa) + xOffset
725
+ baseY = math.sin(angle)*baseRadius + Vertex.Y(origin, mantissa=mantissa) + yOffset
726
+ baseZ = Vertex.Z(origin, mantissa=mantissa) + zOffset
725
727
  baseV.append(Vertex.ByCoordinates(baseX,baseY,baseZ))
726
728
  if topRadius > 0:
727
- topX = math.cos(angle)*topRadius + origin.X() + xOffset
728
- topY = math.sin(angle)*topRadius + origin.Y() + yOffset
729
+ topX = math.cos(angle)*topRadius + Vertex.X(origin, mantissa=mantissa) + xOffset
730
+ topY = math.sin(angle)*topRadius + Vertex.Y(origin, mantissa=mantissa) + yOffset
729
731
  topV.append(Vertex.ByCoordinates(topX,topY,topZ))
730
732
  if baseRadius > 0:
731
733
  baseWire = Wire.ByVertices(baseV)
@@ -735,8 +737,8 @@ class Cell():
735
737
  topWire = Wire.ByVertices(topV)
736
738
  else:
737
739
  topWire = None
738
- baseVertex = Vertex.ByCoordinates(origin.X()+xOffset, origin.Y()+yOffset, origin.Z()+zOffset)
739
- topVertex = Vertex.ByCoordinates(origin.X()+xOffset, origin.Y()+yOffset, origin.Z()+zOffset+height)
740
+ baseVertex = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+xOffset, Vertex.Y(origin, mantissa=mantissa)+yOffset, Vertex.Z(origin, mantissa=mantissa)+zOffset)
741
+ topVertex = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+xOffset, Vertex.Y(origin, mantissa=mantissa)+yOffset, Vertex.Z(origin, mantissa=mantissa)+zOffset+height)
740
742
  cone = createCone(baseWire, topWire, baseVertex, topVertex, tolerance)
741
743
  if cone == None:
742
744
  print("Cell.Cone - Error: Could not create a cone. Returning None.")
@@ -744,11 +746,11 @@ class Cell():
744
746
 
745
747
  if vSides > 1:
746
748
  cutting_planes = []
747
- baseX = origin.X() + xOffset
748
- baseY = origin.Y() + yOffset
749
+ baseX = Vertex.X(origin, mantissa=mantissa) + xOffset
750
+ baseY = Vertex.Y(origin, mantissa=mantissa) + yOffset
749
751
  size = max(baseRadius, topRadius)*3
750
752
  for i in range(1, vSides):
751
- baseZ = origin.Z() + zOffset + float(height)/float(vSides)*i
753
+ baseZ = Vertex.Z(origin, mantissa=mantissa) + zOffset + float(height)/float(vSides)*i
752
754
  tool_origin = Vertex.ByCoordinates(baseX, baseY, baseZ)
753
755
  cutting_planes.append(Face.ByWire(Wire.Rectangle(origin=tool_origin, width=size, length=size), tolerance=tolerance))
754
756
  cutting_planes_cluster = Cluster.ByTopologies(cutting_planes)
@@ -800,7 +802,7 @@ class Cell():
800
802
 
801
803
  @staticmethod
802
804
  def Cylinder(origin = None, radius: float = 0.5, height: float = 1, uSides: int = 16, vSides: int = 1, direction: list = [0, 0, 1],
803
- placement: str = "center", tolerance: float = 0.0001):
805
+ placement: str = "center", mantissa: int = 6, tolerance: float = 0.0001):
804
806
  """
805
807
  Creates a cylinder.
806
808
 
@@ -820,6 +822,8 @@ class Cell():
820
822
  The vector representing the up direction of the cylinder. The default is [0, 0, 1].
821
823
  placement : str , optional
822
824
  The description of the placement of the origin of the cylinder. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "bottom".
825
+ mantissa : int , optional
826
+ The desired length of the mantissa. The default is 6.
823
827
  tolerance : float , optional
824
828
  The desired tolerance. The default is 0.0001.
825
829
 
@@ -848,7 +852,7 @@ class Cell():
848
852
  elif placement.lower() == "lowerleft":
849
853
  xOffset = radius
850
854
  yOffset = radius
851
- circle_origin = Vertex.ByCoordinates(origin.X() + xOffset, origin.Y() + yOffset, origin.Z() + zOffset)
855
+ circle_origin = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa) + xOffset, Vertex.Y(origin, mantissa=mantissa) + yOffset, Vertex.Z(origin, mantissa=mantissa) + zOffset)
852
856
 
853
857
  baseWire = Wire.Circle(origin=circle_origin, radius=radius, sides=uSides, fromAngle=0, toAngle=360, close=True, direction=[0, 0, 1], placement="center", tolerance=tolerance)
854
858
  baseFace = Face.ByWire(baseWire, tolerance=tolerance)
@@ -856,8 +860,8 @@ class Cell():
856
860
  tolerance=tolerance)
857
861
  if vSides > 1:
858
862
  cutting_planes = []
859
- baseX = origin.X() + xOffset
860
- baseY = origin.Y() + yOffset
863
+ baseX = Vertex.X(origin, mantissa=mantissa) + xOffset
864
+ baseY = Vertex.Y(origin, mantissa=mantissa) + yOffset
861
865
  size = radius*3
862
866
  for i in range(1, vSides):
863
867
  baseZ = origin.Z() + zOffset + float(height)/float(vSides)*i
@@ -1212,7 +1216,7 @@ class Cell():
1212
1216
 
1213
1217
  @staticmethod
1214
1218
  def Hyperboloid(origin = None, baseRadius: float = 0.5, topRadius: float = 0.5, height: float = 1, sides: int = 24, direction: list = [0, 0, 1],
1215
- twist: float = 60, placement: str = "center", tolerance: float = 0.0001):
1219
+ twist: float = 60, placement: str = "center", mantissa: int = 6, tolerance: float = 0.0001):
1216
1220
  """
1217
1221
  Creates a hyperboloid.
1218
1222
 
@@ -1234,6 +1238,8 @@ class Cell():
1234
1238
  The angle to twist the base cylinder. The default is 60.
1235
1239
  placement : str , optional
1236
1240
  The description of the placement of the origin of the hyperboloid. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
1241
+ mantissa : int , optional
1242
+ The desired length of the mantissa. The default is 6
1237
1243
  tolerance : float , optional
1238
1244
  The desired tolerance. The default is 0.0001.
1239
1245
 
@@ -1243,10 +1249,10 @@ class Cell():
1243
1249
  The created hyperboloid.
1244
1250
 
1245
1251
  """
1246
- from topologicpy.Cluster import Cluster
1247
1252
  from topologicpy.Vertex import Vertex
1248
1253
  from topologicpy.Wire import Wire
1249
1254
  from topologicpy.Face import Face
1255
+ from topologicpy.Cluster import Cluster
1250
1256
  from topologicpy.Topology import Topology
1251
1257
  import math
1252
1258
 
@@ -1295,13 +1301,13 @@ class Cell():
1295
1301
  for i in range(sides):
1296
1302
  angle = math.radians(360/sides)*i
1297
1303
  if baseRadius > 0:
1298
- baseX = math.sin(angle+math.radians(twist))*baseRadius + w_origin.X() + xOffset
1299
- baseY = math.cos(angle+math.radians(twist))*baseRadius + w_origin.Y() + yOffset
1300
- baseZ = w_origin.Z() + zOffset
1304
+ baseX = math.sin(angle+math.radians(twist))*baseRadius + Vertex.X(w_origin, mantissa=mantissa) + xOffset
1305
+ baseY = math.cos(angle+math.radians(twist))*baseRadius + Vertex.Y(w_origin, mantissa=mantissa) + yOffset
1306
+ baseZ = Vertex.Z(w_origin, mantissa=mantissa) + zOffset
1301
1307
  baseV.append(Vertex.ByCoordinates(baseX,baseY,baseZ))
1302
1308
  if topRadius > 0:
1303
- topX = math.sin(angle-math.radians(twist))*topRadius + w_origin.X() + xOffset
1304
- topY = math.cos(angle-math.radians(twist))*topRadius + w_origin.Y() + yOffset
1309
+ topX = math.sin(angle-math.radians(twist))*topRadius + Vertex.X(w_origin, mantissa=mantissa) + xOffset
1310
+ topY = math.cos(angle-math.radians(twist))*topRadius + Vertex.Y(w_origin, mantissa=mantissa) + yOffset
1305
1311
  topV.append(Vertex.ByCoordinates(topX,topY,topZ))
1306
1312
 
1307
1313
  hyperboloid = createHyperboloid(baseV, topV, tolerance)
@@ -1546,7 +1552,7 @@ class Cell():
1546
1552
  return octahedron
1547
1553
 
1548
1554
  @staticmethod
1549
- def Pipe(edge, profile = None, radius: float = 0.5, sides: int = 16, startOffset: float = 0, endOffset: float = 0, endcapA = None, endcapB = None) -> dict:
1555
+ def Pipe(edge, profile = None, radius: float = 0.5, sides: int = 16, startOffset: float = 0, endOffset: float = 0, endcapA = None, endcapB = None, mantissa: int = 6) -> dict:
1550
1556
  """
1551
1557
  Description
1552
1558
  ----------
@@ -1570,7 +1576,9 @@ class Cell():
1570
1576
  The topology to place at the start vertex of the centerline edge. The positive Z direction of the end cap will be oriented in the direction of the centerline edge.
1571
1577
  endcapB, optional
1572
1578
  The topology to place at the end vertex of the centerline edge. The positive Z direction of the end cap will be oriented in the inverse direction of the centerline edge.
1573
-
1579
+ mantissa : int , optional
1580
+ The desired length of the mantissa. The default is 6
1581
+
1574
1582
  Returns
1575
1583
  -------
1576
1584
  dict
@@ -1580,7 +1588,6 @@ class Cell():
1580
1588
  'endcapB'
1581
1589
 
1582
1590
  """
1583
-
1584
1591
  from topologicpy.Vertex import Vertex
1585
1592
  from topologicpy.Edge import Edge
1586
1593
  from topologicpy.Wire import Wire
@@ -1596,12 +1603,12 @@ class Cell():
1596
1603
  endU = 1.0 - (endOffset / length)
1597
1604
  sv = Edge.VertexByParameter(edge, startU)
1598
1605
  ev = Edge.VertexByParameter(edge, endU)
1599
- x1 = sv.X()
1600
- y1 = sv.Y()
1601
- z1 = sv.Z()
1602
- x2 = ev.X()
1603
- y2 = ev.Y()
1604
- z2 = ev.Z()
1606
+ x1 = Vertex.X(sv, mantissa=mantissa)
1607
+ y1 = Vertex.Y(sv, mantissa=mantissa)
1608
+ z1 = Vertex.Z(sv, mantissa=mantissa)
1609
+ x2 = Vertex.X(ev, mantissa=mantissa)
1610
+ y2 = Vertex.Y(ev, mantissa=mantissa)
1611
+ z2 = Vertex.Z(ev, mantissa=mantissa)
1605
1612
  dx = x2 - x1
1606
1613
  dy = y2 - y1
1607
1614
  dz = z2 - z1
@@ -1615,9 +1622,9 @@ class Cell():
1615
1622
  else:
1616
1623
  for i in range(sides):
1617
1624
  angle = math.radians(360/sides)*i
1618
- x = math.sin(angle)*radius + sv.X()
1619
- y = math.cos(angle)*radius + sv.Y()
1620
- z = sv.Z()
1625
+ x = math.sin(angle)*radius + Vertex.X(sv, mantissa=mantissa)
1626
+ y = math.cos(angle)*radius + Vertex.Y(sv, mantissa=mantissa)
1627
+ z = Vertex.Z(sv, mantissa=mantissa)
1621
1628
  baseV.append(Vertex.ByCoordinates(x, y, z))
1622
1629
  topV.append(Vertex.ByCoordinates(x, y, z+dist))
1623
1630
 
@@ -1635,12 +1642,12 @@ class Cell():
1635
1642
  zzz = Vertex.ByCoordinates(0, 0, 0)
1636
1643
  if endcapA:
1637
1644
  origin = edge.StartVertex()
1638
- x1 = origin.X()
1639
- y1 = origin.Y()
1640
- z1 = origin.Z()
1641
- x2 = edge.EndVertex().X()
1642
- y2 = edge.EndVertex().Y()
1643
- z2 = edge.EndVertex().Z()
1645
+ x1 = Vertex.X(origin, mantissa=mantissa)
1646
+ y1 = Vertex.Y(origin, mantissa=mantissa)
1647
+ z1 = Vertex.Z(origin, mantissa=mantissa)
1648
+ x2 = Vertex.X(edge.EndVertex(), mantissa=mantissa)
1649
+ y2 = Vertex.Y(edge.EndVertex(), mantissa=mantissa)
1650
+ z2 = Vertex.Z(edge.EndVertex(), mantissa=mantissa)
1644
1651
  dx = x2 - x1
1645
1652
  dy = y2 - y1
1646
1653
  dz = z2 - z1
@@ -1653,15 +1660,15 @@ class Cell():
1653
1660
  endcapA = Topology.Copy(endcapA)
1654
1661
  endcapA = Topology.Rotate(endcapA, origin=zzz, axis=[0, 1, 0], angle=theta)
1655
1662
  endcapA = Topology.Rotate(endcapA, origin=zzz, axis=[0, 0, 1], angle=phi+180)
1656
- endcapA = Topology.Translate(endcapA, origin.X(), origin.Y(), origin.Z())
1663
+ endcapA = Topology.Translate(endcapA, Vertex.X(origin, mantissa=mantissa), Vertex.Y(origin, mantissa=mantissa), Vertex.Z(origin, mantissa=mantissa))
1657
1664
  if endcapB:
1658
1665
  origin = edge.EndVertex()
1659
- x1 = origin.X()
1660
- y1 = origin.Y()
1661
- z1 = origin.Z()
1662
- x2 = edge.StartVertex().X()
1663
- y2 = edge.StartVertex().Y()
1664
- z2 = edge.StartVertex().Z()
1666
+ x1 = Vertex.X(origin, mantissa=mantissa)
1667
+ y1 = Vertex.Y(origin, mantissa=mantissa)
1668
+ z1 = Vertex.Z(origin, mantissa=mantissa)
1669
+ x2 = Vertex.X(edge.StartVertex(), mantissa=mantissa)
1670
+ y2 = Vertex.Y(edge.StartVertex(), mantissa=mantissa)
1671
+ z2 = Vertex.Z(edge.StartVertex(), mantissa=mantissa)
1665
1672
  dx = x2 - x1
1666
1673
  dy = y2 - y1
1667
1674
  dz = z2 - z1
@@ -1674,12 +1681,12 @@ class Cell():
1674
1681
  endcapB = Topology.Copy(endcapB)
1675
1682
  endcapB = Topology.Rotate(endcapB, origin=zzz, axis=[0, 1, 0], angle=theta)
1676
1683
  endcapB = Topology.Rotate(endcapB, origin=zzz, axis=[0, 0, 1], angle=phi+180)
1677
- endcapB = Topology.Translate(endcapB, origin.X(), origin.Y(), origin.Z())
1684
+ endcapB = Topology.Translate(endcapB, Vertex.X(origin, mantissa=mantissa), Vertex.Y(origin, mantissa=mantissa), Vertex.Z(origin, mantissa=mantissa))
1678
1685
  return {'pipe': pipe, 'endcapA': endcapA, 'endcapB': endcapB}
1679
1686
 
1680
1687
  @staticmethod
1681
1688
  def Prism(origin= None, width: float = 1, length: float = 1, height: float = 1, uSides: int = 1, vSides: int = 1, wSides: int = 1,
1682
- direction: list = [0, 0, 1], placement: str ="center", tolerance: float = 0.0001):
1689
+ direction: list = [0, 0, 1], placement: str ="center", mantissa: int = 6, tolerance: float = 0.0001):
1683
1690
  """
1684
1691
  Description
1685
1692
  ----------
@@ -1705,6 +1712,8 @@ class Cell():
1705
1712
  The vector representing the up direction of the prism. The default is [0, 0, 1].
1706
1713
  placement : str , optional
1707
1714
  The description of the placement of the origin of the prism. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
1715
+ mantissa : int , optional
1716
+ The desired length of the mantissa. The default is 6.
1708
1717
  tolerance : float , optional
1709
1718
  The desired tolerance. The default is 0.0001.
1710
1719
 
@@ -1755,10 +1764,10 @@ class Cell():
1755
1764
  elif placement.lower() == "lowerleft":
1756
1765
  xOffset = width*0.5
1757
1766
  yOffset = length*0.5
1758
- vb1 = Vertex.ByCoordinates(origin.X()-width*0.5+xOffset,origin.Y()-length*0.5+yOffset,origin.Z()+zOffset)
1759
- vb2 = Vertex.ByCoordinates(origin.X()+width*0.5+xOffset,origin.Y()-length*0.5+yOffset,origin.Z()+zOffset)
1760
- vb3 = Vertex.ByCoordinates(origin.X()+width*0.5+xOffset,origin.Y()+length*0.5+yOffset,origin.Z()+zOffset)
1761
- vb4 = Vertex.ByCoordinates(origin.X()-width*0.5+xOffset,origin.Y()+length*0.5+yOffset,origin.Z()+zOffset)
1767
+ vb1 = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)-width*0.5+xOffset,Vertex.Y(origin, mantissa=mantissa)-length*0.5+yOffset,Vertex.Z(origin, mantissa=mantissa)+zOffset)
1768
+ vb2 = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+width*0.5+xOffset,Vertex.Y(origin, mantissa=mantissa)-length*0.5+yOffset,Vertex.Z(origin, mantissa=mantissa)+zOffset)
1769
+ vb3 = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+width*0.5+xOffset,Vertex.Y(origin, mantissa=mantissa)+length*0.5+yOffset,Vertex.Z(origin, mantissa=mantissa)+zOffset)
1770
+ vb4 = Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)-width*0.5+xOffset,Vertex.Y(origin, mantissa=mantissa)+length*0.5+yOffset,Vertex.Z(origin, mantissa=mantissa)+zOffset)
1762
1771
 
1763
1772
  baseWire = Wire.ByVertices([vb1, vb2, vb3, vb4], close=True)
1764
1773
  baseFace = Face.ByWire(baseWire, tolerance=tolerance)
@@ -831,7 +831,7 @@ class CellComplex():
831
831
  def Prism(origin= None,
832
832
  width: float = 1.0, length: float = 1.0, height: float = 1.0,
833
833
  uSides: int = 2, vSides: int = 2, wSides: int = 2,
834
- direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
834
+ direction: list = [0, 0, 1], placement: str = "center", mantissa: int = 6, tolerance: float = 0.0001):
835
835
  """
836
836
  Creates a prismatic cellComplex with internal cells.
837
837
 
@@ -855,6 +855,8 @@ class CellComplex():
855
855
  The vector representing the up direction of the prism. The default is [0, 0, 1].
856
856
  placement : str , optional
857
857
  The description of the placement of the origin of the prism. This can be "bottom", "center", or "lowerleft". It is case insensitive. The default is "center".
858
+ mantissa : int , optional
859
+ The desired length of the mantissa. The default is 6.
858
860
  tolerance : float , optional
859
861
  The desired tolerance. The default is 0.0001.
860
862
 
@@ -876,9 +878,9 @@ class CellComplex():
876
878
  y = []
877
879
  z = []
878
880
  for aVertex in vertices:
879
- x.append(aVertex.X())
880
- y.append(aVertex.Y())
881
- z.append(aVertex.Z())
881
+ x.append(Vertex.X(aVertex, mantissa=mantissa))
882
+ y.append(Vertex.Y(aVertex, mantissa=mantissa))
883
+ z.append(Vertex.Z(aVertex, mantissa=mantissa))
882
884
  minX = min(x)
883
885
  minY = min(y)
884
886
  minZ = min(z)
@@ -890,19 +892,19 @@ class CellComplex():
890
892
  def slice(topology, uSides, vSides, wSides):
891
893
  minX, minY, minZ, maxX, maxY, maxZ = bb(topology)
892
894
  centroid = Vertex.ByCoordinates(minX+(maxX-minX)*0.5, minY+(maxY-minY)*0.5, minZ+(maxZ-minZ)*0.5)
893
- wOrigin = Vertex.ByCoordinates(Vertex.X(centroid), Vertex.Y(centroid), minZ)
895
+ wOrigin = Vertex.ByCoordinates(Vertex.X(centroid, mantissa=mantissa), Vertex.Y(centroid, mantissa=mantissa), minZ)
894
896
  wFace = Face.Rectangle(origin=wOrigin, width=(maxX-minX)*1.1, length=(maxY-minY)*1.1)
895
897
  wFaces = []
896
898
  wOffset = (maxZ-minZ)/wSides
897
899
  for i in range(wSides-1):
898
900
  wFaces.append(Topology.Translate(wFace, 0,0,wOffset*(i+1)))
899
- uOrigin = Vertex.ByCoordinates(minX, Vertex.Y(centroid), Vertex.Z(centroid))
901
+ uOrigin = Vertex.ByCoordinates(minX, Vertex.Y(centroid, mantissa=mantissa), Vertex.Z(centroid, mantissa=mantissa))
900
902
  uFace = Face.Rectangle(origin=uOrigin, width=(maxZ-minZ)*1.1, length=(maxY-minY)*1.1, direction=[1,0,0])
901
903
  uFaces = []
902
904
  uOffset = (maxX-minX)/uSides
903
905
  for i in range(uSides-1):
904
906
  uFaces.append(Topology.Translate(uFace, uOffset*(i+1),0,0))
905
- vOrigin = Vertex.ByCoordinates(Vertex.X(centroid), minY, Vertex.Z(centroid))
907
+ vOrigin = Vertex.ByCoordinates(Vertex.X(centroid, mantissa=mantissa), minY, Vertex.Z(centroid, mantissa=mantissa))
906
908
  vFace = Face.Rectangle(origin=vOrigin, width=(maxX-minX)*1.1, length=(maxZ-minZ)*1.1, direction=[0,1,0])
907
909
  vFaces = []
908
910
  vOffset = (maxY-minY)/vSides
@@ -917,7 +919,7 @@ class CellComplex():
917
919
  if not Topology.IsInstance(origin, "Vertex"):
918
920
  origin = Vertex.ByCoordinates(0, 0, 0)
919
921
 
920
- c = Cell.Prism(origin=origin, width=width, length=length, height=height, uSides=1, vSides=1, wSides=1, placement=placement, tolerance=tolerance)
922
+ c = Cell.Prism(origin=origin, width=width, length=length, height=height, uSides=1, vSides=1, wSides=1, placement=placement, mantissa=mantissa, tolerance=tolerance)
921
923
  prism = slice(c, uSides=uSides, vSides=vSides, wSides=wSides)
922
924
  if prism:
923
925
  prism = Topology.Orient(prism, origin=origin, dirA=[0, 0, 1], dirB=direction)
topologicpy/Edge.py CHANGED
@@ -348,6 +348,7 @@ class Edge():
348
348
  The direction of the input edge.
349
349
 
350
350
  """
351
+ from topologicpy.Vertex import Vertex
351
352
  from topologicpy.Vector import Vector
352
353
  from topologicpy.Topology import Topology
353
354
 
@@ -356,9 +357,9 @@ class Edge():
356
357
  return None
357
358
  ev = edge.EndVertex()
358
359
  sv = edge.StartVertex()
359
- x = ev.X() - sv.X()
360
- y = ev.Y() - sv.Y()
361
- z = ev.Z() - sv.Z()
360
+ x = Vertex.X(ev, mantissa=mantissa) - Vertex.X(sv, mantissa=mantissa)
361
+ y = Vertex.Y(ev, mantissa=mantissa) - Vertex.Y(sv, mantissa=mantissa)
362
+ z = Vertex.Z(ev, mantissa=mantissa) - Vertex.Z(sv, mantissa=mantissa)
362
363
  uvec = Vector.Normalize([x,y,z])
363
364
  x = round(uvec[0], mantissa)
364
365
  y = round(uvec[1], mantissa)
@@ -538,7 +539,7 @@ class Edge():
538
539
  return None
539
540
 
540
541
  @staticmethod
541
- def Intersect2D(edgeA, edgeB, silent: bool = False):
542
+ def Intersect2D(edgeA, edgeB, mantissa: int = 6, silent: bool = False):
542
543
  """
543
544
  Returns the intersection of the two input edges as a topologic_core.Vertex. This works only in the XY plane. Z coordinates are ignored.
544
545
 
@@ -548,6 +549,8 @@ class Edge():
548
549
  The first input edge.
549
550
  edgeB : topologic_core.Edge
550
551
  The second input edge.
552
+ mantissa : int , optional
553
+ The desired length of the mantissa. The default is 6.
551
554
  silent : bool , optional
552
555
  If set to False, error and warning messages are displayed. Otherwise they are not. The default is False.
553
556
 
@@ -573,14 +576,14 @@ class Edge():
573
576
  svb = Edge.StartVertex(edgeB)
574
577
  evb = Edge.EndVertex(edgeB)
575
578
  # Line AB represented as a1x + b1y = c1
576
- a1 = Vertex.Y(eva) - Vertex.Y(sva)
577
- b1 = Vertex.X(sva) - Vertex.X(eva)
578
- c1 = a1*(Vertex.X(sva)) + b1*(Vertex.Y(sva))
579
+ a1 = Vertex.Y(eva, mantissa=mantissa) - Vertex.Y(sva, mantissa=mantissa)
580
+ b1 = Vertex.X(sva, mantissa=mantissa) - Vertex.X(eva, mantissa=mantissa)
581
+ c1 = a1*(Vertex.X(sva, mantissa=mantissa)) + b1*(Vertex.Y(sva, mantissa=mantissa))
579
582
 
580
583
  # Line CD represented as a2x + b2y = c2
581
- a2 = Vertex.Y(evb) - Vertex.Y(svb)
582
- b2 = Vertex.X(svb) - Vertex.X(evb)
583
- c2 = a2*(Vertex.X(svb)) + b2*(Vertex.Y(svb))
584
+ a2 = Vertex.Y(evb, mantissa=mantissa) - Vertex.Y(svb, mantissa=mantissa)
585
+ b2 = Vertex.X(svb, mantissa=mantissa) - Vertex.X(evb, mantissa=mantissa)
586
+ c2 = a2*(Vertex.X(svb, mantissa=mantissa)) + b2*(Vertex.Y(svb, mantissa=mantissa))
584
587
 
585
588
  determinant = a1*b2 - a2*b1
586
589
 
@@ -639,7 +642,7 @@ class Edge():
639
642
  # Get start and end points of the first edge
640
643
  start_a = Edge.StartVertex(edgeA)
641
644
  end_a = Edge.EndVertex(edgeA)
642
- start_a_coords = np.array([Vertex.X(start_a), Vertex.Y(start_a), Vertex.Z(start_a)])
645
+ start_a_coords = np.array([Vertex.X(start_a, mantissa=mantissa), Vertex.Y(start_a, mantissa=mantissa), Vertex.Z(start_a, mantissa=mantissa)])
643
646
  end_a_coords = np.array(
644
647
  [Vertex.X(end_a, mantissa=mantissa), Vertex.Y(end_a, mantissa=mantissa), Vertex.Z(end_a, mantissa=mantissa)])
645
648
 
@@ -1158,7 +1161,7 @@ class Edge():
1158
1161
  return edgeA
1159
1162
 
1160
1163
  @staticmethod
1161
- def VertexByDistance(edge, distance: float = 0.0, origin= None, tolerance: float = 0.0001):
1164
+ def VertexByDistance(edge, distance: float = 0.0, origin= None, mantissa: int = 6, tolerance: float = 0.0001):
1162
1165
  """
1163
1166
  Creates a vertex along the input edge offset by the input distance from the input origin.
1164
1167
 
@@ -1170,6 +1173,8 @@ class Edge():
1170
1173
  The offset distance. The default is 0.
1171
1174
  origin : topologic_core.Vertex , optional
1172
1175
  The origin of the offset distance. If set to None, the origin will be set to the start vertex of the input edge. The default is None.
1176
+ mantissa : int , optional
1177
+ The desired length of the mantissa. The default is 6
1173
1178
  tolerance : float , optional
1174
1179
  The desired tolerance. The default is 0.0001.
1175
1180
 
@@ -1193,12 +1198,12 @@ class Edge():
1193
1198
  return None
1194
1199
  sv = edge.StartVertex()
1195
1200
  ev = edge.EndVertex()
1196
- vx = ev.X() - sv.X()
1197
- vy = ev.Y() - sv.Y()
1198
- vz = ev.Z() - sv.Z()
1201
+ vx = Vertex.X(ev, mantissa=mantissa) - Vertex.X(sv, mantissa=mantissa)
1202
+ vy = Vertex.Y(ev, mantissa=mantissa) - Vertex.Y(sv, mantissa=mantissa)
1203
+ vz = Vertex.Z(ev, mantissa=mantissa) - Vertex.Z(sv, mantissa=mantissa)
1199
1204
  vector = Vector.Normalize([vx, vy, vz])
1200
1205
  vector = Vector.Multiply(vector, distance, tolerance)
1201
- return Vertex.ByCoordinates(origin.X()+vector[0], origin.Y()+vector[1], origin.Z()+vector[2])
1206
+ return Vertex.ByCoordinates(Vertex.X(origin, mantissa=mantissa)+vector[0], Vertex.Y(origin, mantissa=mantissa)+vector[1], Vertex.Z(origin, mantissa=mantissa)+vector[2])
1202
1207
 
1203
1208
  @staticmethod
1204
1209
  def VertexByParameter(edge, u: float = 0.0):
@@ -128,7 +128,9 @@ class EnergyModel:
128
128
  heatingTemp : float = 20.0,
129
129
  defaultSpaceType : str = "189.1-2009 - Office - WholeBuilding - Lg Office - CZ4-8",
130
130
  spaceNameKey : str = "TOPOLOGIC_name",
131
- spaceTypeKey : str = "TOPOLOGIC_type"):
131
+ spaceTypeKey : str = "TOPOLOGIC_type",
132
+ mantissa : int = 6,
133
+ tolerance : float = 0.0001):
132
134
  """
133
135
  Creates an EnergyModel from the input topology and parameters.
134
136
 
@@ -165,6 +167,10 @@ class EnergyModel:
165
167
  The dictionary key to use to find the space name value. The default is "Name".
166
168
  spaceTypeKey : str , optional
167
169
  The dictionary key to use to find the space type value. The default is "Type".
170
+ mantissa : int , optional
171
+ The desired length of the mantissa. The default is 6.
172
+ tolerance : float , optional
173
+ The desired tolerance. The default is 0.0001.
168
174
 
169
175
  Returns
170
176
  -------
@@ -172,6 +178,7 @@ class EnergyModel:
172
178
  The created OSM model.
173
179
 
174
180
  """
181
+ from topologicpy.Vertex import Vertex
175
182
  from topologicpy.Face import Face
176
183
  from topologicpy.Cell import Cell
177
184
  from topologicpy.Topology import Topology
@@ -229,7 +236,7 @@ class EnergyModel:
229
236
  hf = bhf+thf
230
237
  else:
231
238
  return None
232
- floorLevels = [Vertex.Z(Topology.Centroid(f)) for f in hf]
239
+ floorLevels = [Vertex.Z(Topology.Centroid(f), mantissa=mantissa) for f in hf]
233
240
  floorLevels = list(set(floorLevels))
234
241
  floorLevels.sort()
235
242
  return floorLevels
@@ -294,7 +301,7 @@ class EnergyModel:
294
301
  building_cells = [building]
295
302
  for spaceNumber, buildingCell in enumerate(building_cells):
296
303
  osSpace = openstudio.model.Space(osModel)
297
- osSpaceZ = buildingCell.CenterOfMass().Z()
304
+ osSpaceZ = Vertex.Z(buildingCell.CenterOfMass(), mantissa=mantissa)
298
305
  osBuildingStory = osBuildingStorys[0]
299
306
  for x in osBuildingStorys:
300
307
  osBuildingStoryZ = x.nominalZCoordinate().get()
@@ -344,9 +351,9 @@ class EnergyModel:
344
351
  for faceNumber, buildingFace in enumerate(cellFaces):
345
352
  osFacePoints = []
346
353
  for vertex in Topology.SubTopologies(buildingFace.ExternalBoundary(), "Vertex"):
347
- osFacePoints.append(openstudio.Point3d(vertex.X(), vertex.Y(), vertex.Z()))
354
+ osFacePoints.append(openstudio.Point3d(Vertex.X(vertex, mantissa=mantissa), Vertex.Y(vertex, mantissa=mantissa), Vertex.Z(vertex, mantissa=mantissa)))
348
355
  osSurface = openstudio.model.Surface(osFacePoints, osModel)
349
- faceNormal = Face.Normal(buildingFace)
356
+ faceNormal = Face.Normal(buildingFace, mantissa=mantissa)
350
357
  osFaceNormal = openstudio.Vector3d(faceNormal[0], faceNormal[1], faceNormal[2])
351
358
  osFaceNormal.normalize()
352
359
  if osFaceNormal.dot(osSurface.outwardNormal()) < 1e-6:
@@ -376,9 +383,9 @@ class EnergyModel:
376
383
  osSubSurfacePoints = []
377
384
  apertureFace = Aperture.Topology(aperture)
378
385
  for vertex in Topology.SubTopologies(apertureFace.ExternalBoundary(), "Vertex"):
379
- osSubSurfacePoints.append(openstudio.Point3d(vertex.X(), vertex.Y(), vertex.Z()))
386
+ osSubSurfacePoints.append(openstudio.Point3d(Vertex.X(vertex, mantissa=mantissa), Vertex.Y(vertex, mantissa=mantissa), Vertex.Z(vertex, mantissa=mantissa)))
380
387
  osSubSurface = openstudio.model.SubSurface(osSubSurfacePoints, osModel)
381
- apertureFaceNormal = Face.Normal(apertureFace)
388
+ apertureFaceNormal = Face.Normal(apertureFace, mantissa=mantissa)
382
389
  osSubSurfaceNormal = openstudio.Vector3d(apertureFaceNormal[0], apertureFaceNormal[1], apertureFaceNormal[2])
383
390
  osSubSurfaceNormal.normalize()
384
391
  if osSubSurfaceNormal.dot(osSubSurface.outwardNormal()) < 1e-6:
@@ -414,9 +421,9 @@ class EnergyModel:
414
421
  osSubSurfacePoints = []
415
422
  apertureFace = Aperture.Topology(aperture)
416
423
  for vertex in Topology.SubTopologies(apertureFace.ExternalBoundary(), "Vertex"):
417
- osSubSurfacePoints.append(openstudio.Point3d(vertex.X(), vertex.Y(), vertex.Z()))
424
+ osSubSurfacePoints.append(openstudio.Point3d(Vertex.X(vertex, mantissa=mantissa), Vertex.Y(vertex, mantissa=mantissa), Vertex.Z(vertex.Z, mantissa=mantissa)))
418
425
  osSubSurface = openstudio.model.SubSurface(osSubSurfacePoints, osModel)
419
- apertureFaceNormal = Face.Normal(apertureFace)
426
+ apertureFaceNormal = Face.Normal(apertureFace, mantissa=mantissa)
420
427
  osSubSurfaceNormal = openstudio.Vector3d(apertureFaceNormal[0], apertureFaceNormal[1], apertureFaceNormal[2])
421
428
  osSubSurfaceNormal.normalize()
422
429
  if osSubSurfaceNormal.dot(osSubSurface.outwardNormal()) < 1e-6:
@@ -425,10 +432,10 @@ class EnergyModel:
425
432
  osSubSurface.setSurface(osSurface)
426
433
 
427
434
  osThermalZone = openstudio.model.ThermalZone(osModel)
428
- osThermalZone.setVolume(Cell.Volume(buildingCell))
435
+ osThermalZone.setVolume(Cell.Volume(buildingCell, mantissa=mantissa))
429
436
  osThermalZone.setName(osSpace.name().get() + "_THERMAL_ZONE")
430
437
  osThermalZone.setUseIdealAirLoads(True)
431
- osThermalZone.setVolume(Cell.Volume(buildingCell))
438
+ osThermalZone.setVolume(Cell.Volume(buildingCell, mantissa=mantissa))
432
439
  osThermalZone.setThermostatSetpointDualSetpoint(osThermostat)
433
440
  osSpace.setThermalZone(osThermalZone)
434
441
 
@@ -443,9 +450,9 @@ class EnergyModel:
443
450
  for faceIndex, shadingFace in enumerate(Topology.SubTopologies(shadingSurfaces, "Face")):
444
451
  facePoints = []
445
452
  for aVertex in Topology.SubTopologies(shadingFace.ExternalBoundary(), "Vertex"):
446
- facePoints.append(openstudio.Point3d(aVertex.X(), aVertex.Y(), aVertex.Z()))
453
+ facePoints.append(openstudio.Point3d(Vertex.X(aVertex, mantissa=mantissa), Vertex.Y(aVertex, mantissa=mantissa), Vertex.Z(aVertex, mantissa=mantissa)))
447
454
  aShadingSurface = openstudio.model.ShadingSurface(facePoints, osModel)
448
- faceNormal = Face.Normal(shadingFace)
455
+ faceNormal = Face.Normal(shadingFace, mantissa=mantissa)
449
456
  osFaceNormal = openstudio.Vector3d(faceNormal[0], faceNormal[1], faceNormal[2])
450
457
  osFaceNormal.normalize()
451
458
  if osFaceNormal.dot(aShadingSurface.outwardNormal()) < 0: