DGtal  1.3.beta
shapes/mesh3DConstructionAndVisualisation.cpp
Simple example of 3D mesh construction.
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/Mesh.h"
#include "DGtal/io/viewers/Viewer3D.h"
using namespace std;
using namespace DGtal;
using namespace DGtal::Z3i;
int main( int argc, char** argv )
{
QApplication application(argc,argv);
Viewer3D<> viewer;
viewer.show();
// A mesh is constructed and faces are added from the vertex set.
Mesh<Point> aMesh(true);
aMesh.addVertex(Point(0,0,0));
aMesh.addVertex(Point(1,0,0));
aMesh.addVertex(Point(1,1,0));
aMesh.addVertex(Point(0,0,1));
aMesh.addVertex(Point(1,0,1));
aMesh.addVertex(Point(1,1,1));
aMesh.addVertex(Point(0,1,1));
aMesh.addVertex(Point(0,1,0));
aMesh.addVertex(Point(0,2,0));
aMesh.addVertex(Point(0,3,1));
aMesh.addVertex(Point(0,2,2));
aMesh.addVertex(Point(0,1,2));
aMesh.addVertex(Point(0,0,1));
aMesh.addTriangularFace(0, 1, 2, Color(150,0,150,104));
aMesh.addQuadFace(6,5,4,3, Color::Blue);
vector<unsigned int> listIndex;
listIndex.push_back(7);
listIndex.push_back(8);
listIndex.push_back(9);
listIndex.push_back(10);
listIndex.push_back(11);
listIndex.push_back(12);
aMesh.addFace(listIndex, Color(150,150,0,54));
viewer.setLineColor(Color(150,0,0,254));
viewer << aMesh;
viewer << Viewer3D<>::updateDisplay;
bool res = application.exec();
FATAL_ERROR(res);
return 0;
}
// //
DGtal::Mesh::addTriangularFace
void addTriangularFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, const DGtal::Color &aColor=DGtal::Color::White)
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
DGtal::Mesh::addFace
void addFace(const MeshFace &aFace, const DGtal::Color &aColor=DGtal::Color::White)
DGtal::Mesh::addVertex
void addVertex(const TPoint &vertex)
DGtal::Viewer3D
Definition: Viewer3D.h:135
DGtal::Mesh
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:91
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Display3D< SpaceND< 3 >, KhalimskySpaceND< 3 > >::setLineColor
virtual void setLineColor(DGtal::Color aColor)
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::Mesh::addQuadFace
void addQuadFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, unsigned int indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)