DGtal  0.9.2
testPolygon3D.cpp
1 
28 #include <iostream>
30 #include "DGtal/base/Common.h"
31 #include "DGtal/io/viewers/Viewer3D.h"
32 #include "DGtal/io/DrawWithDisplay3DModifier.h"
33 #include "DGtal/io/Color.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/shapes/Shapes.h"
37 
38 using namespace std;
39 using namespace DGtal;
40 using namespace Z3i;
41 
43 // Functions for testing class Viewer3D.
45 
49 bool testViewer3D()
50 {
51  unsigned int nbok = 0;
52  unsigned int nb = 0;
53  trace.beginBlock ( "Testing block ..." );
54  nbok += true ? 1 : 0;
55  nb++;
56  trace.info() << "(" << nbok << "/" << nb << ") "
57  << "true == true" << std::endl;
58  trace.endBlock();
59 
60  return nbok == nb;
61 }
62 
64 // Standard services - public :
65 
66 int main( int argc, char** argv )
67 {
68 
69  QApplication application(argc,argv);
70  Viewer3D<> viewer;
71  viewer.setWindowTitle("simpleViewer");
72  viewer.show();
73  trace.beginBlock ( "Testing Polygon 3D display in Viewer3D" );
74  std::vector<Z3i::RealPoint> polyg1;
75 
76  polyg1.push_back(Z3i::RealPoint(0,0,0));
77  polyg1.push_back(Z3i::RealPoint(0,1,0));
78  polyg1.push_back(Z3i::RealPoint(1,1,0));
79 
80  viewer.addPolygon(polyg1);
81 
82  viewer.createNewPolygonList("hop");
83 
84  std::vector<Z3i::RealPoint> polyg2;
85 
86  polyg2.push_back(Z3i::RealPoint(0,10,0));
87  polyg2.push_back(Z3i::RealPoint(0,11,0));
88  polyg2.push_back(Z3i::RealPoint(11,11,0));
89 
90  viewer.addPolygon(polyg2);
91 
92  viewer << Viewer3D<>::updateDisplay;
93 
94  bool res = application.exec();
95  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
96  trace.endBlock();
97  return res ? 0 : 1;
98 
99 
100 }
101 // //
103 
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:130
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
STL namespace.
double endBlock()
void createNewPolygonList(std::string s="")
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
std::ostream & emphase()
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & info()
void addPolygon(const std::vector< RealPoint > &vertices)