From 066c2bdb8bf6e2e44352f2caf186fef27e693876 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 27 Mar 2009 15:09:14 +0000 Subject: [PATCH] Corrected ComputePoissonDiskRadius to Manage approximately the PointCloud Case, using area of the bbox as an approx of the surface area. --- vcg/complex/trimesh/point_sampling.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vcg/complex/trimesh/point_sampling.h b/vcg/complex/trimesh/point_sampling.h index efc37eff..de790929 100644 --- a/vcg/complex/trimesh/point_sampling.h +++ b/vcg/complex/trimesh/point_sampling.h @@ -765,7 +765,15 @@ struct PoissonDiskParam static ScalarType ComputePoissonDiskRadius(MetroMesh &origMesh, int sampleNum) { ScalarType meshArea = Stat::ComputeMeshArea(origMesh); - ScalarType diskRadius = sqrt(meshArea / (0.7 * M_PI * sampleNum)); // 0.7 is a density factor + // Manage approximately the PointCloud Case, use the half a area of the bbox. + // TODO: If you had the radius a much better approximation could be done. + if(meshArea ==0) + { + meshArea = (origMesh.bbox.DimX()*origMesh.bbox.DimY() + + origMesh.bbox.DimX()*origMesh.bbox.DimZ() + + origMesh.bbox.DimY()*origMesh.bbox.DimZ()); + } + ScalarType diskRadius = sqrt(meshArea / (0.7 * M_PI * sampleNum)); // 0.7 is a density factor return diskRadius; }