30 #include "WMDatasetManipulator.h"
31 #include "WMDatasetManipulator.xpm"
32 #include "WManipulatorNormalize.h"
33 #include "WManipulatorRotation.h"
34 #include "WManipulatorScaling.h"
35 #include "WManipulatorTranslation.h"
36 #include "core/dataHandler/WDataSetFibers.h"
37 #include "core/dataHandler/WDataSetPoints.h"
38 #include "core/dataHandler/WDataSetSingle.h"
39 #include "core/dataHandler/WGridRegular3D.h"
40 #include "core/dataHandler/WGridTransformOrtho.h"
41 #include "core/graphicsEngine/WTriangleMesh.h"
42 #include "core/kernel/WKernel.h"
48 m_strategy( "Manipulators", "Select one of the manipulators.", NULL, "Manipulator", "A list of all available manipulators" )
67 return WMDatasetManipulator_xpm;
72 return "Dataset Manipulator";
77 return "This module allows manipulation of the dataset properties via manipulators in the 3D scene.";
82 m_input = std::shared_ptr< WModuleInputData< WDataSet > >(
86 m_output = std::shared_ptr< WModuleOutputData < WDataSet > >(
169 std::shared_ptr< WDataSetSingle > asSingle = std::dynamic_pointer_cast< WDataSetSingle >(
m_data );
172 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >( asSingle->getGrid() );
175 return std::shared_ptr< WDataSet >();
183 std::shared_ptr< WGrid > newGrid(
new WGridRegular3D( grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ(), tr ) );
185 return asSingle->clone( newGrid );
188 std::shared_ptr< WDataSetFibers > asFibers = std::dynamic_pointer_cast< WDataSetFibers >(
m_data );
193 std::shared_ptr< std::vector< float > > vertices = asFibers->getVertices();
194 std::shared_ptr< std::vector< float > > newVertices(
new std::vector< float >( vertices->size() ) );
196 for( std::size_t k = 0; k < vertices->size() / 3; ++k )
198 WVector4d v( ( *vertices )[ 3 * k + 0 ], ( *vertices )[ 3 * k + 1 ], ( *vertices )[ 3 * k + 2 ], 1.0 );
200 ( *newVertices )[ 3 * k + 0 ] = w[ 0 ] / w[ 3 ];
201 ( *newVertices )[ 3 * k + 1 ] = w[ 1 ] / w[ 3 ];
202 ( *newVertices )[ 3 * k + 2 ] = w[ 2 ] / w[ 3 ];
205 std::shared_ptr< WDataSetFibers > data(
new WDataSetFibers( newVertices, asFibers->getLineStartIndexes(),
206 asFibers->getLineLengths(), asFibers->getVerticesReverse() ) );
210 std::shared_ptr< WDataSetPoints > asPoints = std::dynamic_pointer_cast< WDataSetPoints >(
m_data );
213 std::shared_ptr< std::vector< float > > p(
new std::vector< float >( asPoints->getVertices()->size() ) );
215 for( std::size_t k = 0; k < asPoints->getVertices()->size(); k += 3 )
217 WVector4d vec( asPoints->getVertices()->operator[]( k + 0 ),
218 asPoints->getVertices()->operator[]( k + 1 ),
219 asPoints->getVertices()->operator[]( k + 2 ),
223 p->operator[] ( k + 0 ) = vec[ 0 ];
224 p->operator[] ( k + 1 ) = vec[ 1 ];
225 p->operator[] ( k + 2 ) = vec[ 2 ];
228 return std::shared_ptr< WDataSetPoints >(
new WDataSetPoints( p, asPoints->getColors() ) );
231 return std::shared_ptr< WDataSet >();
236 std::shared_ptr< WDataSetSingle > asSingle = std::dynamic_pointer_cast< WDataSetSingle >(
m_data );
239 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >( asSingle->getGrid() );
247 else if( std::dynamic_pointer_cast< WDataSetFibers >(
m_data ) )
251 else if( std::dynamic_pointer_cast< WDataSetPoints >(
m_data ) )
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.
Represents a simple set of WFibers.
Dataset to store a bunch of points without order or topology.
A grid that has parallelepiped cells which all have the same proportion.
Module allowing manipulation of the dataset scaling, orientation and position.
std::shared_ptr< WModuleOutputData< WDataSet > > m_output
An output connector for the transformed dataset.
std::shared_ptr< WCondition > m_propCondition
A condition for property updates.
std::shared_ptr< WDataSet > m_data
The current data.
WMatrixFixed< double, 4, 4 > m_currentMat
The current transformation.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual void connectors()
Initialize the connectors this module is using.
WPropTrigger m_applyTrigger
A trigger to add the transformation from the currently active strategy to the current transformation.
virtual void properties()
Initialize the properties for this module.
WPropTrigger m_resetTrigger
A trigger to reset the current transformation to the initial one.
virtual void moduleMain()
Entry point after loading the 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...
std::shared_ptr< WModuleInputData< WDataSet > > m_input
An input connector that accepts any dataset.
WStrategyHelper< WObjectNDIP< WManipulatorInterface > > m_strategy
The strategy to use for dataset transformation manipulation.
virtual const std::string getName() const
Gives back the name of this module.
std::shared_ptr< WDataSet > transformData(WMatrixFixed< double, 4, 4 > const &mat)
Transform the data using the provided transformation matrix.
void initMatrix()
Init the matrix to be applied from the transformations stored in the current dataset.
virtual const std::string getDescription() const
Gives back a description of this module.
WMDatasetManipulator()
Constructor.
virtual ~WMDatasetManipulator()
Destructor.
A manipulator to scale datasets to form a unit cube.
A manipulator for rotating a dataset around an axis in the world coordinate system.
A manipulator to scale datasets in world coords.
A manipulator for translation of datasets in world coordinates.
static MatrixType identity()
Returns an identity matrix.
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.
WProperties::SPtr getProperties() const
Get this strategy selectors properties.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
@ PV_TRIGGER_TRIGGERED
Trigger property: got triggered.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)