OpenWalnut  1.4.0
WROIArbitrary.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 WROIARBITRARY_H
26 #define WROIARBITRARY_H
27 
28 #include <string>
29 #include <utility>
30 #include <vector>
31 
32 #ifndef Q_MOC_RUN
33 #include <boost/thread.hpp>
34 #endif
35 
36 #include "../common/math/WMatrix.h"
37 #include "../common/WColor.h"
38 #include "WPickHandler.h"
39 #include "WGEViewer.h"
40 
41 #include "WTriangleMesh.h"
42 
43 #include "WROI.h"
44 
45 
46 class WDataSetScalar;
47 
48 /**
49  * A box containing information on an arbitrarily shaped a region of interest.
50  */
51 class WROIArbitrary : public WROI
52 {
53 public:
54  /**
55  * constructor
56  * \param nbCoordsX number of vertices in X direction
57  * \param nbCoordsY number of vertices in Y direction
58  * \param nbCoordsZ number of vertices in Z direction
59  * \param mat the matrix transforming the vertices from canonical space
60  * \param vals the values at the vertices
61  * \param triMesh
62  * \param threshold
63  * \param maxThreshold The maximum of the values.
64  * \param color the color to use for the ROI.
65  */
66  WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
67  const WMatrix< double >& mat,
68  const std::vector< float >& vals,
69  boost::shared_ptr< WTriangleMesh > triMesh,
70  float threshold,
71  float maxThreshold,
72  WColor color );
73 
74  /**
75  * constructor
76  * \param nbCoordsX number of vertices in X direction
77  * \param nbCoordsY number of vertices in Y direction
78  * \param nbCoordsZ number of vertices in Z direction
79  * \param mat the matrix transforming the vertices from canonical space
80  * \param vals the values at the vertices
81  * \param maxThreshold The maximum of the values.
82  * \param color the color to use for the ROI.
83  */
84  WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
85  const WMatrix< double >& mat,
86  const std::vector< float >& vals,
87  float maxThreshold,
88  WColor color );
89 
90 
91  /**
92  * destructor
93  */
94  virtual ~WROIArbitrary();
95 
96  /**
97  * initalizes the properties
98  */
99  void properties();
100 
101  /**
102  * Used as callback to mark a change in the ROI
103  */
104  void propertyChanged();
105 
106  /**
107  * setter
108  * \param threshold
109  */
110  void setThreshold( double threshold );
111 
112  /**
113  * getter
114  *
115  * \return The threshold on the data in box which leads to the arbitrary ROI
116  */
117  double getThreshold();
118 
119  /**
120  * Get the number of vertices in the three coordinate directions
121  *
122  * \return A vector containing the numbers of vertices
123  */
124  std::vector< size_t > getCoordDimensions();
125 
126  /**
127  * Get the vertex offsets in the three coordinate directions
128  *
129  * \return The offsets between point in each of the three coordinate directions
130  */
131  std::vector< double > getCoordOffsets();
132 
133  /**
134  * Get the i-th value of the data defining the ROI
135  * \param i the index of the value
136  *
137  * \return The value at the given index.
138  */
139  float getValue( size_t i );
140 
141  /**
142  * updates the graphics
143  */
144  virtual void updateGFX();
145 
146 protected:
147 private:
148  std::vector< size_t > m_nbCoordsVec; //!< The data's number of vertices in X, Y and Z direction.
149 
150  WMatrix< double > m_matrix; //!< The 4x4 transformation matrix for the vertices.
151 
152  const std::vector< float > m_vals; //!< The data at the vertices.
153 
154  boost::shared_ptr< WTriangleMesh > m_triMesh; //!< This triangle mesh is provided as output through the connector.
155 
156  WPropDouble m_threshold; //!< the threshold
157 
158  /**
159  * The ROI color
160  */
161  WColor m_color;
162 
163  /**
164  * Node callback to handle updates properly
165  */
166  class ROIArbNodeCallback : public osg::NodeCallback
167  {
168  public: // NOLINT
169  /**
170  * operator ()
171  *
172  * \param node the osg node
173  * \param nv the node visitor
174  */
175  virtual void operator()( osg::Node* node, osg::NodeVisitor* nv )
176  {
177  osg::ref_ptr< WROIArbitrary > module = static_cast< WROIArbitrary* > ( node->getUserData() );
178  if( module )
179  {
180  module->updateGFX();
181  }
182  traverse( node, nv );
183  }
184  };
185 };
186 
187 #endif // WROIARBITRARY_H
void propertyChanged()
Used as callback to mark a change in the ROI.
Node callback to handle updates properly.
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
operator ()
boost::shared_ptr< WTriangleMesh > m_triMesh
This triangle mesh is provided as output through the connector.
const std::vector< float > m_vals
The data at the vertices.
double getThreshold()
getter
Superclass for different ROI (region of interest) types.
Definition: WROI.h:47
float getValue(size_t i)
Get the i-th value of the data defining the ROI.
void setThreshold(double threshold)
setter
WMatrix< double > m_matrix
The 4x4 transformation matrix for the vertices.
virtual void updateGFX()
updates the graphics
void properties()
initalizes the properties
A box containing information on an arbitrarily shaped a region of interest.
Definition: WROIArbitrary.h:51
WROIArbitrary(size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ, const WMatrix< double > &mat, const std::vector< float > &vals, boost::shared_ptr< WTriangleMesh > triMesh, float threshold, float maxThreshold, WColor color)
constructor
std::vector< double > getCoordOffsets()
Get the vertex offsets in the three coordinate directions.
This data set type contains scalars as values.
WPropDouble m_threshold
the threshold
std::vector< size_t > getCoordDimensions()
Get the number of vertices in the three coordinate directions.
virtual ~WROIArbitrary()
destructor
WColor m_color
The ROI color.
std::vector< size_t > m_nbCoordsVec
The data's number of vertices in X, Y and Z direction.