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