#include "gtest/gtest.h"
#include <algorithm>
TEST(Domains, DiscretizeTriangleWithDensity) {
Vec3d p1 = {0, 0, 1}, p2 = {0, 1, 0}, p3 = {1, 0, 0};
Vec3d n = (p2-p1).cross(p3-p1).normalized();
auto fn = [](
const Vec3d&) {
return 0.3; };
p1, p2, p3, n, fn, false);
p1, p2, p3, n, fn, true);
for (const auto& p : pts_only_int) {
auto it = std::find(pts_with_bnd.begin(), pts_with_bnd.end(), p);
EXPECT_NE(it, pts_with_bnd.end());
}
if (n[0] < 0) { n = -n; }
int s = pts_with_bnd.size();
for (int i = 0; i < s; ++i) {
for (int j = i+1; j < s; ++j) {
auto q1 = pts_with_bnd[i], q2 = pts_with_bnd[j];
for (int k = j+1; k < s; ++k) {
auto q3 = pts_with_bnd[k];
Vec3d local_normal = (q1-q2).cross(q1-q3);
double len = local_normal.norm();
if (len < 1e-14) continue;
local_normal /= len;
if (local_normal[0] < 0) { local_normal = -local_normal; }
EXPECT_LT((local_normal-n).norm(), 2e-14);
}
EXPECT_GE((q2-q1).norm(), 0.2);
}
}
}
}