DGtal  0.9.3
Functions
test3DImageView.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/viewers/DrawWithViewer3DModifier.h"
#include "DGtal/io/Color.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/io/readers/PGMReader.h"
#include "DGtal/io/readers/GenericReader.h"
#include "DGtal/io/writers/GenericWriter.h"
#include "DGtal/io/colormaps/BasicColorToScalarFunctors.h"
#include "DGtal/math/BasicMathFunctions.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "ConfigTest.h"
#include <limits>
Include dependency graph for test3DImageView.cpp:

Go to the source code of this file.

Functions

bool testViewer3D ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2011/01/03

Functions for testing class Viewer3D.

This file is part of the DGtal library.

Definition in file test3DImageView.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 91 of file test3DImageView.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), image(), DGtal::GenericReader< TContainer, Tdim, TValue >::import(), DGtal::PGMReader< TImageContainer, TFunctor >::importPGM(), DGtal::Viewer3D< Space, KSpace >::show(), and DGtal::trace.

92 {
95 
96  QApplication application(argc,argv);
97  Viewer3D<> viewer;
98  viewer.setWindowTitle("simpleViewer");
99  viewer.show();
100  trace.beginBlock("Testing Viewer with 3D Image View ");
101 
102  Point p1( 0, 0, 0 );
103  Point p2( 125, 188, 0 );
104  Point p3( 30, 30, 30 );
105 
106  std::string filename = testPath + "samples/church-small.pgm";
107  std::string filename3 = testPath + "samples/color64.ppm";
108 
109  imageNG image = DGtal::PGMReader<imageNG>::importPGM(filename);
110  imageNG image2 = DGtal::GenericReader<imageNG>::import(filename);
111  imageCol image3 = DGtal::GenericReader<imageCol>::import(filename3);
112  hueFct huefct;
113  functors::Identity defaultfunctor;
114 
115  viewer << DGtal::AddTextureImage2DWithFunctor<imageNG, hueFct , Z3i::Space, Z3i::KSpace>(image2, huefct, Viewer3D<>::RGBMode );
116  viewer << image;
117  viewer << DGtal::AddTextureImage2DWithFunctor<imageCol, functors::Identity, Z3i::Space, Z3i::KSpace>(image3, defaultfunctor, Viewer3D<>::RGBMode );
118  viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(0, Viewer3D<>::xDirection, 50, 50, 50 );
119  viewer << DGtal::UpdateImagePosition<Z3i::Space, Z3i::KSpace>(2, Viewer3D<>::yDirection, 0, 0, 0);
120 
121  viewer << SetMode3D( image.domain().className(), "BoundingBox" );
122  viewer << image.domain();
123  viewer << DGtal::Update2DDomainPosition<Z3i::Space, Z3i::KSpace>(0, Viewer3D<>::xDirection, 0, 0, 0);
124  for(unsigned int i= 0; i< 10; i++){
125  if(i%4==0){
126  viewer << SetMode3D( image.className(), "" );
127  }else if(i%4==1){
128  viewer << SetMode3D( image.className(), "BoundingBox" );
129  }else if(i%4==2){
130  viewer << SetMode3D( image.className(), "Grid" );
131  }else if(i%4==3){
132  viewer << SetMode3D( image.className(), "InterGrid" );
133  }
134  viewer << image;
135  viewer << DGtal::UpdateImageData<imageNG>(i+3, image, i*50, i*50, i*50);
136  }
137 
138 
139  viewer << p1 << p2 << p3;
140  viewer << Viewer3D<>::updateDisplay;
141 
142 
143  bool res = application.exec();
144  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
145  trace.endBlock();
146  return res ? 0 : 1;
147 
148 
149 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
double endBlock()
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)
std::ostream & emphase()
Image image(domain)
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.

◆ testViewer3D()

bool testViewer3D ( )

Example of a test. To be completed.

Definition at line 64 of file test3DImageView.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Color::getRGB(), DGtal::Trace::info(), and DGtal::trace.

65 {
66  unsigned int nbok = 0;
67  unsigned int nb = 0;
68  trace.beginBlock ( "Testing block ..." );
69  nbok += true ? 1 : 0;
70  nb++;
71  trace.info() << "(" << nbok << "/" << nb << ") "
72  << "true == true" << std::endl;
73  trace.endBlock();
74 
75  return nbok == nb;
76 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & info()