Finito e debuggato
This commit is contained in:
parent
6febf16dcb
commit
e6d41f3df5
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.2 2004/07/02 17:42:12 ponchio
|
||||||
|
Backup.
|
||||||
|
|
||||||
Revision 1.1 2004/07/02 13:03:01 ponchio
|
Revision 1.1 2004/07/02 13:03:01 ponchio
|
||||||
Created
|
Created
|
||||||
|
|
||||||
|
@ -74,6 +77,11 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VFile<RemapLink> border_remap;
|
||||||
|
if(!border_remap.Create(argv[1] + string(".tmp"))) {
|
||||||
|
cerr << "Could not create temporary border remap file\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
Nexus nexus;
|
Nexus nexus;
|
||||||
if(!nexus.Create(argv[2])) {
|
if(!nexus.Create(argv[2])) {
|
||||||
|
@ -116,7 +124,6 @@ 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;
|
||||||
|
@ -128,7 +135,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unreferenced)
|
if(unreferenced)
|
||||||
cerr << "Warning: found " << unreferenced << " vertices.\n";
|
cerr << "Warning: found " << unreferenced << " unreferenced vertices.\n";
|
||||||
|
|
||||||
cerr << "Triangles found: " << nexus.totface << endl;
|
cerr << "Triangles found: " << nexus.totface << endl;
|
||||||
cerr << "Vertex found: " << nexus.totvert << endl;
|
cerr << "Vertex found: " << nexus.totvert << endl;
|
||||||
|
@ -143,11 +150,11 @@ int main(int argc, char *argv[]) {
|
||||||
if(patch_faces[i] == 0 || patch_verts[i] == 0)
|
if(patch_faces[i] == 0 || patch_verts[i] == 0)
|
||||||
cerr << "Warning! Empty patch.\n";
|
cerr << "Warning! Empty patch.\n";
|
||||||
|
|
||||||
entry.patch_offset = nexus.totchunks;
|
entry.patch_start = nexus.totchunks;
|
||||||
entry.patch_size = Patch::ChunkSize(patch_verts[i], patch_faces[i]);
|
entry.patch_size = Patch::ChunkSize(patch_verts[i], patch_faces[i]);
|
||||||
|
|
||||||
nexus.totchunks += entry.patch_size;
|
nexus.totchunks += entry.patch_size;
|
||||||
entry.border_offset = 0;
|
entry.border_start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nexus.patches.Resize(nexus.totchunks);
|
nexus.patches.Resize(nexus.totchunks);
|
||||||
|
@ -160,20 +167,28 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
Nexus::Entry &entry = nexus.index[npatch];
|
Nexus::Entry &entry = nexus.index[npatch];
|
||||||
Patch patch = nexus.GetPatch(npatch);
|
Patch patch = nexus.GetPatch(npatch);
|
||||||
if(entry.border_offset == 0) { //first time we find patch
|
if(entry.border_start == 0) { //first time we find patch
|
||||||
entry.border_offset = 0xffffffff;
|
entry.border_start = 0xffffffff;
|
||||||
patch.VertSize() = patch_verts[npatch];
|
entry.nvert = patch_verts[npatch];
|
||||||
patch.FaceSize() = 0;
|
// patch.VertSize() = patch_verts[npatch];
|
||||||
|
entry.nface = 0;
|
||||||
|
// patch.FaceSize() = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Crude::Face *faces = (Crude::Face *)patch.VertBegin();
|
Crude::Face *faces = (Crude::Face *)patch.VertBegin();
|
||||||
faces[patch.FaceSize()] = face;
|
faces[entry.nface] = face;
|
||||||
patch.FaceSize()++;
|
entry.nface++;
|
||||||
|
// faces[patch.FaceSize()] = face;
|
||||||
|
// patch.FaceSize()++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//finally for every patch we collect the vertices
|
//finally for every patch we collect the vertices
|
||||||
//and fill the patch.
|
//and fill the patch.
|
||||||
|
//we need to remember start and size in border_remap;
|
||||||
|
// vector<unsigned int> border_start;
|
||||||
|
// vector<unsigned int> border_size;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < nexus.index.size(); i++) {
|
for(unsigned int i = 0; i < nexus.index.size(); i++) {
|
||||||
Patch patch = nexus.GetPatch(i);
|
Patch patch = nexus.GetPatch(i);
|
||||||
assert(patch.FaceSize() == patch_faces[i]);
|
assert(patch.FaceSize() == patch_faces[i]);
|
||||||
|
@ -187,64 +202,70 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
//collect all vertices we need.
|
//collect all vertices we need.
|
||||||
//TODO an hash_map would be faster?
|
//TODO an hash_map would be faster?
|
||||||
|
unsigned int count = 0;
|
||||||
map<unsigned int, unsigned short> remap;
|
map<unsigned int, unsigned short> remap;
|
||||||
for(unsigned int k = 0; k < patch.FaceSize(); k++) {
|
for(unsigned int k = 0; k < patch.FaceSize(); k++) {
|
||||||
Crude::Face &face = faces[k];
|
Crude::Face &face = faces[k];
|
||||||
|
|
||||||
for(int j = 0; j < 3; j++) {
|
for(int j = 0; j < 3; j++) {
|
||||||
if(!remap.count(face[j])) {
|
if(!remap.count(face[j])) {
|
||||||
assert(remap.size() < patch.VertSize());
|
assert(count < patch.VertSize());
|
||||||
Point3f &v = crude.vert[face[j]];
|
Point3f &v = crude.vert[face[j]];
|
||||||
patch.VertBegin()[remap.size()] = v;
|
patch.VertBegin()[remap.size()] = v;
|
||||||
entry.sphere.Add(v);
|
entry.sphere.Add(v);
|
||||||
remap[face[j]] = remap.size();
|
remap[face[j]] = count++;
|
||||||
}
|
}
|
||||||
patch.FaceBegin()[k*3 + j] = remap[face[j]];
|
patch.FaceBegin()[k*3 + j] = remap[face[j]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//record start of border:
|
||||||
|
entry.border_start = border_remap.Size();
|
||||||
|
// border_start.push_back(border_remap.Size());
|
||||||
//costruiamo la mappa dei bordi:
|
//TODO hash_set?
|
||||||
border_remap.resize(border_offset + info.nbord);
|
set<unsigned int> border_patches;
|
||||||
border_remap_offset.push_back(border_offset);
|
map<unsigned int, unsigned short>::iterator m;
|
||||||
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++) {
|
for(m = remap.begin(); m != remap.end(); m++) {
|
||||||
unsigned int abs_vertex = (*m).first;
|
RemapLink link;
|
||||||
unsigned short rel_vertex = (*m).second;
|
link.abs_vert = (*m).first;
|
||||||
vert_remap.getValues(abs_vertex, bord);
|
link.rel_vert = (*m).second;
|
||||||
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()++;
|
|
||||||
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vert_remap.GetValues(link.abs_vert, border_patches);
|
||||||
|
assert(border_patches.size() >= 1);
|
||||||
|
if(border_patches.size() == 1) continue; //its not a border
|
||||||
|
|
||||||
|
set<unsigned int>::iterator s;
|
||||||
|
for(s = border_patches.begin(); s != border_patches.end(); s++) {
|
||||||
|
if((*s) == i) continue;
|
||||||
|
link.patch = *s;
|
||||||
|
border_remap.PushBack(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//and number of borders:
|
||||||
|
entry.border_size = border_remap.Size() - entry.border_start;
|
||||||
|
//border_size.push_back(border_remap.Size() - border_start.back());
|
||||||
delete []faces;
|
delete []faces;
|
||||||
}
|
}
|
||||||
|
//we can now update bounding sphere.
|
||||||
for(unsigned int i = 0; i < nexus.index.size(); i++) {
|
for(unsigned int i = 0; i < nexus.index.size(); i++) {
|
||||||
nexus.sphere.Add(nexus.index[i].sphere);
|
nexus.sphere.Add(nexus.index[i].sphere);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//and last convert RemapLinks into Links
|
||||||
|
nexus.borders.Resize(border_remap.Size());
|
||||||
|
for(unsigned int i = 0; i < border_remap.Size(); i++) {
|
||||||
|
RemapLink start_link = border_remap[i];
|
||||||
|
Nexus::Entry &entry = nexus.index[start_link.patch];
|
||||||
|
for(unsigned int k = entry.border_start;
|
||||||
|
k < entry.border_start + entry.border_size; k++) {
|
||||||
|
RemapLink end_link = border_remap[k];
|
||||||
|
if(start_link.abs_vert == end_link.abs_vert) { //found the match
|
||||||
|
nexus.borders[i] = Link(start_link.rel_vert,
|
||||||
|
end_link.rel_vert, start_link.patch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nexus.Close();
|
nexus.Close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue