DGtal  0.9.3
testMeshDisplay.cpp
Go to the documentation of this file.
1 
30 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/shapes/Mesh.h"
35 #include "DGtal/io/viewers/Viewer3D.h"
38 
39 using namespace std;
40 using namespace DGtal;
41 using namespace DGtal::Z3i;
42 
44 // Functions for testing class Mesh Display.
46 
48 // Standard services - public :
49 
50 
51 int main( int argc, char** argv )
52 {
53  trace.beginBlock ( "Testing class MeshDisplay" );
54  trace.info() << "Args:";
55  for ( int i = 0; i < argc; ++i )
56  trace.info() << " " << argv[ i ];
57  trace.info() << endl;
59  QApplication application(argc,argv);
60  Viewer3D<> viewer;
61  viewer.show();
63 
65  Mesh<Point> aMesh(true);
66  aMesh.addVertex(Point(0,0,0));
67  aMesh.addVertex(Point(1,0,0));
68  aMesh.addVertex(Point(1,1,0));
69 
70  aMesh.addVertex(Point(0,0,1));
71  aMesh.addVertex(Point(1,0,1));
72  aMesh.addVertex(Point(1,1,1));
73  aMesh.addVertex(Point(0,1,1));
74 
75  aMesh.addVertex(Point(0,1,0));
76  aMesh.addVertex(Point(0,2,0));
77  aMesh.addVertex(Point(0,3,1));
78  aMesh.addVertex(Point(0,2,2));
79  aMesh.addVertex(Point(0,1,2));
80  aMesh.addVertex(Point(0,0,1));
81 
82  aMesh.addTriangularFace(0, 1, 2, Color(150,0,150,104));
83  aMesh.addQuadFace(6,5,4,3, Color::Blue);
84 
85  vector<unsigned int> listIndex;
86  listIndex.push_back(7);
87  listIndex.push_back(8);
88  listIndex.push_back(9);
89  listIndex.push_back(10);
90  listIndex.push_back(11);
91  listIndex.push_back(12);
92 
93  aMesh.addFace(listIndex, Color(150,150,0,54));
96  viewer.setLineColor(Color(150,0,0,254));
97  viewer << aMesh;
98  viewer << Viewer3D<>::updateDisplay;
99  bool res = application.exec();
101  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
102  trace.endBlock();
103  return res ? 0 : 1;
104 }
105 // //
void beginBlock(const std::string &keyword="")
Z3i this namespace gathers the standard of types for 3D imagery.
Trace trace
Definition: Common.h:137
void addQuadFace(unsigned int indexVertex1, unsigned int indexVertex2, unsigned int indexVertex3, unsigned int indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
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.
double endBlock()
virtual void setLineColor(DGtal::Color aColor)
int main(int argc, char **argv)
void addVertex(const TPoint &vertex)
std::ostream & emphase()
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
std::ostream & info()
void addFace(const MeshFace &aFace, const DGtal::Color &aColor=DGtal::Color::White)
Structure representing an RGB triple with alpha component.
Definition: Color.h:66