30 #include <osg/LineWidth>
31 #include <osg/LightModel>
32 #include <osg/Geometry>
34 #include "core/common/algorithms/WMarchingLegoAlgorithm.h"
36 #include "callbacks/WGEFunctorCallback.h"
37 #include "WGraphicsEngine.h"
39 #include "WROIArbitrary.h"
43 const std::vector< float >& vals,
44 boost::shared_ptr< WTriangleMesh > triMesh,
74 const std::vector< float >& vals,
136 std::vector< double > vec( 3 );
158 osg::Geometry* surfaceGeometry =
new osg::Geometry();
161 surfaceGeometry->setVertexArray(
m_triMesh->getVertexArray() );
165 surfaceGeometry->setNormalArray(
m_triMesh->getVertexNormalArray() );
166 surfaceGeometry->setNormalBinding( osg::Geometry::BIND_PER_VERTEX );
170 osg::Vec4Array* colors =
new osg::Vec4Array;
172 surfaceGeometry->setColorArray( colors );
173 surfaceGeometry->setColorBinding( osg::Geometry::BIND_OVERALL );
175 osg::DrawElementsUInt* surfaceElement =
new osg::DrawElementsUInt( osg::PrimitiveSet::TRIANGLES, 0 );
177 std::vector< size_t >tris =
m_triMesh->getTriangles();
178 surfaceElement->reserve( tris.size() );
180 for(
unsigned int vertId = 0; vertId < tris.size(); ++vertId )
182 surfaceElement->push_back( tris[vertId] );
184 surfaceGeometry->addPrimitiveSet( surfaceElement );
185 removeDrawables( 0 );
186 addDrawable( surfaceGeometry );
188 osg::StateSet* state = getOrCreateStateSet();
189 osg::ref_ptr<osg::LightModel> lightModel =
new osg::LightModel();
190 lightModel->setTwoSided(
true );
191 state->setAttributeAndModes( lightModel.get(), osg::StateAttribute::ON );
193 state->setMode( GL_BLEND, osg::StateAttribute::ON );
void propertyChanged()
Used as callback to mark a change in the ROI.
void setDirty()
sets the dirty flag
boost::shared_ptr< WTriangleMesh > m_triMesh
This triangle mesh is provided as output through the connector.
const std::vector< float > m_vals
The data at the vertices.
double getThreshold()
getter
Superclass for different ROI (region of interest) types.
This callback allows you a simple usage of callbacks in your module.
float getValue(size_t i)
Get the i-th value of the data defining the ROI.
void setThreshold(double threshold)
setter
boost::shared_ptr< WProperties > m_properties
the property object for the module
WMatrix< double > m_matrix
The 4x4 transformation matrix for the vertices.
virtual void updateGFX()
updates the graphics
boost::shared_ptr< WTriangleMesh > generateSurface(size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ, const WMatrix< double > &mat, const std::vector< T > *vals, double isoValue, boost::shared_ptr< WProgressCombiner > mainProgress=boost::shared_ptr< WProgressCombiner >())
Generate the triangles for the surface on the given dataSet (inGrid, vals).
void properties()
initalizes the properties
WPropBool m_dirty
dirty flag, indicating the graphics needs updating, it is no longer used for bitfield updating since ...
static boost::shared_ptr< WGraphicsEngine > getGraphicsEngine()
Returns instance of the graphics engine.
WROIArbitrary(size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ, const WMatrix< double > &mat, const std::vector< float > &vals, boost::shared_ptr< WTriangleMesh > triMesh, float threshold, float maxThreshold, WColor color)
constructor
std::vector< double > getCoordOffsets()
Get the vertex offsets in the three coordinate directions.
Creates a non interpolated triangulation of an isosurface.
WPropDouble m_threshold
the threshold
std::vector< size_t > getCoordDimensions()
Get the number of vertices in the three coordinate directions.
virtual ~WROIArbitrary()
destructor
WColor m_color
The ROI color.
std::vector< size_t > m_nbCoordsVec
The data's number of vertices in X, Y and Z direction.