diff --git a/vcg/complex/trimesh/closest.h b/vcg/complex/trimesh/closest.h index 7a444baa..ab4e3a8d 100644 --- a/vcg/complex/trimesh/closest.h +++ b/vcg/complex/trimesh/closest.h @@ -24,6 +24,11 @@ History $Log: not supported by cvs2svn $ +Revision 1.12 2005/09/21 09:24:30 pietroni +Added RayIterators. +Added ClosestIterators on Triangles and Vertices. +Added Closest Functions on triangles and Vertices. + Revision 1.11 2005/09/19 13:36:24 pietroni added ray iterator of faces @@ -76,7 +81,7 @@ header added #include //#include #include -#include +#include namespace vcg { namespace trimesh { @@ -175,116 +180,10 @@ void Closest( MESH & mesh, const Point3 & p, GRID & gr, SCALAR & mdist, Point3 & normf, Point3 & bestq, typename MESH::FaceType * &f, Point3 &ip) { typedef SCALAR ScalarType; - typedef Point3 Point3x; + typedef Point3 Point3x; typedef Box3 Box3x; - //if(!gr.bbox.IsIn(p)) return; - ////typedef typename GridStaticPtr::Link A2UGridLink; - //typedef typename GRID::Link A2UGridLink; - // scalar ax = p[0] - gr.bbox.min[0]; // Real coodinate of point refer to - // scalar ay = p[1] - gr.bbox.min[1]; - // scalar az = p[2] - gr.bbox.min[2]; - - // int gx = int( ax/gr.voxel[0] ); // Integer coordinate of the point - // int gy = int( ay/gr.voxel[1] ); // voxel - // int gz = int( az/gr.voxel[2] ); - - // scalar vx = gr.bbox.min[0]+gx*gr.voxel[0]; // Real world coordinate of the Voxel - // scalar vy = gr.bbox.min[1]+gy*gr.voxel[1]; // origin - //scalar vz = gr.bbox.min[2]+gz*gr.voxel[2]; - - //scalar dx = math::Min(p[0] - vx, vx+gr.voxel[0]-p[0]); // Dist from the voxel - // scalar dy = math::Min(p[1] - vy, vy+gr.voxel[1]-p[1]); - // scalar dz = math::Min(p[2] - vz, vz+gr.voxel[2]-p[2]); - - //scalar vdist,vstep; - - //if(dxElem()->IsD()) - // { - // if( ! mesh.IsMarked( &*(l->Elem())) ) - // { - // if( face::PointDistance((*(l->Elem())), p, error, q) ) - // { - // bestq = q; - // bestf = l->Elem(); - // } - - // mesh.Mark( &*(l->Elem()) ); - // } - // } - // } - // else - // { - // for(int ix=gx-s;ix<=gx+s;++ix) - // if( ix>=0 && ix=0 && iy=0 && izElem()->IsD()) - // { - // if( ! mesh.IsMarked( &*(l->Elem())) ) - // { - // if( vcg::face::PointDistance((*(l->Elem())), p, error, q) ) - // { - // bestq = q; - // bestf = l->Elem(); - // } - // mesh.Mark(&*l->Elem()); - // } - // } - // } - // } - // } - // } - - // if( fabs(error) MarkerFace; MarkerFace t; @@ -292,7 +191,7 @@ void Closest( MESH & mesh, const Point3 & p, GRID & gr, SCALAR & mdist, typedef typename FaceDistance FDistFunct; typename MESH::FaceType* bestf= vcg::GetClosest(p,mdist,FDistFunct() ,error,bestq,t,gr); - if(mdist > scalar(fabs(error))) + if(mdist > ScalarType(fabs(error))) { f=bestf; typename MESH::ScalarType alfa, beta, gamma; @@ -304,7 +203,7 @@ void Closest( MESH & mesh, const Point3 & p, GRID & gr, SCALAR & mdist, ip=Point3x(alfa,beta,gamma); //normf.Normalize(); inutile si assume le normali ai vertici benfatte - mdist = scalar(fabs(error)); + mdist = ScalarType(fabs(error)); } }