Minor changes.

This commit is contained in:
Federico Ponchio 2004-08-27 00:38:34 +00:00
parent 8bb84b10f0
commit 9f065c7a66
4 changed files with 36 additions and 22 deletions

View File

@ -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<unsigned int> 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

View File

@ -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<unsigned int> &patches,
void Nexus::Join(const std::set<unsigned int> &patches,
std::vector<Point3f> &newvert,
std::vector<unsigned int> &newface,
std::vector<Link> &newbord) {
map<unsigned int, vector<unsigned int> > remap;
vector<unsigned int>::const_iterator i;
set<unsigned int>::const_iterator i;
for(i = patches.begin(); i != patches.end(); i++) {
unsigned int patch = *i;
Nexus::Entry &entry = index[patch];

View File

@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <set>
#include <vcg/space/point3.h>
#include <vcg/space/sphere3.h>
#include "vfile.h"
@ -44,7 +45,7 @@ class Nexus {
unsigned int nbord);
// unsigned int Join(std::vector<unsigned int> &patches);
void Join(const std::vector<unsigned int> &patches,
void Join(const std::set<unsigned int> &patches,
std::vector<vcg::Point3f> &vert,
std::vector<unsigned int> &faces,
std::vector<Link> &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<Entry> index;

View File

@ -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] << " <nexus file>\n";
if(argc < 2 || argc > 4) {
cerr << "Usage: " << argv[0] << " <nexus file> [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;