DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testViewer3D.cpp
1 
30 
31 #include <iostream>
32 #include <QtGui/qapplication.h>
33 #include "DGtal/io/viewers/Viewer3D.h"
34 #include "DGtal/io/DrawWithDisplay3DModifier.h"
35 #include "DGtal/io/Color.h"
36 #include "DGtal/base/Common.h"
37 #include "DGtal/helpers/StdDefs.h"
38 #include "DGtal/shapes/Shapes.h"
40 
41 using namespace std;
42 using namespace DGtal;
43 using namespace Z3i;
44 
46 // Functions for testing class Viewer3D.
48 
52 bool testViewer3D()
53 {
54  unsigned int nbok = 0;
55  unsigned int nb = 0;
56  trace.beginBlock ( "Testing block ..." );
57  nbok += true ? 1 : 0;
58  nb++;
59  trace.info() << "(" << nbok << "/" << nb << ") "
60  << "true == true" << std::endl;
61  trace.endBlock();
62 
63  return nbok == nb;
64 }
65 
67 // Standard services - public :
68 
69 int main( int argc, char** argv )
70 {
71 
72  QApplication application(argc,argv);
73  Viewer3D viewer;
74  viewer.setWindowTitle("simpleViewer");
75  viewer.show();
76 
77 
78 
79 
80 
81 
82 
83 
84 
85  Point p1( 14, 14, 14 );
86  Point p2( 27, 27, 27 );
87  Domain domain( p1, p2 );
88 
89  viewer << CustomColors3D(Color(20, 20, 20, 50),Color(20, 0,250,30));
90  viewer << SetMode3D(domain.className(), "Grid");
91  viewer << domain;
92 
93  DigitalSet shape_set( domain );
94  Shapes<Domain>::addNorm1Ball( shape_set, Point( 13, 23, 13 ), 7 );
95  viewer << CustomColors3D(Color(250, 200,0, 100),Color(250, 200,0, 50));
96 
97  viewer << shape_set ;
98  DigitalSet shape_set2( domain );
99  Shapes<Domain>::addNorm1Ball( shape_set2, Point( 24, 15, 12 ), 12 );
100  viewer << shape_set2 ;
101 
102  DigitalSet shape_set3( domain );
103  Shapes<Domain>::addNorm2Ball( shape_set3, Point( 11, 15, 12 ), 12 );
104  viewer << CustomColors3D(Color(250, 20,0, 190),Color(220, 20,20, 250));
105  viewer << shape_set3 ;
106 
107 
108 
109 
110  Point pp1( -1, -1, -2 );
111  Point pp2( 2, 2, 3 );
112 
113 
114  Domain domain2( pp1, pp2 );
115  Point pp3( 1, 1, 1 );
116  Point pp4( 2, -1, 5 );
117  Point pp5( -1, 2, 3 );
118  Point pp6( 0, 0, 0 );
119  Point pp0( 0, 2, 1 );
120 
121  //viewer<< m;
122  viewer << SetMode3D( pp1.className(), "Paving" );
123  viewer << pp1 << pp2 << pp3;
124 
125  //viewer << SetMode3D( pp1.className(), "Grid" );
126  viewer << CustomColors3D(Color(250, 0,0),Color(250, 0,0));
127  viewer << SetMode3D( pp1.className(), "PavingWired" );
128  viewer << pp4 << pp5 ;
129  viewer << SetMode3D( pp1.className(), "Both" );
130  viewer << CustomColors3D(Color(250, 200,0, 100),Color(250, 0,0, 100));
131  viewer << pp6;
132  viewer << CustomColors3D(Color(250, 200,0, 100),Color(250, 200,0, 20));
133  viewer << pp0;
134 
135 
136  viewer << SetMode3D(domain.className(), "Paving");
137  viewer << domain2 << Display3D::updateDisplay;
138 
139 
140  bool res = application.exec();
141  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
142  trace.endBlock();
143  return res ? 0 : 1;
144 
145 
146 }
147 // //
149