pub struct EntityDecoder<'a> { /* private fields */ }Expand description
Entity decoder for lazy parsing - uses Arc for efficient cache sharing
Implementations§
Source§impl<'a> EntityDecoder<'a>
impl<'a> EntityDecoder<'a>
Sourcepub fn with_index(content: &'a str, index: EntityIndex) -> Self
pub fn with_index(content: &'a str, index: EntityIndex) -> Self
Create decoder with pre-built index (faster for repeated lookups)
Sourcepub fn with_arc_index(content: &'a str, index: Arc<EntityIndex>) -> Self
pub fn with_arc_index(content: &'a str, index: Arc<EntityIndex>) -> Self
Create decoder with shared Arc index (for parallel processing)
Sourcepub fn decode_at(&mut self, start: usize, end: usize) -> Result<DecodedEntity>
pub fn decode_at(&mut self, start: usize, end: usize) -> Result<DecodedEntity>
Decode entity at byte offset Returns cached entity if already decoded
Sourcepub fn decode_at_with_id(
&mut self,
id: u32,
start: usize,
end: usize,
) -> Result<DecodedEntity>
pub fn decode_at_with_id( &mut self, id: u32, start: usize, end: usize, ) -> Result<DecodedEntity>
Decode entity at byte offset with known ID (faster - checks cache before parsing) Use this when the scanner provides the entity ID to avoid re-parsing cached entities
Sourcepub fn decode_by_id(&mut self, entity_id: u32) -> Result<DecodedEntity>
pub fn decode_by_id(&mut self, entity_id: u32) -> Result<DecodedEntity>
Decode entity by ID - O(1) lookup using entity index
Sourcepub fn resolve_ref(
&mut self,
attr: &AttributeValue,
) -> Result<Option<DecodedEntity>>
pub fn resolve_ref( &mut self, attr: &AttributeValue, ) -> Result<Option<DecodedEntity>>
Resolve entity reference (follow #ID) Returns None for null/derived values
Sourcepub fn resolve_ref_list(
&mut self,
attr: &AttributeValue,
) -> Result<Vec<DecodedEntity>>
pub fn resolve_ref_list( &mut self, attr: &AttributeValue, ) -> Result<Vec<DecodedEntity>>
Resolve list of entity references
Sourcepub fn get_cached(&self, entity_id: u32) -> Option<DecodedEntity>
pub fn get_cached(&self, entity_id: u32) -> Option<DecodedEntity>
Get cached entity (without decoding)
Sourcepub fn reserve_cache(&mut self, additional: usize)
pub fn reserve_cache(&mut self, additional: usize)
Reserve cache capacity to avoid HashMap resizing during processing. For a 487 MB file with 208 K building elements, the cache can grow to 300 K+ entries (elements + representation chains + placements). Pre-allocating avoids ~6 resize-and-rehash operations that each copy all entries, reducing both peak memory spikes and timing variance.
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear all caches to free memory
Sourcepub fn clear_point_cache(&mut self)
pub fn clear_point_cache(&mut self)
Clear only the point coordinate cache (used after BREP preprocessing). The entity cache is preserved for subsequent geometry processing.
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
Get cache size
Sourcepub fn get_raw_bytes(&mut self, entity_id: u32) -> Option<&'a [u8]>
pub fn get_raw_bytes(&mut self, entity_id: u32) -> Option<&'a [u8]>
Get raw bytes for an entity (for direct/fast parsing) Returns the full entity line including type and attributes
Sourcepub fn get_raw_content(&mut self, entity_id: u32) -> Option<&'a str>
pub fn get_raw_content(&mut self, entity_id: u32) -> Option<&'a str>
Get raw content string for an entity
Sourcepub fn get_first_entity_ref_fast(&mut self, entity_id: u32) -> Option<u32>
pub fn get_first_entity_ref_fast(&mut self, entity_id: u32) -> Option<u32>
Fast extraction of first entity ref from raw bytes Useful for BREP -> shell ID, Face -> FaceBound, etc. Returns the first entity reference ID found in the entity
Sourcepub fn get_entity_ref_list_fast(&mut self, entity_id: u32) -> Option<Vec<u32>>
pub fn get_entity_ref_list_fast(&mut self, entity_id: u32) -> Option<Vec<u32>>
Fast extraction of entity reference IDs from a list attribute in raw bytes Useful for getting face list from ClosedShell, bounds from Face, etc. Returns list of entity IDs
Sourcepub fn get_polyloop_point_ids_fast(
&mut self,
entity_id: u32,
) -> Option<Vec<u32>>
pub fn get_polyloop_point_ids_fast( &mut self, entity_id: u32, ) -> Option<Vec<u32>>
Fast extraction of PolyLoop point IDs directly from raw bytes Bypasses full entity decoding for BREP optimization Returns list of entity IDs for CartesianPoints
Sourcepub fn get_cartesian_point_fast(
&mut self,
entity_id: u32,
) -> Option<(f64, f64, f64)>
pub fn get_cartesian_point_fast( &mut self, entity_id: u32, ) -> Option<(f64, f64, f64)>
Fast extraction of CartesianPoint coordinates directly from raw bytes Bypasses full entity decoding for ~3x speedup on BREP-heavy files Returns (x, y, z) as f64 tuple
Sourcepub fn get_face_bound_fast(
&mut self,
entity_id: u32,
) -> Option<(u32, bool, bool)>
pub fn get_face_bound_fast( &mut self, entity_id: u32, ) -> Option<(u32, bool, bool)>
Fast extraction of FaceBound info directly from raw bytes Returns (loop_id, orientation, is_outer_bound) Bypasses full entity decoding for BREP optimization
Sourcepub fn get_polyloop_coords_fast(
&mut self,
entity_id: u32,
) -> Option<Vec<(f64, f64, f64)>>
pub fn get_polyloop_coords_fast( &mut self, entity_id: u32, ) -> Option<Vec<(f64, f64, f64)>>
Fast extraction of PolyLoop COORDINATES directly from raw bytes This is the ultimate fast path - extracts all coordinates in one go Avoids N+1 HashMap lookups by batching point extraction Returns Vec of (x, y, z) coordinate tuples