From 9f065c7a66dbc7c564cf3c5b026f1e909861abcd Mon Sep 17 00:00:00 2001 From: ponchio Date: Fri, 27 Aug 2004 00:38:34 +0000 Subject: [PATCH] Minor changes. --- apps/nexus/crude2nexus.cpp | 21 ++++++++++++++------- apps/nexus/nexus.cpp | 14 ++++---------- apps/nexus/nexus.h | 5 ++--- apps/nexus/nexusview.cpp | 18 ++++++++++++++++-- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/apps/nexus/crude2nexus.cpp b/apps/nexus/crude2nexus.cpp index 79ca7dd6..fef3ee16 100644 --- a/apps/nexus/crude2nexus.cpp +++ b/apps/nexus/crude2nexus.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.3 2004/07/15 14:32:49 ponchio +Debug. + Revision 1.2 2004/07/05 15:49:39 ponchio Windows (DevCpp, mingw) port. @@ -101,6 +104,8 @@ int main(int argc, char *argv[]) { //lets count faces, vector patch_faces; + unsigned int totface = 0; + unsigned int totvert = 0; for(unsigned int i = 0; i < face_remap.Size(); i++) { unsigned int patch = face_remap[i]; @@ -108,7 +113,7 @@ int main(int argc, char *argv[]) { if(patch >= patch_faces.size()) patch_faces.resize(patch+1, 0); patch_faces[patch]++; - nexus.totface++; + totface++; } cerr << "Vertremap size: " << vert_remap.Size() << endl; @@ -128,7 +133,7 @@ int main(int argc, char *argv[]) { } assert(patch < patch_verts.size()); patch_verts[patch]++; - nexus.totvert++; + totvert++; } unsigned int totbord = 0; @@ -146,12 +151,14 @@ int main(int argc, char *argv[]) { if(unreferenced) cerr << "Warning: found " << unreferenced << " unreferenced vertices.\n"; - cerr << "Triangles found: " << nexus.totface << endl; - cerr << "Vertex found: " << nexus.totvert << endl; + cerr << "Triangles found: " << totface << endl; + cerr << "Vertex found: " << totvert << endl; cerr << "Borders found: " << totbord << endl; nexus.index.resize(patch_verts.size()); + + unsigned int totchunks = 0; //now that we know various sizes, lets allocate space for(unsigned int i = 0; i < nexus.index.size(); i++) { Nexus::Entry &entry = nexus.index[i]; @@ -159,14 +166,14 @@ int main(int argc, char *argv[]) { if(patch_faces[i] == 0 || patch_verts[i] == 0) cerr << "Warning! Empty patch.\n"; - entry.patch_start = nexus.totchunks; + entry.patch_start = totchunks; entry.patch_size = Patch::ChunkSize(patch_verts[i], patch_faces[i]); - nexus.totchunks += entry.patch_size; + totchunks += entry.patch_size; entry.border_start = 0; } - nexus.patches.Resize(nexus.totchunks); + nexus.patches.Resize(totchunks); //now we sort the faces into the patches (but still using absolute indexing //instead of relative indexing diff --git a/apps/nexus/nexus.cpp b/apps/nexus/nexus.cpp index c68497d2..4f592763 100644 --- a/apps/nexus/nexus.cpp +++ b/apps/nexus/nexus.cpp @@ -19,8 +19,6 @@ bool Nexus::Create(const string &file) { totvert = 0; totface = 0; - totchunks = 0; - totlinks = 0; sphere = Sphere3f(); //Important: chunk_size must be 1 so that i can use Region in VFile. @@ -44,10 +42,6 @@ bool Nexus::Load(const string &file) { if(!readed) return false; readed = fread(&totface, sizeof(unsigned int), 1, index_file); if(!readed) return false; - readed = fread(&totchunks, sizeof(unsigned int), 1, index_file); - if(!readed) return false; - readed = fread(&totlinks, sizeof(unsigned int), 1, index_file); - if(!readed) return false; readed = fread(&sphere, sizeof(Sphere3f), 1, index_file); if(!readed) return false; @@ -70,8 +64,6 @@ void Nexus::Close() { fwrite(&totvert, sizeof(unsigned int), 1, index_file); fwrite(&totface, sizeof(unsigned int), 1, index_file); - fwrite(&totchunks, sizeof(unsigned int), 1, index_file); - fwrite(&totlinks, sizeof(unsigned int), 1, index_file); fwrite(&sphere, sizeof(Sphere3f), 1, index_file); unsigned int size = index.size(); //size of index @@ -110,17 +102,19 @@ unsigned int Nexus::AddPatch(unsigned int nvert, unsigned int nface, patches.Resize(patches.Size() + entry.patch_size); borders.Resize(borders.Size() + nbord); index.push_back(entry); + totvert += nvert; + totface += nface; return index.size() -1; } -void Nexus::Join(const std::vector &patches, +void Nexus::Join(const std::set &patches, std::vector &newvert, std::vector &newface, std::vector &newbord) { map > remap; - vector::const_iterator i; + set::const_iterator i; for(i = patches.begin(); i != patches.end(); i++) { unsigned int patch = *i; Nexus::Entry &entry = index[patch]; diff --git a/apps/nexus/nexus.h b/apps/nexus/nexus.h index 7a1a9c26..334d66d6 100644 --- a/apps/nexus/nexus.h +++ b/apps/nexus/nexus.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include "vfile.h" @@ -44,7 +45,7 @@ class Nexus { unsigned int nbord); // unsigned int Join(std::vector &patches); - void Join(const std::vector &patches, + void Join(const std::set &patches, std::vector &vert, std::vector &faces, std::vector &links); @@ -56,8 +57,6 @@ class Nexus { unsigned int totvert; unsigned int totface; - unsigned int totchunks; //number of chunks. - unsigned int totlinks; vcg::Sphere3f sphere; std::vector index; diff --git a/apps/nexus/nexusview.cpp b/apps/nexus/nexusview.cpp index 710cbcd1..78bfd119 100644 --- a/apps/nexus/nexusview.cpp +++ b/apps/nexus/nexusview.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.3 2004/07/15 14:32:49 ponchio +Debug. + Revision 1.2 2004/07/05 15:49:39 ponchio Windows (DevCpp, mingw) port. @@ -110,11 +113,20 @@ bool init() { int main(int argc, char *argv[]) { char file[64]; - if(argc < 2) { - cerr << "Usage: " << argv[0] << " \n"; + if(argc < 2 || argc > 4) { + cerr << "Usage: " << argv[0] << " [start] [end]\n"; return -1; } + unsigned int start = 0; + unsigned int end = 0xffffffff; + + if(argc >= 3) + start = atoi(argv[2]); + + if(argc >= 4) + end = atoi(argv[3]); + Nexus nexus; if(!nexus.Load(argv[1])) { cerr << "Could not load nexus file: " << argv[1] << endl; @@ -190,6 +202,8 @@ int main(int argc, char *argv[]) { for(unsigned int i = 0; i < nexus.index.size(); i++) { + if(i < start) continue; + if(i >= end) continue; Patch patch = nexus.GetPatch(i); unsigned int val = i + 1;