Skip to main content

Module hollow

Module hollow 

Source
Expand description

Hollowing a closed mesh: a sealed cavity inside it, its wall a set distance from the part’s surface.

§The distance field

The part’s distance field is sampled on a grid of cubic cells, a third of the wall wide unless the caller says otherwise, over the part’s box. Each node is inside, outside or on the part by the crossings of the line along x through it: the triangles that line crosses are found exactly, a line through an edge or a vertex resolved by simulation of simplicity, as boolean resolves its rays, and a node is inside where an odd number of them lie ahead of it, each decided by the exact side of the node on the triangle’s plane. A node inside takes its exact distance to the nearest triangle, through the part’s Bvh, negated.

Only distances near the wall decide anything. The field is 1-Lipschitz, so a node deeper than the wall by more than the longest edge of the tetrahedra below, a cell’s diagonal √3 h, has every neighbour deeper than the wall: a node with no triangle within wall + 2h takes that distance and loses nothing. For the same reason a node outside needs no distance unless √3 h reaches across the wall.

§The wall

Each cell is split into six tetrahedra about its diagonal along x + y + z, the same in every cell, so neighbours share their faces’ splits. The cavity is where the field is below -wall; a node exactly at it counts outside the cavity, so no node lies on the surface. In each tetrahedron the surface crosses the edges joining a node in the cavity to one out of it, at the point the field interpolates linearly to -wall, held at least CLAMP of the edge from either end. Points anywhere inside the edges give triangles that meet only along their shared edges, so the cavity’s surface is closed, 2-manifold and crosses itself nowhere; each triangle is wound by the exact side of a node in the cavity, so that it faces into the cavity, out of the part’s material.

The surface is then decimated with Target::Verified within a sixteenth of a cell, every point of each side measured.

§Checked, not assumed

The cavity is added to the part as a second shell, with no boolean, so the result is checked exactly as boolean checks an operand: closed, 2-manifold, no degenerate triangle, no triangle of the cavity meeting another triangle but at shared corners, and every shell wound outward of the material, which puts each cavity strictly inside the part. A decimated cavity that fails, or that misses its tolerance, is replaced by the one marched; one that fails too is an error.

§Error

A point of the cavity’s wall, before decimation, is where the linear interpolation of the field is -wall; the field differs from its interpolation within a tetrahedron by at most the tetrahedron’s diameter, √3 h, and where the field is smooth with curvature κ, by about 3 h² κ / 2. Holding the point off the ends moves it by at most √3 h CLAMP, and the decimation by h / 16.

Structs§

Grid
The grid a hollow’s distance field is sampled on.
Hollowed
A hollowed mesh, and what made it.

Constants§

CLAMP
The share of a grid edge’s length a crossing is held from either end.

Functions§

hollow
Hollow a closed mesh, leaving a wall wall thick.