DATAKIT API  V2025.4
First Step in Datakit SDK for OpenCascade


Directory content

The basis delivery of Datakit SDK (DatakitLibsAndSampleProject_...) contains :

 ./SampleSources : Sample source code
 ./Lib_Include   : CrossCAD / Ware SDK includes
 ./Libs          : CrossCAD / Ware SDK libraries
 ./InputImages   : Images for pdf and writers generation
 ./SampleFiles   : CAD / BIM Sample files (Full zip with sample files can be downloaded separately)
 ./bin           : Binaries directory for Cadds Reader

This delivery file adds following files to support conversion to Opencascade Brep Object :

 ./SampleSources/AllReadersToOccBinaryObject        : Sample to fill 3dShape according to the Occ version you use
 ./Lib_Include/DKOC                                 : Usefull includes for conversion from Dtk_Body to TopoDSShape
 ./Libs/LibUtilOCC                                  : Additionnal lib LibUtilOCC (independent from occ version ) with depending so files
 ./Libs/LibSdkOcc                                   : Additionnal lib dependent on the Occ version you use

Preamble

This archive is meant to link with occ7.7.0. If you use another version of OpenCascad, please download associated LibSdkOcc archive on our website

How to use

Installing CMake

CMake is required to build the example projects.

You can download the CMake tools from https://cmake.org/download/

How to build

Each example must be generated into separate folders. You must set the path of your occ installation directory as en environment variable for linkage and execution :

  • Windows
set OCC_INSTALL_DIRECTORY=MyOCCVersionPath
  • Linux
export OCC_INSTALL_DIRECTORY="MyOCCVersionPath"

On Windows

You can use the CMake GUI or the following command lines to configure projects :

cmake -S ./SampleSources/AllReadersToOccBinaryObject -B ./build/AllReadersToOccBinaryObject -A x64

You can build projects :

  • By opening the generated sln in Visual Studio
  • Or by using the following commands :
cmake --build ./build/AllReadersToOccBinaryObject --config Release

The executable is created in ./bin directory. Note that you have to use your own Opencascad dll files.

On Linux

The following command lines can be used to configure projects :

cmake -S ./SampleSources/AllReadersToOccBinaryObject -B ./build/AllReadersToOccBinaryObject

You can build projects :

  • By running the make command on the generated MakeFile
  • Or by using the following commands :
cmake --build ./build/AllReadersToOccBinaryObject --config Release

The built executables are copied to the ./bin directory and must be run from there.

Note that you have to use your own Opencascad so files (using for example export LD_LIBRARY_PATH=MyOCCVersionPath).

Specific Integration

A class DKOC_BodyToOCCBRep is provided to convert a Dtk_Body to a TopoDS_Shape of a target version of OpenCascade. It is based on (1) the conversion tool provided by CrossCADWare (in LibUtilOCC), (2) a function which copies the result to the final TopoDS_Shape.

So this class wraps and enchains :

  • the conversion itself to OpenCascade
  • the copy to target version of OpenCascade
  • manages the serialization of the result, allowing the caller to ask, for a given item (TopoDS_Shape), which is the starting ID for it in the CAD model, this can then be used to query the Dtk_Body.

This object allows the caller to drive the call to ShapeFix. By default, ShapeFix is called, it is the one embedded in the OCC version used in the Datakit libraries. It can be switched on/off, hence the user can call for instance the ShapeFix of the target OCC version, etc.

WARNING : in practice, it is necessary to call ShapeFix to have a TopoDS_Shape ready to use.

MAPPING : this object keeps the mapping between the initial items of the Dtk_Body (for instance Dtk_Face, etc) and the resulting TopoDS_Shape's of OpenCascade.

The Root Shape is the final result of the whole conversion of the Dtk_Body Each sub-shape is attached to an internal ID, specific of this conversion (by the object DKOC_BodyToOCCBRep) This ID is mapped to the ID coming from the CAD model (recorded in the Dtk_Info of the item of the Dtk_Body) Hence, it is possible to query the Dtk_Body to get the corresponding entity and read its attributes (name, color, etc)

Calls to methods of DKOC_BodyToOCCBRep

  • To Control of ShapeFix use :
DKOC_Body2OCCBRep B2OC;
Dtk_bool mode_shapefix = DTK_FALSE; // DTK_FALSE off, DTK_TRUE on
B2OC.SetConfigShapeFix(mode_shapefix);

If not called, the default mode is 1.

TopoDS_Shape res;
Dtk_ErrorStatus stat = B2OC.ConvertBody(TmpBody);
res = B2OC.GetMainShape();

res is NULL if ConvertBody has failed (see return status not null).

  • To map TopoDS_Shape to datakit entity :

for a sub-shape, its ID of conversion :

TopoDS_Shape aShape ..;
int Shape_id = B2OC.GetShapeID (aShape); // 0 if not found

For an ID of conversion, get the ID if the CAD model :

int dtk_id = B2OC.GetDtkID (Shape_id);

dtk_id can be 0 if this TopoDS_Shape has been added (not in the initial model, example : degenerated edge, seam edge, etc) then the Dtk_Body can be queried with this ID to get the Dtk_Entity it comes from and query this Dtk_Entity (for color, etc)