Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef PCL_OUTOFCORE_DEPTH_FIRST_ITERATOR_IMPL_H_
00040 #define PCL_OUTOFCORE_DEPTH_FIRST_ITERATOR_IMPL_H_
00041
00042 namespace pcl
00043 {
00044 namespace outofcore
00045 {
00046
00047 template<typename PointT, typename ContainerT>
00048 OutofcoreDepthFirstIterator<PointT, ContainerT>::OutofcoreDepthFirstIterator (OutofcoreOctreeBase<ContainerT, PointT>& octree_arg)
00049 : OutofcoreIteratorBase<PointT, ContainerT> (octree_arg)
00050 , currentChildIdx_ (0)
00051 , stack_ (0)
00052 {
00053 stack_.reserve (this->octree_.getTreeDepth ());
00054 OutofcoreIteratorBase<PointT,ContainerT>::reset ();
00055 }
00056
00058
00059 template<typename PointT, typename ContainerT>
00060 OutofcoreDepthFirstIterator<PointT, ContainerT>::~OutofcoreDepthFirstIterator ()
00061 {
00062 }
00063
00065
00066 template<typename PointT, typename ContainerT>
00067 OutofcoreDepthFirstIterator<PointT, ContainerT>&
00068 OutofcoreDepthFirstIterator<PointT, ContainerT>::operator++ ()
00069 {
00070
00071 if (this->currentNode_)
00072 {
00073 bool bTreeUp = false;
00074 OutofcoreOctreeBaseNode<ContainerT, PointT>* itNode = 0;
00075
00076 if (this->currentNode_->getNodeType () == pcl::octree::BRANCH_NODE)
00077 {
00078 BranchNode* currentBranch = static_cast<BranchNode*> (this->currentNode_);
00079
00080 if (currentChildIdx_ < 8)
00081 {
00082 itNode = this->octree_.getBranchChildPtr (*currentBranch, currentChildIdx_);
00083
00084
00085 while ((currentChildIdx_ < 7) && !(itNode))
00086 {
00087
00088 currentChildIdx_++;
00089 itNode = this->octree_.getBranchChildPtr (*currentBranch, currentChildIdx_);
00090 }
00091
00092 if (!itNode)
00093 {
00094 bTreeUp = true;
00095 }
00096 }
00097 else
00098 {
00099 bTreeUp = true;
00100 }
00101 }
00102 else
00103 {
00104 bTreeUp = true;
00105 }
00106
00107 if (bTreeUp)
00108 {
00109 if (stack_.size () > 0)
00110 {
00111 std::pair<OutofcoreOctreeBaseNode<ContainerT, PointT>*, unsigned char>& stackEntry = stack_.back ();
00112 stack_.pop_back ();
00113
00114 this->currentNode_ = stackEntry.first;
00115 currentChildIdx_ = stackEntry.second;
00116
00117
00118 this->currentOctreeDepth_--;
00119 }
00120 else
00121 {
00122 this->currentNode_ = NULL;
00123 }
00124
00125 }
00126 else
00127 {
00128 std::pair<OutofcoreOctreeBaseNode<ContainerT, PointT>*, unsigned char> newStackEntry;
00129 newStackEntry.first = this->currentNode_;
00130 newStackEntry.second = static_cast<unsigned char> (currentChildIdx_+1);
00131
00132 stack_.push_back (newStackEntry);
00133
00134
00135
00136 this->currentOctreeDepth_++;
00137 currentChildIdx_= 0;
00138 this->currentNode_ = itNode;
00139 }
00140 }
00141
00142 return (*this);
00143 }
00144
00146
00147 }
00148 }
00149
00150 #endif //PCL_OUTOFCORE_DEPTH_FIRST_ITERATOR_IMPL_H_
00151