pub struct Assembly { /* private fields */ }Expand description
A hierarchical assembly of positioned components.
The assembly tree supports:
- Adding components with transforms
- Parent-child hierarchy
- Instance sharing (same solid, different transforms)
- Bounding box computation for the entire assembly
- Flattening to a list of positioned solids
Implementations§
Source§impl Assembly
impl Assembly
Sourcepub fn add_root_component(
&mut self,
name: impl Into<String>,
solid: SolidId,
transform: Mat4,
) -> ComponentId
pub fn add_root_component( &mut self, name: impl Into<String>, solid: SolidId, transform: Mat4, ) -> ComponentId
Adds a root-level component (no parent).
Sourcepub fn add_child_component(
&mut self,
parent: ComponentId,
name: impl Into<String>,
solid: SolidId,
transform: Mat4,
) -> Result<ComponentId, OperationsError>
pub fn add_child_component( &mut self, parent: ComponentId, name: impl Into<String>, solid: SolidId, transform: Mat4, ) -> Result<ComponentId, OperationsError>
Adds a child component under an existing parent.
§Errors
Returns an error if the parent ID doesn’t exist.
Sourcepub fn component(&self, id: ComponentId) -> Option<&Component>
pub fn component(&self, id: ComponentId) -> Option<&Component>
Returns a component by ID.
Sourcepub fn roots(&self) -> &[ComponentId] ⓘ
pub fn roots(&self) -> &[ComponentId] ⓘ
Returns root-level component IDs.
Sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
Returns the total number of components.
Sourcepub fn world_transform(&self, id: ComponentId) -> Option<Mat4>
pub fn world_transform(&self, id: ComponentId) -> Option<Mat4>
Computes the world transform for a component by multiplying all parent transforms in the hierarchy.
Sourcepub fn flatten(&self) -> Vec<(SolidId, Mat4)>
pub fn flatten(&self) -> Vec<(SolidId, Mat4)>
Flattens the assembly to a list of (solid, world_transform) pairs.
This resolves the full hierarchy, computing the accumulated transform for each leaf component.
Sourcepub fn bounding_box(&self, topo: &Topology) -> Result<Aabb3, OperationsError>
pub fn bounding_box(&self, topo: &Topology) -> Result<Aabb3, OperationsError>
Computes the bounding box of the entire assembly.
§Errors
Returns an error if any solid’s bounding box computation fails.
Sourcepub fn bill_of_materials(&self) -> Vec<BomEntry>
pub fn bill_of_materials(&self) -> Vec<BomEntry>
Generate a bill of materials: list of unique solids and their instance count.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Assembly
impl RefUnwindSafe for Assembly
impl Send for Assembly
impl Sync for Assembly
impl Unpin for Assembly
impl UnsafeUnpin for Assembly
impl UnwindSafe for Assembly
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more