added GridGetInSphere and GridGetInBox functions
This commit is contained in:
parent
bccc1ad129
commit
3fd167568f
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.5 2005/10/02 23:18:06 cignoni
|
||||||
|
Small bug in the computation of the intersection between the todo box and the grid bbox that failed for extrema points.
|
||||||
|
|
||||||
Revision 1.4 2005/09/30 15:12:16 cignoni
|
Revision 1.4 2005/09/30 15:12:16 cignoni
|
||||||
Completely rewrote the GridClosest, now it:
|
Completely rewrote the GridClosest, now it:
|
||||||
- works for point out of the grid
|
- works for point out of the grid
|
||||||
|
@ -154,10 +157,15 @@ namespace vcg{
|
||||||
|
|
||||||
template <class SPATIALINDEXING,class OBJPOINTDISTFUNCTOR, class OBJMARKER,
|
template <class SPATIALINDEXING,class OBJPOINTDISTFUNCTOR, class OBJMARKER,
|
||||||
class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
|
class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
|
||||||
unsigned int GridGetKClosest(SPATIALINDEXING &_Si,OBJPOINTDISTFUNCTOR & _getPointDistance,
|
unsigned int GridGetKClosest(SPATIALINDEXING &_Si,
|
||||||
OBJMARKER & _marker, const unsigned int _k, const typename SPATIALINDEXING::CoordType & _p,
|
OBJPOINTDISTFUNCTOR & _getPointDistance,
|
||||||
const typename SPATIALINDEXING::ScalarType & _maxDist,OBJPTRCONTAINER & _objectPtrs,
|
OBJMARKER & _marker,
|
||||||
DISTCONTAINER & _distances, POINTCONTAINER & _points)
|
const unsigned int _k,
|
||||||
|
const typename SPATIALINDEXING::CoordType & _p,
|
||||||
|
const typename SPATIALINDEXING::ScalarType & _maxDist,
|
||||||
|
OBJPTRCONTAINER & _objectPtrs,
|
||||||
|
DISTCONTAINER & _distances,
|
||||||
|
POINTCONTAINER & _points)
|
||||||
{
|
{
|
||||||
typedef vcg::ClosestIterator<SPATIALINDEXING,OBJPOINTDISTFUNCTOR,OBJMARKER> ClosestIteratorType;
|
typedef vcg::ClosestIterator<SPATIALINDEXING,OBJPOINTDISTFUNCTOR,OBJMARKER> ClosestIteratorType;
|
||||||
ClosestIteratorType Cli=ClosestIteratorType(_Si,_getPointDistance);
|
ClosestIteratorType Cli=ClosestIteratorType(_Si,_getPointDistance);
|
||||||
|
@ -179,9 +187,12 @@ namespace vcg{
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class SPATIALINDEXING,class OBJRAYISECTFUNCTOR, class OBJMARKER>
|
template <class SPATIALINDEXING,class OBJRAYISECTFUNCTOR, class OBJMARKER>
|
||||||
typename SPATIALINDEXING::ObjPtr GridDoRay(SPATIALINDEXING &_Si,OBJRAYISECTFUNCTOR &_rayIntersector,
|
typename SPATIALINDEXING::ObjPtr GridDoRay(SPATIALINDEXING &_Si,
|
||||||
OBJMARKER &_marker, const Ray3<typename SPATIALINDEXING::ScalarType> & _ray,
|
OBJRAYISECTFUNCTOR &_rayIntersector,
|
||||||
const typename SPATIALINDEXING::ScalarType & _maxDist,typename SPATIALINDEXING::ScalarType & _t)
|
OBJMARKER &_marker,
|
||||||
|
const Ray3<typename SPATIALINDEXING::ScalarType> & _ray,
|
||||||
|
const typename SPATIALINDEXING::ScalarType & _maxDist,
|
||||||
|
typename SPATIALINDEXING::ScalarType & _t)
|
||||||
{
|
{
|
||||||
typedef vcg::RayIterator<SPATIALINDEXING,OBJRAYISECTFUNCTOR,OBJMARKER> RayIteratorType;
|
typedef vcg::RayIterator<SPATIALINDEXING,OBJRAYISECTFUNCTOR,OBJMARKER> RayIteratorType;
|
||||||
RayIteratorType RayIte=RayIteratorType(_Si,_rayIntersector);
|
RayIteratorType RayIte=RayIteratorType(_Si,_rayIntersector);
|
||||||
|
@ -195,6 +206,72 @@ namespace vcg{
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class SPATIALINDEXING, class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
|
||||||
|
unsigned int GridGetInSphere(SPATIALINDEXING &_Si,
|
||||||
|
OBJPOINTDISTFUNCTOR & _getPointDistance,
|
||||||
|
OBJMARKER & _marker,
|
||||||
|
const typename SPATIALINDEXING::CoordType & _p,
|
||||||
|
const typename SPATIALINDEXING::ScalarType & _r,
|
||||||
|
OBJPTRCONTAINER & _objectPtrs,
|
||||||
|
DISTCONTAINER & _distances,
|
||||||
|
POINTCONTAINER & _points)
|
||||||
|
{
|
||||||
|
typedef vcg::ClosestIterator<SPATIALINDEXING,OBJPOINTDISTFUNCTOR,OBJMARKER> ClosestIteratorType;
|
||||||
|
ClosestIteratorType Cli=ClosestIteratorType(_Si,_getPointDistance);
|
||||||
|
Cli.SetMarker(_marker);
|
||||||
|
Cli.Init(_p,_r);
|
||||||
|
_objectPtrs.clear();
|
||||||
|
_distances.clear();
|
||||||
|
_points.clear();
|
||||||
|
while (!Cli.End())
|
||||||
|
{
|
||||||
|
_objectPtrs.push_back(&(*Cli));
|
||||||
|
_distances.push_back(Cli.Dist());
|
||||||
|
_points.push_back(Cli.NearestPoint());
|
||||||
|
++Cli;
|
||||||
|
}
|
||||||
|
return (_objectPtrs.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class SPATIALINDEXING,class OBJMARKER, class OBJPTRCONTAINER>
|
||||||
|
unsigned int GridGetInBox(SPATIALINDEXING &_Si,
|
||||||
|
OBJMARKER & _marker,
|
||||||
|
const vcg::Box3<typename SPATIALINDEXING::ScalarType> _bbox,
|
||||||
|
OBJPTRCONTAINER & _objectPtrs)
|
||||||
|
{
|
||||||
|
SPATIALINDEXING::CellIterator first,last,l;
|
||||||
|
_objectPtrs.clear();
|
||||||
|
vcg::Box3i ibbox;
|
||||||
|
Box3i Si_ibox(Point3i(0,0,0),_Si.siz-Point3i(1,1,1));
|
||||||
|
_Si.BoxToIBox(_bbox, ibbox);
|
||||||
|
ibbox.Intersect(Si_ibox);
|
||||||
|
_marker.UnMarkAll();
|
||||||
|
if (ibbox.IsNull())
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int ix,iy,iz;
|
||||||
|
for (ix=ibbox.min[0]; ix<=ibbox.max[0]; ix++)
|
||||||
|
for (iy=ibbox.min[1]; iy<=ibbox.max[1]; iy++)
|
||||||
|
for (iz=ibbox.min[2]; iz<=ibbox.max[2]; iz++)
|
||||||
|
{
|
||||||
|
_Si.Grid( ix, iy, iz, first, last );
|
||||||
|
for(l=first;l!=last;++l)
|
||||||
|
if (!(**l).IsD())
|
||||||
|
{
|
||||||
|
SPATIALINDEXING::ObjPtr elem=&(**l);
|
||||||
|
if( ! _marker.IsMarked(elem)){
|
||||||
|
_objectPtrs.push_back(elem);
|
||||||
|
_marker.Mark(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (_objectPtrs.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}//end namespace vcg
|
}//end namespace vcg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue