DGtal  1.0.0
mesh3DConstructionAndVisualisation.cpp
Go to the documentation of this file.
1 
39 #include "DGtal/base/Common.h"
41 #include "DGtal/helpers/StdDefs.h"
43 #include "DGtal/shapes/Mesh.h"
45 #include "DGtal/io/viewers/Viewer3D.h"
47 
48 using namespace std;
49 using namespace DGtal;
50 using namespace DGtal::Z3i;
51 
52 
53 int main( int argc, char** argv )
54 {
55 
57  QApplication application(argc,argv);
58  Viewer3D<> viewer;
59  viewer.show();
61 
62 
64  // A mesh is constructed and faces are added from the vertex set.
66  Mesh<Point> aMesh(true);
68 
70  aMesh.addVertex(Point(0,0,0));
71  aMesh.addVertex(Point(1,0,0));
72  aMesh.addVertex(Point(1,1,0));
74 
75  aMesh.addVertex(Point(0,0,1));
76  aMesh.addVertex(Point(1,0,1));
77  aMesh.addVertex(Point(1,1,1));
78  aMesh.addVertex(Point(0,1,1));
79 
80  aMesh.addVertex(Point(0,1,0));
81  aMesh.addVertex(Point(0,2,0));
82  aMesh.addVertex(Point(0,3,1));
83  aMesh.addVertex(Point(0,2,2));
84  aMesh.addVertex(Point(0,1,2));
85  aMesh.addVertex(Point(0,0,1));
87  aMesh.addTriangularFace(0, 1, 2, Color(150,0,150,104));
88  aMesh.addQuadFace(6,5,4,3, Color::Blue);
90 
92  vector<unsigned int> listIndex;
93  listIndex.push_back(7);
94  listIndex.push_back(8);
95  listIndex.push_back(9);
96  listIndex.push_back(10);
97  listIndex.push_back(11);
98  listIndex.push_back(12);
99  aMesh.addFace(listIndex, Color(150,150,0,54));
102 
104  viewer.setLineColor(Color(150,0,0,254));
105  viewer << aMesh;
106  viewer << Viewer3D<>::updateDisplay;
108  bool res = application.exec();
109  FATAL_ERROR(res);
110  return 0;
111 }
112 // //
114 
Z3i this namespace gathers the standard of types for 3D imagery.
void addQuadFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, unsigned int indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:91
virtual void setLineColor(DGtal::Color aColor)
void addVertex(const TPoint &vertex)
void addTriangularFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, const DGtal::Color &aColor=DGtal::Color::White)
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
void addFace(const MeshFace &aFace, const DGtal::Color &aColor=DGtal::Color::White)
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
int main(int argc, char **argv)
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...