ConstructCraft

cc_ifc API

← API reference · Generated from the source by cargo run -p api_doc; edit the doc comments, not this page.

IFC export and import for ConstructCraft. export maps a cc_core::Project to an IFC4 STEP physical file (ISO 10303-21): spatial structure (project, site, building, storeys), walls with openings, doors, windows, slabs, ceilings and roofs as swept solids, element types, material layer sets, surface styles and base quantities. The STEP writer and the mapping are implemented here without third-party IFC libraries. import reads IFC2X3/IFC4 files back into a project (see the import module).

Modules

Module Items Summary
cc_ifc 0 IFC export and import for ConstructCraft.
cc_ifc::export 19 Mapping of the ConstructCraft model to IFC4 entities.
cc_ifc::geometry 12 The IFC geometry resource turned into polygon meshes: placements, curves (polylines, indexed curves with arcs, conics, trimmed and composite curves, B-splines), parametric and arbitrary profiles (with voids), swept solids (extrusions, revolutions, swept disks, directrix sweeps), CSG primitives and trees, half-space clipping, boundary representations, face sets and mapped items.
cc_ifc::guid 3 IFC GlobalId: a 128-bit identifier in the 22-character IFC base64 form.
cc_ifc::import 5 IFC import: maps the spatial structure and building elements of an IFC file (IFC2X3 or IFC4) onto a ConstructCraft project.
cc_ifc::parse 5 Reader for STEP physical files (ISO 10303-21): the header schema and the entity instances of the data section.
cc_ifc::point_list 2 Point lists as text, for the property sets that carry a terrain’s points and boundary (export::TOPOGRAPHY_PSET): coordinates separated by spaces, points by ;.
cc_ifc::schema 4 The part of the IFC4 schema needed to write any physical element class back out: the attribute count of each IfcElement subtype, where its PredefinedType sits and which type object goes with it.
cc_ifc::step 8 Minimal writer for STEP physical files (ISO 10303-21).

cc_ifc

crates/cc_ifc/src/lib.rs

Re-exports

cc_ifc::export

crates/cc_ifc/src/export.rs

Mapping of the ConstructCraft model to IFC4 entities.

Items: NICHE_PSET · ExportOptions · export · export_to_file · COMPONENT_PSET · DESIGN_OPTION_PSET · PHASING_PSET · CURTAIN_PSET · ROOFING_PSET · COLD_FORMED_CATEGORY · TOPOGRAPHY_PSET · PADS_PSET · PILE_CAP_PSET · PILE_PSET · pile_ifc · REBAR_PSET · ROOFING_SIZES · PHASES_PSET · ifc_status

const NICHE_PSET

pub const NICHE_PSET: &str

Property set of a niche’s opening element: its sizes, the face of the wall it is in and the volume it takes out.

struct ExportOptions

pub struct ExportOptions

Traits: Debug, Clone, Default, PartialEq

Fields

fn export

pub fn export(project: &Project, options: &ExportOptions) -> String

Serialize project as an IFC4 STEP physical file: the main model and the primary option of each design option set (whatever option is being edited), the option of each element in DESIGN_OPTION_PSET.

fn export_to_file

pub fn export_to_file(project: &Project, path: &std::path::Path) -> std::io::Result<()>

Export project to an .ifc file at path.

const COMPONENT_PSET

pub const COMPONENT_PSET: &str

Property set with the instance parameter values of components.

const DESIGN_OPTION_PSET

pub const DESIGN_OPTION_PSET: &str

Property set of the design option an element belongs to (OptionSet, Option, Primary).

const PHASING_PSET

pub const PHASING_PSET: &str

Property set of an element’s construction phases (PhaseCreated, PhaseDemolished).

const CURTAIN_PSET

pub const CURTAIN_PSET: &str

Property set of a curtain wall’s grid: the type’s System and the wall’s Edits as text (see cc_core::curtain::to_text), its Height and Bulge.

const ROOFING_PSET

pub const ROOFING_PSET: &str

Property set of a roof’s covering and framing (see write_roof_framing).

const COLD_FORMED_CATEGORY

pub const COLD_FORMED_CATEGORY: &str

Category of the material profile of a cold-formed section (rolled and cold-formed steel share their materials).

const TOPOGRAPHY_PSET

pub const TOPOGRAPHY_PSET: &str

A terrain’s points, boundary, base depth and type settings, for importers to rebuild it as terrain (points as x y z and the boundary as x y, separated by ;).

const PADS_PSET

pub const PADS_PSET: &str

The building pads of a terrain (see Exporter::pads_set).

const PILE_CAP_PSET

pub const PILE_CAP_PSET: &str

Property set of a pile cap: its Placement (position in plan and rotation in degrees), its Cap (thickness and cc_core::pile::PileCap without the pile type) as text (see cc_core::curtain::to_text), and the name of its piles’ type (PileType).

const PILE_PSET

pub const PILE_PSET: &str

Property set of a pile: its Kind (cc_core::pile::PileKind::code), its Section and Embedment as text, and for a pile of a cap the cap’s GlobalId (Cap) and the pile’s place in its layout (CapIndex).

fn pile_ifc

pub fn pile_ifc(kind: cc_core::pile::PileKind) -> (&'static str, &'static str, Option<&'static str>)

The IfcPileTypeEnum, IfcPileConstructionEnum and, for a user-defined type, the object type of a pile kind: bored piles are bored and cast in place, precast and steel piles driven; augered and micro piles, cast in place, have no predefined type of their own.

const REBAR_PSET

pub const REBAR_PSET: &str

What a reinforcement set says of its bars: Partition, BarMark (a mark given by hand), Mark (the mark its bars have, when they all have one) and Grade (see Exporter::write_rebar).

const ROOFING_SIZES

pub const ROOFING_SIZES: [(&str, &str, &str); 4]

The framing’s member sizes in ROOFING_PSET: member, width and height properties.

const PHASES_PSET

pub const PHASES_PSET: &str

Property set of the project’s phases, in time order (properties 1, 2…).

fn ifc_status

pub fn ifc_status(project: &Project, e: &Element) -> Option<cc_core::PhaseStatus>

An element’s IFC Status relative to the project’s last phase (an element demolished before it reads as demolished); None for annotations and projects without phases.

cc_ifc::geometry

crates/cc_ifc/src/geometry.rs

The IFC geometry resource turned into polygon meshes: placements, curves (polylines, indexed curves with arcs, conics, trimmed and composite curves, B-splines), parametric and arbitrary profiles (with voids), swept solids (extrusions, revolutions, swept disks, directrix sweeps), CSG primitives and trees, half-space clipping, boundary representations, face sets and mapped items. Everything is read from public schema definitions; curved surfaces are approximated by facets. Every walk over references is depth-bounded and malformed values are skipped, so a hostile file yields less geometry, never a panic.

Items: Polygon · Profile · ProfileKind · Extrusion · Solid · subtract · bounds2 · affine · frame · clean_loop · clip_mesh · Geometry

type alias Polygon

pub type Polygon = Vec<DVec3>

A planar polygon in world coordinates (counter-clockwise seen from outside).

struct Profile

pub struct Profile

A profile in its plane: outer loop, inner loops and, for parametric rectangles and circles, their exact parameters.

Traits: Debug, Clone

Fields

Methods

enum ProfileKind

pub enum ProfileKind

Traits: Debug, Clone, Copy, PartialEq

Variants

struct Extrusion

pub struct Extrusion

An extruded profile: its plane and extrusion vector in world coordinates.

Traits: Debug, Clone

Fields

Methods

struct Solid

pub struct Solid

A representation item resolved to world coordinates.

Traits: Debug, Clone, Default

Fields

Methods

fn subtract

pub fn subtract(a: &[Polygon], b: &[Polygon]) -> Option<Vec<Polygon>>

a minus b when their bounds overlap (None: nothing to cut or too large to cut).

fn bounds2

pub fn bounds2(pts: &[DVec2]) -> (DVec2, DVec2)

fn affine

pub fn affine(x: DVec3, y: DVec3, z: DVec3, origin: DVec3) -> DAffine3

fn frame

pub fn frame(z: Option<DVec3>, x: Option<DVec3>, origin: DVec3) -> DAffine3

A right-handed frame from a Z axis and an approximate X axis.

fn clean_loop

pub fn clean_loop<T: Copy + PartialEq>(mut pts: Vec<T>, close: impl Fn(&T, &T) -> bool) -> Vec<T>

Drop a repeated closing point and consecutive duplicates.

fn clip_mesh

pub fn clip_mesh(mesh: &[Polygon], point: DVec3, normal: DVec3) -> Vec<Polygon>

Keep the part of mesh on the side of the plane where (p - point)·normal >= 0, closing the cut with cap faces.

struct Geometry

pub struct Geometry<'a>

Reads geometry from a parsed IFC file.

Fields

Some fields are private.

Methods

cc_ifc::guid

crates/cc_ifc/src/guid.rs

IFC GlobalId: a 128-bit identifier in the 22-character IFC base64 form.

Items: encode · decode · guid

fn encode

pub fn encode(n: u128) -> String

Encode a 128-bit value: 2 bits in the first character, 6 in each of the other 21.

fn decode

pub fn decode(s: &str) -> Option<u128>

Decode a 22-character GlobalId (None if malformed).

fn guid

pub fn guid(seed: &str, tag: &str) -> String

Deterministic GlobalId for the object named tag within the project identified by seed, so repeated exports keep the same ids.

cc_ifc::import

crates/cc_ifc/src/import.rs

IFC import: maps the spatial structure and building elements of an IFC file (IFC2X3 or IFC4) onto a ConstructCraft project. Geometry is read from extruded area solids (the usual representation of walls, slabs, columns and beams), with faceted B-reps, face sets and bounding boxes used for extents. Storeys become levels; walls, doors, windows, slabs, ceilings, roofs, spaces, columns and beams become native elements with matching or new types. Products that cannot be interpreted are counted in the report instead of failing the import.

Items: MAX_IFC_BYTES · ImportReport · ImportError · import_file · import

const MAX_IFC_BYTES

pub const MAX_IFC_BYTES: u64

Largest IFC file imported, bytes: the parsed instances take many times the file’s size in memory.

struct ImportReport

pub struct ImportReport

What an import brought in.

Traits: Debug, Clone, Default, PartialEq

Fields

Methods

enum ImportError

pub enum ImportError

Traits: Debug, std::fmt::Display, std::error::Error

Variants

fn import_file

pub fn import_file(path: &std::path::Path, base: Project) -> Result<(Project, ImportReport), ImportError>

Import the IFC file at path into base (see import). Files larger than MAX_IFC_BYTES are refused before they are read (an ImportError::Io of kind FileTooLarge).

fn import

pub fn import(text: &str, base: Project) -> Result<(Project, ImportReport), ImportError>

Import IFC text. base supplies materials, types and project-wide views (usually the default template); its levels, elements, plans and sheets are replaced by the imported building.

cc_ifc::parse

crates/cc_ifc/src/parse.rs

Reader for STEP physical files (ISO 10303-21): the header schema and the entity instances of the data section. Malformed input yields an error, never a panic; nesting depth is bounded.

Items: Param · Entity · StepFile · ParseError · parse

enum Param

pub enum Param

A parsed attribute value.

Traits: Debug, Clone, PartialEq

Variants

Methods

struct Entity

pub struct Entity

An entity instance: upper-case type name and attributes. Complex (multi-type) instances are kept with an empty name.

Traits: Debug, Clone, PartialEq

Fields

Methods

struct StepFile

pub struct StepFile

A parsed exchange structure.

Traits: Debug, Clone, Default

Fields

Methods

struct ParseError

pub struct ParseError

Traits: Debug, Clone, PartialEq, Eq, std::fmt::Display, std::error::Error

Fields

fn parse

pub fn parse(text: &str) -> Result<StepFile, ParseError>

Parse a STEP physical file.

cc_ifc::point_list

crates/cc_ifc/src/point_list.rs

Point lists as text, for the property sets that carry a terrain’s points and boundary (export::TOPOGRAPHY_PSET): coordinates separated by spaces, points by ;.

Items: encode · decode

fn encode

pub(crate) fn encode(points: impl Iterator<Item = Vec<f64>>) -> String

Points as text: coordinates separated by spaces, points by ;.

fn decode

pub(crate) fn decode(text: &str, dims: usize, max: usize) -> Vec<Vec<f64>>

Points read from encode text, dims numbers each: at most max of them; malformed or non-finite entries are skipped.

cc_ifc::schema

crates/cc_ifc/src/schema.rs

The part of the IFC4 schema needed to write any physical element class back out: the attribute count of each IfcElement subtype, where its PredefinedType sits and which type object goes with it. Taken from the published IFC4 ADD2 TC1 schema; all the attributes after the common eight are optional, so the writer fills them with $.

Items: TypeLayout · ElementClass · element_class · display_name

enum TypeLayout

pub enum TypeLayout

Extra attributes of a type object after the nine of IfcElementType.

Traits: Debug, Clone, Copy, PartialEq, Eq

Variants

struct ElementClass

pub struct ElementClass

How an element class is written.

Traits: Debug, Clone, Copy, PartialEq, Eq

Fields

fn element_class

pub fn element_class(entity: &str) -> Option<&'static ElementClass>

How to write occurrences of entity (upper case) in IFC4, if it is a physical element class there.

fn display_name

pub fn display_name(entity: &str) -> String

Readable class name: IFCPIPESEGMENT → IfcPipeSegment for the classes in the table, else the entity name with only its first letters capitalized.

cc_ifc::step

crates/cc_ifc/src/step.rs

Minimal writer for STEP physical files (ISO 10303-21).

Items: Id · Value · opt_str · reals · args · Header · StepWriter · is_type_name

struct Id

pub struct Id(pub u32)

Instance name of an entity in the data section (#n).

Traits: Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash

enum Value

pub enum Value

An attribute value.

Traits: Debug, Clone, PartialEq, From<f64>, From<i64>, From<bool>, From<&str>, From<String>, From<Id>, From<Option<T>>, From<Vec<T>>

Variants

fn opt_str

pub fn opt_str(s: &str) -> Value

A string attribute, or $ when empty.

fn reals

pub fn reals(xs: &[f64]) -> Value

A list of reals, for coordinates and direction ratios.

macro args

macro_rules! args

Builds the attribute list of an entity instance.

struct Header

pub struct Header

File header fields (FILE_DESCRIPTION, FILE_NAME, FILE_SCHEMA).

Traits: Debug, Clone, PartialEq

Fields

struct StepWriter

pub struct StepWriter

Accumulates entity instances and serializes the exchange structure.

Traits: Debug, Default

Some fields are private.

Methods

fn is_type_name

pub fn is_type_name(name: &str) -> bool

An IFC type name: IFC followed by upper-case letters, digits and _.