Skip to main content

ifc_lite_core/
lib.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! # IFC-Lite Core Parser
6//!
7//! High-performance STEP/IFC parser built with [nom](https://docs.rs/nom).
8//! Provides zero-copy tokenization and fast entity scanning for IFC files.
9//!
10//! ## Overview
11//!
12//! This crate provides the core parsing functionality for IFC-Lite:
13//!
14//! - **STEP Tokenization**: Zero-copy parsing of STEP file format
15//! - **Entity Scanning**: SIMD-accelerated entity discovery using [memchr](https://docs.rs/memchr)
16//! - **Lazy Decoding**: On-demand attribute parsing for memory efficiency
17//! - **Streaming Parser**: Event-based parsing for large files
18//!
19//! ## Quick Start
20//!
21//! ```rust,ignore
22//! use ifc_lite_core::{EntityScanner, parse_entity, IfcType};
23//!
24//! // Scan for entities
25//! let content = r#"#1=IFCPROJECT('guid',$,$,$,$,$,$,$,$);"#;
26//! let mut scanner = EntityScanner::new(content);
27//!
28//! while let Some((id, type_name, start, end)) = scanner.next_entity() {
29//!     println!("Found entity #{}: {}", id, type_name);
30//! }
31//!
32//! // Parse individual entity
33//! let input = "#123=IFCWALL('guid',$,$,$,$,$,$,$);";
34//! let (id, ifc_type, attrs) = parse_entity(input).unwrap();
35//! assert_eq!(ifc_type, IfcType::IfcWall);
36//! ```
37//!
38//! ## Streaming Parser
39//!
40//! For large files, use the streaming parser to process entities in batches:
41//!
42//! ```rust,ignore
43//! use ifc_lite_core::{parse_stream, StreamConfig, ParseEvent};
44//!
45//! let config = StreamConfig::default();
46//! for event in parse_stream(content, config) {
47//!     match event {
48//!         ParseEvent::Entity { id, type_name, .. } => {
49//!             println!("Entity #{}: {}", id, type_name);
50//!         }
51//!         ParseEvent::Progress { percent, .. } => {
52//!             println!("Progress: {:.1}%", percent);
53//!         }
54//!         _ => {}
55//!     }
56//! }
57//! ```
58//!
59//! ## Performance
60//!
61//! - **Tokenization**: ~1,259 MB/s throughput
62//! - **Entity scanning**: ~650 MB/s with SIMD acceleration
63//! - **Number parsing**: 10x faster than std using [lexical-core](https://docs.rs/lexical-core)
64//!
65//! ## Feature Flags
66//!
67//! - `serde`: Enable serialization support for parsed data
68
69pub mod decoder;
70pub mod error;
71pub mod fast_parse;
72pub mod generated;
73pub mod georef;
74pub mod legacy_entities;
75pub mod model_bounds;
76pub mod parser;
77pub mod schema_gen;
78pub mod streaming;
79pub mod units;
80
81pub use decoder::{build_entity_index, EntityDecoder, EntityIndex};
82pub use error::{Error, Result};
83pub use fast_parse::{
84    extract_coordinate_list_from_entity, extract_entity_refs_from_list, extract_entity_type_name,
85    extract_face_indices_from_entity, extract_first_entity_ref, parse_coordinates_direct,
86    parse_indices_direct, process_triangulated_faceset_direct, should_use_fast_path, FastMeshData,
87};
88pub use generated::{has_geometry_by_name, IfcType};
89pub use georef::{GeoRefExtractor, GeoReference, RtcOffset};
90pub use legacy_entities::{get_legacy_entity_info, is_legacy_entity, map_legacy_to_base_type, LegacyEntityInfo};
91pub use model_bounds::{scan_model_bounds, scan_placement_bounds, ModelBounds};
92pub use parser::{parse_entity, EntityScanner, Token};
93pub use schema_gen::{AttributeValue, DecodedEntity, GeometryCategory, IfcSchema, ProfileCategory};
94pub use streaming::{parse_stream, ParseEvent, StreamConfig};
95pub use units::{extract_length_unit_scale, get_si_prefix_multiplier};