Skip to content

Commit db97ef6

Browse files
Add tolerance to volume calculation (#1882)
1 parent 2e2db9a commit db97ef6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,16 +795,17 @@ def _mass_calc_function(obj: "Shape") -> Any:
795795
return shape_properties_LUT[type_]
796796

797797
@staticmethod
798-
def computeMass(obj: "Shape") -> float:
798+
def computeMass(obj: "Shape", tol: Optional[float] = None) -> float:
799799
"""
800800
Calculates the 'mass' of an object.
801801
802802
:param obj: Compute the mass of this object
803+
:param tol: Numerical integration tolerance (optional).
803804
"""
804805
Properties = GProp_GProps()
805806
calc_function = Shape._mass_calc_function(obj)
806807

807-
calc_function(obj.wrapped, Properties)
808+
calc_function(obj.wrapped, Properties, *(tol if tol else ()))
808809

809810
return Properties.Mass()
810811

@@ -1010,12 +1011,12 @@ def Area(self) -> float:
10101011

10111012
return Properties.Mass()
10121013

1013-
def Volume(self) -> float:
1014+
def Volume(self, tol: Optional[float] = None) -> float:
10141015
"""
10151016
:returns: The volume of this Shape
10161017
"""
10171018
# when density == 1, mass == volume
1018-
return Shape.computeMass(self)
1019+
return Shape.computeMass(self, tol)
10191020

10201021
def _apply_transform(self: T, Tr: gp_Trsf) -> T:
10211022

0 commit comments

Comments
 (0)