OpenWalnut  1.5.0dev
WSelectorRoi.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 WSELECTORROI_H
26 #define WSELECTORROI_H
27 
28 #include <memory>
29 #include <vector>
30 
31 #include "../dataHandler/WDataSetFibers.h"
32 #include "../graphicsEngine/WROI.h"
33 
34 class WKdTree;
35 
36 /**
37  * class implements the updating of a bitfield for a roi
38  */
40 {
41 public:
42  /**
43  * constructor
44  * \param roi the roi representation
45  * \param fibers the fiber dataset to work on
46  * \param kdTree kd tree for fast intersection checks
47  */
48  WSelectorRoi( osg::ref_ptr< WROI > roi, std::shared_ptr< const WDataSetFibers > fibers, std::shared_ptr< WKdTree> kdTree );
49 
50  /**
51  * destructor
52  */
53  ~WSelectorRoi();
54 
55  /**
56  * getter
57  * \return the bitfield for this ROI
58  */
59  std::shared_ptr< std::vector<bool> >getBitField();
60 
61  /**
62  * getter
63  * access to the ROI representation, mainly for delete and update functions
64  *
65  * \return Pointer to the ROI representation
66  */
67  osg::ref_ptr< WROI > getRoi();
68 
69  /**
70  * setter
71  * sets the dirty flag
72  */
73  void setDirty();
74 
75 protected:
76 private:
77  /**
78  * updates the output bitfiel when something with the rois has changed
79  */
80  void recalculate();
81 
82  /**
83  * recursive function to check for intersections with the roi
84  * \param left
85  * \param right
86  * \param axis
87  */
88  void boxTest( int left, int right, int axis );
89 
90  /**
91  * getter
92  * \param point point to check
93  * \return the index of the line the point is part of
94  *
95  */
96  size_t getLineForPoint( size_t point );
97 
98  /**
99  * pointer to the roi
100  */
101  osg::ref_ptr< WROI > m_roi;
102 
103  /**
104  * Pointer to the fiber data set
105  */
106  std::shared_ptr< const WDataSetFibers > m_fibers;
107 
108  /**
109  * Stores a pointer to the kdTree used for fiber selection
110  */
111  std::shared_ptr< WKdTree > m_kdTree;
112 
113  /**
114  * size of the fiber dataset, stored for convinience
115  */
116  size_t m_size;
117 
118  /**
119  * dirty flag
120  */
121  bool m_dirty;
122 
123  /**
124  * the bitfield that is given to the outside world
125  */
126  std::shared_ptr< std::vector<bool> >m_bitField;
127 
128  /**
129  * the bitfield we work on
130  */
131  std::shared_ptr< std::vector<bool> >m_workerBitfield;
132 
133  /**
134  * pointer to the array that is used for updating
135  * this is used for the recurse update function, to reduce the amount of function parameters
136  */
137  std::shared_ptr< std::vector< float > > m_currentArray;
138 
139  /**
140  * pointer to the reverse array that is used for updating
141  * this is used for the recurse update function, to reduce the amount of function parameters
142  */
143  std::shared_ptr< std::vector< size_t > > m_currentReverse;
144 
145  std::vector<float> m_boxMin; //!< lower boundary of the box, used for boxtest
146  std::vector<float> m_boxMax; //!< upper boundary of the box, used for boxtest
147 
148  std::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the selector ROI
149 };
150 
151 inline std::shared_ptr< std::vector<bool> > WSelectorRoi::getBitField()
152 {
153  if( m_dirty )
154  {
155  recalculate();
156  }
157  return m_bitField;
158 }
159 
160 inline size_t WSelectorRoi::getLineForPoint( size_t point )
161 {
162  return ( *m_currentReverse )[point];
163 }
164 
165 inline osg::ref_ptr< WROI > WSelectorRoi::getRoi()
166 {
167  return m_roi;
168 }
169 
170 #endif // WSELECTORROI_H
implements the computation of a kd tree on a point array
Definition: WKdTree.h:106
class implements the updating of a bitfield for a roi
Definition: WSelectorRoi.h:40
std::shared_ptr< std::vector< float > > m_currentArray
pointer to the array that is used for updating this is used for the recurse update function,...
Definition: WSelectorRoi.h:137
std::shared_ptr< const WDataSetFibers > m_fibers
Pointer to the fiber data set.
Definition: WSelectorRoi.h:106
void recalculate()
updates the output bitfiel when something with the rois has changed
void boxTest(int left, int right, int axis)
recursive function to check for intersections with the roi
std::shared_ptr< std::vector< size_t > > m_currentReverse
pointer to the reverse array that is used for updating this is used for the recurse update function,...
Definition: WSelectorRoi.h:143
WSelectorRoi(osg::ref_ptr< WROI > roi, std::shared_ptr< const WDataSetFibers > fibers, std::shared_ptr< WKdTree > kdTree)
constructor
std::vector< float > m_boxMin
lower boundary of the box, used for boxtest
Definition: WSelectorRoi.h:145
std::shared_ptr< WKdTree > m_kdTree
Stores a pointer to the kdTree used for fiber selection.
Definition: WSelectorRoi.h:111
size_t getLineForPoint(size_t point)
getter
Definition: WSelectorRoi.h:160
osg::ref_ptr< WROI > m_roi
pointer to the roi
Definition: WSelectorRoi.h:101
std::shared_ptr< std::vector< bool > > getBitField()
getter
Definition: WSelectorRoi.h:151
size_t m_size
size of the fiber dataset, stored for convinience
Definition: WSelectorRoi.h:116
std::vector< float > m_boxMax
upper boundary of the box, used for boxtest
Definition: WSelectorRoi.h:146
~WSelectorRoi()
destructor
bool m_dirty
dirty flag
Definition: WSelectorRoi.h:121
std::shared_ptr< boost::function< void() > > m_changeRoiSignal
Signal that can be used to update the selector ROI.
Definition: WSelectorRoi.h:148
osg::ref_ptr< WROI > getRoi()
getter access to the ROI representation, mainly for delete and update functions
Definition: WSelectorRoi.h:165
void setDirty()
setter sets the dirty flag
std::shared_ptr< std::vector< bool > > m_bitField
the bitfield that is given to the outside world
Definition: WSelectorRoi.h:126
std::shared_ptr< std::vector< bool > > m_workerBitfield
the bitfield we work on
Definition: WSelectorRoi.h:131