Commit cf654955 by Philipp Adolf

Add method for converting IB to Triangles

parent b6cc65b3
...@@ -161,13 +161,11 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) { ...@@ -161,13 +161,11 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
QTime trianglesTimer; QTime trianglesTimer;
trianglesTimer.start(); trianglesTimer.start();
QVector<Triangle> triangles; QVector<Triangle> triangles;
for (int i = 0; i < ib.length(); i+=3) { ibToTriangles(&vb, ib, triangles);
triangles.push_back(Triangle(&vb, ib[i], ib[i+1], ib[i+2]));
}
QVector<Triangle> triangles_regular; QVector<Triangle> triangles_regular;
for (int i = 0; i < ib_regular.length(); i+=3) { ibToTriangles(&vb, ib_regular, triangles);
triangles.push_back(Triangle(&vb, ib_regular[i], ib_regular[i+1], ib_regular[i+2]));
}
qCDebug(log_timing) << "building Triangles:" << formatTimeMeasurement(trianglesTimer.elapsed()); qCDebug(log_timing) << "building Triangles:" << formatTimeMeasurement(trianglesTimer.elapsed());
QTime subTimer; QTime subTimer;
......
...@@ -183,6 +183,12 @@ Triangle::Edge::Name rotate_edge_name(Triangle::Edge::Name edge) { ...@@ -183,6 +183,12 @@ Triangle::Edge::Name rotate_edge_name(Triangle::Edge::Name edge) {
} }
} }
void ibToTriangles(QVector<Vertex> *vb, QVector<unsigned int> &ib, QVector<Triangle> &triangles) {
for (int i = 0; i < ib.length(); i+=3) {
triangles.push_back(Triangle(vb, ib[i], ib[i+1], ib[i+2]));
}
}
QDebug operator<<(QDebug d, const Triangle &triangle) { QDebug operator<<(QDebug d, const Triangle &triangle) {
QDebugStateSaver saver(d); QDebugStateSaver saver(d);
d.nospace() << "Triangle(" << triangle.u_idx() << ", " << triangle.v_idx() << ", " << triangle.w_idx() << "; " << triangle.u().pos << ", " << triangle.v().pos << ", " << triangle.w().pos << ")"; d.nospace() << "Triangle(" << triangle.u_idx() << ", " << triangle.v_idx() << ", " << triangle.w_idx() << "; " << triangle.u().pos << ", " << triangle.v().pos << ", " << triangle.w().pos << ")";
......
...@@ -57,6 +57,8 @@ class Triangle { ...@@ -57,6 +57,8 @@ class Triangle {
bool get_shared_edge_(const Triangle &other, Edge &edge_a, Edge &edge_b) const; bool get_shared_edge_(const Triangle &other, Edge &edge_a, Edge &edge_b) const;
}; };
void ibToTriangles(QVector<Vertex> *vb, QVector<unsigned int> &ib, QVector<Triangle> &triangles);
QDebug operator<<(QDebug d, const Triangle &triangle); QDebug operator<<(QDebug d, const Triangle &triangle);
#endif #endif
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