DATAKIT API  V2025.1
WriteMesh.cpp File Reference

Functions

void WriteDtk_Mesh (const Dtk_MeshPtr &inMeshToWrite)
 
void WriteMesh (Dtk_NodePtr inNode)
 

Function Documentation

◆ WriteDtk_Mesh()

void WriteDtk_Mesh ( const Dtk_MeshPtr inMeshToWrite)
9 {
10  // convert triangles-strip, fans, polygons into simple triangles
11  inMeshToWrite->explode();
12 
13  // Used to write a PDF File
14  if (IsPdfDumpActivated())
15  {
17  }
18 
19  // Used to write an XML File
20  if (IsXmlDumpActivated())
21  {
22  XmlWriteMesh(inMeshToWrite);
23  }
24 
25  Dtk_RGB rgb = inMeshToWrite->get_mesh_color(); // mesh global color.
26 
27  // vertices :
28  Dtk_Size_t nbvertices = inMeshToWrite->get_nb_vertices();
29  Dtk_Size_t i, j;
30  for (i = 0; i < nbvertices; i++)
31  {
32  Dtk_pnt pnt;
33  Dtk_dir dir;
34  Dtk_RGB color;
35  float u, v;
36  u = v = 0.0;
37  inMeshToWrite->get_vertex(i, &pnt); // coordinates of the vertices
38  if (inMeshToWrite->has_normals())
39  inMeshToWrite->get_normal(i, &dir); // vertex normal (if enabled)
40  if (inMeshToWrite->has_colors())
41  inMeshToWrite->get_color(i, &color); // vertex color (if enabled)
42  if (inMeshToWrite->has_texcoords())
43  {
44  u = inMeshToWrite->GetUTexture(i); // vertex u,v texture coordinate (if enabled)
45  v = inMeshToWrite->GetVTexture(i);
46  }
47  }
48  // mesh_faces
49  Dtk_Size_t k, m, nbmeshfaces = inMeshToWrite->get_nb_mesh_face();
50  for (i = 0; i < nbmeshfaces; i++)
51  {
52  Dtk_mesh_face* mf = inMeshToWrite->get_mesh_face(i);
53  Dtk_Size_t nbtriangles = mf->get_nbtriangles();
54  Dtk_Int32 trianglesindices[3];
55  for (j = 0; j < nbtriangles; j++)
56  {
57  const Dtk_UInt32* tri = mf->get_triangle_indices(j);
58  trianglesindices[0] = tri[0];
59  trianglesindices[1] = tri[1];
60  trianglesindices[2] = tri[2];
61  // id of vertex in vertices table you read in the first step of this function
62  }
63 
64  //face boundaries
65  Dtk_Size_t nbpolyline = mf->get_nbpolylines();
66  for (j = 0; j < nbpolyline; j++)
67  {
68  const Dtk_tab<Dtk_UInt32> *pnt;
69  pnt = mf->get_polyline_indices(j);
70  Dtk_Size_t nbvertex = pnt->size();
71  for (k = 0; k < nbvertex; k++)
72  {
73  m = (*pnt)[k]; // id of vertex in vertices table
74  Dtk_pnt pt = inMeshToWrite->get_vertex(m);
75  }
76  }
77  }
78 }

◆ WriteMesh()

void WriteMesh ( Dtk_NodePtr  inNode)
81 {
82  Dtk_MeshPtr TmpMesh = inNode->GetDtk_MeshPtr();
83  if (TmpMesh.IsNotNULL())
84  {
86  TmpMesh->Transform(CurrentMatrix);
87  WriteDtk_Mesh(TmpMesh);
88  }
89 }
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
PdfWriteEntity
void PdfWriteEntity(Dtk_EntityPtr inEntity)
Definition: PdfWrite.cpp:173
Dtk_mesh_face
This is a high level face class.
Definition: util_mesh_dtk.hpp:870
XmlWriteMesh
void XmlWriteMesh(const Dtk_MeshPtr &inMeshToWrite)
Definition: XmlWrite.cpp:63
Dtk_SmartPtr::IsNotNULL
Dtk_bool IsNotNULL() const
Definition: util_ptr_dtk.hpp:119
Dtk_UInt32
uint32_t Dtk_UInt32
Definition: define.h:688
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:712
Dtk_mesh_face::get_polyline_indices
const Dtk_tab< Dtk_UInt32 > * get_polyline_indices(Dtk_Size_t inI) const
Get inI-th polygon.
Dtk_mesh_face::get_nbpolylines
Dtk_Size_t get_nbpolylines() const
Get the number of polylines kept in the class instance.
WriteDtk_Mesh
void WriteDtk_Mesh(const Dtk_MeshPtr &inMeshToWrite)
Definition: WriteMesh.cpp:8
Dtk_Int32
int32_t Dtk_Int32
Definition: define.h:687
Dtk_mesh_face::get_triangle_indices
const Dtk_UInt32 * get_triangle_indices(Dtk_Size_t inI) const
Get pointer of triangle indices of i-th triangle.
Dtk_SmartPtr< Dtk_Entity >::DtkDynamicCast
static Dtk_SmartPtr< Dtk_Entity > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
CurrentMatrix
Dtk_transfo CurrentMatrix
Definition: WritePrototype.cpp:11
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
Dtk_mesh_face::get_nbtriangles
Dtk_Size_t get_nbtriangles() const
Get the number of simple triangles kept in the class instance.
Dtk_Node::GetDtk_MeshPtr
Dtk_MeshPtr GetDtk_MeshPtr()
Retrieves the Dtk_Node as a Dtk_meshPtr - if exists -.
Dtk_tab< Dtk_UInt32 >
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:502
IsXmlDumpActivated
Dtk_bool IsXmlDumpActivated()
Definition: XmlWrite.cpp:17
Dtk_RGB
Definition: dtk_rgb.hpp:7
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
IsPdfDumpActivated
Dtk_bool IsPdfDumpActivated()
Definition: PdfWrite.cpp:26