DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
VolReader.h
1
16
17
#pragma once
18
30
31
#if defined(VolReader_RECURSES)
32
#error Recursive header files inclusion detected in VolReader.h
33
#else
// defined(VolReader_RECURSES)
35
#define VolReader_RECURSES
36
37
#if !defined VolReader_h
39
#define VolReader_h
40
42
// Inclusions
43
#include <iostream>
44
#include <sstream>
45
#include <string>
46
#include <cstdio>
47
#include "DGtal/base/Common.h"
48
#include "DGtal/base/CUnaryFunctor.h"
50
51
namespace
DGtal
52
{
53
55
// template class VolReader
87
template
<
typename
TImageContainer
,
88
typename
TFunctor =
functors::Cast< typename TImageContainer::Value >
>
89
struct
VolReader
90
{
91
// ----------------------- Standard services ------------------------------
92
93
typedef
TImageContainer
ImageContainer
;
94
typedef
typename
TImageContainer::Value
Value
;
95
typedef
TFunctor
Functor
;
96
97
BOOST_CONCEPT_ASSERT
((
concepts::CUnaryFunctor<TFunctor, unsigned char, Value >
)) ;
98
99
BOOST_STATIC_ASSERT
(ImageContainer::Domain::dimension == 3);
100
101
114
static
ImageContainer
importVol
(
const
std::string & filename,
115
const
Functor
& aFunctor =
Functor
());
116
117
private
:
118
119
typedef
unsigned
char
voxel
;
125
/* In recent C++, we should use a std::map, but we prefer (badly) code it
126
by hand for compatibility with old compilers.
127
At this time, there is a limit of 30 fields in header :-} */
128
struct
HeaderField
{
130
HeaderField
(
const
char
*t,
const
char
*v ) :
131
type
( strdup(t) ),
value
( strdup(v) ) {}
132
~HeaderField
() {
133
free(
type
);
134
free(
value
);
135
}
136
137
HeaderField
(
const
HeaderField
&h ) :
138
type
( strdup(h.
type
) ),
value
( strdup(h.
value
) ) {};
139
140
HeaderField
() :
type
(NULL),
value
(NULL) {};
142
const
HeaderField
&
operator =
(
const
HeaderField
&h) {
143
free(
type
);
144
free(
value
);
145
if
(h.
type
!= NULL) {
146
type
= strdup( h.
type
);
147
value
= strdup( h.
value
);
148
}
149
return
*
this
;
150
}
151
152
char
*
type
;
154
char
*
value
;
155
};
156
157
159
static
const
char
*
getHeaderValue
(
const
char
*type,
const
HeaderField
* header );
160
162
static
int
getHeaderValueAsInt
(
const
char
*type,
int
*dest ,
const
HeaderField
* header);
163
165
static
int
getHeaderField
(
const
char
*type,
const
HeaderField
* header ) ;
166
168
static
const
char
*
requiredHeaders
[];
169
170
};
// end of class VolReader
171
172
173
}
// namespace DGtal
174
175
177
// Includes inline functions.
178
#include "DGtal/io/readers/VolReader.ih"
179
180
// //
182
183
#endif
// !defined VolReader_h
184
185
#undef VolReader_RECURSES
186
#endif
// else defined(VolReader_RECURSES)
DGtal::ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > >::Value
std::unordered_set< Z2i::Point > Value
Definition
ImageContainerBySTLVector.h:153
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::VolReader::HeaderField
Definition
VolReader.h:128
DGtal::VolReader::HeaderField::~HeaderField
~HeaderField()
Definition
VolReader.h:132
DGtal::VolReader::HeaderField::operator=
const HeaderField & operator=(const HeaderField &h)
Assignment operator.
Definition
VolReader.h:142
DGtal::VolReader::HeaderField::HeaderField
HeaderField(const HeaderField &h)
Copy constructor.
Definition
VolReader.h:137
DGtal::VolReader::HeaderField::type
char * type
Type of field (e.g. Voxel-Size).
Definition
VolReader.h:152
DGtal::VolReader::HeaderField::HeaderField
HeaderField()
Default constructor.
Definition
VolReader.h:140
DGtal::VolReader::HeaderField::HeaderField
HeaderField(const char *t, const char *v)
Constructor. The string are copied.
Definition
VolReader.h:130
DGtal::VolReader::HeaderField::value
char * value
Value of field (e.g. 2).
Definition
VolReader.h:154
DGtal::VolReader
Aim: implements methods to read a "Vol" file format.
Definition
VolReader.h:90
DGtal::VolReader::Functor
TFunctor Functor
Definition
VolReader.h:95
DGtal::VolReader::Value
TImageContainer::Value Value
Definition
VolReader.h:94
DGtal::VolReader::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CUnaryFunctor< TFunctor, unsigned char, Value >))
DGtal::VolReader::getHeaderValueAsInt
static int getHeaderValueAsInt(const char *type, int *dest, const HeaderField *header)
Returns non-zero if failure.
DGtal::VolReader::ImageContainer
TImageContainer ImageContainer
Definition
VolReader.h:93
DGtal::VolReader::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT(ImageContainer::Domain::dimension==3)
DGtal::VolReader::requiredHeaders
static const char * requiredHeaders[]
Global list of required fields in a .vol file.
Definition
VolReader.h:168
DGtal::VolReader::getHeaderValue
static const char * getHeaderValue(const char *type, const HeaderField *header)
Returns NULL if this field is not found.
DGtal::VolReader::importVol
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
DGtal::VolReader::voxel
unsigned char voxel
Definition
VolReader.h:119
DGtal::VolReader::getHeaderField
static int getHeaderField(const char *type, const HeaderField *header)
Internal method which returns the index of a field or -1 if not found.
DGtal::concepts::CUnaryFunctor
Aim: Defines a unary functor, which associates arguments to results.
Definition
CUnaryFunctor.h:90
DGtal::functors::Cast
Aim: Define a simple functor using the static cast operator.
Definition
BasicFunctors.h:394
TImageContainer
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer
Definition
testVoronoiMapComplete.cpp:48
src
DGtal
io
readers
VolReader.h
Generated on
for DGtal by
1.18.0