Skip to main content

Module shape

Module shape 

Source
Expand description

Shape signatures for the similar part search – cheap, explainable, no ML.

A Signature summarises the 3D preview mesh of a file (see mesh):

  • principal extents – the edge lengths of an oriented bounding box, largest first. The box starts from the principal axes of the surface (area-weighted covariance) and is then tightened plane by plane with the minimum-area rectangle of the projected convex hull, so it neither depends on how the part lies in the file nor on the tessellation;
  • surface area and enclosed volume (sum of signed tetrahedra) – the volume is only meaningful when every edge is shared by exactly two consistently oriented triangles (closed);
  • a D2 shape distribution (Osada et al. 2002): the histogram of the distances between random point pairs on the surface, divided by the diagonal of the box – a fingerprint that ignores position, rotation and scale. The points are drawn with a fixed seed, so a file always gets the same signature;
  • the triangle count.

compare ranks two signatures (see there for the formula) and explain says why in one line. All work is bounded: the box search uses at most AXIS_SAMPLE vertices, D2 draws D2_PAIRS pairs, the closedness check stops at CLOSED_CHECK_LIMIT triangles. The server computes signatures in the isolated preview process (see preview).

Structs§

Signature
The shape signature of one mesh.
Similarity
How alike two signatures are.

Enums§

Outcome
What the preview process writes: the signature or why there is none.

Constants§

AXIS_SAMPLE
Vertices used to orient the bounding box (evenly spaced subset).
CLOSED_CHECK_LIMIT
Larger meshes are not checked for closedness (their volume is flagged as unreliable instead).
D2_BINS
Bins of the D2 histogram.
D2_PAIRS
Point pairs drawn for the D2 histogram.
VERSION
Bump when the computation changes: stored signatures of another version are ignored and computed again – also when the preview meshes change (preview::CACHE_VERSION), since the signature is computed from them. 2: the STEP readers of preview cache version 2 (tessellated AP242, partial previews without a signature). 3: preview cache version 3 (Inventor parts with Zstandard segments, #271). 4: preview cache version 4 (Creo parts in millimetres).

Functions§

compare
Compares two signatures:
compute
Computes the signature of a triangle mesh. Point clouds, meshes without surface and broken coordinates are errors, never panics.
explain
One line for people: the extents (or proportions) of both, the shape similarity and – when both are watertight – the volumes.
fmt_extents
120 × 40 × 8.
fmt_len
A length with three significant digits at most: 120, 40.5, 8.25, 0.012.