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,13 +82,24 @@ void Subdivision::precomputeTables(Mesh *mesh) { ...@@ -82,13 +82,24 @@ 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){ /*
* Find edge xy in all other triangles, add to edgeIndices_base
* Find edge yz
* Find edge zx
* - We assume that we have a closed surface, i.e. each triangle has exactly one adjacent triangle at each edge
* - Each edge point will be computed twice. This allows us to implicitly know the adjacent points.
*/
//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 //search all following triangles for common edge
Vertex a,b,c; Vertex a,b,c;
unsigned int a_i, b_i, c_i; unsigned int a_i, b_i, c_i;
...@@ -108,22 +119,30 @@ void Subdivision::precomputeTables(Mesh *mesh) { ...@@ -108,22 +119,30 @@ void Subdivision::precomputeTables(Mesh *mesh) {
if (x.samePos(a) && y.samePos(c)){ if (x.samePos(a) && y.samePos(c)){
edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,b_i)); edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,b_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) && y.samePos(a)){ if (x.samePos(b) && y.samePos(a)){
edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,c_i)); edgeIndices_base.push_back(fillVector(x_i,y_i,z_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) && y.samePos(b)){ if (x.samePos(c) && y.samePos(b)){
edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,a_i)); edgeIndices_base.push_back(fillVector(x_i,y_i,z_i,a_i));
} }
if (x.samePos(c) && z.samePos(a)){ }
edgeIndices_base.push_back(fillVector(x_i,z_i,y_i,b_i));
} }
//find indices for edge point on yz-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];
//yz = ba, cb, ac
if (y.samePos(a) && z.samePos(c)){ if (y.samePos(a) && z.samePos(c)){
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,b_i)); edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,b_i));
} }
...@@ -133,7 +152,37 @@ void Subdivision::precomputeTables(Mesh *mesh) { ...@@ -133,7 +152,37 @@ void Subdivision::precomputeTables(Mesh *mesh) {
if (y.samePos(c) && z.samePos(b)){ if (y.samePos(c) && z.samePos(b)){
edgeIndices_base.push_back(fillVector(y_i,z_i,x_i,a_i)); 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