29 #include "WMMergeComponentsToVector.h"
30 #include "core/common/WPropertyHelper.h"
31 #include "core/dataHandler/WDataHandler.h"
32 #include "core/kernel/WKernel.h"
54 return "Merge Components To Vector";
59 return "Merge components to vector field.";
66 "Needs to be in the same grid as the others." );
69 "Needs to be in the same grid as the others." );
72 "Needs to be in the same grid as the others." );
118 std::shared_ptr< WDataSetScalar > dataSetX =
m_scalarInX->getData();
119 std::shared_ptr< WDataSetScalar > dataSetY =
m_scalarInY->getData();
120 std::shared_ptr< WDataSetScalar > dataSetZ =
m_scalarInZ->getData();
122 bool dataValid = ( dataSetX && dataSetY && dataSetZ );
131 if( dataValid && !dataUpdated )
137 std::shared_ptr< WGridRegular3D > gridX = std::dynamic_pointer_cast< WGridRegular3D >( dataSetX->getGrid() );
138 std::shared_ptr< WGridRegular3D > gridY = std::dynamic_pointer_cast< WGridRegular3D >( dataSetY->getGrid() );
139 std::shared_ptr< WGridRegular3D > gridZ = std::dynamic_pointer_cast< WGridRegular3D >( dataSetZ->getGrid() );
140 if( !( gridX && gridY && gridZ ) )
142 errorLog() <<
"Only regular 3D grids allowed.";
147 if( !( ( *gridX ) == ( *gridY ) ) || !( ( *gridX ) == ( *gridZ ) ) )
149 errorLog() <<
"Grids do not match.";
154 std::shared_ptr< WProgress > progress(
new WProgress(
"Processing", dataSetX->getValueSet()->rawSize() ) );
158 if( !( ( dataSetX->getValueSet()->rawSize() == dataSetY->getValueSet()->rawSize() ) &&
159 ( dataSetX->getValueSet()->rawSize() == dataSetZ->getValueSet()->rawSize() ) ) )
161 errorLog() <<
"Value set sizes do not match.";
166 std::shared_ptr< std::vector< double > > data(
new std::vector< double >() );
167 data->reserve( dataSetX->getValueSet()->rawSize() * 3 );
169 for(
size_t i = 0; i < dataSetX->getValueSet()->rawSize(); ++i )
171 double x = dataSetX->getValueSet()->getScalarDouble( i );
172 double y = dataSetY->getValueSet()->getScalarDouble( i );
173 double z = dataSetZ->getValueSet()->getScalarDouble( i );
175 data->push_back( x );
176 data->push_back( y );
177 data->push_back( z );
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
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 vectors as values.
std::shared_ptr< WDataSetVector > SPtr
shared_ptr abbreviation
This modules takes several scalar inputs and merges them to a vector dataset.
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...
virtual const std::string getName() const
Gives back the name of this module.
WMMergeComponentsToVector()
Default constructor.
virtual void properties()
Initialize the properties for this module.
virtual void connectors()
Initialize the connectors this module is using.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_scalarInY
An input connector used to get datasets from other modules.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_scalarInX
An input connector used to get datasets from other modules.
std::shared_ptr< WModuleOutputData< WDataSetVector > > m_vectorOut
The output connector used to provide the calculated data to other modules.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
virtual ~WMMergeComponentsToVector()
Destructor.
virtual const std::string getDescription() const
Provide description.
virtual void moduleMain()
Entry point after loading the module.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_scalarInZ
An input connector used to get datasets from other modules.
static PtrType createAndAdd(std::shared_ptr< WModule > module, std::string name="", std::string description="")
Convenience method to create a new instance of this out data connector with proper type and add it to...
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 ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
wlog::WStreamedLogger errorLog() const
Logger instance for comfortable error logging.
std::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
virtual void connectors()
Initialize connectors in this function.
Class managing progress inside of modules.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
Base Class for all value set types.