From 0ba814697c6c1ddad775f96e471d27fb2674df56 Mon Sep 17 00:00:00 2001 From: mcallieri Date: Tue, 21 Jan 2014 14:59:45 +0000 Subject: [PATCH] Poisson sampling was ignoring the DELETED flag, so when a part of a mesh was deleted but still in memory, would sample it. added a couple of if(!(*vi).IsD()) tests in [InitSpatialHashTable], [ComputePoissonSampleRadii] and [PoissonDiskPruning]. Seems to work, but please test it. Beware: there could be more places where this is needed; I only checked poisson. --- vcg/complex/algorithms/point_sampling.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/vcg/complex/algorithms/point_sampling.h b/vcg/complex/algorithms/point_sampling.h index baa151ac..3eb589bb 100644 --- a/vcg/complex/algorithms/point_sampling.h +++ b/vcg/complex/algorithms/point_sampling.h @@ -1328,9 +1328,10 @@ static void ComputePoissonSampleRadii(MetroMesh &sampleMesh, ScalarType diskRadi float deltaQ = minmax.second-minmax.first; float deltaRad = maxRad-minRad; for (vi = sampleMesh.vert.begin(); vi != sampleMesh.vert.end(); vi++) - { - (*vi).Q() = minRad + deltaRad*((invert ? minmax.second - (*vi).Q() : (*vi).Q() - minmax.first )/deltaQ); - } + if(!(*vi).IsD()) + { + (*vi).Q() = minRad + deltaRad*((invert ? minmax.second - (*vi).Q() : (*vi).Q() - minmax.first )/deltaQ); + } } // initialize spatial hash table for searching @@ -1358,7 +1359,11 @@ static void InitSpatialHashTable(MetroMesh &montecarloMesh, MontecarloSHT &monte montecarloSHT.InitEmpty(bb, gridsize); for (VertexIterator vi = montecarloMesh.vert.begin(); vi != montecarloMesh.vert.end(); vi++) - montecarloSHT.Add(&(*vi)); + if(!(*vi).IsD()) + { + montecarloSHT.Add(&(*vi)); + } + montecarloSHT.UpdateAllocatedCells(); if(pp.pds) { @@ -1397,10 +1402,11 @@ static void PoissonDiskPruning(VertexSampler &ps, MetroMesh &montecarloMesh, { // Initial pass for pruning the Hashed grid with the an eventual pre initialized set of samples for(VertexIterator vi =pp.preGenMesh->vert.begin(); vi!=pp.preGenMesh->vert.end();++vi) - { - ps.AddVert(*vi); - removedCnt += montecarloSHT.RemoveInSphere(vi->cP(),diskRadius); - } + if(!(*vi).IsD()) + { + ps.AddVert(*vi); + removedCnt += montecarloSHT.RemoveInSphere(vi->cP(),diskRadius); + } montecarloSHT.UpdateAllocatedCells(); } vertex::ApproximateGeodesicDistanceFunctor GDF;