DGtal  1.2.0
testLongvol.cpp
Go to the documentation of this file.
1 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/images/ImageSelector.h"
35 #include "DGtal/images/ImageContainerBySTLVector.h"
36 #include "DGtal/io/writers/LongvolWriter.h"
37 #include "DGtal/io/readers/LongvolReader.h"
38 
40 
41 using namespace std;
42 using namespace DGtal;
43 
45 // Functions for testing class Longvol.
47 
52 {
53  unsigned int nbok = 0;
54  unsigned int nb = 0;
55 
56  trace.beginBlock ( "Testing Longvol writer ..." );
57 
58  Z3i::Point a(0,0,0);
59  Z3i::Point b(15,15,15);
60  Z3i::Point c(7,7,7);
61 
63  Image image(Z3i::Domain(a,b));
64 
65  image.setValue(c,45693);
66 
67  LongvolWriter<Image>::exportLongvol("export-longvol.longvol",image);
68 
69  Image image2 = LongvolReader<Image>::importLongvol("export-longvol.longvol");
70 
71  bool allFine= true;
72  Image::ConstIterator ito = image.begin();
73  for(Image::ConstIterator it = image2.begin(), itend=image2.end();
74  it != itend; ++it, ++ito)
75  if (((*it) != 0 ) || ((*ito) != 0))
76  allFine &= ( ((*it)*(*ito)) != 0);
77 
78  nbok += allFine ? 1 : 0;
79  nb++;
80  trace.info() << "(" << nbok << "/" << nb << ") "
81  << "true == true" << std::endl;
82  trace.endBlock();
83 
84  return nbok == nb;
85 }
86 
88 // Standard services - public :
89 
90 int main( int argc, char** argv )
91 {
92  trace.beginBlock ( "Testing class Longvol" );
93  trace.info() << "Args:";
94  for ( int i = 0; i < argc; ++i )
95  trace.info() << " " << argv[ i ];
96  trace.info() << endl;
97 
98  bool res = testLongvol(); // && ... other tests
99  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
100  trace.endBlock();
101  return res ? 0 : 1;
102 }
103 // //
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
Aim: implements methods to read a "Longvol" file format (with DGtal::uint64_t value type).
Definition: LongvolReader.h:92
Aim: Export a 3D Image using the Longvol formats (volumetric image with DGtal::uint64_t value type).
Definition: LongvolWriter.h:70
bool testLongvol()
Definition: testLongvol.cpp:51
int main(int argc, char **argv)
Definition: testLongvol.cpp:90
Image image(domain)
ImageContainerBySTLVector< Domain, Value > Image