DATAKIT SDK  V2026.1
Sample to tessellate a Dtk_Body
/*If you want to use tessellation library start Tesselation Kernel*/
int status = tess_InitTesselation("tess_tmp",0.05);
// optional parameter
// the following parameter can be call with different value between two
tess_set_angular(0.1745329); // for 10°
tess_set_Ratio(2.0); // see documentation of this function
if ( NoBoundarieCOmpute == TRUE )
if ( NoNormalesComputed == TRUE )
else
const Dtk_BodyPtr TmpBody = inNode->GetDtk_BodyPtr();
if (TmpBody)
{
//we scan all Shell and tesselate one mesh per shell
Dtk_Size_t i,nb,j,nb2,k,nb3,l,nb4;
nb = TmpBody->GetNumLumps();
for ( i=0;i<nb;i++)
{
TmpBody->GetLump(i,lump);
nb3=lump->GetNumVolumes();
for (k=0;k<nb3;k++)
{
lump->GetVolume(k,vol);
nb4=vol->GetNumShells();
for (l=0;l<nb4;l++)
{
Dtk_Int32 isclosed;
vol->GetShell(l,sh);
int err_tess = tess_ShellToMesh(sh,mh,&isclosed);
if(err_tess == 0)
{
/*Your function writing a mesh */
user_WriteDtk_Mesh(mh);
}
else
{
sprintf(ss,"Tesselation error %d\n",err_tess);
}
} // end of shell
} // end of volum
} // end of lump
nb2 = TmpBody->GetNumOpenShells();
for ( j=0;j<nb2;j++)
{
Dtk_Int32 isclosed;
TmpBody->GetOpenShell(j,sh);
int err_tess = tess_ShellToMesh(sh,mh,&isclosed);
if(err_tess == 0)
{
/*Your function writing a mesh */
user_WriteDtk_Mesh(mh);
}
else
{
sprintf(ss,"Tesselation error %d\n",err_tess);
}
}
}
/*Close Tesselation kernel*/

Sample to write a Dtk_mesh

tess_ShellToMesh
Dtk_ErrorStatus tess_ShellToMesh(const Dtk_ShellPtr &inShell, Dtk_MeshPtr &outMesh, Dtk_Int32 *outIsSolid)
Tesselate a shell.
tess_InitTesselation
int tess_InitTesselation(Dtk_string inWorkingDirectory, double inTolerance)
Init the tesselation library.
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:715
tess_ComputeNormalesFromSurface
void tess_ComputeNormalesFromSurface(int value)
Set normales computation from surface option. Enabled by default. If enabled, the normals of each ver...
tess_ComputeBoundariesFromMesh
void tess_ComputeBoundariesFromMesh(int value)
Set boundaries computation from mesh option. Default value is enabled (1). See tess_getBoundariesFrom...
tess_set_linear
void tess_set_linear(double tol)
Set linear tolerance (mm). Maximum chordal error accepted between the CAD surface and the tesselated ...
Dtk_Int32
int32_t Dtk_Int32
Definition: define.h:690
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
tess_set_Ratio
void tess_set_Ratio(double tol)
Set a maximum ratio between longest and shortest edge of each triangle. With 1.0 only equilateral tri...
tess_set_optimize_mesh
void tess_set_optimize_mesh(int ival)
Set a vertex map optimisation that reduces the mesh memory footprint (the geometry stay the same)....
tess_set_angular
void tess_set_angular(double angle)
Set angular tolerance (radian). Default value: 10°. Maximum angle between a triangle and the CAD surf...
tess_EndTesselation
void tess_EndTesselation()
Free the data used by tesselation library.
Dtk_Node::GetDtk_BodyPtr
Dtk_BodyPtr GetDtk_BodyPtr()
Retrieves the Dtk_Node as a Dtk_BodyPtr - if exists -.