DGtal  0.9.3
Functions
testVolReader.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/io/colormaps/ColorBrightnessColorMap.h"
#include "DGtal/io/writers/VolWriter.h"
#include "ConfigTest.h"
Include dependency graph for testVolReader.cpp:

Go to the source code of this file.

Functions

bool testVolReader ()
 
bool testIOException ()
 
bool testConsistence ()
 
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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2010/07/25

Functions for testing class VolReader.

This file is part of the DGtal library.

Definition in file testVolReader.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 175 of file testVolReader.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testConsistence(), testIOException(), testVolReader(), and DGtal::trace.

176 {
177  int aaaaa = 21/2;
178  std::cout << aaaaa << std::endl;
179 
180  trace.beginBlock ( "Testing class VolReader" );
181  trace.info() << "Args:";
182  for ( int i = 0; i < argc; ++i )
183  trace.info() << " " << argv[ i ];
184  trace.info() << endl;
185 
186  bool res = testVolReader() && testIOException() && testConsistence(); // && ... other tests
187  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
188  trace.endBlock();
189  return res ? 0 : 1;
190 
191 }
void beginBlock(const std::string &keyword="")
bool testVolReader()
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & emphase()
bool testIOException()
std::ostream & info()
bool testConsistence()

◆ testConsistence()

bool testConsistence ( )

Definition at line 139 of file testVolReader.cpp.

References DGtal::Trace::beginBlock(), domain(), DGtal::Image< TImageContainer >::domain(), DGtal::Trace::endBlock(), image(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

140 {
141  trace.beginBlock ( "Testing VolWriter ..." );
142 
143  typedef SpaceND<3> Space4Type;
144  typedef HyperRectDomain<Space4Type> TDomain;
145  typedef TDomain::Point Point;
146 
147  //Default image selector = STLVector
149  TDomain domain(Point(-17,-14,-13), Point(5,7,11));
150  Image image(domain);
151  trace.info() << image.domain() <<endl;
152 
153  VolWriter<Image>::exportVol("testConsistence.vol",image);
154 
155  trace.endBlock();
156 
157  trace.beginBlock ( "Testing VolReader ..." );
158 
159  Image image2 = VolReader<Image>::importVol( "testConsistence.vol" );
160 
161  trace.info() << image2.domain() <<endl;
162  trace.endBlock();
163 
164  if( image.domain().lowerBound() != image2.domain().lowerBound()
165  || image.domain().upperBound() != image2.domain().upperBound() )
166  {
167  return false;
168  }
169  return true;
170 }
void beginBlock(const std::string &keyword="")
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:68
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
double endBlock()
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image
const Domain & domain() const
Definition: Image.h:192
Image image(domain)

◆ testIOException()

bool testIOException ( )

Definition at line 103 of file testVolReader.cpp.

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

Referenced by main().

104 {
105  unsigned int nbok = 0;
106  unsigned int nb = 0;
107 
108  trace.beginBlock ( "Testing VolReader ..." );
109 
110  typedef SpaceND<3> Space4Type;
111  typedef HyperRectDomain<Space4Type> TDomain;
112 
113  //Default image selector = STLVector
115 
116 
117  std::string filename = testPath + "samples/null.vol";
118  try
119  {
120  Image image = VolReader<Image>::importVol( filename );
121  }
122  catch(exception& e)
123  {
124  trace.info() << "Exception catched. Message : "<< e.what()<<endl;
125  }
126 
127 
128 
129  nbok += ( true ) ? 1 : 0;
130  nb++;
131 
132  trace.info() << "(" << nbok << "/" << nb << ") "
133  << "true == true" << std::endl;
134  trace.endBlock();
135 
136  return nbok == nb;
137 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
double endBlock()
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image

◆ testVolReader()

bool testVolReader ( )

Example of a test. To be completed.

Definition at line 57 of file testVolReader.cpp.

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

Referenced by main().

58 {
59  unsigned int nbok = 0;
60  unsigned int nb = 0;
61 
62  trace.beginBlock ( "Testing VolReader ..." );
63 
64  typedef SpaceND<3> Space4Type;
65  typedef HyperRectDomain<Space4Type> TDomain;
66 
67  //Default image selector = STLVector
69 
70 
71  std::string filename = testPath + "samples/cat10.vol";
72  Image image = VolReader<Image>::importVol( filename );
73 
74  trace.info() << image <<endl;
75 
76  nbok += true ? 1 : 0;
77  nb++;
78 
79  unsigned int nbval=0;
80  for(Image::ConstIterator it=image.begin(), itend=image.end();
81  it != itend; ++it)
82  if ( (*it) != 0)
83  nbval++;
84 
85  trace.info() << "Number of points with (val!=0) = "<<nbval<<endl;
86 
87  nbok += ( nbval == 8043) ? 1 : 0;
88  nb++;
89 
90  VolWriter<Image>::exportVol("catenoid-export.vol",image);
91 
92  nbok += ( true ) ? 1 : 0;
93  nb++;
94 
95  trace.info() << "(" << nbok << "/" << nb << ") "
96  << "true == true" << std::endl;
97  trace.endBlock();
98 
99  return nbok == nb;
100 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:68
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
double endBlock()
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image