Skip to content

Commit 9e3c8da

Browse files
author
dcoeurjo
committed
New ConfigTest and samples added.
VolReader (ok) Raw8Reader (ok, todo: complete the test) Todo: check io errors more carefully git-svn-id: https://svn.liris.cnrs.fr/dgtal/trunk@395 5422497e-619f-4381-bc00-4cdae604c9f6
1 parent 21538a7 commit 9e3c8da

File tree

7 files changed

+154
-0
lines changed

7 files changed

+154
-0
lines changed

doc/images/logo_Board.png

22.9 KB
Loading

doc/images/simpleSet-color.png

866 Bytes
Loading

src/DGtal/base/Common.ih

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @File Common.ih
3+
* @author Jacques-Olivier Lachaud (\c [email protected] )
4+
* Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
5+
* @author David Coeurjolly (\c [email protected] )
6+
* Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
7+
*
8+
*
9+
* @date 2009/12/10
10+
*
11+
* Implementation of inline methods defined in Common.h
12+
*
13+
* This file is part of the DGtal library.
14+
*/
15+
16+
///////////////////////////////////////////////////////////////////////////////
17+
// IMPLEMENTATION of inline methods.
18+
///////////////////////////////////////////////////////////////////////////////
19+
20+
//////////////////////////////////////////////////////////////////////////////
21+
#include <cstdlib>
22+
//////////////////////////////////////////////////////////////////////////////
23+
24+
25+
///////////////////////////////////////////////////////////////////////////////
26+
// Implementation of inline functions and external operators //
27+
28+
/**
29+
* Overloads 'operator<<' for displaying objects of class 'Common'.
30+
* @param out the output stream where the object is written.
31+
* @param object the object of class 'Common' to write.
32+
* @return the output stream after the writing.
33+
*/
34+
INLINE
35+
std::ostream&
36+
DGtal::operator<<( std::ostream & out,
37+
const Common & object )
38+
39+
// //
40+
///////////////////////////////////////////////////////////////////////////////
41+
42+

tests/ConfigTest.h.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @file ConfigTest.h
3+
* @author David COEURJOLLY <David Coeurjolly <[email protected]>>
4+
* @date 29 Jul. 2010
5+
* @brief Configuration header for test files.
6+
*
7+
**/
8+
9+
#include <string>
10+
11+
///Path to the DGtal test suite.
12+
const std::string testPath= "@PROJECT_SOURCE_DIR@/tests/";
13+

tests/io/testRawReader.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* @file testRawReader.cpp
3+
* @ingroup Tests
4+
* @author David Coeurjolly (\c [email protected] )
5+
* Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
6+
*
7+
* @date 2010/07/29
8+
*
9+
* Functions for testing class RawReader.
10+
*
11+
* This file is part of the DGtal library.
12+
*/
13+
14+
///////////////////////////////////////////////////////////////////////////////
15+
#include <iostream>
16+
#include "DGtal/base/Common.h"
17+
18+
#include "DGtal/kernel/SpaceND.h"
19+
#include "DGtal/kernel/domains/HyperRectDomain.h"
20+
#include "DGtal/kernel/images/ImageSelector.h"
21+
#include "DGtal/io/readers/RawReader.h"
22+
#include "DGtal/io/colormaps/HueShadeColorMap.h"
23+
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
24+
#include "DGtal/io/colormaps/GradientColorMap.h"
25+
#include "DGtal/io/colormaps/ColorBrightnessColorMap.h"
26+
27+
#include "DGtal/io/writers/PNMWriter.h"
28+
29+
#include "ConfigTest.h"
30+
31+
32+
///////////////////////////////////////////////////////////////////////////////
33+
34+
using namespace std;
35+
using namespace DGtal;
36+
37+
///////////////////////////////////////////////////////////////////////////////
38+
// Functions for testing class RawReader.
39+
///////////////////////////////////////////////////////////////////////////////
40+
/**
41+
* Example of a test. To be completed.
42+
*
43+
*/
44+
bool testRawReader()
45+
{
46+
unsigned int nbok = 0;
47+
unsigned int nb = 0;
48+
49+
trace.beginBlock ( "Testing Raw reader ..." );
50+
51+
typedef SpaceND<int,2> Space2Type;
52+
typedef HyperRectDomain<Space2Type> TDomain;
53+
typedef TDomain::Vector Vector;
54+
55+
//Default image selector = STLVector
56+
typedef ImageSelector<TDomain, unsigned char>::Type Image;
57+
58+
std::string filename = testPath + "samples/raw2D-64x64.raw";
59+
60+
Vector ext(16,16);
61+
62+
Image image = RawReader<Image>::importRaw8( filename , ext);
63+
64+
///FIXME: check io errors
65+
trace.info() << image <<endl;
66+
67+
//export
68+
typedef GrayscaleColorMap<unsigned char> Gray;
69+
PNMWriter<Image,Gray>::exportPGM("export-raw-reader.pgm",image,0,255);
70+
71+
72+
nbok += true ? 1 : 0;
73+
nb++;
74+
trace.info() << "(" << nbok << "/" << nb << ") "
75+
<< "true == true" << std::endl;
76+
trace.endBlock();
77+
78+
return nbok == nb;
79+
}
80+
81+
///////////////////////////////////////////////////////////////////////////////
82+
// Standard services - public :
83+
84+
int main( int argc, char** argv )
85+
{
86+
trace.beginBlock ( "Testing class RawReader" );
87+
trace.info() << "Args:";
88+
for ( int i = 0; i < argc; ++i )
89+
trace.info() << " " << argv[ i ];
90+
trace.info() << endl;
91+
92+
bool res = testRawReader(); // && ... other tests
93+
trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
94+
trace.endBlock();
95+
return res ? 0 : 1;
96+
}
97+
// //
98+
///////////////////////////////////////////////////////////////////////////////

tests/samples/cat10.vol

62.6 KB
Binary file not shown.

tests/samples/raw2D-64x64.raw

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
eimptw{����������������������������}yvrnkggknrvy}����������������������������{wtpmieimptw{����������������������������}yvrnkggknrvy}����������������������������{wtpmieimptw{����������������������������}yvrnkggknrvy}����������������������������{wtpmie

0 commit comments

Comments
 (0)