Commit 188a8f55 by Alisa Jung

Compute edge points in order xy, yz, zx (vertex 0-vertex1, vertex1-vertex2, vertex2-vertex0).

Also compute duplicate edge points for second traingle.
parent 21b7ca5c
...@@ -82,58 +82,107 @@ void Subdivision::precomputeTables(Mesh *mesh) { ...@@ -82,58 +82,107 @@ void Subdivision::precomputeTables(Mesh *mesh) {
unsigned int x_i = ib[i]; unsigned int x_i = ib[i];
unsigned int y_i = ib[i+1]; unsigned int y_i = ib[i+1];
unsigned int z_i = ib[i+2]; unsigned int z_i = ib[i+2];
//get vertices x,y,z from vertex buffer
x = vb[x_i];//todo maybe check array length x = vb[x_i];//todo maybe check array length
y = vb[y_i]; y = vb[y_i];
z = vb[z_i]; z = vb[z_i];
//get vertices x,y,z from vertex buffer
for (int j = i+3; j < ib.length(); j+= 3){ /*
//search all following triangles for common edge * Find edge xy in all other triangles, add to edgeIndices_base
Vertex a,b,c; * Find edge yz
unsigned int a_i, b_i, c_i; * Find edge zx
a_i = ib[j]; * - We assume that we have a closed surface, i.e. each triangle has exactly one adjacent triangle at each edge
b_i = ib[j+1]; * - Each edge point will be computed twice. This allows us to implicitly know the adjacent points.
c_i = ib[j+2]; */
a = vb[a_i]; //find indices for edge point on xy-edge
b = vb[b_i]; for (int j = 0; j < ib.length(); j+= 3){
c = vb[c_i]; if (j != i){
//search all following triangles for common edge
//get vertices for a,b,c from vertex buffer Vertex a,b,c;
//comparisons: xy = ba, cb, ac. unsigned int a_i, b_i, c_i;
//yz = ba, cb, ac a_i = ib[j];
//zx = ba, cb, ac b_i = ib[j+1];
//TODO if oder else if? c_i = ib[j+2];
if (x.samePos(a) && y.samePos(c)){
edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,b_i)); a = vb[a_i];
} b = vb[b_i];
if (x.samePos(a) && z.samePos(b)){ c = vb[c_i];
edgeIndices_base.push_back(fillVector(x_i,z_i,y_i,c_i));
} //get vertices for a,b,c from vertex buffer
if (x.samePos(b) && y.samePos(a)){ //comparisons: xy = ba, cb, ac.
edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,c_i)); //yz = ba, cb, ac
} //zx = ba, cb, ac
if (x.samePos(b) && z.samePos(c)){ //TODO if oder else if?
edgeIndices_base.push_back(fillVector(x_i,z_i,y_i,a_i)); if (x.samePos(a) && y.samePos(c)){
} edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,b_i));
if (x.samePos(c) && y.samePos(b)){ }
edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,a_i)); if (x.samePos(b) && y.samePos(a)){
} edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,c_i));
if (x.samePos(c) && z.samePos(a)){ }
edgeIndices_base.push_back(fillVector(x_i,z_i,y_i,b_i)); if (x.samePos(c) && y.samePos(b)){
edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,a_i));
}
} }
}
if (y.samePos(a) && z.samePos(c)){ //find indices for edge point on yz-edge
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,b_i)); for (int j = 0; j < ib.length(); j+= 3){
} if (j != i){
if (y.samePos(b) && z.samePos(a)){ //search all following triangles for common edge
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,c_i)); Vertex a,b,c;
unsigned int a_i, b_i, c_i;
a_i = ib[j];
b_i = ib[j+1];
c_i = ib[j+2];
a = vb[a_i];
b = vb[b_i];
c = vb[c_i];
//yz = ba, cb, ac
if (y.samePos(a) && z.samePos(c)){
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,b_i));
}
if (y.samePos(b) && z.samePos(a)){
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,c_i));
}
if (y.samePos(c) && z.samePos(b)){
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,a_i));
}
} }
if (y.samePos(c) && z.samePos(b)){ }
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,a_i));
//find indices for edge point on xy-edge
for (int j = 0; j < ib.length(); j+= 3){
if (j != i){
//search all following triangles for common edge
Vertex a,b,c;
unsigned int a_i, b_i, c_i;
a_i = ib[j];
b_i = ib[j+1];
c_i = ib[j+2];
a = vb[a_i];
b = vb[b_i];
c = vb[c_i];
if (x.samePos(a) && z.samePos(b)){
edgeIndices_base.push_back(fillVector(x_i,z_i,y_i,c_i));
}
if (x.samePos(b) && z.samePos(c)){
edgeIndices_base.push_back(fillVector(x_i,z_i,y_i,a_i));
}
if (x.samePos(c) && z.samePos(a)){
edgeIndices_base.push_back(fillVector(x_i,z_i,y_i,b_i));
}
} }
}//quadratische Laufzeit ftw }//quadratische Laufzeit ftw
//Wichtig: Wir gehen davon aus, dass wir geschlossene Oberflächen haben, dh für jede Kante von einem Dreieck wird eine passende Kante bei einem anderen Dreieck gefunden.
} }
qDebug()<<"Done with edge table. "<<edgeIndices_base.length()<<" edges found. Table: "<<edgeIndices_base; qDebug()<<"Done with edge table. "<<edgeIndices_base.length()<<" edges found. Table: "<<edgeIndices_base;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment