OpenWalnut 1.3.1
|
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 WFIBERSELECTOR_H 00026 #define WFIBERSELECTOR_H 00027 00028 #include <list> 00029 #include <vector> 00030 00031 #include "../dataHandler/WDataSetFibers.h" 00032 00033 #include "WSelectorRoi.h" 00034 #include "WSelectorBranch.h" 00035 00036 #include "WKdTree.h" 00037 00038 00039 00040 /** 00041 * Adaptor class between the roi manager and the fiber display 00042 */ 00043 class WFiberSelector // NOLINT 00044 { 00045 public: 00046 /** 00047 * constructor 00048 * \param fibers pointer to the datset this selector works on 00049 */ 00050 explicit WFiberSelector( boost::shared_ptr< const WDataSetFibers > fibers ); 00051 00052 /** 00053 * destructor 00054 */ 00055 ~WFiberSelector(); 00056 00057 /** 00058 * Return the number of fibers in the dataset. 00059 * 00060 * \return number of fibers 00061 */ 00062 size_t size(); 00063 00064 /** 00065 * getter 00066 * \return the bitfield calculated from all active rois 00067 */ 00068 boost::shared_ptr< std::vector< bool > > getBitfield(); 00069 00070 /** 00071 * getter for the line start index array 00072 * \return line starts 00073 */ 00074 boost::shared_ptr< std::vector< size_t > > getStarts(); 00075 00076 /** 00077 * getter for the line length array 00078 * \return line lengths 00079 */ 00080 boost::shared_ptr< std::vector< size_t > > getLengths(); 00081 00082 /** 00083 * setter 00084 * sets the dirty flag 00085 */ 00086 void setDirty(); 00087 00088 protected: 00089 /** 00090 * listener function for inserting rois 00091 * \param roi new roi inserted into the roi structure 00092 */ 00093 void slotAddRoi( osg::ref_ptr< WROI > roi ); 00094 00095 /** 00096 * listener function for removing rois 00097 * \param roi roi that is being removed 00098 */ 00099 void slotRemoveRoi( osg::ref_ptr< WROI > roi ); 00100 00101 /** 00102 * listener function for removing rois 00103 * \param branch branch that is being removed 00104 */ 00105 void slotRemoveBranch( boost::shared_ptr< WRMBranch > branch ); 00106 00107 private: 00108 /** 00109 * update the bitfield when there was a change in the roi structure 00110 */ 00111 void recalculate(); 00112 00113 /** 00114 * Pointer to the fiber data set 00115 */ 00116 boost::shared_ptr< const WDataSetFibers > m_fibers; 00117 00118 size_t m_size; //!< number of fibers in the dataset 00119 00120 bool m_dirty; //!< dirty flag 00121 00122 /** 00123 * Stores a pointer to the kdTree used for fiber selection 00124 */ 00125 boost::shared_ptr< WKdTree > m_kdTree; 00126 00127 boost::shared_ptr< std::vector< bool > >m_outputBitfield; //!< bit field of activated fibers 00128 00129 boost::shared_ptr< std::vector< bool > >m_workerBitfield; //!< bit field of activated fibers 00130 00131 std::list< boost::shared_ptr<WSelectorBranch> >m_branches; //!< list of branches int he roi structure 00132 00133 boost::shared_ptr< boost::function< void( osg::ref_ptr< WROI > ) > > m_assocRoiSignal; //!< Signal that can be used to update the selector 00134 boost::shared_ptr< boost::function< void( osg::ref_ptr< WROI > ) > > m_removeRoiSignal; //!< Signal that can be used to update the selector 00135 boost::shared_ptr< boost::function< void( boost::shared_ptr< WRMBranch > ) > > m_removeBranchSignal; //!< Signal for updating the selector 00136 boost::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the selector 00137 }; 00138 00139 inline size_t WFiberSelector::size() 00140 { 00141 return m_size; 00142 } 00143 00144 inline boost::shared_ptr< std::vector< size_t > > WFiberSelector::getStarts() 00145 { 00146 return m_fibers->getLineStartIndexes(); 00147 } 00148 00149 inline boost::shared_ptr< std::vector< size_t > > WFiberSelector::getLengths() 00150 { 00151 return m_fibers->getLineLengths(); 00152 } 00153 00154 #endif // WFIBERSELECTOR_H