Changed Closest Iterators template arguments functor

Corrected Bug in Ray Iterators Added Elems.clear() on Init method
This commit is contained in:
Nico Pietroni 2005-09-20 12:32:33 +00:00
parent 8de0a9f67d
commit 68d1cfee4e
1 changed files with 14 additions and 8 deletions

View File

@ -122,6 +122,7 @@ public:
r=_r; r=_r;
end=false; end=false;
tm.UnMarkAll(); tm.UnMarkAll();
Elems.clear();
//CoordType ip; //CoordType ip;
//control if intersect the bounding box of the mesh //control if intersect the bounding box of the mesh
if(vcg::Intersection<ScalarType>(Si.bbox,r,start)) if(vcg::Intersection<ScalarType>(Si.bbox,r,start))
@ -265,8 +266,7 @@ protected:
}; };
template <class Spatial_Idexing,class DISTFUNCTOR,class TMARKER>
template <class Spatial_Idexing>
class ClosestIterator class ClosestIterator
{ {
typedef typename Spatial_Idexing::ObjType ObjType; typedef typename Spatial_Idexing::ObjType ObjType;
@ -352,7 +352,7 @@ class ClosestIterator
public: public:
///contructor ///contructor
ClosestIterator(Spatial_Idexing &_Si):Si(_Si){} ClosestIterator(Spatial_Idexing &_Si,DISTFUNCTOR _dist_funct):Si(_Si),dist_funct(_dist_funct){}
///set the current spatial indexing structure used ///set the current spatial indexing structure used
void SetIndexStructure(Spatial_Idexing &_Si) void SetIndexStructure(Spatial_Idexing &_Si)
@ -426,10 +426,13 @@ public:
ObjType *elem=&(**l); ObjType *elem=&(**l);
///to change with functor ///to change with functor
ScalarType dist=(elem->P()-p).Norm(); CoordType nearest;
ScalarType dist;
dist_funct((**l),p,dist,nearest);
//ScalarType dist=(elem->P()-p).Norm();
//if (dist>radius_min){ //if (dist>radius_min){
CoordType intersect=elem->P(); //CoordType intersect=elem->P();
Elems.push_back(Entry_Type(elem,fabs(dist),intersect)); Elems.push_back(Entry_Type(elem,fabs(dist),nearest));
//} //}
} }
} }
@ -485,10 +488,10 @@ public:
return ((ScalarType)FLT_MAX); return ((ScalarType)FLT_MAX);
} }
CoordType IntPoint() CoordType NearestPoint()
{return ((*CurrentElem).intersection);} {return ((*CurrentElem).intersection);}
private: protected:
///structure that mantain for the current cell pre-calculated data ///structure that mantain for the current cell pre-calculated data
typedef struct Entry_Type typedef struct Entry_Type
@ -521,6 +524,9 @@ private:
ScalarType voxel_min; //minimum value of the voxel ScalarType voxel_min; //minimum value of the voxel
std::vector<Entry_Type> Elems; //element loaded from the current sphere std::vector<Entry_Type> Elems; //element loaded from the current sphere
DISTFUNCTOR &dist_funct;
TMARKER tm;
typedef typename std::vector<Entry_Type>::iterator ElemIterator; typedef typename std::vector<Entry_Type>::iterator ElemIterator;
ElemIterator CurrentElem; //iterator to current element ElemIterator CurrentElem; //iterator to current element