Commit 4551755f authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD #438] WMReadSphericalHarmonics can now read data set as spherical

harmonics if they are double
parent 0d66cff3
......@@ -28,7 +28,7 @@
#include <stdint.h>
/**
* Dataset types and number values taken from the nifti1.h, at this point it's unknown if it makes sense
* Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense
* to keep the bit coding, but it doesn't hurt either
* \ingroup dataHandler
*/
......@@ -173,6 +173,17 @@ enum qformOrientation
Inferior_to_Superior
};
/**
* Data set types. Not complete! Only those used for distinctions so far.
* \ingroup dataHandler
*/
enum DataSetType
{
W_DATASET_NONE = 0,
W_DATASET_SINGLE = 1,
W_DATASET_SPHERICALHARMONICS = 2
};
/**
* \defgroup dataHandler Data Handler
*
......
......@@ -83,7 +83,7 @@ wmath::WMatrix< double > WReaderNIfTI::convertMatrix( const mat44& in )
return out;
}
boost::shared_ptr< WDataSet > WReaderNIfTI::load()
boost::shared_ptr< WDataSet > WReaderNIfTI::load( DataSetType dataSetType )
{
nifti_image* header = nifti_image_read( m_fname.c_str(), 0 );
......@@ -186,7 +186,7 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load()
// }
// else
if ( description.compare( "WDataSetSphericalHarmonics" ) == 0 )
if ( description.compare( "WDataSetSphericalHarmonics" ) == 0 || dataSetType == W_DATASET_SPHERICALHARMONICS )
{
wlog::debug( "WReaderNIfTI" ) << "Load as spherical harmonics" << std::endl;
newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSphericalHarmonics( newValueSet, newGrid ) );
......
......@@ -60,7 +60,7 @@ public:
*
* \return the dataset loaded.
*/
virtual boost::shared_ptr< WDataSet > load();
virtual boost::shared_ptr< WDataSet > load( DataSetType dataSetType = W_DATASET_NONE );
protected:
private:
......
......@@ -24,8 +24,10 @@
#include <string>
#include "../../kernel/WKernel.h"
#include "../../dataHandler/WDataHandlerEnums.h"
#include "../../dataHandler/io/WReaderNIfTI.h"
#include "../../graphicsEngine/WGERequirement.h"
#include "../../kernel/WKernel.h"
#include "WMReadSphericalHarmonics.xpm"
#include "WMReadSphericalHarmonics.h"
......@@ -74,7 +76,10 @@ void WMReadSphericalHarmonics::connectors()
void WMReadSphericalHarmonics::properties()
{
// Put the code for your properties here. See "src/modules/template/" for an extensively documented example.
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_dataFile = m_properties->addProperty( "NIfTI file", "", WPathHelper::getAppPath() );
m_readTriggerProp = m_properties->addProperty( "Do read", "Press!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
WPropertyHelper::PC_PATHEXISTS::addTo( m_dataFile );
WModule::properties();
}
......@@ -86,6 +91,30 @@ void WMReadSphericalHarmonics::requirements()
void WMReadSphericalHarmonics::moduleMain()
{
// Put the code for your module's main functionality here.
// See "src/modules/template/" for an extensively documented example.
m_moduleState.add( m_propCondition );
ready();
while( !m_shutdownFlag() )
{
m_moduleState.wait();
if( m_shutdownFlag() )
{
break;
}
std::string fileName = m_dataFile->get().string();
WReaderNIfTI niiLoader( fileName );
boost::shared_ptr< WDataSet > data;
data = niiLoader.load( W_DATASET_SPHERICALHARMONICS );
if( data )
{
m_data = boost::shared_dynamic_cast< WDataSetSphericalHarmonics >( data );
if( m_data )
{
m_runtimeName->set( string_utils::tokenize( fileName, "/" ).back() );
m_output->updateData( m_data );
}
}
m_readTriggerProp->set( WPVBaseTypes::PV_TRIGGER_READY, false );
}
}
......@@ -102,10 +102,12 @@ protected:
private:
/**
* The only output of this data module.
*/
boost::shared_ptr< WModuleOutputData< WDataSetSphericalHarmonics > > m_output;
boost::shared_ptr< WModuleOutputData< WDataSetSphericalHarmonics > > m_output; //!< Ouput connector provided by this module.
boost::shared_ptr< WDataSetSphericalHarmonics > m_data; //!< This triangle mesh is provided as output through the connector.
boost::shared_ptr< WCondition > m_propCondition; //!< A condition used to notify about changes in several properties.
WPropTrigger m_readTriggerProp; //!< This property triggers the actual reading,
WPropFilename m_dataFile; //!< The data will be read from this file.
};
#endif // WMREADSPHERICALHARMONICS_H
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