36 void assign_quadrature(
const Quadrature &tri_quadr_pts,
const Eigen::MatrixXi &tris,
const Eigen::MatrixXd pts, Quadrature &quadr)
54 quadr.points.block(i * offset, 0, trafod_pts.rows(), trafod_pts.cols()) = trafod_pts;
55 quadr.weights.block(i * offset, 0, tri_quadr_pts.weights.rows(), tri_quadr_pts.weights.cols()) = tri_quadr_pts.weights * det;
70#ifdef POLYFEM_WITH_TRIANGLE
71 Eigen::MatrixXi E(poly.rows(), 2);
72 const Eigen::MatrixXd H(0, 2);
73 const std::string flags =
"Qzqa0.01";
75 for (
int i = 0; i < poly.rows(); ++i)
76 E.row(i) << i, (i + 1) % poly.rows();
81 igl::triangle::triangulate(poly, E, H, flags, pts, tris);
82 assign_quadrature(tri_quadr_pts, tris, pts, quadr);
84 Eigen::MatrixXd asd(pts.rows(), 3);
85 asd.col(0) = pts.col(0);
86 asd.col(1) = pts.col(1);
88 igl::write_triangle_mesh(
"quad.obj", asd, tris);
91 const int n_vertices = poly.rows();
95 Eigen::MatrixXi tris(n_vertices, 3);
96 Eigen::MatrixXd pts(n_vertices + 1, 2);
97 pts.row(n_vertices) = poly.colwise().mean();
99 for (
int e = 0; e < n_vertices; ++e)
101 const int ep = (e + 1) % n_vertices;
102 tris.row(e) << e, ep, n_vertices;
103 pts.row(e) = poly.row(e);
105 tmp.row(0) = poly.row(e);
106 tmp.row(1) = poly.row(ep);
108 area += tmp.determinant();
113 assign_quadrature(tri_quadr_pts, tris, pts, quadr);
116 if (quadr.
weights.minCoeff() < 0)
118 const Eigen::MatrixXi rt = Eigen::MatrixXi::Zero(poly.rows(), 1);
121 igl::predicates::ear_clipping(poly, rt, tris, I);
123 assign_quadrature(tri_quadr_pts, tris, poly, quadr);
127 assert(quadr.
weights.minCoeff() >= 0);