DGtal  1.0.0
test3DImageView.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/viewers/Viewer3D.h"
34 #include "DGtal/io/viewers/DrawWithViewer3DModifier.h"
35 #include "DGtal/io/Color.h"
36 #include "DGtal/helpers/StdDefs.h"
37 #include "DGtal/shapes/Shapes.h"
38 #include "DGtal/io/readers/PGMReader.h"
39 #include "DGtal/io/readers/GenericReader.h"
40 #include "DGtal/io/writers/GenericWriter.h"
41 #include "DGtal/io/colormaps/BasicColorToScalarFunctors.h"
42 #include "DGtal/math/BasicMathFunctions.h"
43 #include "DGtal/io/colormaps/HueShadeColorMap.h"
44 
45 #include "ConfigTest.h"
46 
47 #include <limits>
49 
50 using namespace std;
51 using namespace DGtal;
52 using namespace Z3i;
53 
54 
55 
56 
58 // Functions for testing class Viewer3D.
60 struct hueFct{
61  inline
62  unsigned int operator() (unsigned char aVal) const
63  {
64  HueShadeColorMap<unsigned int> hueShade(0,255);
65  Color col = hueShade((unsigned int)aVal);
66  return col.getRGB();
67  }
68 };
69 
71 // Standard services - public :
72 
73 int main( int argc, char** argv )
74 {
77 
78  QApplication application(argc,argv);
79  Viewer3D<> viewer;
80  viewer.setWindowTitle("simpleViewer");
81  viewer.show();
82  trace.beginBlock("Testing Viewer with 3D Image View ");
83 
84  Point p1( 0, 0, 0 );
85  Point p2( 125, 188, 0 );
86  Point p3( 30, 30, 30 );
87 
88  std::string filename = testPath + "samples/church-small.pgm";
89  std::string filename3 = testPath + "samples/color64.ppm";
90 
91  imageNG image = DGtal::PGMReader<imageNG>::importPGM(filename);
92  imageNG image2 = DGtal::GenericReader<imageNG>::import(filename);
93  imageCol image3 = DGtal::GenericReader<imageCol>::import(filename3);
94  hueFct huefct;
95  functors::Identity defaultfunctor;
96 
97  viewer << DGtal::AddTextureImage2DWithFunctor<imageNG, hueFct , Z3i::Space, Z3i::KSpace>(image2, huefct, Viewer3D<>::RGBMode );
98  viewer << image;
99  viewer << DGtal::AddTextureImage2DWithFunctor<imageCol, functors::Identity, Z3i::Space, Z3i::KSpace>(image3, defaultfunctor, Viewer3D<>::RGBMode );
100  viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(0, Viewer3D<>::xDirection, 50, 50, 50 );
101  viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(2, Viewer3D<>::yDirection, 0, 0, 0);
102 
103  viewer << SetMode3D( image.domain().className(), "BoundingBox" );
104  viewer << image.domain();
105  viewer << DGtal::Update2DDomainPosition<Z3i::Space, Z3i::KSpace>(0, Viewer3D<>::xDirection, 0, 0, 0);
106  for(unsigned int i= 0; i< 10; i++){
107  if(i%4==0){
108  viewer << SetMode3D( image.className(), "" );
109  }else if(i%4==1){
110  viewer << SetMode3D( image.className(), "BoundingBox" );
111  }else if(i%4==2){
112  viewer << SetMode3D( image.className(), "Grid" );
113  }else if(i%4==3){
114  viewer << SetMode3D( image.className(), "InterGrid" );
115  }
116  viewer << image;
117  viewer << DGtal::UpdateImageData<imageNG>(i+3, image, i*50, i*50, i*50);
118  }
119 
120 
121  viewer << p1 << p2 << p3;
122  viewer << Viewer3D<>::updateDisplay;
123 
124 
125  bool res = application.exec();
126  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
127  trace.endBlock();
128  return res ? 0 : 1;
129 
130 
131 }
132 // //
134 
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:144
double endBlock()
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
Aim: Define a simple default functor that just returns its argument.
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
int main(int argc, char **argv)
std::ostream & emphase()
DGtal::uint32_t getRGB() const
DGtal is the top-level namespace which contains all DGtal functions and types.
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Image image(domain)
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....