DGtal  1.4.beta
testMeshDisplay.cpp
Go to the documentation of this file.
1 
32 #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  Mesh<Point>::MeshFace 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 // //
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
virtual void setLineColor(DGtal::Color aColor)
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:92
void addQuadFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, Index indexVertex4, const DGtal::Color &aColor=DGtal::Color::White)
void addFace(const MeshFace &aFace, const DGtal::Color &aColor=DGtal::Color::White)
std::vector< Index > MeshFace
Definition: Mesh.h:126
void addTriangularFace(Index indexVertex1, Index indexVertex2, Index indexVertex3, const DGtal::Color &aColor=DGtal::Color::White)
void addVertex(const TPoint &vertex)
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
MyPointD Point
Definition: testClone2.cpp:383
int main(int argc, char **argv)