Commit cf654955 by Philipp Adolf

Add method for converting IB to Triangles

parent b6cc65b3
......@@ -161,13 +161,11 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
QTime trianglesTimer;
trianglesTimer.start();
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]));
}
ibToTriangles(&vb, ib, triangles);
QVector<Triangle> triangles_regular;
for (int i = 0; i < ib_regular.length(); i+=3) {
triangles.push_back(Triangle(&vb, ib_regular[i], ib_regular[i+1], ib_regular[i+2]));
}
ibToTriangles(&vb, ib_regular, triangles);
qCDebug(log_timing) << "building Triangles:" << formatTimeMeasurement(trianglesTimer.elapsed());
QTime subTimer;
......
......@@ -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) {
QDebugStateSaver saver(d);
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 {
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);
#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