Skip to main content

exact_properties

Function exact_properties 

Source
pub fn exact_properties(
    brep: &ExactBRep,
    tolerance: Tolerance,
) -> Result<MassProperties, ExactMeasureError>
Expand description

Mass properties of an exact B-rep.

§Method

A planar face bounded by straight edges is a polygon in 3-space. Fanning it into triangles about its first vertex and applying the divergence theorem gives volume, centroid and second moments in one pass – the same closed forms crate::mesh uses, but over the B-rep’s own boundary polygons rather than over a tessellation of them. For planar faces the fan is not an approximation: a planar polygon is exactly the union of its fan triangles.

Every other face – cylinders, cones, spheres, tori, elliptical cylinders, B-spline surfaces, and planar faces with an arc or ellipse on their boundary – contributes the same cone integrals over its own parameter domain, by Green’s theorem round its pcurves (see exact_face). Both paths use the same fields, so a solid mixing them sums consistently.

Every field is integrated about a point of the solid – the centre of its vertices’ bounding box – not about the world origin, and the centroid and second moments are shifted back by the parallel-axis terms (#343). The cone of a face about the world origin grows with the cube of the distance to it: a 0.57 m^3 box on a national grid at (6e5, 5.6e6) summed terms near 1e14 whose cancellation had to produce the volume, and measured up to 18 % wrong with no error. About its own centre the same box measures its closed form up to the grid its corners were placed on, wherever it sits.

Orientation is honoured at every level: a face marked Orientation::Reversed, a reversed use of a face in its shell, and a reversed bound each flip the loop’s winding, exactly as audit_brep reads them. A correctly built solid yields a positive volume wherever it sits, without the caller pre-normalising anything. Every shell is summed, so a void shell, used reversed, subtracts its volume.

§Errors

Refuses an unknown surface family, a face whose pcurves do not bound a domain, an integral that does not converge, and a boundary that encloses nothing – never approximating any of them.