Windows porting small changes.
This commit is contained in:
parent
f3d0f070f1
commit
b3f9365d70
|
|
@ -96,7 +96,6 @@ bool Nexus::Load(const string &file, bool readonly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nexus::Close() {
|
void Nexus::Close() {
|
||||||
cerr << "Closing!" << endl;
|
|
||||||
if(!index_file) return;
|
if(!index_file) return;
|
||||||
rewind(index_file);
|
rewind(index_file);
|
||||||
|
|
||||||
|
|
@ -174,23 +173,23 @@ void Nexus::Join(const std::set<unsigned int> &patches,
|
||||||
map<unsigned int, vector<unsigned int> > remap;
|
map<unsigned int, vector<unsigned int> > remap;
|
||||||
set<Link> newborders;
|
set<Link> newborders;
|
||||||
set<unsigned int> erased;
|
set<unsigned int> erased;
|
||||||
for(int u = 0; u < history.size(); u++)
|
for(unsigned int u = 0; u < history.size(); u++)
|
||||||
for(int e = 0; e < history[u].erased.size(); e++)
|
for(unsigned int e = 0; e < history[u].erased.size(); e++)
|
||||||
erased.insert(history[u].erased[e]);
|
erased.insert(history[u].erased[e]);
|
||||||
|
|
||||||
set<unsigned int>::const_iterator i;
|
set<unsigned int>::const_iterator patch_idx;
|
||||||
for(i = patches.begin(); i != patches.end(); i++) {
|
for(patch_idx = patches.begin(); patch_idx != patches.end(); patch_idx++) {
|
||||||
unsigned int patch = *i;
|
unsigned int patch = *patch_idx;
|
||||||
PatchInfo &entry = index[patch];
|
PatchInfo &entry = index[patch];
|
||||||
remap[*i].resize(entry.nvert, 0xffffffff);
|
remap[patch].resize(entry.nvert, 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int vcount = 0;
|
unsigned int vcount = 0;
|
||||||
unsigned int fcount = 0;
|
unsigned int fcount = 0;
|
||||||
unsigned int bcount = 0;
|
unsigned int bcount = 0;
|
||||||
for(i = patches.begin(); i != patches.end(); i++) {
|
for(patch_idx = patches.begin(); patch_idx != patches.end(); patch_idx++) {
|
||||||
unsigned int patch = *i;
|
unsigned int patch = *patch_idx;
|
||||||
vector<unsigned int> &vmap = remap[*i];
|
vector<unsigned int> &vmap = remap[patch];
|
||||||
|
|
||||||
PatchInfo &entry = index[patch];
|
PatchInfo &entry = index[patch];
|
||||||
fcount += entry.nface;
|
fcount += entry.nface;
|
||||||
|
|
@ -217,6 +216,7 @@ void Nexus::Join(const std::set<unsigned int> &patches,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//internal
|
//internal
|
||||||
|
//TODO unsigned int &rmpv = remap[link.end_patch][link.end_vert];
|
||||||
if(remap[link.end_patch][link.end_vert] == 0xffffffff) { //first time
|
if(remap[link.end_patch][link.end_vert] == 0xffffffff) { //first time
|
||||||
remap[link.end_patch][link.end_vert] = vmap[link.start_vert];
|
remap[link.end_patch][link.end_vert] = vmap[link.start_vert];
|
||||||
}
|
}
|
||||||
|
|
@ -230,41 +230,29 @@ void Nexus::Join(const std::set<unsigned int> &patches,
|
||||||
newbord.resize(0);
|
newbord.resize(0);
|
||||||
|
|
||||||
fcount = 0;
|
fcount = 0;
|
||||||
for(i = patches.begin(); i != patches.end(); i++) {
|
for(patch_idx = patches.begin(); patch_idx != patches.end(); patch_idx++) {
|
||||||
Patch patch = GetPatch(*i);
|
Patch patch = GetPatch(*patch_idx);
|
||||||
|
|
||||||
vector<unsigned int> &vmap = remap[*i];
|
vector<unsigned int> &vmap = remap[*patch_idx];
|
||||||
|
assert(vmap.size() == patch.nv);
|
||||||
|
|
||||||
for(unsigned int i = 0; i < patch.nv; i++) {
|
for(unsigned int i = 0; i < vmap.size(); i++) {
|
||||||
assert(vmap[i] < vcount);
|
assert(vmap[i] < vcount);
|
||||||
newvert[vmap[i]] = patch.Vert(i);
|
newvert[vmap[i]] = patch.Vert(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for(unsigned int i = 0; i < patch.nf; i++) {
|
|
||||||
unsigned short *face = patch.Face(i);
|
|
||||||
if(patch.Vert(face[0]) == patch.Vert(face[1]) ||
|
|
||||||
patch.Vert(face[0]) == patch.Vert(face[2]) ||
|
|
||||||
patch.Vert(face[1]) == patch.Vert(face[2])) {
|
|
||||||
cerr << "MALEDETTO!" << endl;
|
|
||||||
Point3f &v0 = patch.Vert(face[0]);
|
|
||||||
Point3f &v1 = patch.Vert(face[1]);
|
|
||||||
Point3f &v2 = patch.Vert(face[2]);
|
|
||||||
cerr << "V0: " << v0[0] << " " << v0[1] << " " << v0[2] << endl;
|
|
||||||
cerr << "V1: " << v1[0] << " " << v1[1] << " " << v1[2] << endl;
|
|
||||||
cerr << "V2: " << v2[0] << " " << v2[1] << " " << v2[2] << endl;
|
|
||||||
}
|
|
||||||
if(patch.Face(i)[0] == patch.Face(i)[1] ||
|
|
||||||
patch.Face(i)[0] == patch.Face(i)[2] ||
|
|
||||||
patch.Face(i)[1] == patch.Face(i)[2]) {
|
|
||||||
cerr << "Damn: " << i << endl;
|
|
||||||
cerr << patch.Face(i)[0] << " " << patch.Face(i)[1]
|
|
||||||
<< patch.Face(i)[2] << endl;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
for(unsigned int i = 0; i < patch.nf; i++)
|
for(unsigned int i = 0; i < patch.nf; i++)
|
||||||
for(int k = 0; k < 3; k++)
|
for(int k = 0; k < 3; k++) {
|
||||||
|
//TODO remove this check.
|
||||||
|
if(patch.Face(i)[k] >= vmap.size()) {
|
||||||
|
cerr << "Face overflow: " << patch.Face(i)[k] << endl;
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
assert(patch.Face(i)[k] < vmap.size());
|
||||||
newface[fcount++] = vmap[patch.Face(i)[k]];
|
newface[fcount++] = vmap[patch.Face(i)[k]];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert(fcount == newface.size());
|
assert(fcount == newface.size());
|
||||||
|
|
||||||
set<Link>::iterator b;
|
set<Link>::iterator b;
|
||||||
|
|
@ -337,6 +325,15 @@ void Nexus::Unify(float threshold) {
|
||||||
memcpy(patch.VertBegin(), &(newvert[0]), entry.nvert*sizeof(Point3f));
|
memcpy(patch.VertBegin(), &(newvert[0]), entry.nvert*sizeof(Point3f));
|
||||||
memcpy(patch.FaceBegin(), &(newface[0]), entry.nface*3*sizeof(short));
|
memcpy(patch.FaceBegin(), &(newface[0]), entry.nface*3*sizeof(short));
|
||||||
|
|
||||||
|
//testiamo il tutto... TODO remove this of course
|
||||||
|
for(unsigned int i =0; i < patch.nf; i++) {
|
||||||
|
for(int k =0 ; k < 3; k++)
|
||||||
|
if(patch.Face(i)[k] >= patch.nv) {
|
||||||
|
cerr <<" Unify has problems\n";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fix patch borders now
|
//fix patch borders now
|
||||||
set<unsigned int> close; //bordering pathes
|
set<unsigned int> close; //bordering pathes
|
||||||
Border border = GetBorder(p);
|
Border border = GetBorder(p);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue