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 | Static Private Member Functions
DGtal::LongvolWriter< TImage, TFunctor > Struct Template Reference

#include <LongvolWriter.h>

Public Types

typedef TImage Image
typedef TImage::Value Value
typedef TFunctor Functor
typedef DGtal::uint64_t ValueLongvol

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CUnaryFunctor< TFunctor, Value, ValueLongvol >))

Static Public Member Functions

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

Static Private Member Functions

template<typename Word >
static ostream & write_word (ostream &outs, Word value)

Detailed Description

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

Aim: Export a 3D Image using the Longvol formats (volumetric image with DGtal::uint64_t value type).

Description of template struct 'LongvolWriter'

A functor can be specified to convert image values to LongVol values (DGtal::uint64_t).

Template Parameters:
TImagethe Image type.
TFunctorthe type of functor used in the export.
See also:
testLongvol.cpp

Definition at line 69 of file LongvolWriter.h.


Member Typedef Documentation

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

Definition at line 75 of file LongvolWriter.h.

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

Definition at line 73 of file LongvolWriter.h.

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

Definition at line 74 of file LongvolWriter.h.

template<typename TImage , typename TFunctor = DefaultFunctor>
typedef DGtal::uint64_t DGtal::LongvolWriter< TImage, TFunctor >::ValueLongvol

Definition at line 76 of file LongvolWriter.h.


Member Function Documentation

template<typename TImage , typename TFunctor = DefaultFunctor>
DGtal::LongvolWriter< TImage, TFunctor >::BOOST_CONCEPT_ASSERT ( (CUnaryFunctor< TFunctor, Value, ValueLongvol >)  )
template<typename TImage , typename TFunctor = DefaultFunctor>
bool DGtal::LongvolWriter< I, C >::exportLongvol ( const std::string &  filename,
const Image aImage,
const Functor aFunctor = Functor() 
) throw (DGtal::IOException)
static

Export an Image with the Longvol format. A DGtal::IOException is thrown in case of io problems.

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 LongvolWriter.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());
//Longvol format
out << "X: "<< ext[0]<<endl;
out << "Y: "<< ext[1]<<endl;
out << "Z: "<< ext[2]<<endl;
out << "Lvoxel-Size: 4"<<endl; //not used in liblongvol but required
out << "Alpha-Color: 0"<<endl;
out << "Lvoxel-Endian: 0"<<endl;//not used in liblongvol but required
out << "Int-Endian: 0123"<<endl;
out << "Version: 2"<<endl;
out << "."<<endl;
out.close();
out.open(filename.c_str(),ios_base::binary | ios_base::app);
//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) );
write_word(out,aFunctor(val));
}
out.close();
}
catch( ... )
{
std::cout << "LongVol writer IO error on export " << filename << endl;
throw dgtalio;
}
return true;
}
template<typename TImage , typename TFunctor = DefaultFunctor>
template<typename Word >
static ostream& DGtal::LongvolWriter< TImage, TFunctor >::write_word ( ostream &  outs,
Word  value 
)
inlinestaticprivate

Generic write word (binary mode) in little-endian.

Parameters:
outsoutput stream.
valuevalue to write.
Returns:
modified stream.

Definition at line 106 of file LongvolWriter.h.

{
for (unsigned size = sizeof( Word ); size; --size, value >>= 8)
outs.put( static_cast <char> (value & 0xFF) );
return outs;
}

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