From 9f0290bdfe173f580cfa328d2e1b407ce3040ce5 Mon Sep 17 00:00:00 2001 From: Brandon Lai-Cheong <brandon.lai-cheong@uwaterloo.ca> Date: Mon, 16 Dec 2024 16:03:16 -0500 Subject: [PATCH] Fixed overlap case --- src/shapes/triangle.cpp | 2 +- src/union.cpp | 4 ---- tests/quad_tree_tests.cpp | 17 +++++++++++++++++ tests/union_tests.cpp | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/shapes/triangle.cpp b/src/shapes/triangle.cpp index 3cd04ac..0aa49b7 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 0c3952b..79d345b 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 63ae543..abcff55 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 26f957b..edc842e 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 -- GitLab