Refactored CountInSphere / RemoveInSphere for the PoissonDisk sampling optimizations (now you can just count the element inside a given sphere without removing them.
This commit is contained in:
parent
9ad68bc573
commit
be3e74ca6a
|
@ -206,14 +206,13 @@ protected:
|
|||
return true;
|
||||
} ///insert a new cell
|
||||
|
||||
int RemoveInSphere(const Point3<ScalarType> &p, const ScalarType radius)
|
||||
int CountInSphere(const Point3<ScalarType> &p, const ScalarType radius, std::vector<HashIterator> &inSphVec)
|
||||
{
|
||||
Box3x b(p-Point3f(radius,radius,radius),p+Point3f(radius,radius,radius));
|
||||
vcg::Box3i bb;
|
||||
this->BoxToIBox(b,bb);
|
||||
ScalarType r2=radius*radius;
|
||||
int cnt=0;
|
||||
std::vector<HashIterator> toDel;
|
||||
inSphVec.clear();
|
||||
|
||||
for (int i=bb.min.X();i<=bb.max.X();i++)
|
||||
for (int j=bb.min.Y();j<=bb.max.Y();j++)
|
||||
|
@ -223,16 +222,20 @@ protected:
|
|||
for(HashIterator hi = CellRange.first; hi!=CellRange.second;++hi)
|
||||
{
|
||||
if(SquaredDistance(p,hi->second->cP()) <= r2)
|
||||
inSphVec.push_back(hi);
|
||||
}
|
||||
}
|
||||
return inSphVec.size();
|
||||
}
|
||||
|
||||
int RemoveInSphere(const Point3<ScalarType> &p, const ScalarType radius)
|
||||
{
|
||||
cnt++;
|
||||
toDel.push_back(hi);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(typename std::vector<HashIterator>::iterator vi=toDel.begin(); vi!=toDel.end();++vi)
|
||||
std::vector<HashIterator> inSphVec;
|
||||
CountInSphere(p,radius,inSphVec);
|
||||
for(typename std::vector<HashIterator>::iterator vi=inSphVec.begin(); vi!=inSphVec.end();++vi)
|
||||
hash_table.erase(*vi);
|
||||
|
||||
return cnt;
|
||||
return inSphVec.size();
|
||||
}
|
||||
// Specialized version that is able to take in input a
|
||||
template<class DistanceFunctor>
|
||||
|
|
Loading…
Reference in New Issue