Struct LayerSet

Source
pub struct LayerSet { /* private fields */ }
Expand description

The layers of one model and, optionally, the files they import.

Implementations§

Source§

impl LayerSet

Source

pub fn new() -> Self

An empty set that does not resolve imports.

Source

pub fn push_layer(&mut self, bytes: Vec<u8>)

Adds a layer’s UTF-8 JSON bytes on top of the layers already added.

Source

pub fn resolve_imports(&mut self)

Resolves imports, even if no import file is added: every import of every layer must then be one of the added files.

Source

pub fn add_import(&mut self, uri: String, bytes: Vec<u8>)

Serves bytes for imports whose uri is exactly uri, and turns on import resolution.

Source

pub fn len(&self) -> usize

Number of layers added.

Source

pub fn is_empty(&self) -> bool

Whether no layer was added.

Source

pub fn federate(&self) -> Result<IfcxFile, BindingError>

All layers merged into one file. Without imports, the layers’ schemas and data are concatenated in order. With imports, the layers are the imports of a synthetic main layer, each after the layers it imports, so a layer overrides its imports and the next layer overrides both. The header is that of the last layer in this order, the strongest.

Source

pub fn compose(&self) -> Result<Composition, BindingError>

Flattens and composes the federated layers.

Source

pub fn compose_json(&self) -> Result<String, BindingError>

The composed tree as JSON text: the artificial root over every root node, each node {"path", "attributes", "children"}.

Source

pub fn to_glb(&self, settings: &GlbSettings) -> Result<Vec<u8>, BindingError>

The composed layers as a binary glTF 2.0 (.glb) file: their flat render scene with transformed, instanced meshes, lines and points and their materials, one glTF node per instance named by its IFCX path.

Geometry values that do not decode are left out of the scene, as RenderScene does; the file is still written.

Source

pub fn validate_json(&self) -> Result<String, BindingError>

Checks the attributes of the federated layers against their merged schemas, those of resolved imports included (as openbim_ifcx::layers::LayerStack::validate does), and returns the report as JSON text: {"valid": bool, "failures": [{"node", "attribute", "pointer", "kind", "message"}]}. kind is a stable code such as missing-schema or type-mismatch.

Trait Implementations§

Source§

impl Clone for LayerSet

Source§

fn clone(&self) -> LayerSet

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayerSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LayerSet

Source§

fn default() -> LayerSet

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.