Part of the architecture notes indexed in AGENTS.md. Keep each topic in its bullet here; AGENTS.md only lists the topics.
step.rs) and IFC2X3/IFC4 import with an in-house STEP parser (parse.rs, bounded nesting), geometry engine (geometry.rs: placements, curves, profiles, swept/CSG/B-rep/face-set items → world polygon meshes, depth- and size-bounded) and mapping (import.rs); no third-party IFC libraries by design. Import never drops a physical class: products become native elements only when a native element holds their geometry exactly (types matched by name and size; GlobalIds kept as Uids), slabs become floors (with Floor::openings from profile voids and from openings that pass through them vertically) or, as base slabs shaped like slabs, foundation slabs (piles and pile caps written as base slabs stay components); anything else (including coverings, roofs, columns and beams voided by openings) becomes a component with Mesh pieces whose ComponentDef::ifc keeps the class and the type’s property sets (cc_core::properties, values in SI units; instance sets live in Component::properties; objects of one name share a type only when their pieces and class are the same, and a type-less object whose placement lies outside its body is placed at the bottom center of its body, so identical objects written in world coordinates share one; tests/rebar.rs), with its openings subtracted by csg.rs (arena BSP-tree booleans, iterative and budgeted; also used for boolean results); schema.rs (IFC4 attribute layouts and type objects per element class) lets export write that class back. Column and beam types write their structural profile (Exporter::profile_def: the parametric Ifc*ProfileDef with its box centered on the position and the type’s turn as its direction, else the placed outline as an arbitrary profile; a lipped Z has no IFC shape) in an IfcMaterialProfileSet per type and an IfcMaterialProfileSetUsage per element; level square-ended profile beams are swept along their axis, plain rectangles stay boxes, other beams faceted B-reps. Import reads columns and beams extruded from any profile (Geometry::parametric_shape, else the outline as a sketch of literal points, else its box; Importer::profile_for reuses a profile of the same name and shape). tests/round_trip.rs checks export → import. Tanks from other programs (tests/tank.rs, everything in world coordinates with no axes or types): ring_sector reads a profile of two concentric arcs joined by radial sides, which import_column turns into ProfileShape::AnnularSector placed by its ring (values rounded to 0.01 mm and 0.001°, so the columns around a ring share a profile and a type) and import_beam into an arc beam on the middle circle when the body has no axis; a BASESLAB keeps its profile’s curves as Foundation::sketch; import_pile falls back to the construction type; foreign_partition reads a property named Partition (several languages, accents ignored) into a shaped bar set’s partition; ShapedRebar::MAX_BARS is 20,000 with MAX_TOTAL_POINTS. import_bar takes the bar type its IFC type object names, else Importer::nominal_bar_type (the project’s bar type of the nominal diameter within 0.05 mm whose grade, letters and digits compared, is the bar’s or empty, but not empty when the grade is this program’s own Grade in REBAR_PSET, a type’s grade; the same grade first), else makes one with the file’s SteelGrade as its grade; a purely numeric Tag (another program’s element id) is no mark unless the bar carries REBAR_PSET (#369, tests/foreign_bars.rs). Curved outlines (#368, tests/curved_profiles.rs): floors, foundation slabs, ceilings and flat roofs without overhang whose sketch has arcs or circles and still draws them (curve_profile, over Sketch::curve_profile: the loops’ curves in order, outline counter-clockwise, openings clockwise) are written by Exporter::extrude_curves: a lone circle as an IfcCircleProfileDef at its center, else curve_loop composite curves (straight runs as IfcPolylines, each arc an IfcTrimmedCurve of its IfcCircle by its end points, CARTESIAN, the sense its turn; a circle two halves; ellipses and splines their points; every segment CONTINUOUS), shafts’ cuts as polylines; import reads a trimmed circle as one arc (Geometry::circle_arc, by parameter or point, either sense; full turns a circle), arcs of one circle going all the way round as the circle (whole_circle), and gives ceilings and flat roofs their sketch too (Importer::curved_outline). Bar sets (#368, tests/bar_sets.rs): a Rebar set also writes its host’s GlobalId (Host) and itself as text (Layout) in REBAR_PSET; import brings it in as shaped bars, then restore_bar_sets (when the import ends, before repair) makes it the native set of the imported host when Rebar::is_valid and Project::rebar_host_fits, and check_bar_sets (after repair) puts the shaped bars back unless the set laid out again has as many bars within a diameter and a centimeter of their bounds; this program’s stirrups, written a diameter short of closing (directrix), are closed again on import (close_stirrup), so shaped bars keep their length. IFCPROJECT’s Name is the project number and LongName its name (with only one of them, or both equal, it is the name); export writes them so (#369). Curved walls and footings of other programs (#370, tests/curved_elements.rs): ring_band reads a band of a ring from plan curves (two concentric circles, a full ring; or arcs on two radii turning opposite ways through the same angle, split arcs included, joined by two radial sides: start and sweep counter-clockwise; ring_sector is the band within a profile’s limit), and ring_arcs splits it into native arcs on its middle circle, clockwise (a wall’s exterior side, its left, faces out), one arc or two halves past MAX_BULGE (a full ring is two half circles, met end to end). Importer::ring_wall makes arc walls of a vertical extrusion of such a band (an IfcCircleHollowProfileDef, a profile with a circular void, an annular sector outline), only when every opening voiding the wall is filled by a door or window (the fillers take the piece their middle projects into, wall_piece; walls maps an IFC wall to its pieces). geometry::Solid::revolution keeps a single closed profile revolved (Revolution: profile, plane, world axis and signed turn; section gives the outline as distance from the axis and height along it when the plane holds the axis and the outline stays clear of it). import_footing dispatches IfcFootings: this program’s pile caps (import_pile_cap); others’ PILE_CAPs wait in foreign_caps until every pile is in (import_foreign_caps, after link_piles); footing makes native strips of strip_of (a StripSection from strip_section: a rectangle or the outline a StripHaunch draws, corners matched within SECTION_TOL; revolved about a vertical axis by revolved_strip, a ring extruded upwards, or, for STRIP_FOOTING, a plan rectangle extruded upwards or a section extruded level and square to its plane) in a strip type found or made by width, thickness and haunch (add_strips), and native pads of PAD_FOOTING plan rectangles (import_pad, a named type the other way round turns the pad a quarter). foreign_cap reads a CapShape (cap_shape: rectangle, disk, full ring extruded or revolved), takes the free piles whose axes are inside it and heads within it (one type, length and head), tries the layouts that outline can hold for that many piles (single, pair, square, line; circle round a disk; circle with ring_width on a ring’s middle circle; edge distance, spacing and embedment from the outline and piles, rounded to 0.01 mm so caps alike share a type; problem and repair clean) and keeps the first whose positions meet every pile within a millimeter: a native cap whose type names the piles’ type, the piles linked to it by index as cap_piles wants them (so sync_piles changes nothing); otherwise a ring is ring strips and anything else a component. slab_sketch keeps the curves of each opening (Extrusion::footprint_curves of a cut or voiding opening), and with a curved opening builds the sketch even when the outline is a polygon, so a circular hole stays a circle. Not read: sweeps along arcs (IfcSurfaceCurveSweptAreaSolid and the like), composite profiles, round pads (no native round pad) and triangular caps. Walls attached to a roof, ceiling or floor (Wall::attach_top, straight walls only; see attach_wall_tops) export their extrusion up to the top’s highest point (or each layer’s item of a banded wall) cut by a half space per stretch of WallGeom::top_profile (top_cuts: segments merged where one line runs on, those at the body’s top left out; the plane through the stretch, level across the wall, so the body is the app’s and matches the target’s face wherever that slopes along the wall, as under a gable), nested IfcBooleanClippingResults with representation Clipping (Exporter::top_half_spaces, clip_by): an IfcHalfSpaceSolid where the plane runs nowhere below the top, else an IfcPolygonalBoundedHalfSpace bounded to its stretch (past the wall’s faces, and its ends at the top’s ends); a top that drops to the base or leaves gaps is not cut. Qto_WallBaseQuantities takes Height and GrossSideArea from the top (top_face; NetVolume is the geometry’s). The geometry reader subtracts a bounded half space that covers only part of its operand as its boundary’s prism clipped by its plane (Geometry::bounded_half_space), and import reads a straight wall whose one extrusion is cut by faces level across it as a wall with an elevation profile of that top (clipped_top; tests/attached_walls.rs); the attachment itself does not come back, nor the cut top of a banded wall (rebuilt from ConstructCAD_WallLayers). GlobalIds come from Uids; derived objects (relationships, openings) hash the project uid with a tag.cc_core::cad holds the neutral drawing (CadDrawing: layers with RGB colors and file visibility, flat CadPrims in drawing units — polylines with bulges, arcs kept as arcs, single-line texts with alignment, fills — extents and declared units) and the element ElementKind::CadImport(CadImport) (category CadImport, a TypeData::CadImport {} type created with the first import): owned by one view (view, like text notes; plans, ceiling plans, elevations, sections and legends, see cc_views::hosts_cad) and placed by units, scale, position, rotation_deg and mirrored, with hidden_layers, color_mode and halftone. The drawing is an Arc so undo steps and the repair check do not copy it; repair drops invalid primitives (copying only when needed), and the element has no phase. cc_cad reads files into it: an in-house DXF reader (tokens.rs ASCII/binary group pairs and code pages, dxf.rs sections/LAYER table/BLOCKS/ENTITIES, model space flattened while read, flatten.rs OCS → world with the arbitrary axis algorithm, nested/arrayed inserts with a cycle guard, depth, primitive and work budgets, layer 0 and BYBLOCK inheritance, geom.rs ellipses and de Boor splines, text.rs MTEXT codes); DWG goes through the acadrust crate (no default features, read from a byte buffer) on its own thread inside catch_unwind, its document written to binary DXF in memory and read by the same reader. cc_views::cad draws an import in its view under everything (thin lines with their own Pen, tessellated for the view scale), and Drawing2D::background makes hit_test pick it only where nothing else is; graphics::apply merges overrides into a line’s own pen. cc_engine::commands::cad holds cad_import, cad_layers and cad_layers_set; cc_engine::commands::cad_explode holds cad_explode, which turns an import’s visible primitives (CadImport::layer_visible) into native elements of its view through its placement in one undo step: polyline segments (bulges as arcs, negated under a mirror) and arcs (split past 270 degrees, circles as circles) become DetailLines on a LineStyleRef::Project style per layer (found by name, else created with the layer’s cad::on_paper color), fills boundary-less FilledRegions of a solid type per color, texts TextNotes (top left 1.25 sizes above the baseline) of a TypeData::Text per size on paper (tenths of a millimeter), and visible pictures stay in the element (prims emptied; removed when none); MAX_ELEMENTS and MAX_NEW_TYPES refuse it before any edit, and the color mode and halftone are dropped (app: UiCommand::Explode on the Modify tab and the Explode button in cad_ui::props); element_get/element_set show and patch the placement without the drawing (cc_engine::element_params). Pictures share the element: CadDrawing::images holds CadImages (a parallelogram origin, u, v in drawing units over a cc_core::raster::RasterImage: the file’s own bytes, kept as base64 in project files, with format, pixel size and declared dpi), cc_views::raster reads sizes and decodes pixels (the image crate, size-bounded), cc_views::cad draws them as Prim::Image (under everything, faded with the element; Prim::mapped moves any primitive through an affine map), the app paints them as textured quads cached per picture (paint.rs), and exports write them (SVG <image> data URLs, PDF image objects with an alpha mask, PNG through resvg). cc_cad::svg reads SVG through usvg into the same drawing (curves flattened, single-outline fills, embedded pictures; texts skipped); image_import takes either and sizes pictures by their resolution or width. The app’s tools snap to CadImport::snap_features (ends, midpoints, centers, lines, arcs) of the active view’s imports; IFC export and 3D views ignore them.SkpFile::open(..).parse(&ParseOptions) gives an SkpModel (definitions, instances, faces, edges, materials, layers, pages; lengths in inches) from the current (ZIP) and legacy (version 3 to 2020) formats; build_scene flattens it to triangle meshes and build_instanced_scene keeps one mesh per definition plus placed nodes; create::SkpBuilder writes files and edit::open_existing rebuilds a builder from one. Derived from MIT-licensed code: the crate keeps license = "MIT" and its LICENSE. cc_engine::skp maps a parsed model to component types of fixed Mesh pieces (one per material, faces with holes triangulated): skp_import adds an element per placed component or group of the root (instances that differ only by a move or a plan rotation share a type; tilt, scale and mirror are built into the type; nested instances are flattened into their parent; the root’s loose faces make one more element), skp_component_load makes the whole file one type; hidden objects and hidden layers are left out, materials are matched or added by name, and nesting depth and face count are bounded. cc_engine::obj reads Wavefront OBJ text into the same skp::Converted (in-house parser: v, f, o/g, usemtl, mtllib read by file name only next to the file, Kd colors; bad indices drop the face, bent faces become triangle fans, sizes bounded): obj_import (units, z_up, merge) places a type per object at the center of its footprint and its bottom; the app asks for those options in obj_ui.rs (Insert → Import OBJ…). Imported materials (cc_engine::import_material::ImportedMaterial in Converted::materials: name, color, opacity, texture) carry SketchUp textures (tile size in inches), OBJ Kd (read as sRGB), d/Tr and map_Kd, and glTF base color, baseColorTexture (buffer view, data URI or file beside; WebP source) and blended alpha; the color is the factor times the picture’s average (average_color, linear), and the repeat the area-weighted meters per texture coordinate unit (UvScale), since textures are laid on face planes. Imported mesh pieces (SketchUp, OBJ, glTF, IFC) have their coplanar faces merged by cc_geom::coplanar::merge: neighbors across shared edges in one plane (1°, 0.01 mm) grow into one simple polygon, joining only along one run of edges so no hole or pinch forms; Face::triangulate splits a concave quad along its inner diagonal. cc_engine::gltf reads glTF 2.0 (.glb chunks, or .gltf JSON; buffers from the binary chunk, base64 data URIs or files by name only next to the file) into the same Converted: each root node of the scene with its descendants (node transforms composed, a depth limit and a visited set) is an object, triangles (modes 4 to 6, float or normalized integer positions, every offset and count checked) are turned from Y up to Z up, materials named with their base color as sRGB; required Draco/meshopt compression is refused; gltf_import (merge) places them like obj_import (place_converted), and obj_ui.rs serves Insert → Import glTF… too, asking only merge.