DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testMeshFromPointsDisplay.cpp
1 
30 
31 
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/shapes/fromPoints/MeshFromPoints.h"
35 #include "DGtal/io/viewers/Viewer3D.h"
36 #include <QtGui/qapplication.h>
39 
40 using namespace std;
41 using namespace DGtal;
42 using namespace DGtal::Z3i;
43 
45 // Functions for testing class MeshFromPointsDisplay.
47 
49 // Standard services - public :
50 
51 
52 int main( int argc, char** argv )
53 {
54  trace.beginBlock ( "Testing class MeshFromPointsDisplay" );
55  trace.info() << "Args:";
56  for ( int i = 0; i < argc; ++i )
57  trace.info() << " " << argv[ i ];
58  trace.info() << endl;
60  QApplication application(argc,argv);
61  Viewer3D viewer;
62  viewer.show();
64 
66  MeshFromPoints<Point> aMesh(true);
67  aMesh.addVertex(Point(0,0,0));
68  aMesh.addVertex(Point(1,0,0));
69  aMesh.addVertex(Point(1,1,0));
70 
71  aMesh.addVertex(Point(0,0,1));
72  aMesh.addVertex(Point(1,0,1));
73  aMesh.addVertex(Point(1,1,1));
74  aMesh.addVertex(Point(0,1,1));
75 
76  aMesh.addVertex(Point(0,1,0));
77  aMesh.addVertex(Point(0,2,0));
78  aMesh.addVertex(Point(0,3,1));
79  aMesh.addVertex(Point(0,2,2));
80  aMesh.addVertex(Point(0,1,2));
81  aMesh.addVertex(Point(0,0,1));
82 
83  aMesh.addTriangularFace(0, 1, 2, Color(150,0,150,104));
84  aMesh.addQuadFace(6,5,4,3, Color::Blue);
85 
86  vector<unsigned int> listIndex;
87  listIndex.push_back(7);
88  listIndex.push_back(8);
89  listIndex.push_back(9);
90  listIndex.push_back(10);
91  listIndex.push_back(11);
92  listIndex.push_back(12);
93 
94  aMesh.addFace(listIndex, Color(150,150,0,54));
97  viewer.setLineColor(Color(150,0,0,254));
98  viewer << aMesh;
99  viewer << Viewer3D::updateDisplay;
100  bool res = application.exec();
102  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
103  trace.endBlock();
104  return res ? 0 : 1;
105 }
106 // //