diff --git a/apps/nexus/nxsdispatcher.cpp b/apps/nexus/nxsdispatcher.cpp index 9615f2cf..e0fd0701 100644 --- a/apps/nexus/nxsdispatcher.cpp +++ b/apps/nexus/nxsdispatcher.cpp @@ -158,10 +158,10 @@ void Dispatcher::msghandler(message &msg) { vector newbord; Join(*fragin, newvert, newface, newbord); - float error = Decimate(QUADRIC, - (unsigned int)((newface.size()/3) * 0.5), + float error = Decimate(mode, + (unsigned int)((newface.size()/3) * scaling), newvert, newface, newbord); - + Fragment *fragout = new Fragment; fragout->error = error; diff --git a/apps/nexus/nxsdispatcher.h b/apps/nexus/nxsdispatcher.h index 47a06aa2..be4b1c64 100644 --- a/apps/nexus/nxsdispatcher.h +++ b/apps/nexus/nxsdispatcher.h @@ -7,6 +7,8 @@ #include #include +#include "decimate.h" + namespace nxs { #define MSG_SEND MSG_USER + 1 @@ -63,6 +65,8 @@ namespace nxs { int maxqueue; Nexus *nexus; VoronoiChain *chain; + Decimation mode; + float scaling; std::vector servers; std::map frags; }; diff --git a/apps/nexus/nxsserver.cpp b/apps/nexus/nxsserver.cpp index 330a1188..3687cc13 100644 --- a/apps/nexus/nxsserver.cpp +++ b/apps/nexus/nxsserver.cpp @@ -1,10 +1,12 @@ #include #include #include -using namespace pt; + #include "fragment.h" #include "decimate.h" + +using namespace pt; using namespace nxs; using namespace vcg; using namespace std; diff --git a/apps/nexus/patchserver.cpp b/apps/nexus/patchserver.cpp index 892c29e7..c52acce5 100644 --- a/apps/nexus/patchserver.cpp +++ b/apps/nexus/patchserver.cpp @@ -141,7 +141,8 @@ Patch &PatchServer::GetPatch(unsigned int idx, } PTime &ptime = lru[entry.lru_pos]; - pexchange(&(ptime.frame), frame++); + //pexchange(&(ptime.frame), frame++); + ptime.frame = frame++; // ramlock.unlock(); diff --git a/apps/nexus/pvoronoi.cpp b/apps/nexus/pvoronoi.cpp index 48a8a087..0821111c 100644 --- a/apps/nexus/pvoronoi.cpp +++ b/apps/nexus/pvoronoi.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.8 2004/11/03 16:31:38 ponchio +Trying to fix big patches. + Revision 1.7 2004/10/30 20:17:03 ponchio Fixed big patches problem. @@ -85,9 +88,9 @@ void VoronoiPartition::Init() { fprintf(ft, "%f\t%f\t%f\n", operator[](i)[0], operator[](i)[1], operator[](i)[2]); } fclose(ft);*/ - std::cerr << "Building kd!\n"; + //std::cerr << "Building kd!\n"; bd = new ANNkd_tree(&*points.begin(), size(), 3); - std::cerr << "Done!\n"; + //std::cerr << "Done!\n"; } void VoronoiPartition::Closest(const vcg::Point3f &p, unsigned int nsize, vector &nears, diff --git a/apps/nexus/voronoichain.cpp b/apps/nexus/voronoichain.cpp index 8bf2dbe2..aa9d6c93 100644 --- a/apps/nexus/voronoichain.cpp +++ b/apps/nexus/voronoichain.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.22 2004/11/28 04:14:12 ponchio +*** empty log message *** + Revision 1.21 2004/11/28 01:23:26 ponchio Fixing borders... let's hope. @@ -180,22 +183,19 @@ bool VoronoiChain::Optimize(int mean, VoronoiPartition &part, for(unsigned int i = 0; i < part.size(); i++) { if(counts[i] > max_size || counts[i] > 2 * mean) { failed++; - cerr << "Failed> " << counts[i] << endl; + //cerr << "Failed> " << counts[i] << endl; float radius= getClosest(part[i], part); - cerr << "RADIUS: " << radius << endl; + //cerr << "RADIUS: " << radius << endl; if(radius == 0) { cerr << "Radius zero???\n"; exit(0); } radius /= 3; if(radius < 0) continue; - seeds.push_back(part[i] + Point3f(1, 0, 0) * radius); - seeds.push_back(part[i] + Point3f(0, 1, 0) * radius); - seeds.push_back(part[i] + Point3f(0, 0, 1) * radius); - - seeds.push_back(part[i] - Point3f(1, 0, 0) * radius); - seeds.push_back(part[i] - Point3f(0, 1, 0) * radius); - seeds.push_back(part[i] - Point3f(0, 0, 1) * radius); + seeds.push_back(part[i] + Point3f(1, -1, 1) * radius); + seeds.push_back(part[i] + Point3f(-1, 1, 1) * radius); + seeds.push_back(part[i] + Point3f(-1, -1, -1) * radius); + seeds.push_back(part[i] + Point3f(1, 1, -1) * radius); mark[i]; } } @@ -462,7 +462,7 @@ void VoronoiChain::BuildLevel(Nexus &nexus, unsigned int offset, coarse.push_back(patch.Vert(0)); } - float coarse_vmean = totvert/(float)coarse.size(); + float coarse_vmean = totface/(float)coarse.size(); coarse.Init(); cerr << "Coarse size: " << coarse.size() << endl; @@ -485,17 +485,18 @@ void VoronoiChain::BuildLevel(Nexus &nexus, unsigned int offset, for(unsigned int idx = offset; idx < nexus.index.size(); idx++) { report.Step(idx); Patch patch = nexus.GetPatch(idx); - for(unsigned int i = 0; i < patch.nv; i++) { - - unsigned int ctarget = coarse.Locate(patch.Vert(i)); - assert(ctarget < coarse.size()); - centroids[ctarget] += patch.Vert(i); - counts[ctarget]++; + for(unsigned int i = 0; i < patch.nf; i++) { + unsigned short *face = patch.Face(i); + Point3f bari = (patch.Vert(face[0]) + patch.Vert(face[1]) + patch.Vert(face[2]))/3; + unsigned int ctarget = coarse.Locate(bari); + assert(ctarget < coarse.size()); + centroids[ctarget] += bari; + counts[ctarget]++; } } if(step == steps-1) { if(!Optimize((int)coarse_vmean, coarse, centroids, counts, false)) - step--; + step--; } else Optimize((int)coarse_vmean, coarse, centroids, counts, true); } diff --git a/apps/nexus/voronoinxs.cpp b/apps/nexus/voronoinxs.cpp index e3957747..6e2cfbcc 100644 --- a/apps/nexus/voronoinxs.cpp +++ b/apps/nexus/voronoinxs.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.23 2004/11/28 01:23:26 ponchio +Fixing borders... let's hope. + Revision 1.22 2004/11/18 18:30:15 ponchio Using baricenters... lotsa changes. @@ -330,6 +333,8 @@ int main(int argc, char *argv[]) { Report report; Dispatcher dispatcher(&nexus, &vchain); + dispatcher.mode = decimation; + dispatcher.scaling = scaling; if(!dispatcher.Init("servers.txt")) { cerr << "Could not parse server file: " << "servers.txt" << " proceding locally\n";