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: 10x faster than std using lexical-core
Re-exports§
pub use columnar_index::ColumnLengthMismatch;pub use columnar_index::ColumnarEntityIndex;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_entity_refs_from_list;pub use fast_parse::extract_entity_type_name;pub use fast_parse::extract_face_indices_from_entity;pub use fast_parse::extract_first_entity_ref;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 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::UnknownIfcType;pub use generated::IFC_TYPES;pub use georef::GeoRefExtractor;pub use georef::GeoRefSource;pub use georef::GeoReference;pub use limits::RtcVerdict;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::report_malformed_records;pub use parser::report_oversized_ids;pub use parser::report_scan_diagnostics;pub use parser::set_report_sink;pub use parser::skip_step_comment;pub use parser::EntityScanner;pub use parser::StepListItems;pub use parser::Token;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 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 step_encoding::decode_ifc_string;pub use streaming::parse_stream;pub use streaming::ParseEvent;pub use streaming::StreamConfig;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::try_extract_length_unit_scale;pub use units::try_extract_plane_angle_to_radians;
Modules§
- columnar_
index - Columnar entity index — a compact, binary-searched alternative to the
EntityIndexFxHashMap<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
- 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
- generated
- Auto-generated IFC Schema Types
- georef
- IFC Georeferencing Support
- 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_
units - Canonical resolution of a file’s declared units for display.
- schema_
gen - IFC Schema - Dynamic type system
- step_
encoding - STEP string escape decoding (ISO 10303-21 / IFC).
- streaming
- Streaming IFC Parser
- units
- Unit extraction and conversion for IFC files
Functions§
- geometry_
flags_ by_ name - Return the geometry-bearing and representationless-spatial predicates together.
The tuple matches
has_geometry_by_nameandis_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
IfcProductsubtype that can bear geometry (hasObjectPlacement+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 ownedUnknownvalues and are handled explicitly byhas_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_
representationless_ spatial_ container_ by_ name - Whether
type_nameis one of the spatial-container types thathas_geometry_by_namestill blocks by name (IfcBuildingStorey,IfcFacility,IfcFacilityPart,IfcSpatialElement,IfcSpatialStructureElement, and their subtypes) — i.e.IfcProductsubtypes thatis_non_geometric_spatialtreats as never carrying geometry directly.IfcBuilding(along withIfcSpace,IfcSiteandIfcSpatialZone) is handled class-wide byhas_geometry_by_nameinstead — 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.
IfcSolarDeviceunderIfcEnergyConversionDevice) are categorised correctly without code changes — see PR #585. - type_
product_ ifc_ type - The
IfcTypeProductsubtype a STEP keyword names, orNonewhen it is not one.