Cleaned up small bug in the vertex clustering alg (crashed on empty sets and on non compacted meshes
This commit is contained in:
parent
5b6f8055f2
commit
5c358c02a4
|
@ -1513,13 +1513,15 @@ static int MergeCloseVertex(MeshType &m, const ScalarType radius)
|
|||
|
||||
static int ClusterVertex(MeshType &m, const ScalarType radius)
|
||||
{
|
||||
if(m.vn==0) return 0;
|
||||
// some spatial indexing structure does not work well with deleted vertices...
|
||||
tri::Allocator<MeshType>::CompactVertexVector(m);
|
||||
typedef vcg::SpatialHashTable<VertexType, ScalarType> SampleSHT;
|
||||
SampleSHT sht;
|
||||
tri::VertTmark<MeshType> markerFunctor;
|
||||
typedef vcg::vertex::PointDistanceFunctor<ScalarType> VDistFunct;
|
||||
std::vector<VertexType*> closests;
|
||||
int mergedCnt=0;
|
||||
Point3f closestPt;
|
||||
sht.Set(m.vert.begin(), m.vert.end());
|
||||
UpdateFlags<MeshType>::VertexClearV(m);
|
||||
for(VertexIterator viv = m.vert.begin(); viv!= m.vert.end(); ++viv)
|
||||
|
@ -1535,7 +1537,7 @@ static int ClusterVertex(MeshType &m, const ScalarType radius)
|
|||
float dist = Distance(p,closests[i]->cP());
|
||||
if(dist < radius && !closests[i]->IsV())
|
||||
{
|
||||
printf("%f %f \n",dist,radius);
|
||||
// printf("%f %f \n",dist,radius);
|
||||
mergedCnt++;
|
||||
closests[i]->SetV();
|
||||
closests[i]->P()=p;
|
||||
|
|
Loading…
Reference in New Issue