29 #include "WMMergePoints.h"
30 #include "core/common/WPropertyHelper.h"
31 #include "core/common/math/WMath.h"
32 #include "core/dataHandler/WDataHandler.h"
33 #include "core/kernel/WKernel.h"
60 return "Merge Points";
65 return "This module merges several given point datasets into one new dataset";
95 for(
size_t i = 0; i < src->size() / srcType; ++i )
99 case WDataSetPoints::GRAY:
100 dest->push_back( src->operator[]( i ) );
101 dest->push_back( src->operator[]( i ) );
102 dest->push_back( src->operator[]( i ) );
103 dest->push_back( 1.0 );
105 case WDataSetPoints::RGB:
106 dest->push_back( src->operator[]( srcType * i + 0 ) );
107 dest->push_back( src->operator[]( srcType * i + 1 ) );
108 dest->push_back( src->operator[]( srcType * i + 2 ) );
109 dest->push_back( 1.0 );
111 case WDataSetPoints::RGBA:
112 dest->push_back( src->operator[]( srcType * i + 0 ) );
113 dest->push_back( src->operator[]( srcType * i + 1 ) );
114 dest->push_back( src->operator[]( srcType * i + 2 ) );
115 dest->push_back( src->operator[]( srcType * i + 3 ) );
146 std::shared_ptr< WDataSetPoints > dataSet1 =
m_pointsInput1->getData();
147 std::shared_ptr< WDataSetPoints > dataSet2 =
m_pointsInput2->getData();
148 bool dataValid = ( dataSet1 && dataSet2 );
158 if( dataValid && dataUpdated )
163 debugLog() <<
"Merging " << dataSet1->size() <<
" with " << dataSet2->size() <<
" points.";
168 verts->resize( verts->size() + dataSet2->getVertices()->size() );
169 std::copy( dataSet2->getVertices()->begin(), dataSet2->getVertices()->end(), verts->begin() + dataSet1->getVertices()->size() );
172 if( dataSet1->getColorType() != dataSet2->getColorType() )
176 debugLog() <<
"Color types are different. Handling them properly.";
179 colors->reserve( dataSet1->size() * dataSet1->size() * 4 );
182 copyColors( dataSet1->getColors(), dataSet1->getColorType(), colors );
183 copyColors( dataSet2->getColors(), dataSet2->getColorType(), colors );
187 debugLog() <<
"Color types are equal.";
191 colors->resize( colors->size() + dataSet2->getColors()->size() );
192 std::copy( dataSet2->getColors()->begin(), dataSet2->getColors()->end(), colors->begin() + dataSet1->getColors()->size() );
197 bb.
expandBy( dataSet2->getBoundingBox() );
199 debugLog() <<
"Done merging. Result are " << verts->size() <<
" points.";
void expandBy(const WBoundingBoxImpl< VT > &bb)
Expands this bounding box to include the given bounding box.
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.
Dataset to store a bunch of points without order or topology.
std::shared_ptr< WDataSetPoints > SPtr
Pointer to dataset.
ColorType
The type of colors we have for each point.
std::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
This modules takes some point data and merges them into one new point dataset.
std::shared_ptr< WModuleInputData< WDataSetPoints > > m_pointsInput1
The input data.
virtual const std::string getName() const
Gives back the name of this module.
virtual ~WMMergePoints()
Destructor.
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 void properties()
Initialize the properties for this module.
virtual void moduleMain()
Entry point after loading the module.
virtual void connectors()
Initialize the connectors this module is using.
std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_pointsOutput
The output connector used to provide the calculated point data to other modules.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual const std::string getDescription() const
Gives back a description of this module.
std::shared_ptr< WModuleInputData< WDataSetPoints > > m_pointsInput2
The input data.
WMMergePoints()
Default constructor.
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.
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.
std::shared_ptr< WProgress > SPtr
Shared pointer on a WProgress.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.