25 #ifndef WMREADRAWDATA_H
26 #define WMREADRAWDATA_H
34 #include "core/dataHandler/WDataSetScalar.h"
35 #include "core/kernel/WModule.h"
36 #include "core/kernel/WModuleInputData.h"
37 #include "core/kernel/WModuleOutputData.h"
61 virtual const std::string
getName()
const;
75 virtual std::shared_ptr< WModule >
factory()
const;
114 std::shared_ptr< WDataSetScalar >
readData( std::string fileName );
123 template<
class T > std::shared_ptr< std::vector< T > >
readDataTyped( std::string fileName );
139 std::shared_ptr< WModuleOutputData< WDataSetScalar > >
m_output;
147 size_t numX =
m_X->get();
148 size_t numY =
m_Y->get();
149 size_t numZ =
m_Z->get();
150 size_t numVoxels = numX * numY * numZ;
151 std::shared_ptr< std::vector< T > > values;
152 values = std::shared_ptr< std::vector< T > >(
new std::vector< T >( numVoxels ) );
155 ifs.open( fileName.c_str(), std::ifstream::in|std::ios::binary );
156 if( !ifs || ifs.bad() )
159 throw std::runtime_error(
"Problem during reading file. Probably file not found." );
162 T *data =
new T[ numVoxels ];
163 ifs.read(
reinterpret_cast< char*
>( data ),
sizeof( T ) * numVoxels );
166 for(
size_t voxelId = 0; voxelId < numVoxels; ++voxelId )
168 (*values)[voxelId] = data[voxelId];
void addLogMessage(std::string message, std::string source="", LogLevel level=LL_DEBUG)
Appends a log message to the logging queue.
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
A module to read scalar data stored as array of raw data.
WPropSelection m_dataTypeSelection
Selection property for file types.
WPropDouble m_yScale
Scaling in Y direction.
WMReadRawData()
Constructor of module.
virtual const std::string getDescription() const
Gives back a description of this module.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
WPropDouble m_zScale
Scaling in Z direction.
WPropFilename m_dataFile
The data will be read from this file.
std::shared_ptr< std::vector< T > > readDataTyped(std::string fileName)
Helper function to read data of the given data type.
WPropInt m_Y
Samples in Y direction.
virtual void connectors()
Initialize the connectors this module is using.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
WPropDouble m_xScale
Scaling in X direction.
std::shared_ptr< WItemSelection > m_dataTypeSelectionsList
A list of file type selection types.
std::shared_ptr< WDataSetScalar > readData(std::string fileName)
Perform the reading from file an interpretation.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
std::shared_ptr< WDataSetScalar > m_dataSet
This data set is provided as output through the connector.
WPropInt m_Z
Samples in Z direction.
virtual void requirements()
Initialize requirements for this module.
virtual ~WMReadRawData()
Destructor of module.
WPropInt m_X
Samples in X direction.
std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output
Output connector provided by this module.
virtual const std::string getName() const
Gives back the name of this module.
virtual void properties()
Initialize the properties for this module.
virtual void moduleMain()
Entry point after loading the module.
Class representing a single module of OpenWalnut.