Backup.
This commit is contained in:
parent
8c15285f04
commit
b5173291bb
|
@ -24,10 +24,15 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.1 2004/07/02 13:03:01 ponchio
|
||||||
|
Created
|
||||||
|
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set> //DEBUG
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "../nexus.h"
|
#include "../nexus.h"
|
||||||
#include "../crude.h"
|
#include "../crude.h"
|
||||||
|
@ -111,6 +116,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
unsigned int totbord = 0;
|
unsigned int totbord = 0;
|
||||||
VFile<MFHash::Bucket> &border = vert_remap.borders.buffer;
|
VFile<MFHash::Bucket> &border = vert_remap.borders.buffer;
|
||||||
|
cerr << "border: " << border.Size() << endl;
|
||||||
for(unsigned int i = 0; i < border.Size(); i++) {
|
for(unsigned int i = 0; i < border.Size(); i++) {
|
||||||
MFHash::Bucket &bucket = border[i];
|
MFHash::Bucket &bucket = border[i];
|
||||||
if(bucket.key == 0xffffffff) continue;
|
if(bucket.key == 0xffffffff) continue;
|
||||||
|
@ -150,19 +156,95 @@ int main(int argc, char *argv[]) {
|
||||||
//instead of relative indexing
|
//instead of relative indexing
|
||||||
for(unsigned int i = 0; i < crude.face.Size(); i++) {
|
for(unsigned int i = 0; i < crude.face.Size(); i++) {
|
||||||
Crude::Face &face = crude.face[i];
|
Crude::Face &face = crude.face[i];
|
||||||
unsigned int n = face_remap[i];
|
unsigned int npatch = face_remap[i];
|
||||||
Nexus::Entry &entry = nexus.index[n];
|
|
||||||
Patch patch = nexus.GetPatch(n);
|
Nexus::Entry &entry = nexus.index[npatch];
|
||||||
|
Patch patch = nexus.GetPatch(npatch);
|
||||||
if(entry.border_offset == 0) { //first time we find patch
|
if(entry.border_offset == 0) { //first time we find patch
|
||||||
entry.border_offset = 0xffffffff;
|
entry.border_offset = 0xffffffff;
|
||||||
patch.VertSize() = 0;
|
patch.VertSize() = patch_verts[npatch];
|
||||||
patch.FaceSize() = 0;
|
patch.FaceSize() = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Crude::Face *faces = (Crude::Face *)patch.VertBegin();
|
Crude::Face *faces = (Crude::Face *)patch.VertBegin();
|
||||||
faces[patch.FaceSize()] = face;
|
faces[patch.FaceSize()] = face;
|
||||||
patch.FaceSize()++;
|
patch.FaceSize()++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//finally for every patch we collect the vertices
|
//finally for every patch we collect the vertices
|
||||||
|
//and fill the patch.
|
||||||
|
for(unsigned int i = 0; i < nexus.index.size(); i++) {
|
||||||
|
Patch patch = nexus.GetPatch(i);
|
||||||
|
assert(patch.FaceSize() == patch_faces[i]);
|
||||||
|
|
||||||
|
Nexus::Entry &entry = nexus.index[i];
|
||||||
|
|
||||||
|
//make a copy of faces (we need to write there :P)
|
||||||
|
Crude::Face *faces = new Crude::Face[patch_faces[i]];
|
||||||
|
memcpy(faces, (Crude::Face *)patch.VertBegin(),
|
||||||
|
patch.FaceSize() * sizeof(Crude::Face));
|
||||||
|
|
||||||
|
//collect all vertices we need.
|
||||||
|
//TODO an hash_map would be faster?
|
||||||
|
map<unsigned int, unsigned short> remap;
|
||||||
|
for(unsigned int k = 0; k < patch.FaceSize(); k++) {
|
||||||
|
Crude::Face &face = faces[k];
|
||||||
|
|
||||||
|
for(int j = 0; j < 3; j++) {
|
||||||
|
if(!remap.count(face[j])) {
|
||||||
|
assert(remap.size() < patch.VertSize());
|
||||||
|
Point3f &v = crude.vert[face[j]];
|
||||||
|
patch.VertBegin()[remap.size()] = v;
|
||||||
|
entry.sphere.Add(v);
|
||||||
|
remap[face[j]] = remap.size();
|
||||||
|
}
|
||||||
|
patch.FaceBegin()[k*3 + j] = remap[face[j]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
//costruiamo la mappa dei bordi:
|
||||||
|
border_remap.resize(border_offset + info.nbord);
|
||||||
|
border_remap_offset.push_back(border_offset);
|
||||||
|
border_remap_size.push_back(0);
|
||||||
|
|
||||||
|
vector<unsigned int> bord;
|
||||||
|
hash_map<unsigned int, unsigned short>::iterator m;
|
||||||
|
for(m = remap.begin(); m != remap.end(); m++) {
|
||||||
|
unsigned int abs_vertex = (*m).first;
|
||||||
|
unsigned short rel_vertex = (*m).second;
|
||||||
|
vert_remap.getValues(abs_vertex, bord);
|
||||||
|
if(bord.size() == 0) {
|
||||||
|
cerr << "EEEEEEEEEKKKKKKK" << endl;
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
if(bord.size() ==1) continue; // non e' un bordo.
|
||||||
|
BigLink link;
|
||||||
|
link.abs_vert = abs_vertex;
|
||||||
|
link.rel_vert = rel_vertex;
|
||||||
|
|
||||||
|
|
||||||
|
for(unsigned int j = 0; j < bord.size(); j++) {
|
||||||
|
if(bord[j] == i) continue;
|
||||||
|
link.patch = bord[j];
|
||||||
|
border_remap.setElement(border_offset++, link);
|
||||||
|
border_remap_size.back()++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
delete []faces;
|
||||||
|
}
|
||||||
|
for(unsigned int i = 0; i < nexus.index.size(); i++) {
|
||||||
|
nexus.sphere.Add(nexus.index[i].sphere);
|
||||||
|
}
|
||||||
|
nexus.Close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue