30 #include <osg/LineWidth>
31 #include <osg/LightModel>
32 #include <osg/Geometry>
34 #include "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,
110 m_threshold =
m_properties->addProperty(
"Threshold",
"description", 0. , boost::bind( &WROIArbitrary::propertyChanged,
this ) );
113 void WROIArbitrary::propertyChanged()
136 std::vector< double > vec( 3 );
158 osg::Geometry* surfaceGeometry =
new osg::Geometry();
161 surfaceGeometry->setVertexArray(
m_triMesh->getVertexArray() );
165 surfaceGeometry->setNormalArray(
m_triMesh->getTriangleNormalArray() );
166 surfaceGeometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
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 );