Expand description
Scenes of several editable meshes, built on fast_mesh_store,
fast_mesh_bvh and fast_mesh_query.
A Scene owns meshes, each with a BVH, an UpdateMode and a
Placement (a rotation, a per-axis scale and a translation into the
world). Meshes are addressed by generational MeshIds: once a mesh is
removed, its id is rejected with SceneError::UnknownMesh for good.
- Registry:
Scene::add_mesh,Scene::remove_mesh,Scene::meshandScene::ids(in index order). - Placements:
Scene::placementandScene::set_placement. A placement is validated (a proper rotation, a finite positive scale) and stored exactly as given. World queries, fields and sections all follow the scale; pair queries run on copies baked into one mesh’s local space (or into the world) when a scale is involved. - Editing:
Scene::editruns a store transaction on one mesh and records its patch. All-or-nothing: a failed edit changes nothing. The closure may fail with any error that converts intoSceneError, so repair operations fromops(the re-exportedfast-mesh-ops) run directly:scene.edit(id, |tx| ops::fill_holes(tx, &options)). - Joining:
Scene::joinappends one mesh’s geometry into another and bridges a loop on each, as one undo step, then removes the source mesh. - Cutting:
Scene::cut_by_planesplits a mesh with a world plane, capping both openings flat by default, and adds the removed side as a new mesh with the same placement, as one undo step. - Booleans:
Scene::booleanunions, subtracts or intersects mesh B into mesh A in the world; the result replaces A with A’s placement, as one undo step. - Registration:
Scene::registerrigidly aligns one mesh to another by trimmed point-to-plane ICP from their current placements, and sets the moving mesh’s placement as one undo step when the result is good. - History: one undo history across all meshes, in steps.
Scene::begin_step/Scene::end_stepgroup edits and placement changes (otherwise each is its own step);Scene::undo,Scene::redoandScene::cancel_stepare all-or-nothing per step.SceneOptions::history_budgetevicts the oldest steps. - BVH state: each mesh’s
UpdateModesays when its BVH follows the mesh;Scene::set_mode,Scene::update,Scene::flushandScene::is_current. - Change reports:
Scene::take_changesdrains oneMeshChangesper affected mesh. Further consumers each get their own copy of every report:Scene::subscribe,Scene::take_changes_forandScene::unsubscribe. - UVs: a mesh added with
Mesh::add_uvskeeps them through edits, undo and redo. Every operation preserves or undoably drops them; seedocs/uv-channel.md. - Maintenance:
Scene::add_channel,Scene::remove_channel,Scene::derived_channel_mut(all three reported, and thefield:prefix reserved) andScene::compact. - Local space:
Scene::bvh(current BVHs only),Scene::relative_transform,Scene::world_to_localandScene::local_to_world. - World queries, in world
f64coordinates:Scene::raycast,Scene::closest_pointandScene::closest_point_on, and between two meshesScene::intersects,Scene::mesh_distanceandScene::triangles_near. Each maps into mesh-local space, runs the Phase 3 query and maps the result back; bounds are rounded outward tof32and results filtered against the exact bound. Queries over all meshes update every Lazy BVH and fail withSceneError::StaleBvhon a stale Manual one; queries naming meshes touch only those. - Contacts:
Scene::find_contactsfinds the mesh pairs within a margin (broadphase over world boxes, then Phase 3b per pair), optionally restricted by aContactFilter. - Distance fields:
Scene::add_distance_fieldregisters a signed distance field (DistanceField) from one mesh’s vertices to another mesh, stored in a derived channelfield:<name>and kept up to date incrementally under theUpdateModeof the mesh it is on (Scene::update_fields,Scene::flush). Read withScene::field_valuesandScene::field_status; list a mesh’s withScene::fields_on; changemax_distanceor the sign mode withScene::reconfigure_field; remove withScene::remove_field(or with either mesh). - Colours:
Scene::set_coloringcolours a mesh from one of its fields with aColorRule;Scene::coloringreturns the colouring,Scene::colorsone RGBA8 per vertex slot, and recoloured vertices are reported inMeshChanges::colors_dirty. - Normals:
Scene::set_normalsturns a mesh’s smooth vertex normals on;Scene::normalsreturns one mesh-local normal per vertex slot, kept up to date incrementally under the mesh’sUpdateMode, and recomputed vertices are reported inMeshChanges::normals_dirty. - Sections:
Scene::add_sectioncuts meshes with a worldPlane(SectionDesc) into contours in world and plane(u, v)coordinates, with length, signed area and an optional fill (SectionResult), kept up to date under each mesh’sUpdateMode(Scene::update_sections,Scene::flush). Read withScene::section,Scene::section_statusandScene::section_gap; changes are reported inMeshChanges::sections_changed.
Re-exports§
pub use fast_mesh_ops as ops;
Structs§
- Boolean
Report - What
Scene::booleandid. - Color
Rule - How a scalar field is turned into colours.
- Coloring
- How a mesh is coloured from one of its fields, for
Scene::set_coloring. - Contact
- Two meshes within the margin of
Scene::find_contacts. - Contact
Filter - Which mesh pairs
Scene::find_contactslooks at. - Curvature
Field - A per-vertex curvature field to register with
Scene::add_curvature_field. - CutOptions
- What to cut: a world plane and whether to cap.
- CutReport
- What
Scene::cut_by_planedid. - Distance
Field - A signed distance field to register with
Scene::add_distance_field. - FieldId
- A field registered on a mesh of the scene.
- Field
Status - The state of a field, from
Scene::field_status. - Fill
- The filled cross-section made by
fill: triangles over(u, v)points. - Gap
- The closest pair between two meshes’ contours in a section, from
Scene::section_gap. - Join
Options - What to join: a loop on the target and a loop on the source.
- Join
Report - What
Scene::joindid. - Mesh
Build - A mesh being prepared for
Scene::add_mesh_builtoutside any scene: its BVH, and its vertex normals when asked for (MeshBuild::set_normals), are built in steps (MeshBuild::step), so that a caller can yield between them (the Worker engine adds large meshes this way). Nothing of it is in a scene until it is added. - Mesh
Changes - What happened to one mesh since the subscriber’s last
Scene::take_changes_for(orScene::take_changesfor the default subscriber). - MeshId
- A handle to a mesh in a
Scene. - Mesh
Options - Options for adding a mesh to a
Scene. - Placement
- A transform from a mesh’s points to the world:
world = rotation * (scale * p) + translation, wherepis the mesh’s own point (its origin plus a local position), all inf64. - Plane
- A plane in mesh-local coordinates, with an orthonormal 2D frame
(u, v)in it. The frame is right-handed:normal = u × v. - Register
Options - Options for
Scene::register. - Register
Report - What
Scene::registerfound. - Scene
- Several meshes, each with a BVH and a placement in the world.
- Scene
Closest Hit - The point of the scene nearest to a world point.
- Scene
Closest Options - Options for
Scene::closest_pointandScene::closest_point_on, in world units. - Scene
Mesh Distance - The closest pair of points between two meshes, in the world.
- Scene
Options - Options for a
Scene. - Scene
RayHit - Where a world ray hit a mesh of the scene.
- Scene
RayOptions - Options for
Scene::raycast, in world units. - Section
Contour - One chain of a section: a closed loop or an open polyline.
- Section
Desc - A plane section to register with
Scene::add_section. - Section
Id - A plane section of the scene, from
Scene::add_section. - Section
Result - A section’s result for one mesh, from
Scene::section. - Sign
Status - What
SignData::buildfound out about a mesh, so that an application can warn when signs are doubtful. - Subscriber
Id - A consumer of change reports, from
Scene::subscribe. - Thickness
Field - A per-vertex wall-thickness field to register with
Scene::add_thickness_field.
Enums§
- Boolean
Op - Which boolean to compute.
- Colormap
- A colormap from
tin[0, 1]to RGBA8. - Field
Budget - How much one
Scene::field_stepcomputes. - Fields
Error - Why a field kernel could not run.
- NotApplied
- Why a result was not applied.
- OutOf
Range - What to show for a value outside the colour range.
- Scene
Error - Why a scene operation could not run. A failed operation leaves the scene unchanged.
- Section
Status - Whether a section’s result for a mesh matches the scene as it is now,
from
Scene::section_status. - Sign
Mode - How the sign of a distance is decided.
- Step
State - Where the field step unit stands after
Scene::field_step. - Update
Mode - When a mesh’s BVH is brought up to date after the mesh changes.
Constants§
- DEFAULT_
MAX_ RMSE_ FRACTION - The default
RegisterOptions::max_rmse, as a fraction of the moving points’ extent. A wrong local minimum measured about 3%, and the same mesh with noise of 1% of its size correctly aligned at about 0.4% (icp_surveyinfast-mesh-ops). Scans noisier than this need their own limit.
Functions§
- color_
of - The colour of value
vunderrule.
Type Aliases§
- Result
ResultwithSceneErroras the error type.