Skip to main content

compile_product_item_meshes_with

Function compile_product_item_meshes_with 

Source
pub fn compile_product_item_meshes_with<B: MeshCompiler>(
    backend: &B,
    model: &Model,
    product: EntityId,
    tolerance: Tolerance,
) -> GeometryResult<Option<Vec<ItemMesh>>>
Expand description

Mesh each leaf item of a product’s Body with a caller-supplied backend.

A viewer that colours per item needs one mesh per styled item, in the order its colours come: index i here and index i of ColourResolver::item_colours name the same item.

§Return values

  • Ok(None): the product has no Body representation, in the cases where compile_product_mesh_with returns None.
  • Ok(Some(vec![])): the Body’s items expand to no leaves. Unlike this, compile_product_mesh_with returns Ok(None) for an empty Items.

§Order

One entry per leaf, in authored Items order, depth first, every IfcMappedItem expanded through MappingSource.MappedRepresentation. Every other item is a leaf, including booleans, CSG and geometric sets. The representation is the one select_product_representation picks for the Body. Two occurrences of one map give two entries with the same item and different mapped_by.

§Geometry

Each leaf compiles the nodes and transforms the whole Body does, so for a single-item Body without maps the mesh equals compile_product_mesh_with’s bit for bit. For several items the triangle counts sum to the product mesh’s and the bounds join to its bounds. The meshes are gross: openings are not subtracted (ADR 0014). A curve leaf is compiled as the backend treats a one-item Body of that curve.

§Errors

All or nothing; no partial list is returned. Any lowering error of any leaf is returned unchanged (MissingEntity, Unsupported, CyclicChain or ChainTooDeep of kind "mapped item", units errors), as compile_product_mesh_with raises them. A backend refusal of any leaf is GeometryError::CompilationRefused naming product, or its seam-window variants.

§Cost

One lowering per product and one compilation per leaf. A map’s source is lowered once per product and instanced.