From b6cb2fc881105191ea865fa537da59316b1f8202 Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 23 Mar 2010 07:26:34 +0000 Subject: [PATCH] added option to the Poisson sampling filter of using an additional mesh as source of already generated samples. In this way it is possible to refine existing sampling by using different sample pools --- vcg/complex/trimesh/point_sampling.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/vcg/complex/trimesh/point_sampling.h b/vcg/complex/trimesh/point_sampling.h index 33ad618a..893c2594 100644 --- a/vcg/complex/trimesh/point_sampling.h +++ b/vcg/complex/trimesh/point_sampling.h @@ -955,10 +955,14 @@ struct PoissonDiskParam radiusVariance =1; MAXLEVELS = 5; invertQuality = false; - } + preGenFlag = false; + preGenMesh = NULL; + } bool adaptiveRadiusFlag; float radiusVariance; bool invertQuality; + bool preGenFlag; // when generating a poisson distribution, you can initialize the set pof omputed points with ALL the vertices of another mesh. Usefull for building progressive refinements. + MetroMesh *preGenMesh; int MAXLEVELS; }; @@ -1035,9 +1039,23 @@ static void PoissonDiskPruning(MetroMesh &origMesh, VertexSampler &ps, MetroMesh #ifdef QT_VERSION qDebug("PDS: Completed creation of activeCells, %i cells (%i msec)", montecarloSHT.AllocatedCells.size(), tt.restart()); #endif +int removedCnt=0; + if(pp.preGenFlag) + { + // 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); + } + montecarloSHT.UpdateAllocatedCells(); +#ifdef QT_VERSION + qDebug("Removed %i samples in %i",removedCnt,tt.restart()); +#endif + } while(!montecarloSHT.AllocatedCells.empty()) { - int removedCnt=0; + removedCnt=0; for (size_t i = 0; i < montecarloSHT.AllocatedCells.size(); i++) { if( montecarloSHT.EmptyCell(montecarloSHT.AllocatedCells[i]) ) continue;