added the possibility to decide the size of the grid with an optional parameter of the Set

This commit is contained in:
Paolo Cignoni 2009-01-08 11:29:24 +00:00
parent 28c4843567
commit 51e1718626
1 changed files with 4 additions and 2 deletions

View File

@ -371,7 +371,7 @@ namespace vcg {
} }
template <class OBJITER> template <class OBJITER>
inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd) inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd, int _size=0)
{ {
Box3<FLT> _bbox; Box3<FLT> _bbox;
Box3<FLT> b; Box3<FLT> b;
@ -382,7 +382,9 @@ namespace vcg {
_bbox.Add(b); _bbox.Add(b);
} }
///inflate the bb calculated ///inflate the bb calculated
int _size=(int)std::distance<OBJITER>(_oBegin,_oEnd); if(_size ==0)
_size=(int)std::distance<OBJITER>(_oBegin,_oEnd);
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);