DGtal  0.9.3beta
Static Public Member Functions
DGtal::MeshWriter< TPoint > Struct Template Reference

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

Static Public Member Functions

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

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);

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

template<typename TPoint >
static bool DGtal::MeshWriter< TPoint >::export2OBJ ( std::ostream &  out,
const Mesh< TPoint > &  aMesh 
)
throw (DGtal::IOException
)
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.
template<typename TPoint >
static bool DGtal::MeshWriter< TPoint >::export2OBJ_colors ( std::ostream &  out,
std::ostream &  outMTL,
const std::string  nameMTLFile,
const Mesh< TPoint > &  aMesh 
)
throw (DGtal::IOException
)
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.
template<typename TPoint >
static bool DGtal::MeshWriter< TPoint >::export2OFF ( std::ostream &  out,
const Mesh< TPoint > &  aMesh,
bool  exportColor = true 
)
throw (DGtal::IOException
)
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.

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