OpenWalnut  1.5.0dev
WMImageSpaceLIC.h
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 #ifndef WMIMAGESPACELIC_H
26 #define WMIMAGESPACELIC_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include "core/dataHandler/WDataSetScalar.h"
33 #include "core/dataHandler/WDataSetVector.h"
34 #include "core/dataHandler/WSubject.h"
35 #include "core/graphicsEngine/WGEManagedGroupNode.h"
36 #include "core/graphicsEngine/WTriangleMesh.h"
37 #include "core/kernel/WModule.h"
38 #include "core/kernel/WModuleInputData.h"
39 
40 /**
41  * This module takes an vector dataset and used it to apply an image space based (fast) LIC to an arbitrary surface. The surface can be specified
42  * as tri mesh or, if not specified, slices.
43  *
44  * \ingroup modules
45  */
46 class WMImageSpaceLIC: public WModule
47 {
48 public:
49  /**
50  * Default constructor.
51  */
53 
54  /**
55  * Destructor.
56  */
57  virtual ~WMImageSpaceLIC();
58 
59  /**
60  * Gives back the name of this module.
61  * \return the module's name.
62  */
63  virtual const std::string getName() const;
64 
65  /**
66  * Gives back a description of this module.
67  * \return description to module.
68  */
69  virtual const std::string getDescription() const;
70 
71  /**
72  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
73  * should never be initialized or modified in some other way. A simple new instance is required.
74  *
75  * \return the prototype used to create every module in OpenWalnut.
76  */
77  virtual std::shared_ptr< WModule > factory() const;
78 
79 protected:
80  /**
81  * Entry point after loading the module. Runs in separate thread.
82  */
83  virtual void moduleMain();
84 
85  /**
86  * Initialize the connectors this module is using.
87  */
88  virtual void connectors();
89 
90  /**
91  * Initialize the properties for this module.
92  */
93  virtual void properties();
94 
95 private:
96  /**
97  * Initializes the needed geodes, transformations and vertex arrays. This needs to be done once for each new dataset.
98  *
99  * \param grid the grid to places the slices in
100  * \param mesh the mesh to use if not NULL and m_useSlices is false
101  */
102  void initOSG( std::shared_ptr< WGridRegular3D > grid, std::shared_ptr< WTriangleMesh > mesh );
103 
104  /**
105  * The input connector containing the vector field.
106  */
107  std::shared_ptr< WModuleInputData< WDataSetVector > > m_vectorsIn;
108 
109  /**
110  * The input connector containing the scalar field whose derived field is used for LIC.
111  */
112  std::shared_ptr< WModuleInputData< WDataSetScalar > > m_scalarIn;
113 
114  /**
115  * The input containing the surface on which the LIC should be applied on
116  */
117  std::shared_ptr< WModuleInputData< WTriangleMesh > > m_meshIn;
118 
119  /**
120  * A property allowing the user to select whether the slices or the mesh should be used
121  */
122  WPropSelection m_geometrySelection;
123 
124  /**
125  * A list of items that can be selected using m_geometrySelection.
126  */
127  std::shared_ptr< WItemSelection > m_geometrySelections;
128 
129  /**
130  * A condition used to notify about changes in several properties.
131  */
132  std::shared_ptr< WCondition > m_propCondition;
133 
134  /**
135  * The Geode containing all the slices and the mesh
136  */
137  osg::ref_ptr< WGEGroupNode > m_output;
138 
139  /**
140  * Scene root node.
141  */
142  osg::ref_ptr< WGEManagedGroupNode > m_root;
143 
144  WPropGroup m_sliceGroup; //!< the group contains several slice properties
145 
146  WPropGroup m_geometryGroup; //!< the group contains several input geometry parameters
147 
148  WPropGroup m_licGroup; //!< the group contains several LIC properties
149 
150  WPropBool m_useSlices; //!< indicates whether the vector should be shown on slices or input geometry
151 
152  WPropInt m_xPos; //!< x position of the slice
153 
154  WPropInt m_yPos; //!< y position of the slice
155 
156  WPropInt m_zPos; //!< z position of the slice
157 
158  WPropBool m_showonX; //!< indicates whether the vector should be shown on slice X
159 
160  WPropBool m_showonY; //!< indicates whether the vector should be shown on slice Y
161 
162  WPropBool m_showonZ; //!< indicates whether the vector should be shown on slice Z
163 
164  WPropBool m_showHUD; //!< indicates whether to show the texture HUD
165 
166  WPropBool m_useEdges; //!< indicates whether to show the edges
167 
168  WPropColor m_useEdgesColor; //!< indicated whether the edges (if enabled) should be black or white or green or red or ....
169 
170  WPropDouble m_useEdgesStep; //!< define the steepness of the step function used to blend in the edge color.
171 
172  WPropBool m_useLight; //!< indicates whether to use Phong
173 
174  WPropDouble m_lightIntensity; //!< light intensity
175 
176  WPropBool m_useDepthCueing; //!< indicates whether to use depth cueing in the shader
177 
178  WPropBool m_useHighContrast; //!< use the high contrast version?
179 
180  WPropInt m_numIters; //!< the number of iterations done per frame
181 
182  WPropDouble m_cmapRatio; //!< the ratio between colormap and LIC
183 
184  WPropDouble m_projectionAngleThreshold; //!< the angle threshold between surface and vector before clipping the vector.
185 
186  /**
187  * The group for more advanced LIC features
188  */
189  WPropGroup m_advancedLicGroup;
190 
191  /**
192  * If true, a 3d noise texture is used for advection
193  */
194  WPropBool m_3dNoise;
195 
196  /**
197  * The resolution scaling for the 3d noise
198  */
199  WPropDouble m_3dNoiseRes;
200 
201  /**
202  * Automatically adapt resolution of 3d texture according to zoom level
203  */
204  WPropBool m_3dNoiseAutoRes;
205 };
206 
207 #endif // WMIMAGESPACELIC_H
208 
This module takes an vector dataset and used it to apply an image space based (fast) LIC to an arbitr...
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
WPropBool m_showonY
indicates whether the vector should be shown on slice Y
WPropBool m_useEdges
indicates whether to show the edges
WPropDouble m_cmapRatio
the ratio between colormap and LIC
WPropInt m_yPos
y position of the slice
WPropBool m_showHUD
indicates whether to show the texture HUD
WPropGroup m_geometryGroup
the group contains several input geometry parameters
WPropInt m_numIters
the number of iterations done per frame
WPropBool m_useLight
indicates whether to use Phong
virtual void moduleMain()
Entry point after loading the module.
WPropColor m_useEdgesColor
indicated whether the edges (if enabled) should be black or white or green or red or ....
WPropGroup m_sliceGroup
the group contains several slice properties
WPropBool m_useHighContrast
use the high contrast version?
WPropBool m_useSlices
indicates whether the vector should be shown on slices or input geometry
std::shared_ptr< WModuleInputData< WTriangleMesh > > m_meshIn
The input containing the surface on which the LIC should be applied on.
std::shared_ptr< WModuleInputData< WDataSetVector > > m_vectorsIn
The input connector containing the vector field.
WPropGroup m_advancedLicGroup
The group for more advanced LIC features.
void initOSG(std::shared_ptr< WGridRegular3D > grid, std::shared_ptr< WTriangleMesh > mesh)
Initializes the needed geodes, transformations and vertex arrays.
virtual const std::string getDescription() const
Gives back a description of this module.
WPropBool m_3dNoiseAutoRes
Automatically adapt resolution of 3d texture according to zoom level.
osg::ref_ptr< WGEManagedGroupNode > m_root
Scene root node.
WPropBool m_showonX
indicates whether the vector should be shown on slice X
WPropDouble m_3dNoiseRes
The resolution scaling for the 3d noise.
WPropDouble m_lightIntensity
light intensity
WPropDouble m_useEdgesStep
define the steepness of the step function used to blend in the edge color.
WPropInt m_xPos
x position of the slice
osg::ref_ptr< WGEGroupNode > m_output
The Geode containing all the slices and the mesh.
WPropGroup m_licGroup
the group contains several LIC properties
WPropInt m_zPos
z position of the slice
WPropBool m_3dNoise
If true, a 3d noise texture is used for advection.
std::shared_ptr< WItemSelection > m_geometrySelections
A list of items that can be selected using m_geometrySelection.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_scalarIn
The input connector containing the scalar field whose derived field is used for LIC.
WPropBool m_useDepthCueing
indicates whether to use depth cueing in the shader
virtual void connectors()
Initialize the connectors this module is using.
virtual ~WMImageSpaceLIC()
Destructor.
WPropSelection m_geometrySelection
A property allowing the user to select whether the slices or the mesh should be used.
virtual void properties()
Initialize the properties for this module.
WPropBool m_showonZ
indicates whether the vector should be shown on slice Z
WMImageSpaceLIC()
Default constructor.
virtual const std::string getName() const
Gives back the name of this module.
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_projectionAngleThreshold
the angle threshold between surface and vector before clipping the vector.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72