31 #include <osg/Geometry>
33 #include <osg/Material>
34 #include <osg/ShapeDrawable>
35 #include <osg/StateAttribute>
37 #include "WMProjectionsAsContext.h"
38 #include "core/dataHandler/WDataSetScalar.h"
39 #include "core/graphicsEngine/WGEColormapping.h"
40 #include "core/graphicsEngine/WGEGeodeUtils.h"
41 #include "core/graphicsEngine/WGEManagedGroupNode.h"
42 #include "core/graphicsEngine/WGEUtils.h"
43 #include "core/graphicsEngine/callbacks/WGELinearTranslationCallback.h"
44 #include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
45 #include "core/graphicsEngine/shaders/WGEShader.h"
46 #include "core/kernel/WKernel.h"
47 #include "core/kernel/WModuleInputData.h"
69 return "Projections As Context";
74 return "This module draws projections of scalar data on the faces of the data set's bounding box."
75 " The data can be projected by using either MIP or DVR.";
96 "Do not show this plane."
102 "MIP (Maximum Intensity Projection)",
103 "Show this plane using the MIP Algorithm."
109 "Compositing Front-to-Back (Transfer Function Needed)",
110 "Show this plane using the Compositing Algorithm (F2B)."
116 "Compositing Back-to-Front (Transfer Function Needed)",
117 "Show this plane using the Compositing Algorithm (B2F)."
123 "Choose action for this Plane.",
127 "Choose action for this Plane.",
131 "Choose action for this Plane.",
135 "Choose action for this Plane.",
139 "Choose action for this Plane.",
143 "Choose action for this Plane.",
162 "Early Ray Termination",
163 "Used by Compositing Front-to-Back.",
206 m_geode->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
207 m_geode->getOrCreateStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
216 std::vector<osg::ref_ptr<osg::Geometry> > planeList;
217 for(
int i = 0; i < 6; i++ )
218 planeList.push_back( NULL );
221 osg::ref_ptr< osg::Image > tfImage =
new osg::Image();
222 osg::ref_ptr< osg::Texture1D > tfTexture =
new osg::Texture1D();
223 tfTexture->setDataVariance( osg::Object::DYNAMIC );
224 tfTexture->setImage( tfImage );
251 WGridRegular3D::SPtr regGrid = std::dynamic_pointer_cast< WGridRegular3D >( dsSingle->getGrid() );
253 X = regGrid->getNbCoordsX();
254 Y = regGrid->getNbCoordsY();
255 Z = regGrid->getNbCoordsZ();
268 for(
int i = 0; i < 6; i++ )
283 for(
int i = 0; i < 6; i++ )
284 m_geode->removeDrawable( planeList[i] );
286 osg::ref_ptr<osg::Geometry> planeGeometry = NULL;
287 for(
int i = 0; i < 6; i++ )
290 if( selection[i] != 0 )
292 planeList[i] = osg::ref_ptr<osg::Geometry>(
new osg::Geometry() );
293 planeGeometry = planeList[i];
294 osg::Vec3Array* planeVertices =
new osg::Vec3Array;
295 osg::Vec3Array* planeNormales =
new osg::Vec3Array;
297 switch(
static_cast<int>( floor( i/2.0f ) ) )
301 WPosition tempV0( 0-10, ( i%2 == 0 )?0-10:Y+10, 0-10 );
302 WPosition tempV1( X+10, ( i%2 == 0 )?0-10:Y+10, 0-10 );
303 WPosition tempV2( X+10, ( i%2 == 0 )?0-10:Y+10, Z+10 );
304 WPosition tempV3( 0-10, ( i%2 == 0 )?0-10:Y+10, Z+10 );
306 planeVertices->push_back( tempV0 );
307 planeVertices->push_back( tempV1 );
308 planeVertices->push_back( tempV2 );
309 planeVertices->push_back( tempV3 );
311 normal[0] = normal[2] = 0;
320 WPosition tempV0( 0-10, 0-10, ( i%2 == 0 )?0-10:Z+10 );
321 WPosition tempV1( X+10, 0-10, ( i%2 == 0 )?0-10:Z+10 );
322 WPosition tempV2( X+10, Y+10, ( i%2 == 0 )?0-10:Z+10 );
323 WPosition tempV3( 0-10, Y+10, ( i%2 == 0 )?0-10:Z+10 );
324 planeVertices->push_back( tempV0 );
325 planeVertices->push_back( tempV1 );
326 planeVertices->push_back( tempV2 );
327 planeVertices->push_back( tempV3 );
329 normal[0] = normal[1] = 0;
338 WPosition tempV0( ( i%2 == 0 )?0-10:X+10, 0-10, 0-10 );
339 WPosition tempV1( ( i%2 == 0 )?0-10:X+10, 0-10, Z+10 );
340 WPosition tempV2( ( i%2 == 0 )?0-10:X+10, Y+10, Z+10 );
341 WPosition tempV3( ( i%2 == 0 )?0-10:X+10, Y+10, 0-10 );
342 planeVertices->push_back( tempV0 );
343 planeVertices->push_back( tempV1 );
344 planeVertices->push_back( tempV2 );
345 planeVertices->push_back( tempV3 );
347 normal[1] = normal[2] = 0;
358 planeNormales->push_back( normal );
359 planeNormales->push_back( normal );
360 planeNormales->push_back( normal );
361 planeNormales->push_back( normal );
362 planeGeometry->setVertexArray( planeVertices );
363 planeGeometry->setNormalArray( planeNormales );
364 planeGeometry->setNormalBinding( ( osg::Geometry::AttributeBinding )4 );
367 osg::DrawElementsUInt* quad =
new osg::DrawElementsUInt( osg::PrimitiveSet::QUADS, 0 );
368 quad->push_back( 3 );
369 quad->push_back( 2 );
370 quad->push_back( 1 );
371 quad->push_back( 0 );
372 planeGeometry->addPrimitiveSet( quad );
374 m_geode->addDrawable( planeGeometry );
388 WAssert( dataSet,
"data set" );
389 std::shared_ptr< WValueSetBase > valueSet = dataSet->getValueSet();
390 WAssert( valueSet,
"value set" );
391 std::shared_ptr< WValueSet< unsigned char > > cvalueSet(
400 size_t tfsize = cvalueSet->rawSize();
402 tfImage->allocateImage( tfsize/4, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE );
403 tfImage->setInternalTextureFormat( GL_RGBA );
404 unsigned char* data =
reinterpret_cast< unsigned char*
>( tfImage->data() );
405 std::copy( cvalueSet->rawData(), &cvalueSet->rawData()[ tfsize ], data );
408 tfTexture->dirtyTextureObject();
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< WDataSetSingle > SPtr
Convenience typedef for a std::shared_ptr.
static void apply(osg::ref_ptr< osg::Node > node, WMatrix4d preTransform=WMatrix4d::identity(), osg::ref_ptr< WGEShader > shader=osg::ref_ptr< WGEShader >(), size_t startTexUnit=0)
Apply the colormapping to the specified node.
This class adds some convenience methods to WGEGroupNode.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
std::shared_ptr< WGridRegular3DTemplate > SPtr
Convenience typedef for a std::shared_ptr< WGridRegular3DTemplate >.
A derivation of WItemSelection which can store a value of any type.
static SPtr create(T value, std::string name, std::string description="", const char **icon=NULL)
Create a instance of the item.
A class containing a list of named items.
std::shared_ptr< WItemSelection > SPtr
Convenience typedef for a std::shared_ptr< WItemSelection >
static WKernel * getRunningKernel()
Returns pointer to the currently running kernel.
std::shared_ptr< WGraphicsEngine > getGraphicsEngine() const
Returns pointer to currently running instance of graphics engine.
Computes contour lines (aka isolines) for the given data and render them on a 2D plane.
WPropSelection m_singleSelectionCoronalTop
Plane orientation type.
osg::ref_ptr< osg::Geode > m_geode
Geode holding the planes.
WPropSelection m_singleSelectionSagittalTop
Plane orientation type.
virtual ~WMProjectionsAsContext()
Destroys this module.
virtual void requirements()
Initialize requirements for this module.
std::shared_ptr< WCondition > m_propCondition
Needed for recreating the geometry, incase when resolution changes.
WPropSelection m_singleSelectionAxialTop
Plane orientation type.
WPropSelection m_singleSelectionAxialBottom
Plane orientation type.
WMProjectionsAsContext()
Creates the module for drawing contour lines.
WPropSelection m_singleSelectionSagittalBottom
Plane orientation type.
std::shared_ptr< WDataSetScalar > scalarData
The treated data set.
std::shared_ptr< WItemSelection > m_possibleSelectionsUsingTypes
Plane orientation type selection.
virtual void moduleMain()
Entry point after loading the module.
WPropPosition m_normalOut
Info property.
osg::ref_ptr< WGEShader > m_shader
Reference to shader object.
virtual const std::string getDescription() const
Gives back a description of this module.
osg::ref_ptr< WGEManagedGroupNode > m_rootNode
The OSG root node for this module.
WPropSelection m_singleSelectionCoronalBottom
Plane orientation type.
std::shared_ptr< WModuleInputData< WDataSetSingle > > m_transferFunction
The transfer function as an input data set.
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_scalarIC
Input connector for scalar data.
WPropPosition m_maxCoordsPosition
Info property.
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_earlyRayTerminationAlpha
Threshold for early ray termination of DVR.
virtual const std::string getName() const
Gives back the name of this module.
WPropInt m_planeTypes[6]
Info property.
Class representing a single module of OpenWalnut.
boost::filesystem::path m_localPath
The path where the module binary resides in.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
std::shared_ptr< WProperties > m_properties
The property object for the module.
std::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION".
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
WPropBool m_active
True whenever the module should be active.
wlog::WStreamedLogger infoLog() const
Logger instance for comfortable info logging.
virtual void connectors()
Initialize connectors in this function.
This only is a 3d double vector.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
Base Class for all value set types.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
void bindTexture(osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture, size_t unit=0, std::string prefix="")
Binds the specified texture to the specified unit.