Commit 5cd95e0c authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD #180] can read vectors from file as colors for surface now

parent f28a77ac
......@@ -119,6 +119,12 @@ void WMReadMesh::properties()
m_propDatasetSizeZ->setHidden( true );
m_propVectorAsColor = m_properties->addProperty( "Read vectors as color",
"If the module can load vectors from the file "
"it will interpret them as colors of the surface.",
true );
m_propVectorAsColor->setHidden( false );
m_readTriggerProp = m_properties->addProperty( "Do read", "Press!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
WPropertyHelper::PC_PATHEXISTS::addTo( m_meshFile );
......@@ -429,6 +435,32 @@ boost::shared_ptr< WTriangleMesh > WMReadMesh::readMesh()
}
}
char* marker = new char[30];
size_t nbVectors;
ifs >> marker >> nbVectors;
if( std::string( marker ) == "POINT_DATA" && nbVectors == numPoints )
{
// ----- Vector as color ---------
char* vectorMarker = new char[30];
char* vectorName = new char[30];
char* vectorDataType = new char[30];
ifs >> vectorMarker >> vectorName >> vectorDataType;
if( std::string( vectorMarker ) == "VECTORS"
&& m_propVectorAsColor->get()
&& std::string( vectorDataType ) == "float" )
{
WColor vectorComp;
for( unsigned int i = 0; i < nbVectors; ++i )
{
std::string line;
std::getline( ifs, line, '\n' );
ifs >> vectorComp[0] >> vectorComp[1] >> vectorComp[2];
triMesh->setVertexColor( i, vectorComp );
}
}
}
ifs.close();
progress->finish();
......@@ -815,6 +847,8 @@ std::string WMReadMesh::getLine( boost::shared_ptr< std::ifstream > ifs, const s
void WMReadMesh::meshTypeSelected()
{
m_propVectorAsColor->setHidden( m_fileTypeSelection->get( true ).getItemIndexOfSelected( 0 ) != 0 );
if( m_fileTypeSelection->get().getItemIndexOfSelected( 0 ) == 2 ||
m_fileTypeSelection->get().getItemIndexOfSelected( 0 ) == 3 ||
m_fileTypeSelection->get().getItemIndexOfSelected( 0 ) == 4 )
......
......@@ -176,6 +176,7 @@ private:
WPropInt m_propDatasetSizeX; //!< Size of the dataset (X)
WPropInt m_propDatasetSizeY; //!< Size of the dataset (Y)
WPropInt m_propDatasetSizeZ; //!< Size of the dataset (Z)
WPropBool m_propVectorAsColor; //!< Use vectors from file as color of surface.
WPropInt m_nbTriangles; //!< Info-property showing the number of triangles in the mesh.
WPropInt m_nbVertices; //!< Info-property showing the number of vertices in the mesh.
......
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