CAD Exchanger SDK
B-Rep Modeling

Applications that need to represent their objects in exact geometrical form may create 3D models using B-Rep representation.

CAD Exchanger offers the following options to create precise B-Rep representations:

  • solid primitives such as boxes, spheres, cylinders, etc;
  • shape extrusions and revolutions;
  • bottom-up - from vertices, edges, up to solids;
  • generation from polygonal representations.

The sections below explain in details available options.

Constructed B-Rep representation can be added to a part, which in its turn can be added to a new (or existing) model and exported to a target format. The example below demonstrates how this could be done:

ModelData_Solid aBox = ModelAlgo_TopoPrimitives::CreateBox (50, 50, 1);
ModelData_Part aPart (aBRep, "my_part");
aPart.SetAppearance (ModelData_Color (1.f, 0.f, 0.f)); //red
ModelData_Model aModel ("my_model");
aModel.AddRoot (aPart);
Para_Writer aWriter;
bool anIsOk = aWriter.Transfer (aModel) && aWriter.WriteFile ("my_file.x_t");

Solid Primitives

torus_trimmed.png
Creating a torus

CAD Exchanger SDK provides high level API to create basic solid primitives such as box, sphere, cylinder, cone, etc using the ModelAlgo_TopoPrimitives class. A part can be created from a solid as follows:

ModelData_Solid aSphere = ModelAlgo_TopoPrimitives::CreateSphere (ModelData_Point (10., 20., 30.), 25. /*radius*/);
ModelData_Part aPart (aBRep, "my_sphere");

Extrusions and Rotations

extrusion_face.png
Creating a solid by extruding a face

B-Rep shapes can be created by extruding or rotating simpler input shapes. For instance a face can be created by rotating an edge and solid can be created by extruding a face. Refer to ModelAlgo_BRepFeatures for details.

Creation Bottom-up

A bottom-up creation assumes a step-by-step process of creating a ModelData_Body (solid, sheet, wireframe or accorn) starting with the lower level shapes (e.g. vertices).

Here is a typical workflow you might have to follow:

  1. Create vertices from points;
  2. Create edges from curves and vertices;
  3. Create wires from edges;
  4. Create faces from surfaces and wires;
  5. Create a shell from faces (shell must be closed for a solid body);
  6. Create a solid from a shell (if constructing a solid body);
  7. Create a body from a resulting shape (e.g. solid or shell);
  8. Invoke automatic healing (correction) to ensure validity of the model.

Refer to particular subclasses of the ModelData_Shape for details on constructing a particular type. Refer to the example Assembly Modeling Example for demonstration of the entire workflow.

Warning
The bottom-up creation requires significant care to ensure validity of the model being created. Therefore it is recommended to use higher-level approaches (such as constructing solid primitives or using extrusions) instead of the bottom-up creation whenever possible.

Generation from Polygonal Representation

A B-Rep representation can be created from polygonal representation. This takes place when exporting a model with parts containing only polygonal representations to a format that requires B-Rep representation. For instance, this may happen when a model previously imported from an STL file to a file in IGES, STEP, ACIS or Parasolid format.

In this case each triangle of ModelData_IndexedTriangleSet will be converted to a planar triangle ModelData_Face. The whole triangle set will be converted into one or several ModelData_Shells where each shell will correspond to a connected subset of triangles (i.e. triangles sharing the same vertex indices). Each closed shell will be additionally converted into a ModelData_Solid.

Given that such B-Rep will have very high memory footprint on the one hand and may have limited usability in any CAD system for modeling operations on the other, this conversion is discouraged and should only be used when direct use of polygonal representations is impossible.

See also
Creating 3D Models.