Helper to find the correct mass calculation function with special compound handling.
(obj: Shape)
| 785 | |
| 786 | @staticmethod |
| 787 | def _mass_calc_function(obj: Shape) -> Any: |
| 788 | """ |
| 789 | Helper to find the correct mass calculation function with special compound handling. |
| 790 | """ |
| 791 | |
| 792 | type_ = shapetype(obj.wrapped) |
| 793 | |
| 794 | # special handling of compounds - first non-compound child is assumed to define the type of the operation |
| 795 | if type_ == ta.TopAbs_COMPOUND: |
| 796 | |
| 797 | # if the compound is not empty check its children |
| 798 | if obj: |
| 799 | # first child |
| 800 | child = next(iter(obj)) |
| 801 | |
| 802 | # if compound, go deeper |
| 803 | while child.ShapeType() == "Compound": |
| 804 | child = next(iter(child)) |
| 805 | |
| 806 | type_ = shapetype(child.wrapped) |
| 807 | |
| 808 | # if the compound is empty assume it was meant to be a solid |
| 809 | else: |
| 810 | type_ = ta.TopAbs_SOLID |
| 811 | |
| 812 | # get the function based on dimensionality of the object |
| 813 | return shape_properties_LUT[type_] |
| 814 | |
| 815 | @staticmethod |
| 816 | def computeMass(obj: Shape, tol: float | None = None) -> float: |
no test coverage detected