Commit 9bec9e51 authored by Alexander Wiebel's avatar Alexander Wiebel

[CLEAN] removed unused code ... solved a TODO

parent 7be92e22
......@@ -335,141 +335,6 @@ WPosition WDataSetFibers::getTangent( size_t fiber, size_t vertex ) const
return normalize( tangent );
}
/**
* Special helper functions for the saveSelected member function.
*/
namespace
{
/**
* converts an integer into a byte array and back
*/
union converterByteINT32
{
unsigned char b[4]; //!< the bytes
int i; //!< the int
};
/**
* converts a float into a byte array and back
*/
union converterByteFloat
{
unsigned char b[4]; //!< the bytes
float f; //!< the float
};
}
void WDataSetFibers::saveSelected( std::string filename, boost::shared_ptr< std::vector< bool > > active ) const
{
std::vector< float > pointsToSave;
std::vector< int > linesToSave;
std::vector< unsigned char > colorsToSave;
int pointIndex = 0;
int countLines = 0;
for( size_t l = 0; l < m_lineLengths->size(); ++l )
{
if( ( *active )[l] )
{
unsigned int pc = ( *m_lineStartIndexes )[l] * 3;
linesToSave.push_back( ( *m_lineLengths )[l] );
boost::shared_ptr< std::vector< float > > localColors =
boost::shared_static_cast< const ColorScheme >( ( *m_colors )[1] )->getColor();
for( size_t j = 0; j < ( *m_lineLengths )[l]; ++j )
{
// TODO(schurade): replace this with a permanent solution
pointsToSave.push_back( 160 - ( *m_vertices )[pc] );
colorsToSave.push_back( static_cast<unsigned char> ( ( *localColors )[pc] * 255 ) );
++pc;
pointsToSave.push_back( 200 - ( *m_vertices )[pc] );
colorsToSave.push_back( static_cast<unsigned char> ( ( *localColors )[pc] * 255 ) );
++pc;
pointsToSave.push_back( ( *m_vertices )[pc] );
colorsToSave.push_back( static_cast<unsigned char> ( ( *localColors )[pc] * 255 ) );
++pc;
linesToSave.push_back( pointIndex );
++pointIndex;
}
++countLines;
}
}
converterByteINT32 c;
converterByteFloat f;
std::vector< char > vBuffer;
std::string header1 = "# vtk DataFile Version 3.0\nvtk output\nBINARY\nDATASET POLYDATA\nPOINTS ";
header1 += boost::lexical_cast<std::string>( pointsToSave.size() / 3 );
header1 += " float\n";
for( unsigned int i = 0; i < header1.size(); ++i )
{
vBuffer.push_back( header1[i] );
}
for( unsigned int i = 0; i < pointsToSave.size(); ++i )
{
f.f = pointsToSave[i];
vBuffer.push_back( f.b[3] );
vBuffer.push_back( f.b[2] );
vBuffer.push_back( f.b[1] );
vBuffer.push_back( f.b[0] );
}
vBuffer.push_back( '\n' );
std::string header2 = "LINES " + boost::lexical_cast<std::string>( countLines ) + " " +
boost::lexical_cast<std::string>( linesToSave.size() ) + "\n";
for( unsigned int i = 0; i < header2.size(); ++i )
{
vBuffer.push_back( header2[i] );
}
for( unsigned int i = 0; i < linesToSave.size(); ++i )
{
c.i = linesToSave[i];
vBuffer.push_back( c.b[3] );
vBuffer.push_back( c.b[2] );
vBuffer.push_back( c.b[1] );
vBuffer.push_back( c.b[0] );
}
vBuffer.push_back( '\n' );
std::string header3 = "POINT_DATA ";
header3 += boost::lexical_cast<std::string>( pointsToSave.size() / 3 );
header3 += " float\n";
header3 += "COLOR_SCALARS scalars 3\n";
for( unsigned int i = 0; i < header3.size(); ++i )
{
vBuffer.push_back( header3[i] );
}
for( unsigned int i = 0; i < colorsToSave.size(); ++i )
{
vBuffer.push_back( colorsToSave[i] );
}
vBuffer.push_back( '\n' );
boost::filesystem::path p( filename );
boost::filesystem::ofstream ofs( p, std::ios_base::binary );
for( unsigned int i = 0; i < vBuffer.size(); ++i )
{
ofs << vBuffer[i];
}
}
WBoundingBox WDataSetFibers::getBoundingBox() const
{
return m_bb;
......
......@@ -347,14 +347,6 @@ public:
*/
WPosition getTangent( size_t fiber, size_t vertex ) const;
/**
* saves the selected fiber bundles to a file
*
*\param filename
* \param active bitfield of the fiber selection
*/
void saveSelected( std::string filename, boost::shared_ptr< std::vector< bool > > active ) const;
/**
* Get the bounding box.
* \return The bounding box of all lines.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment