From 6be9fe3b03dc7a1bc307de14d9379cc9bd090448 Mon Sep 17 00:00:00 2001 From: maxcorsini Date: Sun, 18 Jan 2009 19:33:50 +0000 Subject: [PATCH] fix typos --- vcg/complex/trimesh/point_sampling.h | 54 +++++++--------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/vcg/complex/trimesh/point_sampling.h b/vcg/complex/trimesh/point_sampling.h index 241d64b2..46e34769 100644 --- a/vcg/complex/trimesh/point_sampling.h +++ b/vcg/complex/trimesh/point_sampling.h @@ -99,7 +99,7 @@ public: static math::MarsenneTwisterRNG &SamplingRandomGenerator() { - static math::MarsenneTwisterRNG rnd(); + static math::MarsenneTwisterRNG rnd; return rnd; } @@ -720,6 +720,13 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte verticescounter[i] = 0; } + + // create a support mesh with markers for vertices and enable vertex marker for all the meshes + MetroMesh supportMesh; + supportMesh.vert.EnableMark(); + ps.m->vert.EnableMark(); + montecarloMesh.vert.EnableMark(); + const int MAXLEVELS = 5; // maximum level of subdivision // spatial index of montecarlo samples - used to choose a new sample to insert @@ -752,41 +759,6 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte checkSHT.InitEmpty(origMesh.bbox, gridsize); - - // write some statistics - QFile data("C:/temp/performances.txt"); - if (data.open(QFile::WriteOnly | QFile::Truncate)) - { - QTextStream out(&data); - - int t1 = clock(); - - for (int k = 0; k < 100; k++) - { - VertexType *v = new VertexType; - v->P() = RandomBox(origMesh.bbox); - ps.AddVert(*v); - checkSHT.Add(v); - } - - int t2 = clock(); - - for (int k = 0; k < 100; k++) - { - Point3 p = RandomBox(origMesh.bbox); - checkPoissonDisk(*ps.m, checkSHT, p, r); - } - - int t3 = clock(); - - out << t2-t1 << endl; - out << t3-t2 << endl; - } - - data.close(); - - exit(2); - // sampling algorithm // ------------------ // @@ -860,12 +832,12 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte if (acceptedsample) { // add sample - VertexType *v = new VertexType; - v->P() = s; - ps.AddVert(*v); + tri::Allocator::AddVertices(supportMesh,1); + supportMesh.vert.back().P() = s; + ps.AddVert(supportMesh.vert.back()); // add to control spatial index - checkSHT.Add(v); + checkSHT.Add(&supportMesh.vert.back()); samplesaccepted[level]++; } @@ -922,7 +894,7 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte QFile outfile("C:/temp/poissondisk_statistics.txt"); if (outfile.open(QFile::WriteOnly | QFile::Truncate)) { - QTextStream out(&data); + QTextStream out(&outfile); for (int k = 0; k < MAXLEVELS; k++) out << "Cells used for level " << k << ": " << cellusedcounter[k] << endl;