Run the Cauchy-Crofton ray-sampling estimator on an already-prepared raytrace instance. The caller owns rtip and must call rt_free_rti after this function returns.
- Parameters
-
| out_surf_area | Receives the estimated surface area (mm^2). |
| out_volume | Receives the estimated volume (mm^3). |
| rtip | Prepared raytrace instance (rt_prep_parallel must have been called first). |
| params | Stopping criteria. NULL or all-zero -> 2 000-ray default. |
| bbox_min | Optional focused sampling bbox minimum. Pass NULL to derive the sampling sphere from prepared soltab extents. |
| bbox_max | Optional focused sampling bbox maximum. Pass NULL to derive the sampling sphere from prepared soltab extents. |
- Returns
- The total number of ray-surface crossings accumulated during sampling (>= 0) on success; -1 on bad arguments. A return value of 0 means no geometry was intersected by the sampler.
Near-tolerance sliver geometry: CSG vs BoT divergence
The Cauchy-Crofton formula is mathematically exact for any well-defined solid, but its numerical result depends critically on how the underlying raytracer reports intersections. Two representations of what is intended to be the same geometry can yield radically different – and both internally consistent – surface-area estimates when the geometry contains a sub-tolerance sliver.
Anatomy of the sliver
Consider a window-frame region modelled as a base box minus a slightly smaller cutout box (the r.wind6 pattern in havoc.g). If the subtractor's face protrudes less than BN_TOL_DIST (0.0005 mm) past the base face, a thin sliver of near-zero thickness is present in the raw CSG description. The sliver has two large faces (the Z-faces of the cutout interior, each ~41 600 mm² for a 160 × 260 mm cutout) and a negligible edge band.
CSG raytracer behavior (boolweave filtering)
The BRL-CAD CSG Boolean evaluator (boolweave) discards any solid segment whose thickness is below BN_TOL_DIST. For a ray fired perpendicular to the sliver faces the two-segment chord through the sliver is 0.000340 mm thick – shorter than BN_TOL_DIST – so boolweave merges the entry and exit events and reports a MISS through that region.
For oblique rays, however, the apparent thickness grows with the secant of the angle from normal: chord = d / cos(θ). Once θ exceeds approximately 47° (for a 0.000340 mm gap and a 0.0005 mm tolerance) the sliver segment survives boolweave filtering and contributes two crossing events. Since the Crofton bounding sphere uniformly samples all directions, roughly 68% of solid angles subtend the sliver at angles steep enough to be counted. The result is that the CSG SA estimate converges to a value that is ~74% higher than the ideal clean-frame SA – not because sampling is insufficient, but because the CSG raytracer is correctly reflecting its own view of the geometry: the sliver is visible from the majority of directions but hidden from near-perpendicular directions. Denser sampling does not reduce this bias; experiments with up to 2 000 000 rays confirm that the CSG estimate is stable at ~89 900 mm² (vs an ideal of 51 520 mm²) within the first 500 000 rays and does not drift further regardless of sample count.
BoT raytracer behavior (per-triangle hits)
A triangle mesh (BoT) has no boolweave layer. Every ray that intersects a triangle face produces a hit event regardless of how thin the resulting segment is. A BoT tessellated from the raw CSG without any sliver correction therefore exposes both large sliver faces to the full Crofton hemisphere, converging to ~130 400 mm² – approximately the ideal frame SA plus both full sliver faces (51 520 + 2 × 41 600 ≈ 134 720 mm²).
Perturbed BoT (correct result)
The facetize command's variant-planning / perturb pass enlarges the subtractor just enough to eliminate the sub-tolerance sliver before Manifold performs its Boolean evaluation. The resulting BoT has no phantom interior faces and its Crofton SA converges to ~51 750 mm² – within 0.5% of the analytic ideal – typically in fewer than 64 000 rays (<0.1 s).
Summary table (measured, 200 × 300 × 8 mm frame,
gap = 0.000340 mm < BN_TOL_DIST = 0.0005 mm)
| Representation | Converged SA (mm²) | vs ideal | Stable by |
| CSG (raw, unperturbed) | ~89 900 | +74.5% | ~500k rays |
| BoT (perturbed) | ~51 750 | +0.5% | ~64k rays |
| BoT (no perturb) | ~130 400 | +153% | ~32k rays |
Design implication
The Crofton estimator is accurate and well-converged in all three cases; the divergence is caused by the geometry, not by sampling noise. When comparing a CSG Crofton SA against a BoT Crofton SA as a facetize quality check, geometry with sub-tolerance slivers will always produce a mismatch no matter how many rays are fired. For such geometry the volume estimate (which is insensitive to sliver SA: sliver volume is ~14 mm³ out of 147 200 mm³, or 0.01%) is a far more reliable cross-check metric.