Пример #1
0
TEST(PointInsideComponent, near_corner) {
    Eigen::MatrixXd V1;
    Eigen::MatrixXi F1;
    test_common::load_mesh("cube.obj", V1, F1);

    const double EPS = std::numeric_limits<double>::epsilon();
    Eigen::MatrixXd P_out(8, 3);
    P_out << 0.5 + EPS, 0.5 + EPS, 0.5 + EPS,
            -0.5 - EPS, 0.5 + EPS, 0.5 + EPS,
             0.5 + EPS,-0.5 - EPS, 0.5 + EPS,
            -0.5 - EPS,-0.5 - EPS, 0.5 + EPS,
             0.5 + EPS, 0.5 + EPS,-0.5 - EPS,
            -0.5 - EPS, 0.5 + EPS,-0.5 - EPS,
             0.5 + EPS,-0.5 - EPS,-0.5 - EPS,
            -0.5 - EPS,-0.5 - EPS,-0.5 - EPS;

    Eigen::VectorXi inside;
    EXPECT_NO_THROW(igl::copyleft::cgal::points_inside_component(V1, F1, P_out, inside));
    ASSERT_TRUE((inside.array()==0).all());

    Eigen::MatrixXd P_in(8, 3);
    P_in << 0.5 - EPS, 0.5 - EPS, 0.5 - EPS,
           -0.5 + EPS, 0.5 - EPS, 0.5 - EPS,
            0.5 - EPS,-0.5 + EPS, 0.5 - EPS,
           -0.5 + EPS,-0.5 + EPS, 0.5 - EPS,
            0.5 - EPS, 0.5 - EPS,-0.5 + EPS,
           -0.5 + EPS, 0.5 - EPS,-0.5 + EPS,
            0.5 - EPS,-0.5 + EPS,-0.5 + EPS,
           -0.5 + EPS,-0.5 + EPS,-0.5 + EPS;
    EXPECT_NO_THROW(igl::copyleft::cgal::points_inside_component(V1, F1, P_in, inside));
    ASSERT_TRUE((inside.array()==1).all());
}
Пример #2
0
IGL_INLINE bool igl::decimate(
  const Eigen::MatrixXd & V,
  const Eigen::MatrixXi & F,
  const size_t max_m,
  Eigen::MatrixXd & U,
  Eigen::MatrixXi & G,
  Eigen::VectorXi & J,
  Eigen::VectorXi & I)
{
  // Original number of faces
  const int orig_m = F.rows();
  // Tracking number of faces
  int m = F.rows();
  typedef Eigen::MatrixXd DerivedV;
  typedef Eigen::MatrixXi DerivedF;
  DerivedV VO;
  DerivedF FO;
  igl::connect_boundary_to_infinity(V,F,VO,FO);
  bool ret = decimate(
    VO,
    FO,
    shortest_edge_and_midpoint,
    max_faces_stopping_condition(m,orig_m,max_m),
    U,
    G,
    J,
    I);
  const Eigen::Array<bool,Eigen::Dynamic,1> keep = (J.array()<orig_m);
  igl::slice_mask(Eigen::MatrixXi(G),keep,1,G);
  igl::slice_mask(Eigen::VectorXi(J),keep,1,J);
  Eigen::VectorXi _1,I2;
  igl::remove_unreferenced(Eigen::MatrixXd(U),Eigen::MatrixXi(G),U,G,_1,I2);
  igl::slice(Eigen::VectorXi(I),I2,1,I);
  return ret;
}