29 #include "WMSampleOnFibers.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 "Sample On Fibers";
65 return "This module allows you to sample points on fibers using the parameters on a fiber.";
71 m_fiberInput = std::shared_ptr< WModuleInputData < WDataSetFibers > >(
79 m_pointsOutput = std::shared_ptr< WModuleOutputData < WDataSetPoints > >(
94 m_paramHint =
m_properties->addProperty(
"Hint",
"If you see this, your data does not contain fiber parameters.",
95 std::string(
"Your data cannot be filtered due to missing parameters." ) );
129 std::shared_ptr< WDataSetFibers > dataSet =
m_fiberInput->getData();
130 bool dataValid = ( dataSet != NULL );
142 if( dataValid && dataUpdated )
144 if( dataSet->getVertexParameters() )
148 for( WDataSetFibers::VertexParemeterArray::element_type::const_iterator it = dataSet->getVertexParameters()->begin();
149 it != dataSet->getVertexParameters()->end(); ++it )
166 if( dataValid && !dataUpdated && !propsChanged )
177 debugLog() <<
"Creating point data.";
193 for(
size_t fidx = 0; fidx < fibStart->size() ; ++fidx )
198 size_t sidx = fibStart->at( fidx ) * 3;
201 size_t len = fibLen->at( fidx );
206 if( fibParams->at( fibStart->at( fidx ) ) == v )
208 filteredVerts->push_back( fibVerts->at( sidx + 0 ) );
209 filteredVerts->push_back( fibVerts->at( sidx + 1 ) );
210 filteredVerts->push_back( fibVerts->at( sidx + 2 ) );
214 fibVerts->at( sidx + 0 ),
215 fibVerts->at( sidx + 1 ),
216 fibVerts->at( sidx + 2 ) )
223 osg::Vec3 lastVert = osg::Vec3( fibVerts->at( sidx ),
224 fibVerts->at( sidx + 1 ),
225 fibVerts->at( sidx + 2 ) );
227 double lastParam = fibParams->at( fibStart->at( fidx ) );
230 for(
size_t k = 0; k < len; ++k )
233 osg::Vec3 vert = osg::Vec3( fibVerts->at( ( 3 * k ) + sidx ),
234 fibVerts->at( ( 3 * k ) + sidx + 1 ),
235 fibVerts->at( ( 3 * k ) + sidx + 2 ) );
236 double param = fibParams->at( k + fibStart->at( fidx ) );
240 if( isInClosed( interval, v ) )
243 double n = ( v - lastParam ) / ( param - lastParam );
244 osg::Vec3 interpolatedVert( lastVert + ( vert - lastVert ) * n );
246 filteredVerts->push_back( interpolatedVert.x() );
247 filteredVerts->push_back( interpolatedVert.y() );
248 filteredVerts->push_back( interpolatedVert.z() );
250 filteredBB.
expandBy( interpolatedVert );
260 for(
size_t i = 0; i < filteredVerts->size() / 3; ++i )
262 filteredColors->push_back(
m_color->get(
true ).r() );
263 filteredColors->push_back(
m_color->get(
true ).g() );
264 filteredColors->push_back(
m_color->get(
true ).b() );
265 filteredColors->push_back(
m_color->get(
true ).a() );
272 debugLog() <<
"Done filtering. Result are " << filteredVerts->size() / 3 <<
" points.";
276 warnLog() <<
"Data does not contain the values to use for sampling.";
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.
std::shared_ptr< std::vector< size_t > > IndexArray
Index list indexing fibers in VertexArray in terms of vertex numbers.
std::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
std::shared_ptr< std::vector< size_t > > LengthArray
Lengths of fibers in terms of vertices.
std::shared_ptr< std::vector< double > > VertexParemeterArray
Parameter storage for each vertex.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
Dataset to store a bunch of points without order or topology.
std::shared_ptr< WDataSetPoints > SPtr
Pointer to dataset.
This modules takes a fiber dataset and samples it at a given parameter value.
std::shared_ptr< WModuleInputData< WDataSetFibers > > m_fiberInput
The fiber dataset which is going to be used.
WPropDouble m_parameter
Filter fib point according to its parameter value and this value.
WPropString m_paramHint
A string which informs the user whether filtering is possible.
WMSampleOnFibers()
Default constructor.
virtual const std::string getName() const
Gives back the name of this module.
std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_pointsOutput
The output connector used to provide the calculated point data to other modules.
WPropColor m_color
The color to use for the resulting points.
virtual void connectors()
Initialize the connectors this module is using.
virtual ~WMSampleOnFibers()
Destructor.
double m_parameterMax
fiber parameter max
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 char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual void properties()
Initialize the properties for this module.
virtual void moduleMain()
Entry point after loading the module.
virtual const std::string getDescription() const
Gives back a description of this module.
double m_parameterMin
fiber parameter min
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
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.
wlog::WStreamedLogger warnLog() const
Logger instance for comfortable warning- logs.
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.
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.