From fe38b3887b695f27baf791df34b7361ee11b379f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 3 Nov 2024 22:00:46 +0000 Subject: Remove extrusion extents that rounded to the same vertex --- test/test-geoData.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 35d6bae..b0261db 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -276,3 +276,15 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/ Texture::save(tro.outImage, cam.second.c_str()); }); } + +BOOST_DATA_TEST_CASE( + deformMulti, loadFixtureJson>>("geoData/deform/multi1.json"), points) +{ + BOOST_REQUIRE(!points.empty()); + Surface surface; + auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); + for (const auto & strip : points) { + BOOST_REQUIRE_GE(strip.size(), 3); + BOOST_CHECK_NO_THROW(gd->setHeights(strip, surface)); + } +} -- cgit v1.2.3 From 39985f36e807126b2c7b9ec6096bda3922903a54 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 15 Dec 2024 14:38:00 +0000 Subject: 2D triangle area support --- test/test-geoData.cpp | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 5411b61..1ca050d 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -190,23 +190,6 @@ BOOST_DATA_TEST_CASE(walkTerrainUntil, BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); } -BOOST_AUTO_TEST_CASE(triangle_helpers) -{ - constexpr static GeoData::Triangle<3> t {{0, 0, 0}, {5, 0, 0}, {5, 5, 0}}; - - BOOST_CHECK_EQUAL(t.nnormal(), up); - BOOST_CHECK_CLOSE(t.angle(0), quarter_pi, 0.01F); - BOOST_CHECK_CLOSE(t.angleAt({0, 0, 0}), quarter_pi, 0.01F); - BOOST_CHECK_CLOSE(t.angle(1), half_pi, 0.01F); - BOOST_CHECK_CLOSE(t.angleAt({5, 0, 0}), half_pi, 0.01F); - BOOST_CHECK_CLOSE(t.angle(2), quarter_pi, 0.01F); - BOOST_CHECK_CLOSE(t.angleAt({5, 5, 0}), quarter_pi, 0.01F); - - BOOST_CHECK_CLOSE(t.angleAt({0, 1, 0}), 0.F, 0.01F); - - BOOST_CHECK_CLOSE(t.area(), 12.5F, 0.01F); -} - using FindEntiesData = std::tuple; BOOST_DATA_TEST_CASE(findEntries, -- cgit v1.2.3 From 9f80b4b9ed43db91035ed3ddbf9bad4c40c9cf9d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 18 Dec 2024 14:55:33 +0000 Subject: Don't make arbitrary changes to mesh for triangle boundaries Making these arbitrary changes can lead to inverted adjacent faces, instead just: a) use the near node where it is, or b) create the edge split along its length without lateral movement Same principal as previous commit, addresses issues where tracing would fail seemingly at random and throws on error now. --- test/test-geoData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 1ca050d..5998789 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -269,6 +269,6 @@ BOOST_DATA_TEST_CASE( auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); for (const auto & strip : points) { BOOST_REQUIRE_GE(strip.size(), 3); - BOOST_CHECK_NO_THROW(gd->setHeights(strip, {.surface = surface})); + BOOST_CHECK_NO_THROW(gd->setHeights(strip, {.surface = surface, .nearNodeTolerance = 50})); } } -- cgit v1.2.3 From a007ffeed3cfa6af2cbe1053c330ad11927d58de Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 18 Dec 2024 17:24:02 +0000 Subject: Add sanity checking logic to GeoData --- test/test-geoData.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 5998789..9ec4656 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -29,11 +29,9 @@ BOOST_AUTO_TEST_CASE(loadSuccess) BOOST_CHECK_EQUAL(upper, GlobalPosition3D(319950000, 499950000, 571600)); } -BOOST_AUTO_TEST_CASE(normalsAllPointUp) +BOOST_AUTO_TEST_CASE(sanityCheck) { - BOOST_CHECK(std::ranges::all_of(vertices(), [this](auto && vertex) { - return normal(vertex).z > 0; - })); + BOOST_CHECK_NO_THROW(sanityCheck()); } BOOST_AUTO_TEST_CASE(trianglesContainsPoints) @@ -214,9 +212,7 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/ surface.colorBias = RGB {0, 0, 1}; auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); BOOST_CHECK_NO_THROW(gd->setHeights(points, {.surface = surface})); - BOOST_CHECK(std::ranges::all_of(gd->vertices(), [&gd](auto && vertex) { - return gd->normal(vertex).z > 0; - })); + BOOST_CHECK_NO_THROW(gd->sanityCheck()); ApplicationBase ab; TestMainWindow tmw; -- cgit v1.2.3 From 7a0121a612e901585fef39c1b599d53a21cb0afe Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 22 Dec 2024 12:58:57 +0000 Subject: SetHeightOptions surface changed to defaulted pointer --- test/test-geoData.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 9ec4656..589f675 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -211,7 +211,7 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/ Surface surface; surface.colorBias = RGB {0, 0, 1}; auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); - BOOST_CHECK_NO_THROW(gd->setHeights(points, {.surface = surface})); + BOOST_CHECK_NO_THROW(gd->setHeights(points, {.surface = &surface})); BOOST_CHECK_NO_THROW(gd->sanityCheck()); ApplicationBase ab; @@ -265,6 +265,6 @@ BOOST_DATA_TEST_CASE( auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); for (const auto & strip : points) { BOOST_REQUIRE_GE(strip.size(), 3); - BOOST_CHECK_NO_THROW(gd->setHeights(strip, {.surface = surface, .nearNodeTolerance = 50})); + BOOST_CHECK_NO_THROW(gd->setHeights(strip, {.surface = &surface, .nearNodeTolerance = 50})); } } -- cgit v1.2.3 From 89068c56f3236b65e392cdc8794c5bc1977e5556 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 30 Dec 2024 17:18:26 +0000 Subject: Pass lots more information during GeoData::walk --- test/test-geoData.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 589f675..dd68375 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -148,8 +148,11 @@ BOOST_DATA_TEST_CASE(walkTerrain, from, to, visits) { std::vector visited; - BOOST_CHECK_NO_THROW(fixedTerrtain.walk(from, to, [&visited](auto fh) { - visited.emplace_back(fh.idx()); + BOOST_CHECK_NO_THROW(fixedTerrtain.walk(from, to, [&visited](auto step) { + if (!visited.empty()) { + BOOST_CHECK_EQUAL(step.previous.idx(), visited.back()); + } + visited.emplace_back(step.current.idx()); })); BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); } @@ -181,8 +184,8 @@ BOOST_DATA_TEST_CASE(walkTerrainUntil, from, to, visits) { std::vector visited; - BOOST_CHECK_NO_THROW(fixedTerrtain.walkUntil(from, to, [&visited](auto fh) { - visited.emplace_back(fh.idx()); + BOOST_CHECK_NO_THROW(fixedTerrtain.walkUntil(from, to, [&visited](const auto & step) { + visited.emplace_back(step.current.idx()); return visited.size() >= 5; })); BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); -- cgit v1.2.3 From ca3736b3a896557536c0aa4c0cee1f156e118b54 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 1 Jan 2025 12:53:43 +0000 Subject: Walk terrain along a curve - edge cases exist --- test/test-geoData.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index dd68375..049d896 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -191,6 +191,46 @@ BOOST_DATA_TEST_CASE(walkTerrainUntil, BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); } +using WalkTerrainCurveData = std::tuple, + std::vector>; + +BOOST_TEST_DECORATOR(*boost::unit_test::timeout(1)) + +BOOST_DATA_TEST_CASE(walkTerrainCurveSetsFromFace, + boost::unit_test::data::make({ + {{310002000, 490003000}, {310002000, 490003000}, {310002000, 490003000}, {0}, {}}, + {{310003000, 490002000}, {310003000, 490002000}, {310003000, 490002000}, {1}, {}}, + {{310202000, 490203000}, {310002000, 490003000}, {310002000, 490203000}, + {1600, 1601, 1202, 1201, 802, 803, 404, 403, 4, 3, 2, 1, 0}, + { + {310201997, 490201997}, + {310201977, 490200000}, + {310200000, 490174787}, + {310194850, 490150000}, + {310192690, 490142690}, + {310173438, 490100000}, + {310150000, 490068479}, + {310130806, 490050000}, + {310100000, 490028656}, + {310062310, 490012310}, + {310050000, 490008845}, + {310003003, 490003003}, + }}, + }), + from, to, centre, visits, exits) +{ + BOOST_REQUIRE_EQUAL(visits.size(), exits.size() + 1); + + std::vector visited; + std::vector exited; + BOOST_CHECK_NO_THROW(fixedTerrtain.walk(from, to, centre, [&](const auto & step) { + visited.emplace_back(step.current.idx()); + exited.emplace_back(step.exitPosition); + })); + BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); + BOOST_CHECK_EQUAL_COLLECTIONS(exited.begin() + 1, exited.end(), exits.begin(), exits.end()); +} + using FindEntiesData = std::tuple; BOOST_DATA_TEST_CASE(findEntries, -- cgit v1.2.3 From 02c37c477099f69d1468a51ab66d05f3e7bf35fd Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 2 Jan 2025 17:29:09 +0000 Subject: Fix curve walk edge case where the curve legitimately returns to the previous face --- test/test-geoData.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 049d896..8e5ef2d 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -216,6 +216,11 @@ BOOST_DATA_TEST_CASE(walkTerrainCurveSetsFromFace, {310050000, 490008845}, {310003003, 490003003}, }}, + {{310999999, 490205000}, {310999999, 490203000}, {310999000, 490204000}, {1631, 1632, 1631}, + { + {311000000, 490204999}, + {311000000, 490203001}, + }}, }), from, to, centre, visits, exits) { @@ -225,6 +230,7 @@ BOOST_DATA_TEST_CASE(walkTerrainCurveSetsFromFace, std::vector exited; BOOST_CHECK_NO_THROW(fixedTerrtain.walk(from, to, centre, [&](const auto & step) { visited.emplace_back(step.current.idx()); + BOOST_REQUIRE(!std::ranges::contains(exited, step.exitPosition)); exited.emplace_back(step.exitPosition); })); BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); -- cgit v1.2.3 From ec29d7bb5e786549eaa960016ddf511fad010cc5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 9 Feb 2025 15:23:15 +0000 Subject: Split GeoData mesh basics into a subclass Declutters the class for terrain related things --- test/test-geoData.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 8e5ef2d..dbf5f29 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -34,21 +34,6 @@ BOOST_AUTO_TEST_CASE(sanityCheck) BOOST_CHECK_NO_THROW(sanityCheck()); } -BOOST_AUTO_TEST_CASE(trianglesContainsPoints) -{ - const auto face = face_handle(0); - - BOOST_TEST_CONTEXT(this->triangle<2>(face)) { - BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner, yllcorner}, face)); - BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner + cellsize, yllcorner + cellsize}, face)); - BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner, yllcorner + cellsize}, face)); - BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner + 1, yllcorner + 1}, face)); - BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner + 1, yllcorner + 2}, face)); - BOOST_CHECK(!triangleContainsPoint(GlobalPosition2D {xllcorner + 3, yllcorner + 2}, face)); - BOOST_CHECK(!triangleContainsPoint(GlobalPosition2D {xllcorner + cellsize, yllcorner}, face)); - } -} - BOOST_AUTO_TEST_SUITE_END(); static const TestTerrainMesh fixedTerrtain; @@ -103,7 +88,7 @@ BOOST_DATA_TEST_CASE(findPositionAt, }), p, h) { - BOOST_CHECK_EQUAL(fixedTerrtain.positionAt(p), GlobalPosition3D(p, h)); + BOOST_CHECK_EQUAL(fixedTerrtain.positionAt(p), p || h); } using FindRayIntersectData = std::tuple; @@ -261,7 +246,6 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/ surface.colorBias = RGB {0, 0, 1}; auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); BOOST_CHECK_NO_THROW(gd->setHeights(points, {.surface = &surface})); - BOOST_CHECK_NO_THROW(gd->sanityCheck()); ApplicationBase ab; TestMainWindow tmw; -- cgit v1.2.3 From 42e16ad8ad853c6e97d7eb6718ee0f78b868be30 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 9 Feb 2025 20:14:51 +0000 Subject: Combine GeoData and Terrain class hierarchies --- test/test-geoData.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index dbf5f29..4979327 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -244,15 +244,13 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/ { Surface surface; surface.colorBias = RGB {0, 0, 1}; - auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); - BOOST_CHECK_NO_THROW(gd->setHeights(points, {.surface = &surface})); ApplicationBase ab; TestMainWindow tmw; TestRenderOutput tro {{640, 480}}; struct TestTerrain : public SceneProvider { - explicit TestTerrain(std::shared_ptr gd) : terrain(std::move(gd)) { } + explicit TestTerrain(GeoData gd) : terrain(std::move(gd)) { } const Terrain terrain; @@ -281,7 +279,11 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/ } }; - TestTerrain t {gd}; + TestTerrain t {[&points, &surface]() { + auto gd = GeoData::createFlat({0, 0}, {1000000, 1000000}, 100); + BOOST_CHECK_NO_THROW(gd.setHeights(points, {.surface = &surface})); + return gd; + }()}; SceneRenderer ss {tro.size, tro.output}; std::for_each(cams.begin(), cams.end(), [&ss, &t, &tro](const auto & cam) { ss.camera.setView(cam.first.first, glm::normalize(cam.first.second)); -- cgit v1.2.3 From b73c73e8a925bd14fcb8954377939e127a0614d0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Feb 2025 23:55:04 +0000 Subject: Add timeouts to more geoData tests --- test/test-geoData.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/test-geoData.cpp') diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 4979327..2332513 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -292,6 +292,8 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson("geoData/deform/ }); } +BOOST_TEST_DECORATOR(*boost::unit_test::timeout(2)); + BOOST_DATA_TEST_CASE( deformMulti, loadFixtureJson>>("geoData/deform/multi1.json"), points) { -- cgit v1.2.3