diff --git a/vcg/space/index/space_iterators.h b/vcg/space/index/space_iterators.h index 85e8404a..4a123609 100644 --- a/vcg/space/index/space_iterators.h +++ b/vcg/space/index/space_iterators.h @@ -56,7 +56,6 @@ added missing header #include #include #include -//#include #include #include #include @@ -251,28 +250,18 @@ namespace vcg{ } } ////then control if there are more than 1 element - if (Elems.size()>1) - std::sort(Elems.begin(),Elems.end()); - - CurrentElem=Elems.end(); - if (Elems.size() > 0) { - CurrentElem--; - } + std::sort(Elems.begin(),Elems.end()); + CurrentElem=Elems.rbegin(); return((Elems.size()==0)||(Dist()>dist)); } void operator ++() { - //if (CurrentElem!=Elems.end()) - if (Elems.size()>0) - { - CurrentElem--; - //std::pop_heap(Elems.begin(),Elems.end()); - Elems.pop_back(); - } - /*if (CurrentElem==Elems.end()) - {*/ + if (!Elems.empty()) Elems.pop_back(); + + CurrentElem = Elems.rbegin(); + if (Dist()>dist) { if (!End()) @@ -296,7 +285,6 @@ namespace vcg{ else return ((ScalarType)FLT_MAX); } - //{return ((*CurrentElem).dist);} ///set the current spatial indexing structure used void SetIndexStructure(Spatial_Idexing &_Si) @@ -323,14 +311,14 @@ namespace vcg{ CoordType intersection; }; - RayType r; //ray to find intersections + RayType r; //ray to find intersections Spatial_Idexing &Si; //reference to spatial index algorithm - bool end; //true if the scan is terminated + bool end; //true if the scan is terminated INTFUNCTOR &int_funct; TMARKER tm; std::vector Elems; //element loaded from curren cell - typedef typename std::vector::iterator ElemIterator; + typedef typename std::vector::reverse_iterator ElemIterator; ElemIterator CurrentElem; //iterator to current element vcg::Point3i CurrentCell; //current cell @@ -429,19 +417,6 @@ namespace vcg{ while ((!End())&& Refresh()&&(!_EndGrid())) _NextShell(); - - /////until don't find an element - /////that is inside the radius - //while ((!End())&&(Dist()>radius)) - //{ - // if ((_NextShell())&&(!_EndGrid())) - // Refresh(); - //} - - ////set to the last element ..the nearest - //CurrentElem=Elems.end(); - //CurrentElem--; - } //return true if the scan is complete @@ -543,12 +518,12 @@ namespace vcg{ CoordType intersection; }; - CoordType p; //initial point + CoordType p; //initial point Spatial_Idexing &Si; //reference to spatial index algorithm - bool end; //true if the scan is terminated + bool end; //true if the scan is terminated ScalarType max_dist; //max distance when the scan terminate vcg::Box3i explored; //current bounding box explored - vcg::Box3i to_explore; //current bounding box explored + vcg::Box3i to_explore; //current bounding box explored ScalarType radius; //curret radius for sphere expansion ScalarType step_size; //radius step std::vector Elems; //element loaded from the current sphere