Changed one of the init overload Set(), the one that allowed to specify the cell radius but ACTUALLY it did not use it...

now has a new name : SetWithRadius
This commit is contained in:
Paolo Cignoni 2012-07-06 09:40:09 +00:00
parent 118eb65a9f
commit 58eced0506
1 changed files with 25 additions and 24 deletions

View File

@ -246,16 +246,15 @@ namespace vcg {
{ {
Box3<FLT> _bbox; Box3<FLT> _bbox;
Box3<FLT> b; Box3<FLT> b;
OBJITER i; for(OBJITER i = _oBegin; i!= _oEnd; ++i)
for(i = _oBegin; i!= _oEnd; ++i)
{ {
(*i).GetBBox(b); (*i).GetBBox(b);
_bbox.Add(b); _bbox.Add(b);
} }
///inflate the bb calculated
if(_size ==0) if(_size ==0)
_size=(int)std::distance<OBJITER>(_oBegin,_oEnd); _size=(int)std::distance<OBJITER>(_oBegin,_oEnd);
///inflate the bb calculated
ScalarType infl=_bbox.Diag()/_size; ScalarType infl=_bbox.Diag()/_size;
_bbox.min-=vcg::Point3<FLT>(infl,infl,infl); _bbox.min-=vcg::Point3<FLT>(infl,infl,infl);
_bbox.max+=vcg::Point3<FLT>(infl,infl,infl); _bbox.max+=vcg::Point3<FLT>(infl,infl,infl);
@ -270,28 +269,28 @@ namespace vcg {
// Note that the bbox must be already 'inflated' so to be sure that no object will fall on the border of the grid. // Note that the bbox must be already 'inflated' so to be sure that no object will fall on the border of the grid.
template <class OBJITER> template <class OBJITER>
inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd, const Box3x &_bbox, FLT radius) inline void SetWithRadius(const OBJITER & _oBegin, const OBJITER & _oEnd, FLT _cellRadius)
{ {
Point3i _siz; Box3<FLT> _bbox;
Point3<FLT> _dim = _bbox.max - _bbox.min; Box3<FLT> b;
_dim/=radius; for(OBJITER i = _oBegin; i!= _oEnd; ++i)
assert(_dim[0]>0 && _dim[1]>0 && _dim[2]>0 ); {
_siz[0] = (int)ceil(_dim[0]); (*i).GetBBox(b);
_siz[1] = (int)ceil(_dim[1]); _bbox.Add(b);
_siz[2] = (int)ceil(_dim[2]); }
Point3<FLT> offset=Point3<FLT>::Construct(_siz); _bbox.min-=vcg::Point3<FLT>(_cellRadius,_cellRadius,_cellRadius);
offset*=radius; _bbox.max+=vcg::Point3<FLT>(_cellRadius,_cellRadius,_cellRadius);
offset -= (_bbox.max - _bbox.min);
offset /=2; Point3i _siz;
Point3<FLT> _dim = _bbox.max - _bbox.min;
assert( offset[0]>=0 && offset[1]>=0 && offset[2]>=0 ); _dim/=_cellRadius;
assert(_dim[0]>0 && _dim[1]>0 && _dim[2]>0 );
Box3x bb = _bbox; _siz[0] = (int)ceil(_dim[0]);
bb.min -= offset; _siz[1] = (int)ceil(_dim[1]);
bb.max += offset; _siz[2] = (int)ceil(_dim[2]);
Set(_oBegin,_oEnd, bb,_siz); Set(_oBegin,_oEnd, _bbox,_siz);
} }
@ -312,6 +311,8 @@ namespace vcg {
Set(_oBegin,_oEnd,_bbox,_siz); Set(_oBegin,_oEnd,_bbox,_siz);
} }
// This is the REAL LOW LEVEL function
template <class OBJITER> template <class OBJITER>
inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd, const Box3x &_bbox, Point3i _siz) inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd, const Box3x &_bbox, Point3i _siz)