From 6416a20ba2935d1f1e4c19156e85922ce3fae17e Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Fri, 30 Sep 2005 13:13:47 +0000 Subject: [PATCH] changing order of parameter for functor calling (distance to point, intersection to ray...) --- vcg/space/index/space_iterators.h | 51 +++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/vcg/space/index/space_iterators.h b/vcg/space/index/space_iterators.h index b2e2478b..c91cbcb0 100644 --- a/vcg/space/index/space_iterators.h +++ b/vcg/space/index/space_iterators.h @@ -1,11 +1,16 @@ +#ifndef __VCGLIB_SPATIAL_ITERATORS +#define __VCGLIB_SPATIAL_ITERATORS + #include +//#include +#include #include +//#include +#include +#include #include #include -#include -#include //to remove -#ifndef _VCG_SPACE_ITERATORS -#define _VCG_SPACE_ITERATORS + namespace vcg{ template @@ -15,7 +20,7 @@ protected: typedef typename Spatial_Idexing::ObjType ObjType; typedef typename Spatial_Idexing::ScalarType ScalarType; typedef typename vcg::Point3 CoordType; - typedef typename vcg::Line3 RayType; + typedef typename vcg::Ray3 RayType; typedef typename Spatial_Idexing::CellIterator CellIterator; ///control right bonding current cell index (only on initialization) @@ -116,8 +121,13 @@ public: ///contructor RayIterator(Spatial_Idexing &_Si,INTFUNCTOR _int_funct):Si(_Si),int_funct(_int_funct){ }; + + void SetMarker(TMARKER _tm) + { + tm=_tm; + } - void Init(RayType _r) + void Init(const RayType _r) { r=_r; end=false; @@ -125,7 +135,7 @@ public: Elems.clear(); //CoordType ip; //control if intersect the bounding box of the mesh - if(vcg::Intersection(Si.bbox,r,start)) + if(vcg::Intersection_Ray_Box(Si.bbox,r,start)) { Si.PToIP(start,CurrentCell); _ControlLimits(); @@ -155,25 +165,14 @@ public: for(l=first;l!=last;++l) { ObjType* elem=&(*(*l)); - /* CoordType p0 = elem->V(0)->P(); - CoordType p1 = elem->V(1)->P(); - CoordType p2 = elem->V(2)->P();*/ - - //ScalarType dist=0; + ScalarType t; CoordType Int; - if((!tm.IsMarked(elem))&&(int_funct((**l),r,Int))) + if((!tm.IsMarked(elem))&&(int_funct((**l),r,t))) { - Elems.push_back(Entry_Type(elem,(r.Origin()-Int).Norm(),Int)); - //std::push_heap(Elems.begin(),Elems.end()); + Int=r.Origin()+r.Direction()*t; + Elems.push_back(Entry_Type(elem,t,Int)); tm.Mark(elem); } - - /////different types of intersections as required - //if ((!_Unique)&&(_DoubleIntersect(r,p0,p1,p2,Int))) - // Elems.push_back(Entry_Type(elem,(r.Origin()-Int).Norm(),Int)); - //else - //if ((_Unique)&&(_UniqueIntersection(r,p0,p1,p2,Int))) - // Elems.push_back(Entry_Type(elem,(r.Origin()-Int).Norm(),Int)); } ////then control if there are more than 1 element if (Elems.size()>1) @@ -361,6 +360,11 @@ public: void SetIndexStructure(Spatial_Idexing &_Si) {Si=_Si;} + void SetMarker(TMARKER _tm) + { + tm=_tm; + } + ///initialize the Itarator void Init(CoordType _p,const ScalarType &_max_dist) { @@ -433,7 +437,7 @@ public: { CoordType nearest; - ScalarType dist; + ScalarType dist=Si.bbox.Diag(); dist_funct((**l),p,dist,nearest); Elems.push_back(Entry_Type(elem,fabs(dist),nearest)); tm.Mark(elem); @@ -536,4 +540,5 @@ protected: }; } + #endif \ No newline at end of file