DGtal 1.3.0
Loading...
Searching...
No Matches
Static Public Member Functions
DGtal::MeshWriter< TPoint > Struct Template Reference

Aim: Export a Mesh (Mesh object) in different format as OFF and OBJ). More...

#include <DGtal/io/writers/MeshWriter.h>

Static Public Member Functions

static bool export2OFF (std::ostream &out, const Mesh< TPoint > &aMesh, bool exportColor=true)
 
static bool export2OBJ (std::ostream &out, const Mesh< TPoint > &aMesh)
 
static bool export2OBJ_colors (std::ostream &out, std::ostream &outMTL, const std::string nameMTLFile, const Mesh< TPoint > &aMesh)
 

Detailed Description

template<typename TPoint>
struct DGtal::MeshWriter< TPoint >

Aim: Export a Mesh (Mesh object) in different format as OFF and OBJ).

Description of template struct 'MeshWriter'

The exportation can be done automatically according the input file extension with the ">>" operator

Example of typical use: First you have to add the following include files:

#include "DGtal/shapes/Mesh.h"
#include "DGtal/io/writers/MeshWriter.h"

Then you create a simple Mesh object:

// Constructing the mesh to export in OFF format
Mesh<Point> aMesh(true);
vector<Point> vectVertex;
Point p1(0, 0, 0);
Point p2(1, 0, 0);
Point p3(1, 1, 0);
Point p4(0, 1, 0);
Point p11(0, 0, 1);
Point p21(1, 0, 1);
Point p31(1, 1, 1);
Point p41(0, 1, 1);
aMesh.addVertex(p1);
aMesh.addVertex(p2);
aMesh.addVertex(p3);
aMesh.addVertex(p4);
aMesh.addVertex(p11);
aMesh.addVertex(p21);
aMesh.addVertex(p31);
aMesh.addVertex(p41);
vector<DGtal::Color> vectColor;
DGtal::Color col (250,0,0, 200);
DGtal::Color col2 (250,250,0, 200);
aMesh.addQuadFace(0,1,2,3, col);
aMesh.addQuadFace(4,5,6,7, col2);
aMesh.addQuadFace(0,1,5,4, col);
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:92
MyPointD Point
Definition: testClone2.cpp:383

Finally you can export directly the Mesh object:

bool isOK = aMesh >> "test.off";
See also
Mesh MeshWriter

Definition at line 76 of file MeshWriter.h.

Member Function Documentation

◆ export2OBJ()

template<typename TPoint >
static bool DGtal::MeshWriter< TPoint >::export2OBJ ( std::ostream &  out,
const Mesh< TPoint > &  aMesh 
)
static

Export a Mesh towards a OBJ format (colors are exported).

Parameters
outthe output stream of the exported OBJ object.
aMeshthe Mesh object to be exported.
Returns
true if no errors occur.

Referenced by testMeshWriter().

◆ export2OBJ_colors()

template<typename TPoint >
static bool DGtal::MeshWriter< TPoint >::export2OBJ_colors ( std::ostream &  out,
std::ostream &  outMTL,
const std::string  nameMTLFile,
const Mesh< TPoint > &  aMesh 
)
static

Export a Mesh towards a OBJ format including face colors.

Parameters
[out]outthe output stream of the exported OBJ object.
[out]outMTLthe output stream associated to the material file.
[in]nameMTLFilethe file name of the material file.
[in]aMeshthe Mesh object to be exported.
Returns
true if no errors occur.

◆ export2OFF()

template<typename TPoint >
static bool DGtal::MeshWriter< TPoint >::export2OFF ( std::ostream &  out,
const Mesh< TPoint > &  aMesh,
bool  exportColor = true 
)
static

Export Mesh towards a OFF format. By default the face colors are exported (if they are stored in the Mesh object).

Parameters
outthe output stream of the exported OFF object.
aMeshthe Mesh object to be exported.
exportColortrue to try to export the face colors if they are stored in the Mesh object (default true).
Returns
true if no errors occur.

Referenced by DGtal::Shortcuts< TKSpace >::saveOFF(), and testMeshGeneration().


The documentation for this struct was generated from the following file: