DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::MeshReader< TPoint > Struct Template Reference

Aim: Defined to import OFF and OFS surface mesh. It allows to import a Mesh object and takes into accouts the optional color faces. More...

#include <DGtal/io/readers/MeshReader.h>

Static Public Member Functions

static bool importOFFFile (const std::string &filename, DGtal::Mesh< TPoint > &aMesh, bool invertVertexOrder=false, bool onlyFaceVertex=false)
 
static bool importOFSFile (const std::string &filename, DGtal::Mesh< TPoint > &aMesh, bool invertVertexOrder=false, double scale=1.0)
 
static bool importOBJFile (const std::string &filename, DGtal::Mesh< TPoint > &aMesh, bool onlyFaceVertex=false)
 
static bool verifyIndicesUniqueness (const std::vector< typename DGtal::Mesh< TPoint >::Index > &indices)
 
static std::map< std::string, DGtal::ColorreadMaterial (std::istream &input)
 

Detailed Description

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

Aim: Defined to import OFF and OFS surface mesh. It allows to import a Mesh object and takes into accouts the optional color faces.

Description of class 'MeshReader'

The importation can be done automatically according the input file extension with the operator <<

Example of typical use: Add these include files:

#include "DGtal/shapes/Mesh.h"
#include "DGtal/io/readers/MeshReader.h"

And automatic import the Mesh through the filename extension:

std::string filenameOFF = testPath + "samples/box.off";
Mesh<Point> a3DMesh;
bool importOK = a3DMesh << filenameOFF;
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition Mesh.h:92

Then you can also display the resulting with a Viewer3D:

viewer.setLineColor(DGtal::Color(150,0,0,254));
viewer << a3DMesh;
Structure representing an RGB triple with alpha component.
Definition Color.h:68
See also
Mesh MeshWriter

Definition at line 98 of file MeshReader.h.

Member Function Documentation

◆ importOBJFile()

template<typename TPoint >
static bool DGtal::MeshReader< TPoint >::importOBJFile ( const std::string & filename,
DGtal::Mesh< TPoint > & aMesh,
bool onlyFaceVertex = false )
static

Reads an input file as an OBJ file format and outputs the corresponding surface mesh.

Parameters
[in]filenamethe input filename of the OBJ file to be read.
[out]aMeshthe output mesh.
[in]onlyFaceVertexflag used to import only vertces associated to a face.
Returns
'true' if both reading the input stream was ok and the created mesh is ok.

◆ importOFFFile()

template<typename TPoint >
static bool DGtal::MeshReader< TPoint >::importOFFFile ( const std::string & filename,
DGtal::Mesh< TPoint > & aMesh,
bool invertVertexOrder = false,
bool onlyFaceVertex = false )
static

Main method to import OFF meshes file (Geomview Object File Format)

Parameters
[in]filenamethe file name to import.
[out]aMeshthe mesh object to be imported.
[in]invertVertexOrderused to invert (default value=false) the order of imported points (important for normal
[in]onlyFaceVertexflag used to import only vertces associated to a face.
Returns
an instance of the imported mesh: MeshFromPoint.

Referenced by TEST_CASE().

◆ importOFSFile()

template<typename TPoint >
static bool DGtal::MeshReader< TPoint >::importOFSFile ( const std::string & filename,
DGtal::Mesh< TPoint > & aMesh,
bool invertVertexOrder = false,
double scale = 1.0 )
static

Main method to import OFS meshes file (an equivalent of OFF format)

Parameters
filenamethe file name to import.
aMesh(return) the mesh object to be imported.
invertVertexOrderused to invert (default value=false) the order of imported points (important for normal orientation).
scaleused to avoid to display tiny shapes (since OFS shapes are generally included in a 1x1x1 cube)
Returns
an instance of the imported mesh: MeshFromPoint.

◆ readMaterial()

template<typename TPoint >
static std::map< std::string, DGtal::Color > DGtal::MeshReader< TPoint >::readMaterial ( std::istream & input)
static

Reads an input material file associated ot an OBJ file format and outputs the corresponding materials as a map assiating name and diffuse color.

Parameters
[in,out]inputthe input stream where the OBJ file is read.
Returns
'true' if both reading the input stream was ok and the created mesh is ok.

◆ verifyIndicesUniqueness()

template<typename TPoint >
static bool DGtal::MeshReader< TPoint >::verifyIndicesUniqueness ( const std::vector< typename DGtal::Mesh< TPoint >::Index > & indices)
static

Checks that each index in indices is unique.

Parameters
indicesa vector of integer indices
Returns
'true' iff the integer indices are all pairwise different.

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