Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,16 +795,17 @@ def _mass_calc_function(obj: "Shape") -> Any:
return shape_properties_LUT[type_]

@staticmethod
def computeMass(obj: "Shape") -> float:
def computeMass(obj: "Shape", tol: Optional[float] = None) -> float:
"""
Calculates the 'mass' of an object.

:param obj: Compute the mass of this object
:param tol: Numerical integration tolerance (optional).
"""
Properties = GProp_GProps()
calc_function = Shape._mass_calc_function(obj)

calc_function(obj.wrapped, Properties)
calc_function(obj.wrapped, Properties, *(tol if tol else ()))

return Properties.Mass()

Expand Down Expand Up @@ -1010,12 +1011,12 @@ def Area(self) -> float:

return Properties.Mass()

def Volume(self) -> float:
def Volume(self, tol: Optional[float] = None) -> float:
"""
:returns: The volume of this Shape
"""
# when density == 1, mass == volume
return Shape.computeMass(self)
return Shape.computeMass(self, tol)

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

Expand Down