Repository navigation
Reference Model Brep
Relevant source files
The following files were used as context for generating this wiki page:
Boundary Representation (B-Rep) defines the topological and geometric structure of 3D models within the Kit project. It provides a neutral format to facilitate bidirectional interoperability between proprietary CAD formats like SOLIDWORKS (Parasolid) and open formats like FreeCAD (OpenCASCADE).
B-Rep models represent shapes by defining their boundaries as a hierarchical arrangement of topological entities (e.g., bodies, faces, edges) associated with underlying geometric carriers (e.g., surfaces, curves, points).
The B-Rep system uses a nested hierarchy to define the connectivity of a 3D solid or sheet. Every entity includes a unique identifier, provenance metadata, and optional attributes.
The following entities compose the topological structure:
- BrepBody: The root container for a single solid or sheet object. It manages regions, wire IDs, and vertex IDs.
- BrepRegion: Represents a continuous volume (solid) or a set of shells (voids or sheets).
- BrepShell: Defines a boundary of a region as a collection of face uses.
- BrepFace: A bounded portion of a surface. It references one or more loops.
- BrepLoop: A closed circuit of coedges that defines the boundaries of a face.
- BrepCoedge: An oriented use of an edge within a loop.
- BrepEdge: A bounded portion of a curve, defined by start and end vertices.
- BrepVertex: A point in 3D space marking the end of an edge.
graph TD
Body[BrepBody] --> Region[BrepRegion]
Region --> ShellUse[BrepShellUse]
ShellUse --> Shell[BrepShell]
Shell --> FaceUse[BrepFaceUse]
FaceUse --> Face[BrepFace]
Face --> Loop[BrepLoop]
Loop --> Coedge[BrepCoedge]
Coedge --> Edge[BrepEdge]
Edge --> Vertex[BrepVertex]
The diagram shows the parent-child relationships between topological entities in a B-Rep model.
Geometry defines the mathematical representation of topological entities. Every edge and face references a specific curve or surface carrier.
Surfaces provide the mathematical definition for faces. The project supports several analytic and free-form types.
| Surface Type | Description | Key Fields |
|---|---|---|
| PlaneSurface | A flat, infinite surface. | Origin, Normal, Ref Direction |
| CylinderSurface | A cylindrical surface defined by an axis. | Origin, Axis, Radius |
| ConeSurface | A conical surface with a specific half-angle. | Origin, Axis, Radius, Half Angle |
| SphereSurface | A spherical surface centered at a point. | Center, Radius, Axis |
| TorusSurface | A donut-shaped surface. | Center, Axis, Major/Minor Radius |
| NurbsSurface | A Non-Uniform Rational B-Spline surface. | Control Points, Knots, Multiplicities |
Curves provide the mathematical definition for edges.
- LineCurve: A straight line defined by an origin and direction.
- CircleCurve: A circular path defined by center, axis, and radius.
- EllipseCurve: An elliptical path defined by major and minor radii.
- NurbsCurve: A B-spline curve defined by control points and knot vectors.
- IntersectionCurve: A curve derived from the intersection of two surfaces.
The project implements specific logic to handle B-Rep data from different CAD kernels.
The Parasolid module handles binary and ASCII Parasolid data used by SOLIDWORKS. It encodes BrepModel instances into "transmit files" using specific schema markers like SCH_1200000_12006.
-
Encoding: The
EncodeBrepModelfunction validates topology before serializing entities into a byte stream. It ensures body transforms are identity and handles SOLIDWORKS-specific feature ID mapping. -
Indexing: Uses an
IndexAllocatorto map interchange identifiers to native record indices (e.g., Bridges, Loops, Edges). -
Vendor Attributes: Writes specific SOLIDWORKS attributes such as
SWEntUnchangedandSDL/TYSA_COLOUR.
The Opencascade and Brep modules handle the ASCII B-Rep format used by OpenCASCADE and FreeCAD.
-
Structure: Files start with the header
CASCADE Topology V1, (c) Matra-Datavision. -
Parsing: The
DecodeAsciiBrepfunction tokenizes the ASCII stream to reconstruct the topological graph. It validates object counts (e.g.,TShapes) and ensures bottom-up ordering. - Tessellation: Converts B-Rep surfaces into mesh data (vertices and triangles) for visualization when native execution is unavailable.
flowchart TD
A[Neutral BrepModel] --> B{Adapter Choice}
B -- SOLIDWORKS --> C[Parasolid Encoder]
B -- FreeCAD --> D[OpenCASCADE Encoder]
C --> E[Binary .x_b / ASCII .x_t]
D --> F[ASCII .brep]
The flowchart illustrates the transformation of a neutral BrepModel into format-specific outputs.
Every B-Rep model undergoes structural and geometric validation.
- Topology Validation: Detects incomplete ownership, non-manifold edges, or disconnected wires.
- Geometric Verification: Confirms that curve endpoints match vertex locations and that sampled points on a face reside on the underlying surface carrier.
-
Round-trip Integrity: The
VerifyBrepDatafunction ensures that encoding a model and immediately decoding it results in identical topological counts and class types.
B-Rep serves as the foundational data structure for geometry within Kit. It ensures that complex topological relationships and precise analytic surfaces are preserved during translation between different CAD applications.
Published from repository revision 1149072d · PR #50 is awaiting merge · Maintenance guide
- Home
- Getting started
- API reference
- Architecture
- Conversion engine
- Contributing
- Change entries
- Gotchas
- Maintaining the wiki
- Assembly & Constraints Model
- Boundary Representation (B-Rep)
- Neutral Document Model
- Parametric Features Model