add SetByPointers to deal with containers of pointers instead of containers of elements

This commit is contained in:
Massimiliano Corsini 2012-09-03 13:50:42 +00:00
parent 7cf395c033
commit dec783bcf0
1 changed files with 39 additions and 1 deletions

View File

@ -409,7 +409,7 @@ namespace vcg{
{
for(i = _oBegin; i!= _oEnd; ++i)
{
(*i).GetBBox(b);
(*i)->GetBBox(b);
this->bbox.Add(b);
}
///inflate the bb calculated
@ -429,6 +429,44 @@ namespace vcg{
}
}
/// Insert a mesh in the grid.
template <class OBJITER>
void SetByPointers(const OBJITER & _oBegin, const OBJITER & _oEnd,
bool subdivideBox=false,const Box2x &_bbox=Box2x() )
{
OBJITER i;
Box2x b;
Box2x &bbox = this->bbox;
CoordType &dim = this->dim;
Point2i &siz = this->siz;
CoordType &voxel = this->voxel;
int _size=(int)std::distance<OBJITER>(_oBegin,_oEnd);
if(!_bbox.IsNull()) this->bbox=_bbox;
else
{
for(i = _oBegin; i!= _oEnd; ++i)
{
(*i)->GetBBox(b);
this->bbox.Add(b);
}
///inflate the bb calculated
bbox.Offset(bbox.Diag()/100.0) ;
}
dim = bbox.max - bbox.min;
BestDim2D( _size, dim, siz );
// find voxel size
voxel[0] = dim[0]/siz[0];
voxel[1] = dim[1]/siz[1];
cell_size=voxel.Norm();
for(i = _oBegin; i!= _oEnd; ++i)
{
Add(*i,subdivideBox);
}
}
///return the simplexes of the cell that contain p
void GridReal( const Point2<ScalarType> & p, CellIterator & first, CellIterator & last )
{