From a7c15f807d4309886796df318e1351cfc62675c0 Mon Sep 17 00:00:00 2001 From: maxcorsini Date: Thu, 15 Jan 2009 15:30:07 +0000 Subject: [PATCH] add index-to-box conversion --- vcg/space/index/grid_util.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/vcg/space/index/grid_util.h b/vcg/space/index/grid_util.h index 6f48c070..ff431010 100644 --- a/vcg/space/index/grid_util.h +++ b/vcg/space/index/grid_util.h @@ -116,7 +116,7 @@ public: this->dim = this->bbox.max - this->bbox.min; this->voxel[0] = this->dim[0]/this->siz[0]; this->voxel[1] = this->dim[1]/this->siz[1]; - this->voxel[2] = this->dim[2]/this->siz[2]; + this->voxel[2] = this->dim[2]/this->siz[2]; } /* Given a 3D point, returns the coordinates of the cell where the point is * @param p is a 3D point @@ -153,6 +153,21 @@ public: p += bbox.min; } + /* Given a cell index return the corresponding box + * @param integer coordinates pi of the cell + * @return b is the corresponding box in coordinates + */ + inline void IPiToBox(const Point3i & pi, Box3x & b ) const + { + CoordType p; + p[0] = ((ScalarType)pi[0])*voxel[0]; + p[1] = ((ScalarType)pi[1])*voxel[1]; + p[2] = ((ScalarType)pi[2])*voxel[2]; + p += bbox.min; + b.min = p; + b.max = (p + voxel); + } + // Same of above but for the case that you just want to transform // from a space to the other. inline void IPfToPf(const CoordType & pi, CoordType &p ) const