123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <test_common.h>
- #include <iostream>
- #include <Eigen/Dense>
- #include <igl/cgal/peel_outer_hull_layers.h>
- #include <igl/cgal/remesh_self_intersections.h>
- #include <igl/cgal/RemeshSelfIntersectionsParam.h>
- #include <igl/per_face_normals.h>
- #include <igl/remove_unreferenced.h>
- #include <igl/writeOBJ.h>
- #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
- TEST(PeelOuterHullLayers, TwoCubes) {
- Eigen::MatrixXd V;
- Eigen::MatrixXi F;
- test_common::load_mesh("two-boxes-bad-self-union.ply", V, F);
- ASSERT_EQ(486, V.rows());
- ASSERT_EQ(708, F.rows());
- typedef CGAL::Exact_predicates_exact_constructions_kernel K;
- typedef K::FT Scalar;
- typedef Eigen::Matrix<Scalar,
- Eigen::Dynamic,
- Eigen::Dynamic> MatrixXe;
- MatrixXe Vs;
- Eigen::MatrixXi Fs, IF;
- Eigen::VectorXi J, IM;
- igl::cgal::RemeshSelfIntersectionsParam param;
- igl::cgal::remesh_self_intersections(V, F, param, Vs, Fs, IF, J, IM);
- std::for_each(Fs.data(),Fs.data()+Fs.size(),
- [&IM](int & a){ a=IM(a); });
- MatrixXe Vt;
- Eigen::MatrixXi Ft;
- igl::remove_unreferenced(Vs,Fs,Vt,Ft,IM);
- const size_t num_faces = Ft.rows();
- Eigen::VectorXi I, flipped;
- size_t num_peels = igl::cgal::peel_outer_hull_layers(Vt, Ft, I, flipped);
- Eigen::MatrixXd vertices(Vt.rows(), Vt.cols());
- std::transform(Vt.data(), Vt.data() + Vt.rows() * Vt.cols(),
- vertices.data(), [](Scalar v) { return CGAL::to_double(v); });
- igl::writeOBJ("debug.obj", vertices, Ft);
- ASSERT_EQ(num_faces, I.rows());
- ASSERT_EQ(0, I.minCoeff());
- ASSERT_EQ(1, I.maxCoeff());
- }
|