Skip to main content

Crate openbim_ifc_binding_core

Crate openbim_ifc_binding_core 

Source
Expand description

Host-independent core of the IFC language bindings (ADR 0013, #34).

The WebAssembly, C and Python bindings each wrap IfcModel and move value::Tagged values into and out of their host. The operations, the lossless value encoding and the error codes live here once, so the three hosts cannot drift apart: a fix or a new operation lands in one place and every binding exposes it.

This crate adds no IFC behaviour of its own. It is a thin, host-shaped view of openbim-ifc; if a binding needs more, the facade grows first.

§Features

Beyond the release features (ifc2x3 … ifc4x3, #112), three default features select facade capabilities that add to a browser build’s size: ifcxml (the ifcXML codec), validate (schema validation) and unreachable (the viewer reachability lint). An operation whose feature is off still exists, so every host keeps one surface, and refuses with feature-disabled.

Every read recognizes an ifcZIP archive by its ZIP signature and reads the STEP or ifcXML model it holds within a decompression budget (ifczip, feature zip); IfcModel::write_ifczip writes one.

Attributes are read and written by position or by name (IfcModel::attribute_by_name); a name resolves against the release the header declares, inherited attributes included, and is refused with unknown-attribute (or derived-attribute for a write to a * slot) rather than guessed. A by-name write also takes a plain host value (Plain, #342), coerced against the attribute’s declared type (coerce): a string to a label or an enumeration item, an integer to an INTEGER or a REAL, refused with type-mismatch when it does not fit and ambiguous-value when several SELECT members would take it.

Property sets resolve per object (IfcModel::property_sets) or for many objects in one pass (IfcModel::property_sets_many, #358), which validates the file’s property relationships once rather than per object.

Entities are created by type and named attributes (#330, feature author), alone or with the spatial, product, type and placement builders in one checked batch (IfcModel::author); a refused batch leaves the model unchanged.

Geometry crosses at two levels (#328, ADR 0021): each product’s world placement and selected Body representation (IfcModel::product_placements, feature placements, default), and triangle meshes from the reference backend (IfcModel::product_meshes, feature mesh, opt-in because it links an execution provider). A product that cannot be placed or meshed is a record with a typed refusal, never a failed call.

Property edits check Pset_/Qto_ sets against the PSD/QTO catalog (catalog): embedded with property-catalog (default), or loaded at runtime from pinned snapshot files with property-catalog-runtime, the npm package’s choice, where a write before loading refuses with catalog-not-loaded. Entities are found by GlobalId (IfcModel::by_guid, #463) through an index built on the first lookup and rebuilt only after an edit; a GlobalId several entities carry is refused with invalid-model, never answered with one. new_guid draws a random GlobalId and name_based_guid derives a reproducible one. An object’s type, a type’s occurrences, an element’s openings and an opening’s fillings and host (IfcModel::type_object and its siblings) read the relationships the declared release states.

Selectors (#464, selector) filter the model by class, attribute, property, type, material, classification, location and group (IfcModel::select); values are read and written by path (IfcModel::get_value, IfcModel::set_value). A query that does not parse is refused with invalid-selector and the byte span of the offending text (BindingError::span).

Units convert between each other (convert_unit, IfcModel::convert_unit_value, format_length, #469), and IfcModel::convert_length_unit rescales a whole model to a new project length unit as one checked transaction (units). Tables of values by path (#474, table): the entities a selector selects exported as CSV, TSV or XLSX (IfcModel::export_table), and a table applied back by GlobalId or id as one checked transaction (IfcModel::import_table), with every refusal by row and column and a dry run. XLSX needs feature sheet-xlsx (default; the browser package leaves it out and refuses with feature-disabled).

INVERSE attributes read by name too (inverse, #462): attribute_by_name(wall, "IsDefinedBy") follows the declared release’s FOR clause through a reverse index built on first use and rebuilt only after an edit; IfcModel::inverse_references and IfcModel::total_inverses list and count every referrer.

Re-exports§

pub use authoring::AppendOptions;
pub use authoring::AuthorOp;
pub use authoring::AuthoringResult;
pub use authoring::CopiedEntity;
pub use authoring::CopyProductOptions;
pub use authoring::CopyReport;
pub use authoring::KeptEntity;
pub use authoring::PurgeOptions;
pub use authoring::RemovalReport;
pub use authoring::RemoveProductOptions;
pub use authoring::RemovedEntity;
pub use coerce::Plain;
pub use geometry::curves::ProductCurves;
pub use geometry::curves::ProductPolyline;
pub use geometry::graph::GeometryEncoding;
pub use geometry::graph::ProductGeometry;
pub use geometry::graph::GEOMETRY_FORMAT;
pub use geometry::graph::GEOMETRY_FORMAT_VERSION;
pub use geometry::GeometryRefusal;
pub use geometry::ProductMesh;
pub use geometry::ProductPlacement;
pub use geometry::SelectedRepresentation;
pub use geometry::SurfaceColour;
pub use history::HistoryChange;
pub use history::HistoryState;
pub use inverse::InverseAttributeInfo;
pub use inverse::InverseReference;
pub use record::Field;
pub use record::Record;
pub use record::ToRecord;
pub use relations::name_based_guid;
pub use relations::new_guid;
pub use relations::DuplicateGlobalId;
pub use selector::canonical_selector;
pub use selector::Selected;
pub use selector::SELECTOR_GRAMMAR_VERSION;
pub use table::TableChange;
pub use table::TableImport;
pub use table::TableRefusal;
pub use units::convert_unit;
pub use units::format_length;
pub use units::ConvertedValues;
pub use units::KeptValues;
pub use units::LengthUnitOptions;
pub use units::LengthUnitReport;
pub use unreachable::UnreachableProduct;
pub use validation::ValidationFinding;
pub use validation::ValidationReport;
pub use validation::ValidationSummary;

Modules§

authoring
Schema-checked entity creation (#330, feature author).
catalog
The PSD/QTO catalog that property edits check Pset_ and Qto_ sets against (ADR 0017; #123, #318).
classification
Classification references (feature classification, #123).
coerce
Plain host values written by name, coerced against the declared type (#342).
cost
Cost schedules, items and values (feature cost, #123).
geometry
Geometry for the hosts (#328, #367, ADR 0021), at three levels.
georef
Georeferencing (feature georef, #123).
header
The STEP file header: read it whole, replace it whole.
history
Undo and redo for every mutator (#465).
ifczip
ifcZIP (#450, feature zip): a STEP or ifcXML model in a ZIP archive.
inverse
INVERSE attributes by name and the entities referencing one (#462).
material
Materials (feature material, #123).
properties
Property sets, quantities and units (feature properties, #123).
property_edit
Writing property sets and quantities (feature properties-write, #123).
record
The host-independent shape of a domain record (#123).
relations
Entities by GlobalId, new GlobalIds, and an object’s type, a type’s occurrences and the openings and fillings of elements (#463).
selector
Selectors and values by path (#464): the facade’s ifc::selector.
spatial
The spatial tree and containment (feature spatial, #123).
systems
Distribution systems and their membership (feature systems, #123).
table
Tables of values by path (#474): the facade’s ifc::sheet.
units
Unit conversion and a model’s length unit (feature properties, #469).
unreachable
Products no viewer will draw (feature unreachable).
validation
Schema validation as plain records (feature validate).
value
The lossless tagged value encoding (ADR 0013).

Structs§

AttributeInfo
One explicit attribute of an entity, as its declared release defines it.
IfcModel
An IFC model: entities keyed by their #id, in file order.
ParseOptions
How a STEP read treats damaged or non-conforming input.

Enums§

BindingError
Why a binding call failed.
OnMalformed
What a STEP read does with a data record it cannot parse.