- Change to avoid dangerous iterators decrement in RayITerator: reverse iterator used (same as in ClosestIterator)

-removed some old commented code
This commit is contained in:
ganovelli 2008-07-29 16:05:29 +00:00
parent 1a9220ce98
commit 3712ddfd50
1 changed files with 12 additions and 37 deletions

View File

@ -56,7 +56,6 @@ added missing header
#include <vcg/space/intersection3.h>
#include <vcg/space/point3.h>
#include <vcg/space/box3.h>
//#include <vcg/space/point4.h>
#include <vcg/space/ray3.h>
#include <vcg/math/base.h>
#include <algorithm>
@ -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--;
}
CurrentElem=Elems.rbegin();
return((Elems.size()==0)||(Dist()>dist));
}
void operator ++()
{
//if (CurrentElem!=Elems.end())
if (Elems.size()>0)
{
CurrentElem--;
//std::pop_heap<ElemIterator>(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)
@ -330,7 +318,7 @@ namespace vcg{
TMARKER tm;
std::vector<Entry_Type> Elems; //element loaded from curren cell
typedef typename std::vector<Entry_Type>::iterator ElemIterator;
typedef typename std::vector<Entry_Type>::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