19 const Eigen::Ref<Eigen::MatrixXd> p,
20 const Eigen::Ref<Eigen::MatrixXd> v)
22 REQUIRE(p.cols() == v.cols());
23 REQUIRE(p.rows() <= v.rows());
25 std::vector<Eigen::VectorXd> vv;
27 for (Eigen::Index i = 0; i < v.rows(); ++i) {
28 vv.emplace_back(v.row(i));
31 auto v_less = [](
const Eigen::Ref<Eigen::VectorXd> a,
const Eigen::Ref<Eigen::VectorXd> b) {
32 for (Eigen::Index i = 0; i < a.rows() - 1; ++i) {
37 return a[a.rows() - 1] < b[b.rows() - 1];
40 std::sort(vv.begin(), vv.end(), v_less);
41 for (Eigen::Index i = 0; i < p.rows(); ++i) {
42 const Eigen::VectorXd r = p.row(i);
43 CHECK(std::find(vv.begin(), vv.end(), r) != vv.end());
101TEST_CASE(
"delaunay_2d_random",
"[components][delaunay]")
103 std::uniform_real_distribution<double> distribution(-1, 1);
104 std::default_random_engine random_engine;
108 for (
size_t i = 0; i < 100; ++i) {
109 const double x = distribution(random_engine);
110 const double y = distribution(random_engine);
111 points.row(i) << x, y;
114 Eigen::MatrixXd vertices;
115 Eigen::MatrixXi faces;
120 paraviewo::VTUWriter writer;
121 writer.write_mesh(
"delaunay_2d_random.vtu", vertices, faces);
125TEST_CASE(
"delaunay_3d_nine_points",
"[components][delaunay]")
129 points.row(0) << -1, -1, -1;
130 points.row(1) << 1, -1, -1;
131 points.row(2) << -1, 1, -1;
132 points.row(3) << -1, -1, 1;
133 points.row(4) << 1, 1, -1;
134 points.row(5) << -1, 1, 1;
135 points.row(6) << 1, -1, 1;
136 points.row(7) << 1, 1, 1;
137 points.row(8) << 0, 0, 0;
139 Eigen::MatrixXd vertices;
140 Eigen::MatrixXi faces;
142 CHECK(points == vertices);
145 paraviewo::VTUWriter writer;
146 writer.write_mesh(
"delaunay_3d_nine_points.vtu", vertices, faces);
150TEST_CASE(
"delaunay_3d_random",
"[components][delaunay]")
152 std::uniform_real_distribution<double> distribution(-1, 1);
153 std::default_random_engine random_engine;
157 for (
size_t i = 0; i < 100; ++i) {
158 const double x = distribution(random_engine);
159 const double y = distribution(random_engine);
160 const double z = distribution(random_engine);
161 points.row(i) << x, y, z;
164 Eigen::MatrixXd vertices;
165 Eigen::MatrixXi faces;
170 paraviewo::VTUWriter writer;
171 writer.write_mesh(
"delaunay_3d_random.vtu", vertices, faces);