DGtal  0.9.2
mesh3DConstructionAndVisualisation.cpp
1 
30 #include "DGtal/base/Common.h"
32 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/shapes/Mesh.h"
36 #include "DGtal/io/viewers/Viewer3D.h"
38 
39 using namespace std;
40 using namespace DGtal;
41 using namespace DGtal::Z3i;
42 
43 
44 int main( int argc, char** argv )
45 {
46 
48  QApplication application(argc,argv);
49  Viewer3D<> viewer;
50  viewer.show();
52 
53 
55  // A mesh is constructed and faces are added from the vertex set.
57  Mesh<Point> aMesh(true);
59 
61  aMesh.addVertex(Point(0,0,0));
62  aMesh.addVertex(Point(1,0,0));
63  aMesh.addVertex(Point(1,1,0));
65 
66  aMesh.addVertex(Point(0,0,1));
67  aMesh.addVertex(Point(1,0,1));
68  aMesh.addVertex(Point(1,1,1));
69  aMesh.addVertex(Point(0,1,1));
70 
71  aMesh.addVertex(Point(0,1,0));
72  aMesh.addVertex(Point(0,2,0));
73  aMesh.addVertex(Point(0,3,1));
74  aMesh.addVertex(Point(0,2,2));
75  aMesh.addVertex(Point(0,1,2));
76  aMesh.addVertex(Point(0,0,1));
78  aMesh.addTriangularFace(0, 1, 2, Color(150,0,150,104));
79  aMesh.addQuadFace(6,5,4,3, Color::Blue);
81 
83  vector<unsigned int> listIndex;
84  listIndex.push_back(7);
85  listIndex.push_back(8);
86  listIndex.push_back(9);
87  listIndex.push_back(10);
88  listIndex.push_back(11);
89  listIndex.push_back(12);
90  aMesh.addFace(listIndex, Color(150,150,0,54));
93 
95  viewer.setLineColor(Color(150,0,0,254));
96  viewer << aMesh;
97  viewer << Viewer3D<>::updateDisplay;
99  bool res = application.exec();
100  FATAL_ERROR(res);
101  return true;
102 }
103 // //
105 
Z3i this namespace gathers the standard of types for 3D imagery.
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Aim: This class is defined to represent a surface mesh through a set of vertices and faces...
Definition: Mesh.h:91
STL namespace.
virtual void setLineColor(DGtal::Color aColor)
DGtal is the top-level namespace which contains all DGtal functions and types.
Structure representing an RGB triple with alpha component.
Definition: Color.h:66