OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WSELECTORROI_H 00026 #define WSELECTORROI_H 00027 00028 #include <vector> 00029 00030 #include "../dataHandler/WDataSetFibers.h" 00031 00032 #include "../graphicsEngine/WROI.h" 00033 00034 class WKdTree; 00035 00036 /** 00037 * class implements the updating of a bitfield for a roi 00038 */ 00039 class WSelectorRoi 00040 { 00041 public: 00042 /** 00043 * constructor 00044 * \param roi the roi representation 00045 * \param fibers the fiber dataset to work on 00046 * \param kdTree kd tree for fast intersection checks 00047 */ 00048 WSelectorRoi( osg::ref_ptr< WROI > roi, boost::shared_ptr< const WDataSetFibers > fibers, boost::shared_ptr< WKdTree> kdTree ); 00049 00050 /** 00051 * destructor 00052 */ 00053 ~WSelectorRoi(); 00054 00055 /** 00056 * getter 00057 * \return the bitfield for this ROI 00058 */ 00059 boost::shared_ptr< std::vector<bool> >getBitField(); 00060 00061 /** 00062 * getter 00063 * access to the ROI representation, mainly for delete and update functions 00064 * 00065 * \return Pointer to the ROI representation 00066 */ 00067 osg::ref_ptr< WROI > getRoi(); 00068 00069 /** 00070 * setter 00071 * sets the dirty flag 00072 */ 00073 void setDirty(); 00074 00075 protected: 00076 private: 00077 /** 00078 * updates the output bitfiel when something with the rois has changed 00079 */ 00080 void recalculate(); 00081 00082 /** 00083 * recursive function to check for intersections with the roi 00084 * \param left 00085 * \param right 00086 * \param axis 00087 */ 00088 void boxTest( int left, int right, int axis ); 00089 00090 /** 00091 * getter 00092 * \param point point to check 00093 * \return the index of the line the point is part of 00094 * 00095 */ 00096 size_t getLineForPoint( size_t point ); 00097 00098 /** 00099 * pointer to the roi 00100 */ 00101 osg::ref_ptr< WROI > m_roi; 00102 00103 /** 00104 * Pointer to the fiber data set 00105 */ 00106 boost::shared_ptr< const WDataSetFibers > m_fibers; 00107 00108 /** 00109 * Stores a pointer to the kdTree used for fiber selection 00110 */ 00111 boost::shared_ptr< WKdTree > m_kdTree; 00112 00113 /** 00114 * size of the fiber dataset, stored for convinience 00115 */ 00116 size_t m_size; 00117 00118 /** 00119 * dirty flag 00120 */ 00121 bool m_dirty; 00122 00123 /** 00124 * the bitfield that is given to the outside world 00125 */ 00126 boost::shared_ptr< std::vector<bool> >m_bitField; 00127 00128 /** 00129 * the bitfield we work on 00130 */ 00131 boost::shared_ptr< std::vector<bool> >m_workerBitfield; 00132 00133 /** 00134 * pointer to the array that is used for updating 00135 * this is used for the recurse update function, to reduce the amount of function parameters 00136 */ 00137 boost::shared_ptr< std::vector< float > > m_currentArray; 00138 00139 /** 00140 * pointer to the reverse array that is used for updating 00141 * this is used for the recurse update function, to reduce the amount of function parameters 00142 */ 00143 boost::shared_ptr< std::vector< size_t > > m_currentReverse; 00144 00145 std::vector<float> m_boxMin; //!< lower boundary of the box, used for boxtest 00146 std::vector<float> m_boxMax; //!< upper boundary of the box, used for boxtest 00147 00148 boost::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the selector ROI 00149 }; 00150 00151 inline boost::shared_ptr< std::vector<bool> > WSelectorRoi::getBitField() 00152 { 00153 if( m_dirty ) 00154 { 00155 recalculate(); 00156 } 00157 return m_bitField; 00158 } 00159 00160 inline size_t WSelectorRoi::getLineForPoint( size_t point ) 00161 { 00162 return ( *m_currentReverse )[point]; 00163 } 00164 00165 inline osg::ref_ptr< WROI > WSelectorRoi::getRoi() 00166 { 00167 return m_roi; 00168 } 00169 00170 #endif // WSELECTORROI_H