31 #include "../../common/WIOTools.h"
32 #include "../exceptions/WDHIOFailure.h"
33 #include "WWriterMatrixSymVTK.h"
43 fstream out(
m_fname.c_str(), fstream::out | fstream::in | fstream::trunc );
44 if( !out || out.bad() )
48 out <<
"# vtk DataFile Version 3.0" << std::endl;
49 out <<
"WMatrixSym from OpenWalnut" << std::endl;
50 out <<
"BINARY" << std::endl;
52 out <<
"FIELD WMatrixSym 1" << std::endl;
53 unsigned int numDistances = table.size() + 1;
54 out <<
"ELEMENTS " << numDistances <<
" 1 float" << std::endl;
55 float *data =
new float[numDistances];
57 for(
size_t i = 0; i < table.size() ; ++i )
59 data[i] =
static_cast< float >( table[i] );
61 data[ numDistances - 1 ] =
static_cast< float >( dim );
63 switchByteOrderOfArray< float >( data, numDistances );
64 out.write(
reinterpret_cast< char*
>( data ),
sizeof(
float ) * numDistances );
Use this for IO error handling.
WWriterMatrixSymVTK(std::string fname, bool overwrite=false)
Creates a writer object for FiberVTK file writing.
void writeTable(const std::vector< double > &table, size_t dim) const
Actually perform writing to file.
Write some data to the given file.
std::string m_fname
Absolute path of the file to write to.