diff --git a/src/shapes/triangle.cpp b/src/shapes/triangle.cpp index 3cd04ac24c41d26415986e63c02ada90cbe358a2..0aa49b718225ea591b97c31cf4823de87e8ec4d1 100644 --- a/src/shapes/triangle.cpp +++ b/src/shapes/triangle.cpp @@ -3,7 +3,7 @@ #include "edge.h" #include <triangle_fragment_id_assigner.h> -Triangle::Triangle(const Point &p1, const Point &p2, const Point &p3, int mainTriangleId, std::shared_ptr<std::vector<int>> neighbours) : +Triangle::Triangle(const Point &p1, const Point &p2, const Point &p3, int mainTriangleId, std::shared_ptr<std::vector<int>> neighbours = {}) : points{p1, p2, p3}, mainTriangleId{mainTriangleId}, fragmentId{TriangleFragmentIdAssigner::getInstance().generateUniqueId()}, neighbours{neighbours} {} Triangle::Triangle(const Point &p1, const Point &p2, const Point &p3, int mainTriangleId, const std::vector<int> neighbours) : diff --git a/src/union.cpp b/src/union.cpp index 0c3952b1fee9c1e3129f78f3751b6374b670569e..79d345b4f3a5cc46477a497e424e72f344ca3268 100644 --- a/src/union.cpp +++ b/src/union.cpp @@ -55,10 +55,6 @@ std::vector<Triangle> unionize(const Triangle &t1, const Triangle &t2) if (std::find(t1.neighbours->begin(), t1.neighbours->end(), t2.mainTriangleId) != t1.neighbours->end()) { return {t1, t2}; } - if (intersections(t1, t2).empty()) - { - return {t1, t2}; - } if (t1.points[0].z < t2.points[0].z) { return unionizeTopAndBottom(t1, t2); diff --git a/tests/quad_tree_tests.cpp b/tests/quad_tree_tests.cpp index 63ae5431214287db2beb614c7ed2c257fb9953a7..abcff5559a1560cfe09d67baedb1bc05e5ce79fe 100644 --- a/tests/quad_tree_tests.cpp +++ b/tests/quad_tree_tests.cpp @@ -94,4 +94,21 @@ TEST (QuadTreeTests, DegenerateTrianglesTest) { std::vector<Triangle> expected_surface {t1, t3, t2}; EXPECT_EQ(surface, expected_surface); +} + +TEST (QuadTreeTests, StackingPointsTest) { + +} + +TEST (QuadTreeTests, TriangleCompletelyCoversOthers) { + + QuadTree q({{1,1}, {0,0}}); + Triangle t1{{0,0.1,10}, {0.234, 0.3, 9}, {0.1, 0.5, 9}, 1}; + + Triangle cover{{-100,-100,0}, {100,-1000,0}, {25, 50,0}, 100}; + + q.addTriangle(t1); + q.addTriangle(cover); + std::vector<Triangle> expected {cover}; + EXPECT_EQ(q.visibleSurface(), expected); } \ No newline at end of file diff --git a/tests/union_tests.cpp b/tests/union_tests.cpp index 26f957b44bd02408f4d3f3e2c3d94a5332d38dae..edc842e8ba03d310068aac5900b1e29f137d3308 100644 --- a/tests/union_tests.cpp +++ b/tests/union_tests.cpp @@ -150,5 +150,5 @@ INSTANTIATE_TEST_SUITE_P(ParameterizedUnionTests, InstantiateUnionTests, testing UnionParams{Triangle({0, 0, 0}, {5, 0, 0}, {2, 3, 0}, 1), Triangle(Point{3, 1, 10}, Point{6, 1, 2}, Point{4, 3, 1}, 2), {Triangle({6,1,2}, {4,3,1}, {3.333333,1.66666,7.23542}, 2), Triangle({6,1,2}, {3.33333,1.66667,7.23542}, {4,1,7.3680},2), - Triangle({0,0}, {5,0}, {2,3}, 1)}} + Triangle({0,0}, {5,0}, {2,3}, 1)}}, UnionParams{Triangle({0,0.1,10}, {0.234, 0.3, 9}, {0.1, 0.5, 9}, 1), Triangle({-100, -100, 0}, {100, -100, 0}, {25, 50, 0}, 2), {Triangle({-100, -100}, {100, -100}, {25, 50}, 2)}} )); \ No newline at end of file