29 #include "WMReadRawData.h"
30 #include "WMReadRawData.xpm"
31 #include "core/common/WPathHelper.h"
32 #include "core/kernel/WKernel.h"
54 return WMReadRawData_xpm;
58 return "Read Raw Data";
63 return "Read scalar data defined on uniform lattices"
64 "in raw format, i.e., plain three-dimensional arrays of data.";
69 m_output = std::shared_ptr< WModuleOutputData< WDataSetScalar > >(
138 std::shared_ptr< WProgress > progress(
new WProgress(
"Read Raw Data", 2 ) );
151 std::shared_ptr< WValueSetBase > newValueSet;
152 if( dataTypeName ==
"UINT8" )
154 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< uint8_t >( 0, 1, readDataTyped< uint8_t >( fileName ), W_DT_UINT8 ) );
156 else if( dataTypeName ==
"UINT16" )
158 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< uint16_t >( 0, 1, readDataTyped< uint16_t >( fileName ), W_DT_UINT16 ) );
160 else if( dataTypeName ==
"UINT32" )
162 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< uint32_t >( 0, 1, readDataTyped< uint32_t >( fileName ), W_DT_UINT32 ) );
164 else if( dataTypeName ==
"UINT64" )
166 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< uint64_t >( 0, 1, readDataTyped< uint64_t >( fileName ), W_DT_UINT64 ) );
168 else if( dataTypeName ==
"INT8" )
170 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< int8_t >( 0, 1, readDataTyped< int8_t >( fileName ), W_DT_INT8 ) );
172 else if( dataTypeName ==
"INT16" )
174 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< int16_t >( 0, 1, readDataTyped< int16_t >( fileName ), W_DT_INT16 ) );
176 else if( dataTypeName ==
"INT32" )
178 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< int32_t >( 0, 1, readDataTyped< int32_t >( fileName ), W_DT_SIGNED_INT ) );
180 else if( dataTypeName ==
"INT64" )
182 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< int64_t >( 0, 1, readDataTyped< int64_t >( fileName ), W_DT_INT64 ) );
184 else if( dataTypeName ==
"FLOAT" )
186 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< float >( 0, 1, readDataTyped< float >( fileName ), W_DT_FLOAT ) );
188 else if( dataTypeName ==
"DOUBLE" )
190 newValueSet = std::shared_ptr< WValueSetBase >(
new WValueSet< double >( 0, 1, readDataTyped< double >( fileName ), W_DT_DOUBLE ) );
192 else if( dataTypeName ==
"FLOAT128" )
195 std::shared_ptr< WValueSetBase >(
new WValueSet< long double >( 0, 1, readDataTyped< long double >( fileName ), W_DT_FLOAT128 ) );
199 throw WException(
"Not supported data type while reading raw data." );
202 std::shared_ptr< WGridRegular3D > newGrid;
203 size_t numX =
m_X->get();
204 size_t numY =
m_Y->get();
205 size_t numZ =
m_Z->get();
208 std::shared_ptr< WDataSetScalar > newDataSet;
209 newDataSet = std::shared_ptr< WDataSetScalar >(
new WDataSetScalar( newValueSet, newGrid ) );
virtual void wait() const
Wait for the condition.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
This data set type contains scalars as values.
A grid that has parallelepiped cells which all have the same proportion.
A class containing a list of named items.
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.
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 offering an instantiate-able data connection between modules.
Class representing a single module of OpenWalnut.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
void addConnector(std::shared_ptr< WModuleInputConnector > con)
Adds the specified connector to the list of inputs.
std::shared_ptr< WProperties > m_properties
The property object for the module.
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
virtual void connectors()
Initialize connectors in this function.
static boost::filesystem::path getAppPath()
The path where the binary file resides in.
Class managing progress inside of modules.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
Base Class for all value set types.
void addTo(WPropFilename prop)
Add the PC_PATHEXISTS constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.