CAD Exchanger SDK
Creating 3D Models


CAD Exchanger SDK allows to construct a 3D model bottom-up in a user's application. This can be used in order to export to a target format or to perform some operations inside the user's application (for instance to generate a polygonal representation from B-Rep and to explore its contents).

CAD Exchanger SDK does not pretend to be a full-fledged geometrical modeling kernel. Nonetheless available API allows to address many real-world application needs.

Part Modeling

A single part can be constructed using either its precise definition (B-Rep representation) or approximated faceted definition (polygonal representation) or both. A part may also contain multiple polygonal representations to describe different levels of details (LOD's).

Refer to B-Rep modeling and Polygonal representation creation for details on how to create B-Rep and polygonal representations respectively.

The following example demonstrates how to create a model with a single part consisting of one B-Rep representation and one polygonal representation. The latter is created using a visualization mesher with fine granularity settings:

ModelData_Solid aSolid = ...;
ModelData_BRepRepresentation aBRep (aSolid);
ModelData_PolyRepresentation aPoly (aBRep, ModelAlgo_BRepMesherParameters::Fine);
ModelData_Part aPart (aBRep, aPoly, "my_part");
aPart.SetAppearance (ModelData_Color (1.f, 0.f, 0.f)); //red
ModelData_Model aModel ("my_model");
aModel.AddRoot (aPart);

Assembly Modeling

Applications working with complex assemblies may use available data model API in order to create hierarchical assembly structures, including shared elements (sub-assemblies or parts), adding transformation matrices, properties, material and/or color attributes.

The following example demonstrates creation of an assembly of two cylinder instances and export to the JT format:

ModelData_Solid aSolid = ModelAlgo_TopoPrimitives::CreateCylinder (1. /*radius*/, 10. /*height*/);
ModelData_BRepRepresentation aBRep (aSolid);
ModelData_PolyRepresentation aPoly (aBRep, ModelAlgo_BRepMesherParameters::Medium);
ModelData_Part aPart (aBRep, aPoly, "my_link");
ModelData_Assembly anAsm ("my_assembly");
anAsm.AddInstance (aPart, "my_link_1");
anAsm.AddInstance (aPart, ModelData_Transformation (ModelData_Vector (5., 0, 0.), "my_link_2")); //translated by {5,0,0}
ModelData_Model aModel ("my_model");
aModel.AddRoot (anAsm);
JT_Writer aWriter;
bool anIsOk = aWriter.Transfer (aModel) && aWriter.WriteFile ("my_file.jt");


Refer to Assembly Creation.