Commit bf2d4e3a authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[test][disttoboundary] test polygon as well

parent c0e4d447
......@@ -7,6 +7,7 @@
#include <frackit/geometry/disk.hh>
#include <frackit/geometry/quadrilateral.hh>
#include <frackit/geometry/segment.hh>
#include <frackit/geometry/polygon.hh>
#include <frackit/distance/distancetoboundary.hh>
#include <frackit/precision/precision.hh>
......@@ -22,6 +23,7 @@ int main()
using Vector = typename Direction::Vector;
using Segment = Frackit::Segment<ctype, 3>;
using Quad = Frackit::Quadrilateral<ctype, 3>;
using Polygon = Frackit::Polygon<ctype, 3>;
// base directions
Direction e1(Vector(1.0, 0.0, 0.0));
......@@ -70,6 +72,15 @@ int main()
if (!std::holds_alternative<Segment>(is2)) throw std::runtime_error("Expected segment intersection");
d = computeDistanceToBoundary(Frackit::OCCUtilities::getShape(std::get<Segment>(is2)), quad);
if (abs(d - 1e-6*f) > eps) printAndThrow(d, "Test 6 failed");
// do the same with the quadrilateral represented by a polygon
using CornerVector = std::vector<Point>;
const Polygon poly(CornerVector{{Point(-0.5*f, -0.5*f, 0.0), Point(0.5*f, -0.5*f, 0.0),
Point(0.5*f, 0.5*f, 0.0), Point(-0.5*f, 0.5*f, 0.0)}});
const auto is3 = intersect(poly, disk2, eps);
if (!std::holds_alternative<Segment>(is3)) throw std::runtime_error("Expected segment intersection");
d = computeDistanceToBoundary(Frackit::OCCUtilities::getShape(std::get<Segment>(is3)), poly);
if (abs(d - 1e-6*f) > eps) printAndThrow(d, "Test 7 failed");
}
std::cout << "All tests passed" << std::endl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment