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