Skip to main content

Crate ifc_lite_geometry

Crate ifc_lite_geometry 

Source
Expand description

§IFC-Lite Geometry Processing

Efficient geometry processing for IFC models using earcutr triangulation and nalgebra for transformations.

§Overview

This crate transforms IFC geometry representations into GPU-ready triangle meshes:

  • Profile Handling: Extract and process 2D profiles (rectangle, circle, arbitrary)
  • Extrusion: Generate 3D meshes from extruded profiles
  • Triangulation: Polygon triangulation with hole support via earcutr
  • CSG Operations: Full boolean operations (difference, union, intersection)
  • Mesh Processing: Normal calculation and coordinate transformations

§Supported Geometry Types

TypeStatusDescription
IfcExtrudedAreaSolidFullMost common - extruded profiles
IfcFacetedBrepFullBoundary representation meshes
IfcTriangulatedFaceSetFullPre-triangulated (IFC4)
IfcBooleanClippingResultFullCSG operations (difference, union, intersection)
IfcMappedItemFullInstanced geometry
IfcSweptDiskSolidFullPipe/tube geometry

§Quick Start

use ifc_lite_geometry::{
    Profile2D, extrude_profile, triangulate_polygon,
    Point2, Point3, Vector3
};

// Create a rectangular profile
let profile = Profile2D::rectangle(2.0, 1.0);

// Extrude to 3D
let direction = Vector3::new(0.0, 0.0, 1.0);
let mesh = extrude_profile(&profile, direction, 3.0)?;

println!("Generated {} triangles", mesh.triangle_count());

§Geometry Router

Use the GeometryRouter to automatically dispatch entities to appropriate processors:

use ifc_lite_geometry::{GeometryRouter, GeometryProcessor};

let router = GeometryRouter::new();

// Process entity
if let Some(mesh) = router.process(&decoder, &entity)? {
    renderer.add_mesh(mesh);
}

§Performance

  • Simple extrusions: ~2000 entities/sec
  • Complex Breps: ~200 entities/sec
  • Boolean operations: ~20 entities/sec

Re-exports§

pub use bool2d::compute_signed_area;
pub use bool2d::ensure_ccw;
pub use bool2d::ensure_cw;
pub use bool2d::is_valid_contour;
pub use bool2d::point_in_contour;
pub use bool2d::subtract_2d;
pub use bool2d::subtract_multiple_2d;
pub use bool2d::union_contours;
pub use csg::calculate_normals;
pub use csg::ClippingProcessor;
pub use csg::Plane;
pub use csg::Triangle;
pub use error::Error;
pub use error::Result;
pub use extrusion::extrude_profile;
pub use extrusion::extrude_profile_with_voids;
pub use mesh::CoordinateShift;
pub use mesh::Mesh;
pub use mesh::SubMesh;
pub use mesh::SubMeshCollection;
pub use processors::AdvancedBrepProcessor;
pub use processors::BooleanClippingProcessor;
pub use processors::ExtrudedAreaSolidProcessor;
pub use processors::FaceBasedSurfaceModelProcessor;
pub use processors::FacetedBrepProcessor;
pub use processors::MappedItemProcessor;
pub use processors::PolygonalFaceSetProcessor;
pub use processors::RevolvedAreaSolidProcessor;
pub use processors::SurfaceOfLinearExtrusionProcessor;
pub use processors::SweptDiskSolidProcessor;
pub use processors::TriangulatedFaceSetProcessor;
pub use profile::Profile2D;
pub use profile::Profile2DWithVoids;
pub use profile::ProfileType;
pub use profile::VoidInfo;
pub use profiles::ProfileProcessor;
pub use router::GeometryProcessor;
pub use router::GeometryRouter;
pub use transform::apply_rtc_offset;
pub use transform::parse_axis2_placement_3d;
pub use transform::parse_axis2_placement_3d_from_id;
pub use transform::parse_cartesian_point;
pub use transform::parse_cartesian_point_from_id;
pub use transform::parse_direction;
pub use transform::parse_direction_from_id;
pub use triangulation::triangulate_polygon;
pub use void_analysis::classify_voids_batch;
pub use void_analysis::extract_coplanar_voids;
pub use void_analysis::extract_nonplanar_voids;
pub use void_analysis::VoidAnalyzer;
pub use void_analysis::VoidClassification;
pub use void_index::VoidIndex;
pub use void_index::VoidStatistics;

Modules§

bool2d
2D Boolean Operations for Profile-Level Void Subtraction
csg
CSG (Constructive Solid Geometry) Operations
error
extrusion
Extrusion operations - converting 2D profiles to 3D meshes
mesh
Mesh data structures
processors
Geometry Processors - P0 implementations
profile
2D Profile definitions and triangulation
profiles
Profile Processors - Handle all IFC profile types
router
Geometry Router - Dynamic dispatch to geometry processors
transform
Shared transform utilities for IFC geometry processing
triangulation
Polygon triangulation utilities
void_analysis
Void Analysis Module
void_index
Void Index Module

Type Aliases§

Point2
A statically sized 2-dimensional column point.
Point3
A statically sized 3-dimensional column point.
Vector2
A stack-allocated, 2-dimensional column vector.
Vector3
A stack-allocated, 3-dimensional column vector.