DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions
DGtal::VolWriter< TImage, TFunctor > Struct Template Reference

#include <VolWriter.h>

Public Types

typedef TImage Image
typedef TImage::Value Value
typedef TFunctor Functor

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CUnaryFunctor< TFunctor, Value, unsigned char >))
 BOOST_STATIC_ASSERT (TImage::Domain::dimension==3)

Static Public Member Functions

static bool exportVol (const std::string &filename, const Image &aImage, const Functor &aFunctor=Functor()) throw (DGtal::IOException)

Detailed Description

template<typename TImage, typename TFunctor = DefaultFunctor>
struct DGtal::VolWriter< TImage, TFunctor >

Aim: Export a 3D Image using the Vol formats.

Description of template struct 'VolWriter'

A functor can be specified to convert image values to Vol values (unsigned char).

Template Parameters:
TImagethe Image type.
TFunctorthe type of functor used in the export.

Definition at line 68 of file VolWriter.h.


Member Typedef Documentation

template<typename TImage , typename TFunctor = DefaultFunctor>
typedef TFunctor DGtal::VolWriter< TImage, TFunctor >::Functor

Definition at line 73 of file VolWriter.h.

template<typename TImage , typename TFunctor = DefaultFunctor>
typedef TImage DGtal::VolWriter< TImage, TFunctor >::Image

Definition at line 71 of file VolWriter.h.

template<typename TImage , typename TFunctor = DefaultFunctor>
typedef TImage::Value DGtal::VolWriter< TImage, TFunctor >::Value

Definition at line 72 of file VolWriter.h.


Member Function Documentation

template<typename TImage , typename TFunctor = DefaultFunctor>
DGtal::VolWriter< TImage, TFunctor >::BOOST_CONCEPT_ASSERT ( (CUnaryFunctor< TFunctor, Value, unsigned char >)  )
template<typename TImage , typename TFunctor = DefaultFunctor>
DGtal::VolWriter< TImage, TFunctor >::BOOST_STATIC_ASSERT ( TImage::Domain::dimension  = =3)
template<typename TImage , typename TFunctor = DefaultFunctor>
bool DGtal::VolWriter< I, F >::exportVol ( const std::string &  filename,
const Image aImage,
const Functor aFunctor = Functor() 
) throw (DGtal::IOException)
static

Export an Image with the Vol format.

Parameters:
filenamename of the output file
aImagethe image to export
aFunctorfunctor used to cast image values
Returns:
true if no errors occur.

Definition at line 44 of file VolWriter.ih.

{
ofstream out;
typename I::Domain::Vector ext = aImage.extent();
typename I::Domain domain = aImage.domain();
typename I::Value val;
try
{
out.open(filename.c_str());
//Vol format
out << "X: "<< ext[0]<<endl;
out << "Y: "<< ext[1]<<endl;
out << "Z: "<< ext[2]<<endl;
out << "Voxel-Size: 1"<<endl;
out << "Alpha-Color: 0"<<endl;
out << "Voxel-Endian: 0"<<endl;
out << "Int-Endian: 0123"<<endl;
out << "Version: 2"<<endl;
out << "."<<endl;
//We scan the domain instead of the image because we cannot
//trust the image container Iterator
for(typename I::Domain::ConstIterator it = domain.begin(), itend=domain.end();
it!=itend;
++it)
{
val = aImage( (*it) );
out.put(aFunctor(val));
}
out.close();
}
catch( ... )
{
std::cout << "Vol writer IO error on export " << filename << endl;
throw dgtalio;
}
return true;
}

The documentation for this struct was generated from the following files: