added GetInSphere and GetInBox functions

This commit is contained in:
Nico Pietroni 2005-10-03 13:58:21 +00:00
parent 3fd167568f
commit 3a54e6d7c3
3 changed files with 143 additions and 3 deletions

View File

@ -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 <vcg/space/point3.h>
#include <vcg/space/ray3.h>
#include <vcg/space/box3.h>
namespace vcg {
@ -65,6 +69,7 @@ public:
typedef SCALARTYPE ScalarType;
typedef ObjType * ObjPtr;
typedef Point3<ScalarType> CoordType;
typedef vcg::Box3<ScalarType> 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 <class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
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 <class OBJMARKER, class OBJPTRCONTAINER>
unsigned int GetInBox(OBJMARKER & _marker, const BoxType _bbox,OBJPTRCONTAINER & _objectPtrs) {
assert(0);
(void)_marker;
(void)_bbox;
(void)_objectPtrs;
return (0);
}
/**************************************************************************
Method DoRay.

View File

@ -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 <class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
unsigned int GetInSphere(OBJPOINTDISTFUNCTOR & _getPointDistance,
OBJMARKER & _marker,
const CoordType & _p,
const ScalarType & _r,
OBJPTRCONTAINER & _objectPtrs,
DISTCONTAINER & _distances,
POINTCONTAINER & _points)
{
return(vcg::GridGetInSphere<GridPtrType,
OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER>
(*this,_getPointDistance,_marker,_p,_r,_maxDist,_objectPtrs,_distances,_points));
}
template <class OBJMARKER, class OBJPTRCONTAINER>
unsigned int GetInBox(OBJMARKER & _marker,
const vcg::Box3<typename ScalarType> _bbox,
OBJPTRCONTAINER & _objectPtrs)
{
return(vcg::GridGetInBox<GridPtrType,OBJMARKER,OBJPTRCONTAINER>
(*this,_marker,_bbox,_objectPtrs));
}
template <class OBJRAYISECTFUNCTOR, class OBJMARKER>
ObjPtr DoRay(OBJRAYISECTFUNCTOR & _rayIntersector, OBJMARKER & _marker, const Ray3<ScalarType> & _ray, const ScalarType & _maxDist, ScalarType & _t)
{

View File

@ -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<SpatialHashType,
OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER>(*this,_getPointDistance,_marker,_k,_p,_maxDist,_objectPtrs,_distances,_points));
OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER>
(*this,_getPointDistance,_marker,_k,_p,_maxDist,_objectPtrs,_distances,_points));
}
template <class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
unsigned int GetInSphere(OBJPOINTDISTFUNCTOR & _getPointDistance,
OBJMARKER & _marker,
const CoordType & _p,
const ScalarType & _r,
OBJPTRCONTAINER & _objectPtrs,
DISTCONTAINER & _distances,
POINTCONTAINER & _points)
{
return(vcg::GridGetInSphere<SpatialHashType,
OBJPOINTDISTFUNCTOR,OBJMARKER,OBJPTRCONTAINER,DISTCONTAINER,POINTCONTAINER>
(*this,_getPointDistance,_marker,_p,_r,_objectPtrs,_distances,_points));
}
template <class OBJMARKER, class OBJPTRCONTAINER>
unsigned int GetInBox(OBJMARKER & _marker,
const vcg::Box3<typename ScalarType> _bbox,
OBJPTRCONTAINER & _objectPtrs)
{
return(vcg::GridGetInBox<SpatialHashType,OBJMARKER,OBJPTRCONTAINER>
(*this,_marker,_bbox,_objectPtrs));
}
template <class OBJRAYISECTFUNCTOR, class OBJMARKER>
ObjPtr DoRay(OBJRAYISECTFUNCTOR & _rayIntersector, OBJMARKER & _marker, const Ray3<ScalarType> & _ray, const ScalarType & _maxDist, ScalarType & _t)
{
return(vcg::GridDoRay<SpatialHashType,OBJRAYISECTFUNCTOR,OBJMARKER>(*this,_rayIntersector,_marker,_ray,_maxDist,_t));
return(vcg::GridDoRay<SpatialHashType,OBJRAYISECTFUNCTOR,OBJMARKER>
(*this,_rayIntersector,_marker,_ray,_maxDist,_t));
}
}; // end class
/** Spatial Hash Table Dynamic