Ejemplo n.º 1
0
    void reorientate_triangles(const MatrixFr& vertices, MatrixIr& faces,
            const VectorF& n) {
        assert(vertices.cols() == 3);
        assert(faces.cols() == 3);

        const VectorI& f = faces.row(0);
        const Vector3F& v0 = vertices.row(f[0]);
        const Vector3F& v1 = vertices.row(f[1]);
        const Vector3F& v2 = vertices.row(f[2]);

        Float projected_area = (v1-v0).cross(v2-v0).dot(n);
        if (projected_area < 0) {
            faces.col(2).swap(faces.col(1));
        }
    }
Ejemplo n.º 2
0
 void assert_faces_are_valid(const MatrixIr& faces) {
     assert((faces.col(0).array() != faces.col(1).array()).all());
     assert((faces.col(1).array() != faces.col(2).array()).all());
     assert((faces.col(2).array() != faces.col(1).array()).all());
 }