OpenWalnut  1.5.0dev
WMApplyMask.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 WMAPPLYMASK_H
26 #define WMAPPLYMASK_H
27 
28 #include <map>
29 #include <memory>
30 #include <string>
31 #include <vector>
32 
33 #include <osg/Geode>
34 #include <osg/Node>
35 #include <osg/Uniform>
36 
37 #include "core/dataHandler/WDataSetScalar.h"
38 #include "core/kernel/WModule.h"
39 #include "core/kernel/WModuleInputData.h"
40 
41 
42 class WPickHandler;
43 
44 /**
45  * Set all voxels in a dataset to zero if the other dataset is zero there.
46  *
47  * \ingroup modules
48  */
49 
50 class WMApplyMask : public WModule
51 {
52 public:
53  /**
54  * Standard constructor.
55  */
56  WMApplyMask();
57 
58  /**
59  * Destructor.
60  */
61  ~WMApplyMask();
62 
63  /**
64  * Gives back the name of this module.
65  * \return the module's name.
66  */
67  virtual const std::string getName() const;
68 
69  /**
70  * Gives back a description of this module.
71  * \return description of module.
72  */
73  virtual const std::string getDescription() const;
74 
75  /**
76  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
77  * should never be initialized or modified in some other way. A simple new instance is required.
78  *
79  * \return the prototype used to create every module in OpenWalnut.
80  */
81  virtual std::shared_ptr< WModule > factory() const;
82 
83  /**
84  * Get the icon for this module in XPM format.
85  * \return The icon.
86  */
87  virtual const char** getXPMIcon() const;
88 
89 
90 protected:
91  /**
92  * Entry point after loading the module. Runs in separate thread.
93  */
94  virtual void moduleMain();
95 
96  /**
97  * Initialize the connectors this module is using.
98  */
99  virtual void connectors();
100 
101  /**
102  * Initialize the properties for this module.
103  */
104  virtual void properties();
105 
106 private:
107  /**
108  * Apply the mask to the data.
109  * \param valSet the values which are set to zero if the mask is zero
110  * \param type The enumeration representing of the data type of contained in the value set.
111  */
112  template< typename T > void applyMask( std::shared_ptr< WValueSet< T > > valSet, dataType type );
113 
114  std::shared_ptr< WModuleInputData< WDataSetScalar > > m_dataInput; //!< Input connector for getting the data.
115  std::shared_ptr< WModuleInputData< WDataSetScalar > > m_maskInput; //!< Input connector for getting the mask.
116  std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output; //!< The only output of this mask module.
117  std::shared_ptr< WDataSetScalar > m_dataSet; //!< Pointer providing access to the data set in the whole module.
118  std::shared_ptr< WDataSetScalar > m_dataSetOut; //!< Pointer providing access to the resulting data set in the whole module.
119  std::shared_ptr< WDataSetScalar > m_mask; //!< Pointer providing access to the mask in the whole module.
120 };
121 
122 #endif // WMAPPLYMASK_H
Set all voxels in a dataset to zero if the other dataset is zero there.
Definition: WMApplyMask.h:51
WMApplyMask()
Standard constructor.
Definition: WMApplyMask.cpp:43
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...
Definition: WMApplyMask.cpp:56
std::shared_ptr< WDataSetScalar > m_dataSet
Pointer providing access to the data set in the whole module.
Definition: WMApplyMask.h:117
virtual void connectors()
Initialize the connectors this module is using.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_dataInput
Input connector for getting the data.
Definition: WMApplyMask.h:114
virtual void moduleMain()
Entry point after loading the module.
Definition: WMApplyMask.cpp:76
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
Definition: WMApplyMask.cpp:61
virtual void properties()
Initialize the properties for this module.
std::shared_ptr< WDataSetScalar > m_mask
Pointer providing access to the mask in the whole module.
Definition: WMApplyMask.h:119
void applyMask(std::shared_ptr< WValueSet< T > > valSet, dataType type)
Apply the mask to the data.
virtual const std::string getName() const
Gives back the name of this module.
Definition: WMApplyMask.cpp:66
virtual const std::string getDescription() const
Gives back a description of this module.
Definition: WMApplyMask.cpp:71
~WMApplyMask()
Destructor.
Definition: WMApplyMask.cpp:50
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_maskInput
Input connector for getting the mask.
Definition: WMApplyMask.h:115
std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output
The only output of this mask module.
Definition: WMApplyMask.h:116
std::shared_ptr< WDataSetScalar > m_dataSetOut
Pointer providing access to the resulting data set in the whole module.
Definition: WMApplyMask.h:118
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
Class to handle events with a pick.
Definition: WPickHandler.h:44
Base Class for all value set types.
Definition: WValueSet.h:47
dataType
Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense to...