Skip to main content

Crate ifc

Crate ifc 

Source
Expand description

ifc — the facade. Pick your codecs and domains as cargo features.

§The shape of the library

  codecs                 model                  domain views
  ---------------        ---------------        ------------------
  ifc-step      \                        /      ifc-cost
  ifc-xml        >----->  ifc-model  <--<       ifc-schedule
  (ifc-json)    /         (entities)     \      ifc-properties, ...

Two separations hold this together, and both are enforced by tests rather than convention:

1. The model knows no domain semantics. Model stores (id, type_name, attributes) and nothing else. It has never heard of a cost item. Domain crates are views that borrow a &Model and interpret it, so a build without them still reads and writes their data untouched.

2. The model knows no serialization. Codec is a trait in the model crate; ifc-step and ifc-xml implement it. IFC-JSON would be a third implementation, requiring no change to the model.

§Choosing features

FeaturePulls inFor
step (default)ifc-stepReading .ifc files
ifcxmlifc-xmlReading/writing .ifcxml
schemaifc-schemaSubtype queries, conformant XML names
material-templatesifc-material + template catalogMaterial PSD applicability
cost, schedule, …one domain crate eachInterpreting that domain
codecsboth codecs
domainsevery domain view
fulleverything

A thin viewer takes default-features = false, features = ["step"] and compiles no domain code and no geometry stack, while still round-tripping every entity in the file.

use ifc::{Codec, StepCodec};

let source = b"ISO-10303-21;\nHEADER;\nFILE_DESCRIPTION((''),'2;1');\n\
               FILE_NAME('t.ifc','',( ''),(''),'','','');\n\
               FILE_SCHEMA(('IFC4'));\nENDSEC;\nDATA;\n\
               #1= IFCCOSTITEM('guid',$,'Excavation',$,$,$,$);\n\
               ENDSEC;\nEND-ISO-10303-21;\n";

let model = StepCodec.read_bytes(source).unwrap();
assert_eq!(model.len(), 1);

// The cost entity is present and re-exportable with no `cost` feature on.
let out = StepCodec.write_bytes(&model).unwrap();
assert!(String::from_utf8_lossy(&out).contains("IFCCOSTITEM"));

Modules§

codec
The serialization seam.

Structs§

Applied
What a committed transaction did.
Entity
One IFC entity instance.
EntityId
An entity’s identifier as it appeared in the file (#42 → 42).
Header
Metadata describing the file and the schema it claims to follow.
Model
A parsed IFC file: header, entities, and indices over them.
ParseOptions
A STEP reader with an explicit policy: recovery, eager decoding, or a memory-mapped read (StepReader::read_path_mapped). Malformed-record policy, re-exported so consumers need not depend on openbim-step directly to configure a reader. Parse behavior toggles.
StepCodec
The STEP physical file codec (.ifc). The STEP physical file codec.
StepReader
A STEP reader with an explicit policy: recovery, eager decoding, or a memory-mapped read (StepReader::read_path_mapped). A STEP codec carrying an explicit parse policy.
Transaction
A batch of edits, validated together and applied as a unit.

Enums§

Conflict
A reason a transaction cannot be committed.
ModelError
Errors from reading, writing, or querying a model.
OnMalformed
A STEP reader with an explicit policy: recovery, eager decoding, or a memory-mapped read (StepReader::read_path_mapped). Malformed-record policy, re-exported so consumers need not depend on openbim-step directly to configure a reader. What to do when a data record cannot be parsed.
Value
One attribute slot in an entity.

Traits§

Codec
Read and write one concrete IFC serialization.

Functions§

codecs
Every codec compiled into this build.
compiled_features
The feature set this build was compiled with, for diagnostics.
from_step_bytes
Parse a .ifc (STEP physical file) buffer without importing Codec or naming ifc_step::StepCodec directly.
read_path
Read a file, choosing the codec by content sniffing then extension.