Debian Codegraph @

test/unit/cpp/geometry/IntersectionConstruction.cpp

raw
1 // Copyright (C) 2017 Benjamin Kehlet
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // Unit tests for intersection construction
19
20 #include <dolfin/geometry/IntersectionConstruction.h>
21 #include <dolfin/geometry/Point.h>
22 #include <dolfin/geometry/predicates.h>
23 #include <catch.hpp>
24
25 using namespace dolfin;
26
27
28 //-----------------------------------------------------------------------------
29 TEST_CASE("Intersection construction test")
30 {
31 SECTION("failing case triangle_segment_3d")
32 {
33 const Point p0(0.333333333333333315, 0, 0.333333333333333315);
34 const Point p1(0.66666666666666663, 0, 0.333333333333333315);
35 const Point p2(0.66666666666666663, 0.333333333333333315, 0.333333333333333315);
36
37 const Point q0(0.5, 0.25, 0.25);
38 const Point q1(0.75, 0.25, 0.5);
39
40 const Point ref_res(0.583333333333333259, 0.25, 0.333333333333333315);
41
42 std::vector<Point> res = dolfin::IntersectionConstruction::intersection_triangle_segment_3d(p0, p1, p2,
43 q0, q1);
44
45 CHECK( res.size() == 1 );
46 CHECK( (res[0] - ref_res).norm() < 1e-15 );
47 }
48
49 // SECTION("failing case tetrahedron_tetrahedron_3d")
50 // {
51 // const Point p0(0.333333333333333315, 0, 0.333333333333333315);
52 // const Point p1(0.333333333333333315, 0, 0.66666666666666663);
53 // const Point p2(0.333333333333333315, 0.333333333333333315, 0.66666666666666663);
54 // const Point p3(0.66666666666666663, 0.333333333333333315, 0.66666666666666663);
55 // const Point q0(0.25, 0.25, 0.5);
56 // const Point q1(0.25, 0.25, 0.75);
57 // const Point q2(0.5, 0.25, 0.75);
58 // const Point q3(0.5, 0.5, 0.75);
59
60 // const std::vector<Point> res =
61 // IntersectionConstruction::intersection_tetrahedron_tetrahedron_3d(p0, p1, p2, p3,
62 // q0, q1, q2, q3);
63 // CHECK(res.size() == 5);
64 // }
65 }
66 //-----------------------------------------------------------------------------