RasmahRasmah

Exact CAD exchange (STEP & IGES)

Overview

A triangle mesh is an approximation of a surface. For engineering exchange you usually want the exact thing: the boundary representation — the precise faces, edges, and vertices with their analytic surfaces. Two formats dominate this role, and Rasmah reads and writes both natively.

STEP (ISO 10303) is the modern standard for exchanging exact BRep solids; IGES is its older, fixed-column predecessor. Both carry the analytic geometry of each face — a plane, a cylinder, a sphere — rather than triangles, so a part round-trips without losing its true shape.

STEP

STEP encodes geometry (points, directions, curves, surfaces), topology (vertices, edges, faces, shells, solids), and the product wrapper that makes a CAD tool recognize the file as a valid solid. Rasmah implements a native AP203 subset with no foreign-function calls:

Rasmah.write_stepFunction
write_step(bodies::Vector{<:BRep}, io)
write_step(bodies::Vector{<:BRep}, path)

Write several solids as one multi-body STEP part: each BRep becomes its own MANIFOLD_SOLID_BREP in a single ADVANCED_BREP_SHAPE_REPRESENTATION (shared coordinate system). read_step reads the result back as a compound BRep.

source
write_step(mesh::TriangleMesh, io)
write_step(mesh::TriangleMesh, path)

Write a surface triangle mesh as a FACETED_BREP (a tessellated STEP solid). read_step reads it back as a faceted BRep.

source
Rasmah.read_stepFunction
read_step(io)
read_step(path)

Read a STEP (ISO 10303-21) file into a BRep, reconstructing its solids, faces, edges, and vertices (falling back to faceted/tessellated geometry when the file carries only a mesh). Returns a compound BRep merging all solids in the file.

source
b = brep(sphere(1.0))
io = IOBuffer()
write_step(b, io)
seekstart(io)
b2 = read_step(io)
b2 isa Rasmah.BRep
true

A sphere written as STEP and read back is still a BRep — the exact representation, not a mesh.

The supported analytic surfaces are the plane, cylinder, cone, and sphere, with the line and circle as curves; the reader is also tolerant of the numeric and string artifacts real files contain (leading-decimal numbers, defined-type values, nested entity definitions). NURBS, trimmed surfaces, assemblies, and tessellated representations are out of scope — see File I/O.

IGES

IGES is the fixed-80-column, section-based format (Start / Global / Directory Entry / Parameter Data / Terminate). Rasmah writes each BRep face as its exact IGES surface entity and each edge as its curve entity, wrapped in a MANIFOLD_SOLID_BREP_OBJECT:

Rasmah.write_igesFunction
write_iges(b::BRep, io::IO; style=:trimmed)

Write b as an IGES file (the analytic + NURBS surface subset). Two B-rep representations are supported:

  • style=:trimmed (default) — OpenCASCADE's trimmed-surface style: each face is a 144 trimmed surface over its base surface (108/120/128), bounded by a 102 composite curve of edge curves (110/126) linked through a 142 curve-on-surface, grouped by a 402 group.
  • style=:classic — the classic IGES manifold-solid B-rep topology (502/504/508/510/514/186).

read_iges reads both back. Procedural surfaces are NURBS-approximated.

source
Rasmah.read_igesFunction
read_iges(path::AbstractString) -> BRep
read_iges(io::IO) -> BRep

Read an IGES file (the analytic + NURBS surface subset emitted by write_iges) and reconstruct a BRep. Supported entities are circular arcs (100), planes (108), lines (110), surfaces of revolution (120), rational B-spline surfaces (128) and manifold solid B-rep objects (186).

Returns

A BRep whose faces are the reconstructed unbounded surfaces.

source
io = IOBuffer()
write_iges(brep(cylinder(1.0, 2.0)), io)
seekstart(io)
read_iges(io) isa Rasmah.BRep
true

A cylinder round-trips through IGES as a BRep too. Faces that have no direct IGES entity (such as swept or chamfer surfaces) are first approximated as NURBS so the file remains a valid solid.

Next steps

Exact exchange is the geometry side of file I/O. For the triangle-mesh and volume formats, return to File I/O; for medical imaging and scan data, continue to Volumes and point clouds.