Debug
This commit is contained in:
parent
2f18ab315f
commit
03863f15b8
|
@ -172,7 +172,11 @@ float Cluster(MyMesh &mesh, unsigned int target_faces) {
|
||||||
unsigned int starting = mesh.vn;
|
unsigned int starting = mesh.vn;
|
||||||
|
|
||||||
unsigned int nseeds = target_faces/2;
|
unsigned int nseeds = target_faces/2;
|
||||||
assert(nseeds < mesh.vert.size());
|
#ifndef NDEBUG
|
||||||
|
if(nseeds >= mesh.vert.size()) {
|
||||||
|
cerr << "Strange! nseeds > vert.size(): " << nseeds << " >= "<< mesh.vert.size() << endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
vector<unsigned int> remap;
|
vector<unsigned int> remap;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool Nexus::Create(const string &file, Signature sig, unsigned int c_size) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Important: chunk_size must be 1 so that i can use Region in VFile.
|
//Important: chunk_size must be 1 so that i can use Region in VFile.
|
||||||
if(!borders.Create(file + ".nxb", 1)) {
|
if(!borders.Create(file + ".nxb", 1, 100)) {
|
||||||
cerr << "Could not create file: " << file << ".nxb" << endl;
|
cerr << "Could not create file: " << file << ".nxb" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ bool Nexus::Load(const string &file, bool readonly) {
|
||||||
//TODO support readonly
|
//TODO support readonly
|
||||||
if(!patches.Load(file + ".nxp", signature, chunk_size, readonly))
|
if(!patches.Load(file + ".nxp", signature, chunk_size, readonly))
|
||||||
return false;
|
return false;
|
||||||
if(!borders.Load(file + ".nxb", readonly, 1)) return false;
|
if(!borders.Load(file + ".nxb", readonly, 1, 100)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,18 +373,22 @@ void Nexus::Unify(float threshold) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO: better to compact directly borders than setting them null.
|
//better to compact directly borders than setting them null.
|
||||||
//finally: there may be duplicated borders
|
//finally: there may be duplicated borders
|
||||||
for(unsigned int p = 0; p < index.size(); p++) {
|
for(unsigned int p = 0; p < index.size(); p++) {
|
||||||
Border border = GetBorder(p);
|
Border border = GetBorder(p);
|
||||||
set<Link> links;
|
set<Link> links;
|
||||||
for(unsigned int b = 0; b < border.Size(); b++) {
|
for(unsigned int b = 0; b < border.Size(); b++) {
|
||||||
if(border[b].IsNull()) continue;
|
Link &link = border[b];
|
||||||
if(links.count(border[b]))
|
assert(!link.IsNull());
|
||||||
border[b] = Link();
|
//if(border[b].IsNull()) continue;
|
||||||
else
|
links.insert(link);
|
||||||
links.insert(border[b]);
|
|
||||||
}
|
}
|
||||||
|
int count = 0;
|
||||||
|
for(set<Link>::iterator k = links.begin(); k != links.end(); k++)
|
||||||
|
border[count++] = *k;
|
||||||
|
|
||||||
|
borders.borders[p].border_used = links.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
totvert -= duplicated;
|
totvert -= duplicated;
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.6 2004/12/02 20:22:42 ponchio
|
||||||
|
Level 5;
|
||||||
|
|
||||||
Revision 1.5 2004/12/02 19:10:18 ponchio
|
Revision 1.5 2004/12/02 19:10:18 ponchio
|
||||||
Bounding sphere fix.
|
Bounding sphere fix.
|
||||||
|
|
||||||
|
@ -306,17 +309,15 @@ void ThirdStep(const string &crudefile, const string &output,
|
||||||
assert(vcount == vertices.size());
|
assert(vcount == vertices.size());
|
||||||
assert(fcount == faces.size());
|
assert(fcount == faces.size());
|
||||||
|
|
||||||
if(vcount > 65000) {
|
//TODO deal with this case adding another patch at the end... its not that difficult!
|
||||||
cerr << "Too many vertices in this patch: "
|
|
||||||
<< vcount << endl;
|
//This can happen on degenerate cases when we have a lot of detached faces....
|
||||||
|
if(vcount > 65000 && fcount > 65000) {
|
||||||
|
cerr << "Too many vertices or faces in patch: " << patch << " v: " << vcount
|
||||||
|
<< " f: " << fcount << endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fcount > 65000) {
|
|
||||||
cerr << "Too many faces in this patch: "
|
|
||||||
<< fcount << endl;
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
unsigned int patch_idx = nexus.AddPatch(vertices.size(),
|
unsigned int patch_idx = nexus.AddPatch(vertices.size(),
|
||||||
faces.size()/3,
|
faces.size()/3,
|
||||||
0); //no borders!
|
0); //no borders!
|
||||||
|
@ -329,6 +330,12 @@ void ThirdStep(const string &crudefile, const string &output,
|
||||||
sphere.Add(vertices[i]);
|
sphere.Add(vertices[i]);
|
||||||
sphere.Radius() *= 1.01;
|
sphere.Radius() *= 1.01;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
for(int i = 0; i < vertices.size(); i++) {
|
||||||
|
assert(sphere.IsIn(vertices[i]));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//saving vert_remap
|
//saving vert_remap
|
||||||
int64 vroffset = vert_remap.Size();
|
int64 vroffset = vert_remap.Size();
|
||||||
|
@ -369,12 +376,11 @@ void ThirdStep(const string &crudefile, const string &output,
|
||||||
void FourthStep(const string &crudefile, const string &output,
|
void FourthStep(const string &crudefile, const string &output,
|
||||||
unsigned int ram_buffer) {
|
unsigned int ram_buffer) {
|
||||||
Nexus nexus;
|
Nexus nexus;
|
||||||
|
|
||||||
nexus.patches.SetRamBufferSize(ram_buffer);
|
|
||||||
if(!nexus.Load(output)) {
|
if(!nexus.Load(output)) {
|
||||||
cerr << "Could not load nexus " << output << endl;
|
cerr << "Could not load nexus " << output << endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
nexus.patches.SetRamBufferSize(ram_buffer);
|
||||||
//TODO Clear borders in case of failure!
|
//TODO Clear borders in case of failure!
|
||||||
|
|
||||||
VFile<unsigned int> vert_remap;
|
VFile<unsigned int> vert_remap;
|
||||||
|
@ -390,6 +396,10 @@ void FourthStep(const string &crudefile, const string &output,
|
||||||
}
|
}
|
||||||
Report report(nexus.index.size());
|
Report report(nexus.index.size());
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
map<unsigned int, set<unsigned int> > reciprocal;
|
||||||
|
#endif
|
||||||
|
|
||||||
for(int start = 0; start < nexus.index.size(); start++) {
|
for(int start = 0; start < nexus.index.size(); start++) {
|
||||||
report.Step(start);
|
report.Step(start);
|
||||||
Nexus::PatchInfo &s_entry = nexus.index[start];
|
Nexus::PatchInfo &s_entry = nexus.index[start];
|
||||||
|
@ -407,7 +417,20 @@ void FourthStep(const string &crudefile, const string &output,
|
||||||
|
|
||||||
Nexus::PatchInfo &e_entry = nexus.index[end];
|
Nexus::PatchInfo &e_entry = nexus.index[end];
|
||||||
float dist = Distance(s_entry.sphere, e_entry.sphere);
|
float dist = Distance(s_entry.sphere, e_entry.sphere);
|
||||||
if(dist > 0.1) continue;
|
|
||||||
|
if(dist > (s_entry.sphere.Radius() + e_entry.sphere.Radius()) * 0.01) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if(start > end)
|
||||||
|
assert(!reciprocal[end].count(start));
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if(start > end)
|
||||||
|
assert(reciprocal[end].count(start));
|
||||||
|
else
|
||||||
|
reciprocal[start].insert(end);
|
||||||
|
#endif
|
||||||
|
|
||||||
for(unsigned int i = 0; i < vert_index[end].size; i++) {
|
for(unsigned int i = 0; i < vert_index[end].size; i++) {
|
||||||
unsigned int global = vert_remap[vert_index[end].offset + i];
|
unsigned int global = vert_remap[vert_index[end].offset + i];
|
||||||
|
@ -438,12 +461,11 @@ void FifthStep(const string &crudefile, const string &output,
|
||||||
unsigned int max_level) {
|
unsigned int max_level) {
|
||||||
|
|
||||||
Nexus nexus;
|
Nexus nexus;
|
||||||
|
|
||||||
nexus.patches.SetRamBufferSize(ram_buffer);
|
|
||||||
if(!nexus.Load(output)) {
|
if(!nexus.Load(output)) {
|
||||||
cerr << "Could not load nexus " << output << endl;
|
cerr << "Could not load nexus " << output << endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
nexus.patches.SetRamBufferSize(ram_buffer);
|
||||||
|
|
||||||
VChain vchain;
|
VChain vchain;
|
||||||
if(!vchain.Load(output + ".vchain")) {
|
if(!vchain.Load(output + ".vchain")) {
|
||||||
|
@ -761,6 +783,7 @@ void SaveFragment(Nexus &nexus, VChain &chain,
|
||||||
entry.sphere.Add(outpatch.vert[v]);
|
entry.sphere.Add(outpatch.vert[v]);
|
||||||
nexus.sphere.Add(outpatch.vert[v]);
|
nexus.sphere.Add(outpatch.vert[v]);
|
||||||
}
|
}
|
||||||
|
entry.sphere.Radius() *= 1.01;
|
||||||
|
|
||||||
//remap internal borders
|
//remap internal borders
|
||||||
for(unsigned int k = 0; k < outpatch.bord.size(); k++) {
|
for(unsigned int k = 0; k < outpatch.bord.size(); k++) {
|
||||||
|
@ -786,9 +809,11 @@ void SaveFragment(Nexus &nexus, VChain &chain,
|
||||||
Link up(link.end_vert, link.start_vert, patch_idx);
|
Link up(link.end_vert, link.start_vert, patch_idx);
|
||||||
newlinks[link.end_patch].insert(up);
|
newlinks[link.end_patch].insert(up);
|
||||||
|
|
||||||
|
assert(link.end_patch != patch_idx);
|
||||||
Border cborder = nexus.GetBorder(link.end_patch);
|
Border cborder = nexus.GetBorder(link.end_patch);
|
||||||
for(unsigned int k = 0; k < cborder.Size(); k++) {
|
for(unsigned int k = 0; k < cborder.Size(); k++) {
|
||||||
|
//cerr << "Cborder.size: " << cborder.Size() << endl;
|
||||||
|
//cerr << "K: " << k << endl;
|
||||||
Link &clink = cborder[k];
|
Link &clink = cborder[k];
|
||||||
assert(!clink.IsNull());
|
assert(!clink.IsNull());
|
||||||
|
|
||||||
|
@ -839,7 +864,11 @@ void SaveFragment(Nexus &nexus, VChain &chain,
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReverseHistory(vector<Nexus::Update> &history) {
|
void ReverseHistory(vector<Nexus::Update> &history) {
|
||||||
std::reverse(history.begin(), history.end());
|
vector<Nexus::Update> revert = history;
|
||||||
|
history.clear();
|
||||||
|
for(int i = revert.size()-1; i >= 0; i--)
|
||||||
|
history.push_back(revert[i]);
|
||||||
|
//std::reverse(history.begin(), history.end());
|
||||||
vector<Nexus::Update>::iterator i;
|
vector<Nexus::Update>::iterator i;
|
||||||
for(i = history.begin(); i != history.end(); i++)
|
for(i = history.begin(); i != history.end(); i++)
|
||||||
swap((*i).erased, (*i).created);
|
swap((*i).erased, (*i).created);
|
||||||
|
|
|
@ -15,15 +15,18 @@ void SaveFragment(Nexus &nexus, VChain &chain,
|
||||||
|
|
||||||
|
|
||||||
void Opener::execute() {
|
void Opener::execute() {
|
||||||
|
cerr << "Trying to connect to: " << server->get_host() << endl;
|
||||||
server->reading.lock();
|
server->reading.lock();
|
||||||
server->writing.lock();
|
server->writing.lock();
|
||||||
while(1) {
|
while(1) {
|
||||||
if(get_signaled())
|
if(get_signaled())
|
||||||
return;
|
return;
|
||||||
|
cerr << "Trying to connect to: " << server->get_host() << endl;
|
||||||
try {
|
try {
|
||||||
server->open();
|
server->open();
|
||||||
server->connected = true;
|
server->connected = true;
|
||||||
server->queue = 0;
|
server->queue = 0;
|
||||||
|
cerr << "Connected to: " << server->get_host() << endl;
|
||||||
break;
|
break;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,6 @@ void PatchServer::GetVbo(unsigned int p,
|
||||||
void PatchServer::Flush() {
|
void PatchServer::Flush() {
|
||||||
|
|
||||||
if(ram_used < ram_size * 1.1) return;
|
if(ram_used < ram_size * 1.1) return;
|
||||||
|
|
||||||
// ramlock.wrlock();
|
// ramlock.wrlock();
|
||||||
|
|
||||||
make_heap(lru.begin(), lru.end());
|
make_heap(lru.begin(), lru.end());
|
||||||
|
@ -299,6 +298,5 @@ bool PatchServer::FlushVbo(PTime &ptime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchServer::SetRamBufferSize(unsigned int r_buffer) {
|
void PatchServer::SetRamBufferSize(unsigned int r_buffer) {
|
||||||
cerr << "Chunk_size: " << chunk_size << endl;
|
|
||||||
ram_size = (unsigned int)(r_buffer/chunk_size) + 1;
|
ram_size = (unsigned int)(r_buffer/chunk_size) + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,7 @@ void nxs::Remap(VChain &chain,
|
||||||
//Fixing offset
|
//Fixing offset
|
||||||
int64 offset = 0;
|
int64 offset = 0;
|
||||||
for(unsigned int i = 0; i < index.size(); i++) {
|
for(unsigned int i = 0; i < index.size(); i++) {
|
||||||
|
assert(index[i].size < 65000);
|
||||||
index[i].offset = offset;
|
index[i].offset = offset;
|
||||||
offset += index[i].size;
|
offset += index[i].size;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +245,8 @@ void nxs::BuildLevel(VChain &chain,
|
||||||
VPartition &fine = chain[chain.size()-2];
|
VPartition &fine = chain[chain.size()-2];
|
||||||
fine.Init();
|
fine.Init();
|
||||||
|
|
||||||
unsigned int ncells = (unsigned int)(fine.size() * scaling);
|
//unsigned int ncells = (unsigned int)(fine.size() * scaling);
|
||||||
|
unsigned int ncells = (unsigned int)(scaling * totface/target_size);
|
||||||
|
|
||||||
//TODO this method for selecting the seeds is ugly!
|
//TODO this method for selecting the seeds is ugly!
|
||||||
float ratio = ncells/(float)(nexus.index.size() - offset);
|
float ratio = ncells/(float)(nexus.index.size() - offset);
|
||||||
|
@ -382,6 +384,8 @@ bool nxs::Optimize(VPartition &part,
|
||||||
mark[i];
|
mark[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(failed > 0)
|
||||||
|
cerr << "Found " << failed << " patches too big.\n";
|
||||||
|
|
||||||
if(join) {
|
if(join) {
|
||||||
for(unsigned int i = 0; i < part.size(); i++) {
|
for(unsigned int i = 0; i < part.size(); i++) {
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.18 2004/12/01 03:24:32 ponchio
|
||||||
|
Level 2.
|
||||||
|
|
||||||
Revision 1.17 2004/11/30 22:49:39 ponchio
|
Revision 1.17 2004/11/30 22:49:39 ponchio
|
||||||
Level 0.
|
Level 0.
|
||||||
|
|
||||||
|
@ -100,6 +103,8 @@ Created
|
||||||
/**Vector structure on file with simulated mmapping.
|
/**Vector structure on file with simulated mmapping.
|
||||||
* a priority queue of buffers is used
|
* a priority queue of buffers is used
|
||||||
* TODO: port to over 4Gb usable space
|
* TODO: port to over 4Gb usable space
|
||||||
|
* add interface for readonly reads even when file is readwrite...
|
||||||
|
* instead of queue size use ramsize!!!!
|
||||||
* some mechanism to report errors?
|
* some mechanism to report errors?
|
||||||
* use an Iterator?
|
* use an Iterator?
|
||||||
*/
|
*/
|
||||||
|
@ -194,6 +199,7 @@ template <class T> class VFile: public MFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Resize(unsigned int elem) {
|
void Resize(unsigned int elem) {
|
||||||
|
//TODO do i really need to flush?
|
||||||
Flush();
|
Flush();
|
||||||
MFile::Redim((int64)elem * (int64)sizeof(T));
|
MFile::Redim((int64)elem * (int64)sizeof(T));
|
||||||
n_elements = elem;
|
n_elements = elem;
|
||||||
|
|
Loading…
Reference in New Issue