OpenWalnut  1.5.0dev
WMTriangleMeshRenderer.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <algorithm>
26 #include <limits>
27 #include <list>
28 #include <map>
29 #include <memory>
30 #include <string>
31 #include <vector>
32 
33 #include <osg/Geode>
34 
35 #include "WMTriangleMeshRenderer.h"
36 #include "WMTriangleMeshRenderer.xpm"
37 #include "core/common/WLimits.h"
38 #include "core/common/math/WMath.h"
39 #include "core/graphicsEngine/WGEColormapping.h"
40 #include "core/graphicsEngine/WGEGeodeUtils.h"
41 #include "core/graphicsEngine/WGEUtils.h"
42 #include "core/graphicsEngine/WTriangleMesh.h"
43 #include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
44 #include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
45 #include "core/graphicsEngine/shaders/WGEShader.h"
46 #include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
47 #include "core/kernel/WKernel.h"
48 
49 // This line is needed by the module loader to actually find your module.
50 W_LOADABLE_MODULE( WMTriangleMeshRenderer )
51 
53  WModule()
54 {
55 }
56 
58 {
59  // Cleanup!
60 }
61 
62 std::shared_ptr< WModule > WMTriangleMeshRenderer::factory() const
63 {
64  // See "src/modules/template/" for an extensively documented example.
65  return std::shared_ptr< WModule >( new WMTriangleMeshRenderer() );
66 }
67 
69 {
70  // just return the icon
71  return WMTriangleMeshRenderer_xpm;
72 }
73 
74 const std::string WMTriangleMeshRenderer::getName() const
75 {
76  // Specify your module name here. This name must be UNIQUE!
77  return "Triangle Mesh Renderer";
78 }
79 
80 const std::string WMTriangleMeshRenderer::getDescription() const
81 {
82  return "Takes a triangle mesh as input and renders it as a shaded surface.";
83 }
84 
85 void WMTriangleMeshRenderer::updateMinMax( double& minX, double& maxX, // NOLINT
86  double& minY, double& maxY, // NOLINT
87  double& minZ, double& maxZ, const osg::Vec3d& vector ) const // NOLINT
88 {
89  minX = std::min( minX, vector.x() );
90  minY = std::min( minY, vector.y() );
91  minZ = std::min( minZ, vector.z() );
92 
93  maxX = std::max( maxX, vector.x() );
94  maxY = std::max( maxY, vector.y() );
95  maxZ = std::max( maxZ, vector.z() );
96 }
97 
98 double WMTriangleMeshRenderer::getMedian( double x, double y, double z ) const
99 {
100  if( ( y < x && z > x ) || ( z < x && y > x ) )
101  {
102  return x;
103  }
104 
105  if( ( x < y && z > y ) || ( x < y && z > y ) )
106  {
107  return y;
108  }
109 
110  if( ( y < z && x > z ) || ( x < z && y > z ) )
111  {
112  return z;
113  }
114 
115  if( x == y )
116  {
117  return x;
118  }
119  if( x == z )
120  {
121  return x;
122  }
123  if( y == z )
124  {
125  return z;
126  }
127  if( x == y && y == z && x == z )
128  {
129  return x;
130  }
131 
132  return 0;
133 }
134 
135 double WMTriangleMeshRenderer::getIntervallCenterMiddle( double min, double max ) const
136 {
137  return min + ( max - min ) / 2;
138 }
139 
141 {
142  // this input contains the triangle data
143  m_meshInput = WModuleInputData< WTriangleMesh >::createAndAdd( shared_from_this(), "mesh", "The mesh to display" );
144 
145  // this input provides an additional map from vertex ID to color. This is especially useful for using the trimesh renderer in conjunction
146  // with clustering mechanisms and so on
147  m_colorMapInput = WModuleInputData< WColoredVertices >::createAndAdd( shared_from_this(), "colorMap", "The special colors" );
148 
149  // call WModule's initialization
151 }
152 
154 {
155  m_nbTriangles = m_infoProperties->addProperty( "Triangles", "The number of triangles in the mesh.", 0 );
156  m_nbTriangles->setMax( std::numeric_limits< int >::max() );
157 
158  m_nbVertices = m_infoProperties->addProperty( "Vertices", "The number of vertices in the mesh.", 0 );
159  m_nbVertices->setMax( std::numeric_limits< int >::max() );
160 
161  // some properties need to trigger an update
162  m_propCondition = std::shared_ptr< WCondition >( new WCondition() );
163 
164  // setup all the properties. See header file for their meaning and purpose.
165  // Allow the user to select different colormodes
166 
167  std::shared_ptr< WItemSelection > renderingModes( std::shared_ptr< WItemSelection >( new WItemSelection() ) );
168  renderingModes->addItem( "Smooth Shading", "Smooth shading with Phong illumination model." );
169  renderingModes->addItem( "Flat Shading", "Each triangle has one constant color for shading." );
170  renderingModes->addItem( "Outline", "The surface is represented by lines only." );
171  m_renderingMode = m_properties->addProperty( "Rendering mode", "Choose one of the available rendering modes.", renderingModes->getSelectorFirst(),
172  m_propCondition );
174 
175  const bool hideProperty = true;
176  m_showOutline = m_properties->addProperty( "Outline", "Show all edges of the triangulation as lines.", false, m_propCondition, hideProperty );
177  m_mainComponentOnly = m_properties->addProperty( "Main component", "Main component only", false, m_propCondition );
178  m_showCoordinateSystem = m_properties->addProperty( "Coordinate system", "If enabled, the coordinate system of the mesh will be shown.",
179  false, m_propCondition );
180 
181  m_coloringGroup = m_properties->addPropertyGroup( "Coloring", "Coloring options and colormap options." );
182 
183  m_opacity = m_coloringGroup->addProperty( "Opacity %", "Opaqueness of surface.", 100.0 );
184  m_opacity->setMin( 0.0 );
185  m_opacity->setMax( 100.0 );
186 
187  // Allow the user to select different colormodes
188  std::shared_ptr< WItemSelection > colorModes( std::shared_ptr< WItemSelection >( new WItemSelection() ) );
189  colorModes->addItem( "Single Color", "The whole surface is colored using the default color." );
190  colorModes->addItem( "From Mesh", "The surface is colored according to the mesh." );
191  colorModes->addItem( "From colormap connector", "The surface is colored using the colormap on colorMap connector." );
192  m_colorMode = m_coloringGroup->addProperty( "Color mode", "Choose one of the available colorings.", colorModes->getSelectorFirst(),
193  m_propCondition );
195 
196  // this is the color used if single color is selected
197  m_color = m_coloringGroup->addProperty( "Default color", "The color of of the surface.",
198  WColor( .9f, .9f, 0.9f, 1.0f ), m_propCondition );
199 
200  m_colormap = m_coloringGroup->addProperty( "Enable colormapping", "Turn colormapping on", false );
201  m_colormapRatio = m_coloringGroup->addProperty( "Colormap ratio", "Set the colormap Ratio", 0.5 );
202  m_colormapRatio->setMin( 0.0 );
203  m_colormapRatio->setMax( 1.0 );
204 
205  m_groupTransformation = m_properties->addPropertyGroup( "Transformation", "A group which contains transformation tools." );
206 
207  //Scaling
208  m_scale = m_groupTransformation->addProperty( "Scale whole surface?", "The whole surface will be scaled.", false );
209 
210  m_scaleX = m_groupTransformation->addProperty( "Scale X", "Scaling X of surface.", 1.0 );
211  m_scaleX->setMin( -10.0 );
212  m_scaleX->setMax( 100.0 );
213 
214  m_scaleY = m_groupTransformation->addProperty( "Scale Y", "Scaling Y of surface.", 1.0 );
215  m_scaleY->setMin( -10.0 );
216  m_scaleY->setMax( 100.0 );
217 
218  m_scaleZ = m_groupTransformation->addProperty( "Scale Z", "Scaling Z of surface.", 1.0 );
219  m_scaleZ->setMin( -10.0 );
220  m_scaleZ->setMax( 100.0 );
221 
222  //Rotating
223  m_rotateX = m_groupTransformation->addProperty( "Rotate X", "Rotate X in °", 0.0 );
224  m_rotateX->setMin( -360.0 );
225  m_rotateX->setMax( 360.0 );
226 
227  m_rotateY = m_groupTransformation->addProperty( "Rotate Y", "Rotate Y in °", 0.0 );
228  m_rotateY->setMin( -360.0 );
229  m_rotateY->setMax( 360.0 );
230 
231  m_rotateZ = m_groupTransformation->addProperty( "Rotate Z", "Rotate Z in °", 0.0 );
232  m_rotateZ->setMin( -360.0 );
233  m_rotateZ->setMax( 360.0 );
234 
235  //Translating
236  m_translateX = m_groupTransformation->addProperty( "Translate X", "Translate the surface to X", 0.0 );
237  m_translateX->setMin( -100.0 );
238  m_translateX->setMax( 100.0 );
239 
240  m_translateY = m_groupTransformation->addProperty( "Translate Y", "Translate the surface to Y", 0.0 );
241  m_translateY->setMin( -100.0 );
242  m_translateY->setMax( 100.0 );
243 
244  m_translateZ = m_groupTransformation->addProperty( "Translate Z", "Translate the surface to Z", 0.0 );
245  m_translateZ->setMin( -100.0 );
246  m_translateZ->setMax( 100.0 );
247 
248  m_setDefault = m_groupTransformation->addProperty( "Reset to default", "Set!",
250  boost::bind( &WMTriangleMeshRenderer::setToDefault, this ) );
251 
252  // call WModule's initialization
254 }
255 
256 /**
257  * Compares two WTrianglesMeshes on their size of vertices. This is private here since it makes sense only to this module ATM.
258  */
260 {
261  /**
262  * Comparator on num vertex of two WTriangleMeshes
263  *
264  * \param m First Mesh
265  * \param n Second Mesh
266  *
267  * \return True if and only if the first Mesh has less vertices as the second mesh.
268  */
269  bool operator()( const std::shared_ptr< WTriangleMesh >& m, const std::shared_ptr< WTriangleMesh >& n ) const
270  {
271  return m->vertSize() < n->vertSize();
272  }
273 };
274 
276 {
277  // let the main loop awake if the data changes.
278  m_moduleState.setResetable( true, true );
279  m_moduleState.add( m_meshInput->getDataChangedCondition() );
280  m_moduleState.add( m_colorMapInput->getDataChangedCondition() );
282 
283  // create the post-processing node which actually does the nice stuff to the rendered image
284  osg::ref_ptr< WGEPostprocessingNode > postNode = new WGEPostprocessingNode(
285  WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getCamera()
286  );
287  // provide the properties of the post-processor to the user
288  m_properties->addProperty( postNode->getProperties() );
289 
290  ////////////////////////////////////////////////////////////////////////////////////////////////////
291  // setup the main graphics-node:
292  ////////////////////////////////////////////////////////////////////////////////////////////////////
293 
294  // create a OSG node, which will contain the triangle data and allows easy transformations:
296  osg::StateSet* moduleNodeState = m_moduleNode->getOrCreateStateSet();
297 
298  // set the member function "updateTransformation" as callback
299  WGEFunctorCallback< osg::Node >::SPtr transformationCallback(
301  );
302  m_moduleNode->addUpdateCallback( transformationCallback );
303 
304  // load the GLSL shader:
305  m_shader = new WGEShader( "WMTriangleMeshRenderer", m_localPath );
306  m_colorMapTransformation = new osg::Uniform( "u_colorMapTransformation", osg::Matrixd::identity() );
307  m_shader->addPreprocessor( WGEShaderPreprocessor::SPtr(
308  new WGEShaderPropertyDefineOptions< WPropBool >( m_colormap, "COLORMAPPING_DISABLED", "COLORMAPPING_ENABLED" ) )
309  );
310 
311  // set the opacity and material color property as GLSL uniforms:
312  moduleNodeState->addUniform( new WGEPropertyUniform< WPropDouble >( "u_opacity", m_opacity ) );
313  moduleNodeState->addUniform( new WGEPropertyUniform< WPropBool >( "u_outline", m_showOutline ) );
314 
315  // signal ready state. The module is now ready to be used.
316  ready();
317 
318  // add it to postproc node and register shader
319  postNode->insert( m_moduleNode, m_shader );
320  WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( postNode );
321 
322  // loop until the module container requests the module to quit
323  while( !m_shutdownFlag() )
324  {
325  // Now, the moduleState variable comes into play. The module can wait for the condition, which gets fired whenever the input receives data
326  // or an property changes. The main loop now waits until something happens.
327  debugLog() << "Waiting ...";
329 
330  WItemSelector renderingModeSelector = m_renderingMode->get();
331  m_showOutline->set( renderingModeSelector.getItemIndexOfSelected( 0 ) == 2 );
332 
333  // woke up since the module is requested to finish
334  if( m_shutdownFlag() )
335  {
336  break;
337  }
338 
339  // Get data and check for invalid data.
340  std::shared_ptr< WTriangleMesh > mesh = m_meshInput->getData();
341  if( !mesh )
342  {
343  debugLog() << "Invalid Data. Disabling.";
344  continue;
345  }
346 
347  renderMesh( mesh );
348  }
349 
350  // it is important to always remove the modules again
351  WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( postNode );
352 }
353 
354 void WMTriangleMeshRenderer::renderMesh( std::shared_ptr< WTriangleMesh > mesh )
355 {
356  std::shared_ptr< WColoredVertices > colorMap = m_colorMapInput->getData();
357 
358  m_nbTriangles->set( mesh->triangleSize() );
359  m_nbVertices->set( mesh->vertSize() );
360 
361  // prepare the geometry node
362  debugLog() << "Start rendering Mesh";
363  osg::ref_ptr< osg::Geometry > geometry;
364  osg::ref_ptr< osg::Geode > geode( new osg::Geode );
365  geode->setName( "Triangle Mesh Renderer Geode" );
366  geode->getOrCreateStateSet()->addUniform( m_colorMapTransformation );
367  geode->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropDouble >( "u_colormapRatio", m_colormapRatio ) );
368 
369  // apply shader only to mesh
370  m_shader->apply( geode );
371 
372  // get the middle point of the mesh
373  std::vector< size_t >triangles = mesh->getTriangles();
374  std::vector< size_t >::const_iterator trianglesIterator;
375  double minX = wlimits::MAX_DOUBLE;
376  double minY = wlimits::MAX_DOUBLE;
377  double minZ = wlimits::MAX_DOUBLE;
378 
379  double maxX = wlimits::MIN_DOUBLE;
380  double maxY = wlimits::MIN_DOUBLE;
381  double maxZ = wlimits::MIN_DOUBLE;
382 
383  for( trianglesIterator = triangles.begin();
384  trianglesIterator != triangles.end();
385  trianglesIterator++ )
386  {
387  osg::Vec3d vectorX = mesh->getVertex( *trianglesIterator );
388  updateMinMax( minX, maxX, minY, maxY, minZ, maxZ, vectorX );
389  }
390 
392  getIntervallCenterMiddle( minY, maxY ),
393  getIntervallCenterMiddle( minZ, maxZ ) );
394 
395  // start rendering
396  std::shared_ptr< WProgress > progress( new WProgress( "Rendering", 3 ) );
397  m_progress->addSubProgress( progress );
398 
399  if( m_mainComponentOnly->get( true ) )
400  {
401  // component decomposition
402  debugLog() << "Start mesh decomposition";
403  std::shared_ptr< std::list< std::shared_ptr< WTriangleMesh > > > m_components = tm_utils::componentDecomposition( *mesh );
404  mesh = *std::max_element( m_components->begin(), m_components->end(), WMeshSizeComp() );
405  debugLog() << "Decomposing mesh done";
406  }
407  ++*progress;
408 
409  // now create the mesh but handle the color mode properly
410  WItemSelector renderingModeSelector = m_renderingMode->get( true );
411 
412  if( renderingModeSelector.getItemIndexOfSelected( 0 ) == 2 )
413  {
414  geometry = wge::convertToOsgGeometryLines( mesh, m_color->get(), false );
415  }
416  else if( renderingModeSelector.getItemIndexOfSelected( 0 ) == 1 )
417  {
418  bool useColorFromMesh = m_colorMode->get( true ).getItemIndexOfSelected( 0 ) == 1;
419  geometry = wge::convertToOsgGeometryFlatShaded( mesh, m_color->get(), true, true, useColorFromMesh );
420  }
421  else // if( renderingModeSelector.getItemIndexOfSelected( 0 ) == 0 )
422  {
423  WItemSelector colorModeSelector = m_colorMode->get( true );
424  if( colorModeSelector.getItemIndexOfSelected( 0 ) == 0 )
425  {
426  geometry = wge::convertToOsgGeometry( mesh, m_color->get(), true, true, false );
427  }
428  else if( colorModeSelector.getItemIndexOfSelected( 0 ) == 1 )
429  {
430  // take color from mesh
431  geometry = wge::convertToOsgGeometry( mesh, m_color->get(), true, true, true );
432  }
433  else
434  {
435  // take color from map
436  if( colorMap )
437  {
438  geometry = wge::convertToOsgGeometry( mesh, *colorMap, m_color->get(), true, true );
439  }
440  else
441  {
442  warnLog() << "External colormap not connected. Using default color.";
443  geometry = wge::convertToOsgGeometry( mesh, m_color->get(), true, true, false );
444  }
445  }
446  }
447 
449 
450  // done. Set the new drawable
451  geode->addDrawable( geometry );
452  m_moduleNode->clear();
453  m_moduleNode->insert( geode );
454  if( m_showCoordinateSystem->get() )
455  {
457  maxX-minX,
458  maxY-minY,
459  maxZ-minZ
460  )
461  );
462  }
463  debugLog() << "Rendering Mesh done";
464  progress->finish();
465 }
466 
468 {
469  if( m_moduleNode )
470  {
471  if( m_scale->changed() && m_scale->get( true ) )
472  {
473  m_scaleX->set( getMedian( m_scaleX->get(), m_scaleY->get(), m_scaleZ->get() ) );
474  m_scaleY->set( getMedian( m_scaleX->get(), m_scaleY->get(), m_scaleZ->get() ) );
475  m_scaleZ->set( getMedian( m_scaleX->get(), m_scaleY->get(), m_scaleZ->get() ) );
476  }
477  if( m_scale->get() )
478  {
479  if( m_scaleX->changed() && m_scaleX->get( true ) )
480  {
481  m_scaleY->set( m_scaleX->get() );
482  m_scaleZ->set( m_scaleX->get() );
483  }
484  if( m_scaleY->changed() && m_scaleY->get( true ) )
485  {
486  m_scaleX->set( m_scaleY->get() );
487  m_scaleZ->set( m_scaleZ->get() );
488  }
489  if( m_scaleZ->changed() && m_scaleZ->get( true ) )
490  {
491  m_scaleX->set( m_scaleZ->get() );
492  m_scaleY->set( m_scaleZ->get() );
493  }
494  }
495 
496  osg::Matrixd matrixTranslateTo0 = osg::Matrixd::translate( static_cast< osg::Vec3f >( m_meshCenter ) * -1.0 );
497  osg::Matrixd matrixTranslateFrom0 = osg::Matrixd::translate( static_cast< osg::Vec3f >( m_meshCenter ) );
498  osg::Matrixd matrixScale = osg::Matrixd::scale( m_scaleX->get(), m_scaleY->get(), m_scaleZ->get() );
499  osg::Matrixd matrixRotateX = osg::Matrixd::rotate( m_rotateX->get() * pi() / 180, osg::Vec3f( 1, 0, 0 ) );
500  osg::Matrixd matrixRotateY = osg::Matrixd::rotate( m_rotateY->get() * pi() / 180, osg::Vec3f( 0, 1, 0 ) );
501  osg::Matrixd matrixRotateZ = osg::Matrixd::rotate( m_rotateZ->get() * pi() / 180, osg::Vec3f( 0, 0, 1 ) );
502  osg::Matrixd matrixRotate = matrixRotateX * matrixRotateY * matrixRotateZ;
503  osg::Matrixd matrixTranslate = osg::Matrixd::translate( m_translateX->get(), m_translateY->get(), m_translateZ->get() );
504  osg::Matrixd matrixComplete =
505  matrixTranslateTo0 *
506  matrixScale *
507  matrixTranslateFrom0 *
508  matrixTranslateTo0 *
509  matrixRotate *
510  matrixTranslateFrom0 *
511  matrixTranslate;
512 
513  m_moduleNode->setMatrix( matrixComplete );
514  m_colorMapTransformation->set( matrixComplete );
515  }
516 }
517 
519 {
521  {
523 
524  WMTriangleMeshRenderer::m_scale->set( false );
528 
532 
536 
538  }
539 }
540 
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.
Definition: WCondition.h:42
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 callback allows you a simple usage of callbacks in your module.
osg::ref_ptr< WGEFunctorCallback > SPtr
Shared pointer.
This class adds some convenience methods to WGEGroupNode.
This class enables you to add arbitrary nodes that get post-processed in screen space.
Class implementing a uniform which can be controlled by a property instance.
std::shared_ptr< WGEShaderPreprocessor > SPtr
Shared pointer for this class.
This is a WGEShaderDefineOptions class which additionally uses a property to automatically control th...
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
Definition: WGEShader.h:48
A class containing a list of named items.
This class represents a subset of a WItemSelection.
Definition: WItemSelector.h:53
virtual size_t getItemIndexOfSelected(size_t index) const
Helps to get the index of an selected item in the WItemSelection.
static WKernel * getRunningKernel()
Returns pointer to the currently running kernel.
Definition: WKernel.cpp:117
std::shared_ptr< WGraphicsEngine > getGraphicsEngine() const
Returns pointer to currently running instance of graphics engine.
Definition: WKernel.cpp:122
This module renders the triangle mesh given at its input connector as a surface.
WPropBool m_mainComponentOnly
En/Disable display of only the main component (biggest vertices number)
void renderMesh(std::shared_ptr< WTriangleMesh > mesh)
Render the mesh.
WPropInt m_nbTriangles
Info-property showing the number of triangles in the mesh.
osg::ref_ptr< osg::Uniform > m_colorMapTransformation
OSG Uniform for the transformation matrix which transforms the mesh.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
WPropBool m_showOutline
Toggle showing outline instead fo surface.
virtual const std::string getDescription() const
Gives back a description of this module.
double getIntervallCenterMiddle(double min, double max) const
Calculates the center point of a given interval.
WPropBool m_showCoordinateSystem
Enables mesh's coordinate system.
WPropDouble m_scaleY
The mesh's scale value in Y direction.
WPropGroup m_groupTransformation
A group wich contains all transformation tools.
void setToDefault()
Set the transformation tool to default.
WPropGroup m_coloringGroup
Group for all color and colormapping options.
WPropDouble m_scaleZ
The mesh's scale value in Z direction.
virtual void connectors()
Initialize the connectors this module is using.
WPropDouble m_rotateY
The mesh's rotate value around Y.
void updateTransformation()
Updates the transformation matrix of the main node.
virtual const std::string getName() const
Gives back the name of this module.
WPropDouble m_translateY
The mesh's translate value along X.
WPropDouble m_opacity
The mesh's opacity value.
void updateMinMax(double &minX, double &maxX, double &minY, double &maxY, double &minZ, double &maxZ, const osg::Vec3d &vector) const
Calculates the bounding box of a vector and increases the specified one if needed.
WPropDouble m_translateX
The mesh's translate value along X.
WPropDouble m_scaleX
The mesh's scale value in X direction.
WPropDouble m_colormapRatio
Set Colormap Ratio.
WGEManagedGroupNode::SPtr m_moduleNode
The node containing all geometry nodes.
WPropBool m_colormap
Turn Colormapping on/off.
osg::ref_ptr< WGEShader > m_shader
The shader for the mesh.
std::shared_ptr< WModuleInputData< WTriangleMesh > > m_meshInput
An input connector used to get meshes from other modules.
std::shared_ptr< WModuleInputData< WColoredVertices > > m_colorMapInput
A map for mapping each vertex to a color.
virtual ~WMTriangleMeshRenderer()
Destructor.
WPropDouble m_translateZ
The mesh's translate value along X.
WPropInt m_nbVertices
Info-property showing the number of vertices in the mesh.
WVector3d m_meshCenter
Center of the mesh.
WPropColor m_color
The color of the mesh to be rendered.
virtual void properties()
Initialize the properties for this module.
double getMedian(double x, double y, double z) const
Gets the median of three values.
WPropSelection m_renderingMode
Which rendering mode should be used?
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...
WPropSelection m_colorMode
Which color mode should be used?
WPropBool m_scale
If true, the mesh scale properties are linked.
WPropTrigger m_setDefault
Set the transformation tool to default.
WPropDouble m_rotateX
The mesh's rotate value around X.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual void moduleMain()
Entry point after loading the module.
WPropDouble m_rotateZ
The mesh's rotate value around Z.
static PtrType createAndAdd(std::shared_ptr< WModule > module, std::string name="", std::string description="")
Convenience method to create a new instance of this in data connector with proper type and add it to ...
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
boost::filesystem::path m_localPath
The path where the module binary resides in.
Definition: WModule.h:734
virtual void properties()
Initialize properties in this function.
Definition: WModule.cpp:212
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
Definition: WModule.cpp:575
wlog::WStreamedLogger warnLog() const
Logger instance for comfortable warning- logs.
Definition: WModule.cpp:580
std::shared_ptr< WProperties > m_properties
The property object for the module.
Definition: WModule.h:640
std::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION".
Definition: WModule.h:647
void ready()
Call this whenever your module is ready and can react on property changes.
Definition: WModule.cpp:505
WConditionSet m_moduleState
The internal state of the module.
Definition: WModule.h:703
WPropBool m_active
True whenever the module should be active.
Definition: WModule.h:723
std::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
Definition: WModule.h:652
virtual void connectors()
Initialize connectors in this function.
Definition: WModule.cpp:208
Class managing progress inside of modules.
Definition: WProgress.h:42
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)
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
std::shared_ptr< std::list< std::shared_ptr< WTriangleMesh > > > componentDecomposition(const WTriangleMesh &mesh)
Decompose the given mesh into connected components.
osg::ref_ptr< osg::Geometry > convertToOsgGeometryLines(WTriangleMesh::SPtr mesh, const WColor &defaultColor=WColor(1.0, 1.0, 1.0, 1.0), bool useMeshColor=true)
Convert triangle mesh to lines representing it.
osg::ref_ptr< osg::Geometry > convertToOsgGeometry(WTriangleMesh::SPtr mesh, const WColor &defaultColor=WColor(1.0, 1.0, 1.0, 1.0), bool includeNormals=false, bool lighting=false, bool useMeshColor=true)
Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry.
osg::ref_ptr< osg::Group > creatCoordinateSystem(osg::Vec3 middle, double sizeX, double sizeY, double sizeZ)
Create a coordinate system.
osg::ref_ptr< osg::Geometry > convertToOsgGeometryFlatShaded(WTriangleMesh::SPtr mesh, const WColor &defaultColor=WColor(1.0, 1.0, 1.0, 1.0), bool includeNormals=false, bool lighting=false, bool useMeshColor=true)
Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry in order ...
const double MAX_DOUBLE
Maximum double value.
Definition: WLimits.cpp:31
const double MIN_DOUBLE
Positive minimum double value.
Definition: WLimits.cpp:36
Compares two WTrianglesMeshes on their size of vertices.
bool operator()(const std::shared_ptr< WTriangleMesh > &m, const std::shared_ptr< WTriangleMesh > &n) const
Comparator on num vertex of two WTriangleMeshes.