diff --git a/vcg/space/index/base.h b/vcg/space/index/base.h index 69f0de4e..518da306 100644 --- a/vcg/space/index/base.h +++ b/vcg/space/index/base.h @@ -25,6 +25,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.1 2005/09/28 17:19:28 m_di_benedetto +First Commit. + ****************************************************************************/ @@ -37,6 +40,7 @@ $Log: not supported by cvs2svn $ // vcg headers #include #include +#include namespace vcg { @@ -65,6 +69,7 @@ public: typedef SCALARTYPE ScalarType; typedef ObjType * ObjPtr; typedef Point3 CoordType; + typedef vcg::Box3 BoxType; /************************************************************************** Method Set. @@ -186,7 +191,88 @@ public: (void)_points; return (0); } + + + /************************************************************************** + Method GetInSphere. + Description: + The GetInSphere method finds all the objects in the specified sphere + + Template Parameters: + OBJPOINTDISTFUNCTOR : Object-Point distance functor type; + this type must implement an operator () with signature + bool operator () (const ObjType & obj, const CoordType & p, ScalarType & d, CoordType & q) + where: + obj [IN] is a reference to the current object being tested, + p [IN] is the query point, + d [IN/OUT] is in input the reject distance and in output the closest distance, + q [OUT] is the closest point. + The operator returns true if the closest distance is less than input reject distance. + OBJMARKER : The type of a marker functor. + OBJPTRCONTAINER : The type of a object pointers container. + DISTCONTAINER : The type of a container which, in return, will contain the closest distances. + POINTCONTAINER : The type of a container which, in return, will contain the closest points. + + Method Parameters: + _getPointDistance : [IN] Functor for point-distance calculation. + _marker : [IN] Functor for marking objects already tested. + _p : [IN] The query point. + _r : [IN] The radius of the specified sphere. + _objectPtrs : [OUT] Container which, in return, will contain pointers to the in-sphere objects. + _distances : [OUT] Container which, in return, will contain the in-sphere distances. + _objectPtrs : [OUT] Container which, in return, will contain the in-sphere nearests points for each object. + + Return Value: + The number of in-sphere objects found. + + **************************************************************************/ + template + unsigned int GetInSphere( + OBJPOINTDISTFUNCTOR & _getPointDistance, OBJMARKER & _marker,const CoordType & _p, const ScalarType & _r,OBJPTRCONTAINER & _objectPtrs, DISTCONTAINER & _distances, POINTCONTAINER & _points) { + assert(0); + (void)_getPointDistance; + (void)_marker; + (void)_p; + (void)_r; + (void)_objectPtrs; + (void)_distances; + (void)_points; + return (0); + } + + /************************************************************************** + Method GetInBox. + + Description: + The GetInBox returns all the object in the specified bbox + + Template Parameters: + + OBJMARKER : The type of a marker functor. + OBJPTRCONTAINER : The type of a object pointers container. + + Method Parameters: + _marker : [IN] Functor for marking objects already tested. + _bbox : [IN] The bounding box of spatial query. + _objectPtrs : [OUT] Container which, in return, will contain pointers to the closest objects. + + + Return Value: + The number of in-box objects found. + + **************************************************************************/ + template + unsigned int GetInBox(OBJMARKER & _marker, const BoxType _bbox,OBJPTRCONTAINER & _objectPtrs) { + assert(0); + (void)_marker; + (void)_bbox; + (void)_objectPtrs; + return (0); + } + + + /************************************************************************** Method DoRay. diff --git a/vcg/space/index/grid_static_ptr.h b/vcg/space/index/grid_static_ptr.h index 8ba65e22..443edc2a 100644 --- a/vcg/space/index/grid_static_ptr.h +++ b/vcg/space/index/grid_static_ptr.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.28 2005/10/02 23:15:26 cignoni +Inveted the boolean sign of an assert in Grid() + Revision 1.27 2005/09/30 15:07:28 cignoni Reordered grid access functions Added possibility of setting BBox explicitly in Set(...) @@ -419,7 +422,6 @@ namespace vcg { } - int MemUsed() { return sizeof(GridStaticPtr)+ sizeof(Link)*links.size() + @@ -443,6 +445,29 @@ namespace vcg { OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER>(*this,_getPointDistance,_marker,_k,_p,_maxDist,_objectPtrs,_distances,_points)); } + template + unsigned int GetInSphere(OBJPOINTDISTFUNCTOR & _getPointDistance, + OBJMARKER & _marker, + const CoordType & _p, + const ScalarType & _r, + OBJPTRCONTAINER & _objectPtrs, + DISTCONTAINER & _distances, + POINTCONTAINER & _points) + { + return(vcg::GridGetInSphere + (*this,_getPointDistance,_marker,_p,_r,_maxDist,_objectPtrs,_distances,_points)); + } + + template + unsigned int GetInBox(OBJMARKER & _marker, + const vcg::Box3 _bbox, + OBJPTRCONTAINER & _objectPtrs) + { + return(vcg::GridGetInBox + (*this,_marker,_bbox,_objectPtrs)); + } + template ObjPtr DoRay(OBJRAYISECTFUNCTOR & _rayIntersector, OBJMARKER & _marker, const Ray3 & _ray, const ScalarType & _maxDist, ScalarType & _t) { diff --git a/vcg/space/index/spatial_hashing.h b/vcg/space/index/spatial_hashing.h index c957ca94..3097e3e1 100644 --- a/vcg/space/index/spatial_hashing.h +++ b/vcg/space/index/spatial_hashing.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.11 2005/10/03 10:05:26 pietroni +changed Set functions, added possibility to pass the bbox as parameter + Revision 1.10 2005/09/30 13:14:59 pietroni added wrapping to functions defined in GridClosest: - GetClosest @@ -499,15 +502,41 @@ namespace vcg{ DISTCONTAINER & _distances, POINTCONTAINER & _points) { return (vcg::GridGetKClosest(*this,_getPointDistance,_marker,_k,_p,_maxDist,_objectPtrs,_distances,_points)); + OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER> + (*this,_getPointDistance,_marker,_k,_p,_maxDist,_objectPtrs,_distances,_points)); + } + + template + unsigned int GetInSphere(OBJPOINTDISTFUNCTOR & _getPointDistance, + OBJMARKER & _marker, + const CoordType & _p, + const ScalarType & _r, + OBJPTRCONTAINER & _objectPtrs, + DISTCONTAINER & _distances, + POINTCONTAINER & _points) + { + return(vcg::GridGetInSphere + (*this,_getPointDistance,_marker,_p,_r,_objectPtrs,_distances,_points)); + } + + template + unsigned int GetInBox(OBJMARKER & _marker, + const vcg::Box3 _bbox, + OBJPTRCONTAINER & _objectPtrs) + { + return(vcg::GridGetInBox + (*this,_marker,_bbox,_objectPtrs)); } template ObjPtr DoRay(OBJRAYISECTFUNCTOR & _rayIntersector, OBJMARKER & _marker, const Ray3 & _ray, const ScalarType & _maxDist, ScalarType & _t) { - return(vcg::GridDoRay(*this,_rayIntersector,_marker,_ray,_maxDist,_t)); + return(vcg::GridDoRay + (*this,_rayIntersector,_marker,_ray,_maxDist,_t)); } + }; // end class /** Spatial Hash Table Dynamic