CAD Exchanger SDK
Creation of 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.

B-Rep representation creation

Applications that need to represent their objects in exact geometrical form may create 3D models using B-Rep representation. CAD Exchanger offers key modeling API to create solid primitives - boxes, spheres, cylinders, cones, etc. Refer to Modeling Algorithms for the description of available algorithms.

Constructed B-Reps 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_BRepRepresentation aBRep (aBox);
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");

Polygonal representation creation

Applications that work with mesh data may create 3D models using Poly representations. Polygonal representations can be created from scratch - by populating the vertex sets with vertex coordinates and normals, or by generating polygonal representations from available B-Rep ones.

Refer to Creation for further details on creating polygonal representations.

The example below demonstrates creation of a polygonal representation:

ModelData_IndexedTriangleSet aTriangulation = ...;
ModelData_PolyRepresentation aPoly (aTriangulation);
ModelData_Part aPart (aBRep, aPoly, "my_part");
ModelData_Model aModel ("my_model");
aModel.AddRoot (aPart);
VRML_Writer aWriter;
bool anIsOk = aWriter.Transfer (aModel) && aWriter.WriteFile ("my_file.wrl");

Assembly creation

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.