DGtal 1.3.0
Loading...
Searching...
No Matches
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"

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 172 of file testVolReader.cpp.

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

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

◆ testConsistence()

bool testConsistence ( )

Definition at line 136 of file testVolReader.cpp.

137{
138 trace.beginBlock ( "Testing VolWriter ..." );
139
140 typedef SpaceND<3> Space4Type;
141 typedef HyperRectDomain<Space4Type> TDomain;
142 typedef TDomain::Point Point;
143
144 //Default image selector = STLVector
146 TDomain domain(Point(-17,-14,-13), Point(5,7,11));
147 Image image(domain);
148 trace.info() << image.domain() <<endl;
149
150 VolWriter<Image>::exportVol("testConsistence.vol",image);
151
152 trace.endBlock();
153
154 trace.beginBlock ( "Testing VolReader ..." );
155
156 Image image2 = VolReader<Image>::importVol( "testConsistence.vol" );
157
158 trace.info() << image2.domain() <<endl;
159 trace.endBlock();
160
161 if( image.domain().lowerBound() != image2.domain().lowerBound()
162 || image.domain().upperBound() != image2.domain().upperBound() )
163 {
164 return false;
165 }
166 return true;
167}
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
const Domain & domain() const
Definition: Image.h:192
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
static bool exportVol(const std::string &filename, const Image &aImage, const bool compressed=true, const Functor &aFunctor=Functor())
MyPointD Point
Definition: testClone2.cpp:383
Domain domain

References DGtal::Trace::beginBlock(), DGtal::Image< TImageContainer >::domain(), domain, DGtal::Trace::endBlock(), DGtal::VolWriter< TImage, TFunctor >::exportVol(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

◆ testIOException()

bool testIOException ( )

Definition at line 100 of file testVolReader.cpp.

101{
102 unsigned int nbok = 0;
103 unsigned int nb = 0;
104
105 trace.beginBlock ( "Testing VolReader ..." );
106
107 typedef SpaceND<3> Space4Type;
108 typedef HyperRectDomain<Space4Type> TDomain;
109
110 //Default image selector = STLVector
112
113
114 std::string filename = testPath + "samples/null.vol";
115 try
116 {
117 Image image = VolReader<Image>::importVol( filename );
118 }
119 catch(exception& e)
120 {
121 trace.info() << "Exception catched. Message : "<< e.what()<<endl;
122 }
123
124
125
126 nbok += ( true ) ? 1 : 0;
127 nb++;
128
129 trace.info() << "(" << nbok << "/" << nb << ") "
130 << "true == true" << std::endl;
131 trace.endBlock();
132
133 return nbok == nb;
134}

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

◆ testVolReader()

bool testVolReader ( )

Example of a test. To be completed.

Definition at line 57 of file testVolReader.cpp.

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 unsigned int nbval=0;
77 for(Image::ConstIterator it=image.begin(), itend=image.end();
78 it != itend; ++it)
79 if ( (*it) != 0)
80 nbval++;
81
82 trace.info() << "Number of points with (val!=0) = "<<nbval<<endl;
83
84 nbok += ( nbval == 8043) ? 1 : 0;
85 nb++;
86
87 VolWriter<Image>::exportVol("catenoid-export.vol",image);
88
89 nbok += ( true ) ? 1 : 0;
90 nb++;
91
92 trace.info() << "(" << nbok << "/" << nb << ") "
93 << "true == true" << std::endl;
95
96 return nbok == nb;
97}

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::VolWriter< TImage, TFunctor >::exportVol(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().