Commit a8bc7b1f by Philipp Adolf

Extract code into getAllVertices

parent 25fccdc3
...@@ -1057,19 +1057,32 @@ bool Subdivision::containsVertex(QVector<Vertex> &vertices, Vertex vertex) { ...@@ -1057,19 +1057,32 @@ bool Subdivision::containsVertex(QVector<Vertex> &vertices, Vertex vertex) {
return false; return false;
} }
QVector<Vertex> Subdivision::getAllVertices(const QVector<Triangle> &triangles) {
QVector<Vertex> result;
QVectorIterator<Triangle> i(triangles);
while (i.hasNext()) {
Triangle extra_triangle = i.next();
if (!containsVertex(result, extra_triangle.u()))
result.push_back(extra_triangle.u());
if (!containsVertex(result, extra_triangle.v()))
result.push_back(extra_triangle.v());
if (!containsVertex(result, extra_triangle.w()))
result.push_back(extra_triangle.w());
}
return result;
}
QVector3D Subdivision::updateIrregularVertexForDraw(Vertex currentCorner, QVector<Triangle> neighboring_triangles) { QVector3D Subdivision::updateIrregularVertexForDraw(Vertex currentCorner, QVector<Triangle> neighboring_triangles) {
QVector<Vertex> surroundingVertex; QVector<Vertex> surroundingVertex;
QVectorIterator<Triangle> extra(neighboring_triangles); surroundingVertex = getAllVertices(neighboring_triangles);
while (extra.hasNext()) { QMutableVectorIterator<Vertex> i(surroundingVertex);
Triangle extra_triangle = extra.next(); while (i.hasNext()) {
if (currentCorner.samePos(i.next())) {
if (!currentCorner.samePos(extra_triangle.u()) && !containsVertex(surroundingVertex, extra_triangle.u())) i.remove();
surroundingVertex.push_back(extra_triangle.u()); break;
if (!currentCorner.samePos(extra_triangle.v()) && !containsVertex(surroundingVertex, extra_triangle.v())) }
surroundingVertex.push_back(extra_triangle.v());
if (!currentCorner.samePos(extra_triangle.w()) && !containsVertex(surroundingVertex, extra_triangle.w()))
surroundingVertex.push_back(extra_triangle.w());
} }
QVector3D newPos(0.0, 0.0, 0.0); QVector3D newPos(0.0, 0.0, 0.0);
......
...@@ -72,6 +72,7 @@ private: ...@@ -72,6 +72,7 @@ private:
void runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indices_handle, GLuint output_handle, GLuint offset_handle); void runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indices_handle, GLuint output_handle, GLuint offset_handle);
void updateIrregularForDraw(const QVector<Triangle> &triangles, QMap<Triangle, Triangle::Neighbors> &neighbors, Result &result); void updateIrregularForDraw(const QVector<Triangle> &triangles, QMap<Triangle, Triangle::Neighbors> &neighbors, Result &result);
bool containsVertex(QVector<Vertex> &vertices, Vertex vertex); bool containsVertex(QVector<Vertex> &vertices, Vertex vertex);
QVector<Vertex> getAllVertices(const QVector<Triangle> &triangles);
QVector3D updateIrregularVertexForDraw(Vertex currentCorner, QVector<Triangle> neighboring_triangles); QVector3D updateIrregularVertexForDraw(Vertex currentCorner, QVector<Triangle> neighboring_triangles);
QVector<unsigned int> patchIBToTriangleIB(QVector<unsigned int> ib); QVector<unsigned int> patchIBToTriangleIB(QVector<unsigned int> ib);
......
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