diff --git a/vcg/space/index/grid_util.h b/vcg/space/index/grid_util.h index ff431010..ce307747 100644 --- a/vcg/space/index/grid_util.h +++ b/vcg/space/index/grid_util.h @@ -158,17 +158,27 @@ public: * @return b is the corresponding box in coordinates */ inline void IPiToBox(const Point3i & pi, Box3x & b ) const - { - CoordType p; + { + 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); + p += bbox.min; + b.min = p; + b.max = (p + voxel); } - // Same of above but for the case that you just want to transform + /* Given a cell index return the center of the cell itself + * @param integer coordinates pi of the cell + * @return b is the corresponding box in coordinates + */inline void IPiToBoxCenter(const Point3i & pi, CoordType & c ) const + { + CoordType p; + IPiToPf(pi,p); + c = p + voxel/ScalarType(2.0); + } + + // Same of IPiToPf 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 {