7 #include <Delaunay_psm.h>
12 Eigen::Ref<const Eigen::MatrixXd> points)
15 Eigen::MatrixXi tetrahedra;
17 if (points.rows() == 0) {
18 wmtk::logger().warn(
"Cannot run delaunay on an empty point set");
22 int64_t dim = points.cols();
24 static std::once_flag once_flag;
25 std::call_once(once_flag, []() { GEO::initialize(); });
27 GEO::Delaunay_var engine;
30 engine = GEO::Delaunay::create(2,
"BDEL2d");
34 engine = GEO::Delaunay::create(3,
"BDEL");
37 default:
throw std::runtime_error(
"unexpected vector type in delaunay_geogram");
43 engine->set_reorder(
false);
44 engine->set_stores_cicl(
false);
45 engine->set_stores_neighbors(
false);
46 engine->set_refine(
false);
47 engine->set_keeps_infinite(
false);
50 geo_assert(points.size() > 0);
51 Eigen::MatrixXd points_transposed = points.transpose();
52 engine->set_vertices(
static_cast<GEO::index_t
>(points.rows()), points_transposed.data());
55 vertices.resize(engine->nb_vertices(), dim);
56 tetrahedra.resize(engine->nb_cells(), dim + 1);
58 for (GEO::index_t i = 0; i <
vertices.rows(); ++i) {
62 vertices.row(i) = Eigen::Map<const Eigen::Vector2d>(engine->vertex_ptr(i)).transpose();
66 vertices.row(i) = Eigen::Map<const Eigen::Vector3d>(engine->vertex_ptr(i)).transpose();
78 for (GEO::index_t i = 0; i < tetrahedra.rows(); ++i) {
79 for (GEO::index_t j = 0; j < tetrahedra.cols(); ++j) {
80 tetrahedra(i, j) = engine->cell_vertex(i, j);
std::tuple< Eigen::MatrixXd, Eigen::MatrixXi > delaunay_geogram(Eigen::Ref< const Eigen::MatrixXd > points)
std::vector< Tuple > vertices(const Mesh &m, const Simplex &simplex)
spdlog::logger & logger()
Retrieves the current logger.