Crate ifc_lite_core

Crate ifc_lite_core 

Source
Expand description

§IFC-Lite Core Parser

High-performance STEP/IFC parser built with nom. Provides zero-copy tokenization and fast entity scanning for IFC files.

§Overview

This crate provides the core parsing functionality for IFC-Lite:

  • STEP Tokenization: Zero-copy parsing of STEP file format
  • Entity Scanning: SIMD-accelerated entity discovery using memchr
  • Lazy Decoding: On-demand attribute parsing for memory efficiency
  • Streaming Parser: Event-based parsing for large files

§Quick Start

ⓘ
use ifc_lite_core::{EntityScanner, parse_entity, IfcType};

// Scan for entities
let content = br#"#1=IFCPROJECT('guid',$,$,$,$,$,$,$,$);"#;
let mut scanner = EntityScanner::new(content);

while let Some((id, type_name, start, end)) = scanner.next_entity() {
    println!("Found entity #{}: {}", id, type_name);
}

// Parse individual entity
let input = b"#123=IFCWALL('guid',$,$,$,$,$,$,$);";
let (id, ifc_type, attrs) = parse_entity(input).unwrap();
assert_eq!(ifc_type, IfcType::IfcWall);

§Streaming Parser

For large files, use the streaming parser to process entities in batches:

ⓘ
use ifc_lite_core::{parse_stream, StreamConfig, ParseEvent};

let config = StreamConfig::default();
for event in parse_stream(content, config) {
    match event {
        ParseEvent::Entity { id, type_name, .. } => {
            println!("Entity #{}: {}", id, type_name);
        }
        ParseEvent::Progress { percent, .. } => {
            println!("Progress: {:.1}%", percent);
        }
        _ => {}
    }
}

§Performance

  • Tokenization: ~1,259 MB/s throughput
  • Entity scanning: ~650 MB/s with SIMD acceleration
  • Number parsing: one shared reader (read_step_number) over fast-float2

Re-exports§

pub use attribute_slot::AttrKind;
pub use attribute_slot::AttrSlot;
pub use columnar_index::ColumnLengthMismatch;
pub use columnar_index::ColumnarEntityIndex;
pub use columnar_index::SpanBeyondU32;
pub use compatibility::is_exporter_stratum_alias;
pub use compatibility::EXPORTER_STRATUM_ALIASES;
pub use decoder::build_entity_index;
pub use decoder::EntityDecoder;
pub use decoder::EntityIndex;
pub use decoder::GridAxisIndex;
pub use dense_index::DenseEntityIndex;
pub use error::Error;
pub use error::Result;
pub use fast_parse::extract_coordinate_list_from_entity;
pub use fast_parse::extract_coordinate_list_from_entity_f64;
pub use fast_parse::extract_face_indices_from_entity;
pub use fast_parse::parse_coordinates_direct;
pub use fast_parse::parse_indices_direct;
pub use fast_parse::process_triangulated_faceset_direct;
pub use fast_parse::should_use_fast_path;
pub use fast_parse::FastMeshData;
pub use fast_parse::INVALID_INDEX;
pub use generated::attribute_names_for_schema;
pub use generated::entity_info_for_schema;
pub use generated::is_subtype_of_for_schema;
pub use generated::IfcType;
pub use generated::SchemaEntityInfo;
pub use generated::SchemaVersion;
pub use generated::UnknownIfcType;
pub use generated::IFC_TYPES;
pub use georef::model_true_north;
pub use georef::site_ref_location;
pub use georef::unit_xy;
pub use georef::CoordinateOperationKind;
pub use georef::GeoRefExtractor;
pub use georef::GeoRefSource;
pub use georef::GeoReference;
pub use georef::GeoReferenceDetails;
pub use georef::SiteRefLocation;
pub use limits::RtcVerdict;
pub use limits::MAX_CONTEXT_DEPTH;
pub use limits::MAX_MAPPED_ITEM_DEPTH;
pub use limits::MAX_PLACEMENT_DEPTH;
pub use model_bounds::scan_model_bounds;
pub use model_bounds::scan_placement_bounds;
pub use model_bounds::ModelBounds;
pub use parser::declared_schema_bounded;
pub use parser::entity_count;
pub use parser::find_keyword;
pub use parser::keyword_ends_with;
pub use parser::keyword_eq;
pub use parser::keyword_starts_with;
pub use parser::nth_attribute_is_present;
pub use parser::oversized_id_report;
pub use parser::parse_entity;
pub use parser::parse_step_real;
pub use parser::read_step_number;
pub use parser::report_malformed_records;
pub use parser::report_oversized_ids;
pub use parser::report_scan_diagnostics;
pub use parser::scan_report_events;
pub use parser::set_report_sink;
pub use parser::skip_step_comment;
pub use parser::EntityScanner;
pub use parser::StepListItems;
pub use parser::StepNumber;
pub use parser::Token;
pub use project_locator::find_project_id;
pub use project_locator::find_project_ids;
pub use project_units::measure::measure_unit;
pub use project_units::measure::MeasureUnit;
pub use project_units::resolve_unit_by_ref;
pub use project_units::ProjectUnits;
pub use project_units::ResolvedUnit;
pub use project_units::UnitScales;
pub use schema_family::SchemaFamily;
pub use schema_gen::AttributeValue;
pub use schema_gen::DecodedEntity;
pub use schema_gen::GeometryCategory;
pub use schema_gen::IfcSchema;
pub use schema_gen::ProfileCategory;
pub use typed_value::Logical;
pub use step_encoding::decode_ifc_string;
pub use step_encoding::decode_step_binary;
pub use step_encoding::optional_text;
pub use streaming::parse_stream;
pub use streaming::ParseEvent;
pub use streaming::StreamConfig;
pub use unit_labels::is_us_survey_foot_key;
pub use unit_labels::is_us_survey_foot_tokens;
pub use unit_labels::si_prefix;
pub use unit_labels::SiPrefix;
pub use unit_labels::SI_PREFIXES;
pub use unit_labels::US_SURVEY_FOOT_M;
pub use units::extract_length_unit_scale;
pub use units::extract_plane_angle_to_radians;
pub use units::get_si_prefix_multiplier;
pub use units::resolve_length_unit;
pub use units::LengthUnit;
pub use units::try_extract_length_unit_scale;
pub use units::try_extract_plane_angle_to_radians;
pub use source_bundle::SourceBundle;
pub use sparse_source::build_sparse_preamble;
pub use sparse_source::SparseIndex;
pub use sparse_source::SparseSource;
pub use sparse_source::SparseStats;

Modules§

attribute_slot
Runtime by-name attribute lookup over the generated EXPRESS registries.
columnar_index
Columnar entity index — a compact, binary-searched alternative to the EntityIndex FxHashMap<u32, (usize, usize)>.
compatibility
Bounded interoperability policy for non-EXPRESS exporter spellings.
decoder
Entity Decoder - On-demand entity parsing
dense_index
Direct span lookup for dense express ids, without hash-table bucket padding.
error
execution_owner
Stable execution ownership for warm decoder/router workers. A reservation is owned data, never a mutex/TLS guard, and may survive a scheduling yield.
express_id
The single place in this crate that decides whether a digit run read from a raw IFC byte slice fits an express id.
fast_parse
Fast Direct Parsing Module
fmt_num
Canonical number-to-text for property values, the inverse of the float parsing core already owns.
generated
Auto-generated IFC Schema Types
georef
IFC Georeferencing Support
guid
The IfcGloballyUniqueId (22-char GlobalId) home: alphabet, validators, the leading-GlobalId reader and the two deterministic minters.
hash
Hash homes: FNV-1a for stable, platform-independent fingerprints and one xxh3-128 content key for in-memory dedup grouping.
limits
Bounds on walks over file-supplied entity references, plus the large-coordinate threshold every crate gates the RTC re-base on (LARGE_COORD_THRESHOLD_METERS).
model_bounds
Model bounds calculation for large coordinate handling
parser
STEP/IFC Parser using nom
project_locator
The one IFCPROJECT locator (XCUT-6, CORE-3, PROC-AL-12), whose search also finds the model’s IFCSITEs ([find_site_ids]).
project_units
Canonical resolution of a file’s declared units for display.
resource_stop
Fixed resource terminal signals shared by scoped execution owners. Fixed-size resource terminal record shared only by explicit execution capabilities.
schema_family
The four schema families this workspace converts between and labels files with: IFC2X3, IFC4, IFC4X3 and IFC5 (C6-1, D44).
schema_gen
IFC Schema - Dynamic type system
slot
Typed attribute slots: the named, kind-checked replacement for a literal attribute index (F3e-0b, #7780).
source_bundle
Immutable bytes and their canonically scanned index. No caller-provided identity or independently installed index can manufacture a bundle decoder.
sparse_source
Out-of-core source: a decoder’s content that holds only the records a worker has needed so far, instead of the whole file.
step_encoding
STEP string escape decoding (ISO 10303-21 / IFC).
streaming
Streaming IFC Parser
typed_value
Typed STEP parameters (IFCLABEL('x'), IFCPARAMETERVALUE(0.5)) and STEP LOGICAL enumerations (.T., .F., .U.), read through one home (F3c, #7776).
unit_labels
Unit labels and the scales they resolve to.
units
Unit extraction and conversion for IFC files

Structs§

SourceCache
A cache produced by a decoder. Entries and authority cannot be supplied independently. Moving a worker cache moves only a map header and Arc.
TrustedDecoderInputs
Explicit acceptance of a decoder’s current externally authored inputs. This is a trusted configuration revision, NOT source authentication. Later raw imports invalidate it. It cannot be manufactured from an index/token.

Functions§

geometry_flags_by_name
Return the geometry-bearing and representationless-spatial predicates together. The tuple matches has_geometry_by_name and is_representationless_spatial_container_by_name, respectively, while sharing one lookup of the immutable schema classification (#3987).
has_geometry_by_name
Check if a type name (UPPERCASE STEP string) represents an IfcProduct subtype that can bear geometry (has ObjectPlacement + Representation).
ifc_type_from_keyword
Resolve a STEP keyword to its schema-local IfcType. Supported keywords retain their exact generated variants. The three non-EXPRESS exporter stratum aliases remain owned Unknown values and are handled explicitly by has_geometry_by_name. Any pass that classifies or labels an entity must use this helper rather than reimplementing keyword normalization (#4203).
ifc_type_from_record
The schema-resolved type for an entity, recovered from its RAW STEP RECORD.
is_geometry_job
Whether this scanned record schedules geometry, including spatial containers carrying an exceptional non-null Representation (#1910). Raw exporter names retain the same classification as the name-only schema helpers.
is_representationless_spatial_container_by_name
Whether type_name is one of the spatial-container types that has_geometry_by_name still blocks by name (IfcBuildingStorey, IfcFacility, IfcFacilityPart, IfcSpatialElement, IfcSpatialStructureElement, and their subtypes) — i.e. IfcProduct subtypes that is_non_geometric_spatial treats as never carrying geometry directly. IfcBuilding (along with IfcSpace, IfcSite and IfcSpatialZone) is handled class-wide by has_geometry_by_name instead — see [is_non_geometric_spatial] — so it is no longer part of this instance-level exception.
is_simple_geometry_type
Check if an IFC entity class is “simple” geometry (processed first for fast first frame). Driven off the EXPRESS inheritance graph rather than a leaf-level blacklist, so new IFC4X3 subtypes (e.g. IfcSolarDevice under IfcEnergyConversionDevice) are categorised correctly without code changes — see PR #585.
type_product_ifc_type
The IfcTypeProduct subtype a STEP keyword names, or None when it is not one.