From dfc6417426755de64e289aff1f3401a8a9eb8cc3 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Fri, 31 Oct 2008 10:40:06 +0000 Subject: [PATCH] Changed IPToP calls into IPiToPf, Markers passed by reference --- vcg/space/index/space_iterators.h | 82 +++++++++++++++---------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/vcg/space/index/space_iterators.h b/vcg/space/index/space_iterators.h index df4f08cd..806a5d31 100644 --- a/vcg/space/index/space_iterators.h +++ b/vcg/space/index/space_iterators.h @@ -63,7 +63,7 @@ added missing header #include namespace vcg{ - template + template class RayIterator { public: @@ -84,7 +84,7 @@ namespace vcg{ vcg::Point3i dim=Si.siz; if (CurrentCell.V(i)<0) CurrentCell.V(i) = 0; - else + else if (CurrentCell.V(i)>=dim.V(i)) CurrentCell.V(i)=dim.V(i)-1; } @@ -98,16 +98,16 @@ namespace vcg{ ///da verificare se vanno oltre ai limiti vcg::Point3i ip; Si.PToIP(start,ip); - Si.IPToP(ip,goal); + Si.IPiToPf(ip,goal); for (int i=0;i<3;i++) - if(r.Direction().V(i)>0.0) + if(r.Direction().V(i)>0.0) goal.V(i)+=Si.voxel.V(i); ScalarType gx=goal.X(); ScalarType gy=goal.Y(); ScalarType gz=goal.Z(); - dist=(r.Origin()-goal).Norm(); + dist=(r.Origin()-goal).Norm(); const float LocalMaxScalar = (std::numeric_limits::max)(); const float EPSILON = 1e-50f; @@ -115,19 +115,19 @@ namespace vcg{ /* Parametri della linea */ ScalarType tx,ty,tz; - if( fabs(r.Direction().X())>EPSILON ) + if( fabs(r.Direction().X())>EPSILON ) tx = (gx-r.Origin().X())/r.Direction().X(); - else + else tx =LocalMaxScalar; if( fabs(r.Direction().Y())>EPSILON ) ty = (gy-r.Origin().Y())/r.Direction().Y(); - else + else ty =LocalMaxScalar; - if( fabs(r.Direction().Z())>EPSILON ) + if( fabs(r.Direction().Z())>EPSILON ) tz = (gz-r.Origin().Z())/r.Direction().Z(); - else + else tz =LocalMaxScalar; t=CoordType(tx,ty,tz); @@ -144,8 +144,8 @@ namespace vcg{ assert(!end); vcg::Box3 bb_current; - Si.IPToP(CurrentCell,bb_current.min); - Si.IPToP(CurrentCell+vcg::Point3i(1,1,1),bb_current.max); + Si.IPiToPf(CurrentCell,bb_current.min); + Si.IPiToPf(CurrentCell+vcg::Point3i(1,1,1),bb_current.max); CoordType inters; Intersection_Ray_Box(bb_current,r,inters); @@ -157,20 +157,20 @@ namespace vcg{ { if( t.X()dist) @@ -282,7 +282,7 @@ namespace vcg{ { if (Elems.size()>0) return ((*CurrentElem).dist); - else + else return ((ScalarType)FLT_MAX); } @@ -294,7 +294,7 @@ namespace vcg{ protected: - ///structure that mantain for the current cell pre-calculated data + ///structure that mantain for the current cell pre-calculated data struct Entry_Type { public: @@ -305,7 +305,7 @@ namespace vcg{ dist=_dist; intersection=_intersection; } - inline bool operator < ( const Entry_Type & l ) const{return (dist > l.dist); } + inline bool operator < ( const Entry_Type & l ) const{return (dist > l.dist); } ObjType* elem; ScalarType dist; CoordType intersection; @@ -315,7 +315,7 @@ namespace vcg{ Spatial_Idexing &Si; //reference to spatial index algorithm bool end; //true if the scan is terminated INTFUNCTOR &int_funct; - TMARKER tm; + TMARKER& tm; std::vector Elems; //element loaded from curren cell typedef typename std::vector::reverse_iterator ElemIterator; @@ -325,16 +325,16 @@ namespace vcg{ //used for raterization CoordType start; - CoordType goal; + CoordType goal; ScalarType dist; CoordType t; }; - - template + + template class ClosestIterator - { + { typedef typename Spatial_Idexing::ObjType ObjType; typedef typename Spatial_Idexing::ScalarType ScalarType; typedef typename vcg::Point3 CoordType; @@ -375,7 +375,7 @@ namespace vcg{ if (!to_explore.IsNull()) { assert(!( to_explore.min.X()<0 || to_explore.max.X()>=Si.siz[0] || - to_explore.min.Y()<0 || to_explore.max.Y()>=Si.siz[1] || to_explore.min.Z()<0 + to_explore.min.Y()<0 || to_explore.max.Y()>=Si.siz[1] || to_explore.min.Z()<0 || to_explore.max.Z()>=Si.siz[2] )); return true; } @@ -423,7 +423,7 @@ namespace vcg{ bool End() {return end;} - ///refresh Object found also considering current shere radius, + ///refresh Object found also considering current shere radius, //and object comes from previos that are already in the stack //return false if no elements find bool Refresh() @@ -435,7 +435,7 @@ namespace vcg{ { // this test is to avoid to re-process already analyzed cells. if((explored.IsNull())|| - (ixexplored.max[0] || + (ixexplored.max[0] || iyexplored.max[1] || izexplored.max[2] )) { @@ -472,23 +472,23 @@ namespace vcg{ void operator ++() { if (!Elems.empty()) Elems.pop_back(); - + CurrentElem = Elems.rbegin(); if ((!End())&& ToUpdate()) while ((!End())&& Refresh()&&(!_EndGrid())) _NextShell(); } - + ObjType &operator *(){return *((*CurrentElem).elem);} - //return distance of the element form the point if no element + //return distance of the element form the point if no element //are in the vector then return max dinstance ScalarType Dist() { if (Elems.size()>0) return ((*CurrentElem).dist); - else + else return ((ScalarType)FLT_MAX); } @@ -497,7 +497,7 @@ namespace vcg{ protected: - ///structure that mantain for the current cell pre-calculated data + ///structure that mantain for the current cell pre-calculated data struct Entry_Type { public: @@ -509,9 +509,9 @@ namespace vcg{ intersection=_intersection; } - inline bool operator < ( const Entry_Type & l ) const{return (dist > l.dist); } + inline bool operator < ( const Entry_Type & l ) const{return (dist > l.dist); } - inline bool operator == ( const Entry_Type & l ) const{return (elem == l.elem); } + inline bool operator == ( const Entry_Type & l ) const{return (elem == l.elem); } ObjType* elem; ScalarType dist;