-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add KDOP<2,4> and KDOP<2,8> #1088
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,26 +9,88 @@ | |
* SPDX-License-Identifier: BSD-3-Clause * | ||
****************************************************************************/ | ||
|
||
#include <ArborX_Box.hpp> | ||
#include <ArborX_DetailsAlgorithms.hpp> | ||
#include <ArborX_HyperPoint.hpp> | ||
#include <ArborX_KDOP.hpp> | ||
#include <ArborX_Point.hpp> | ||
|
||
#include "BoostTest_CUDA_clang_workarounds.hpp" | ||
#include <boost/test/unit_test.hpp> | ||
|
||
#include <tuple> | ||
#include <type_traits> | ||
|
||
using ArborX::Box; | ||
using ArborX::Point; | ||
using ArborX::Experimental::KDOP; | ||
|
||
using KDOP_types = | ||
std::tuple<KDOP<3, 6>, KDOP<3, 14>, KDOP<3, 18>, KDOP<3, 26>>; | ||
|
||
BOOST_AUTO_TEST_SUITE(DiscreteOrientedPolytopes) | ||
|
||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_KDOP, KDOP_t, KDOP_types) | ||
using KDOP_2D_types = std::tuple<KDOP<2, 4>, KDOP<2, 8>>; | ||
|
||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_kdop_kdop_2D, KDOP_t, KDOP_2D_types) | ||
{ | ||
using Point = ArborX::ExperimentalHyperGeometry::Point<2>; | ||
KDOP_t x; | ||
BOOST_TEST(!intersects(x, x)); | ||
expand(x, Point{1, 0}); | ||
expand(x, Point{0, 1}); | ||
BOOST_TEST(intersects(x, x)); | ||
BOOST_TEST(!intersects(x, KDOP_t{})); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_point_kdop_2D, KDOP_t, KDOP_2D_types) | ||
{ | ||
using Point = ArborX::ExperimentalHyperGeometry::Point<2>; | ||
{ | ||
KDOP_t x; | ||
BOOST_TEST(!intersects(Point{1, 1}, x)); | ||
} | ||
{ | ||
KDOP_t x; // rombus | ||
expand(x, Point{0.5f, 0}); | ||
expand(x, Point{0.5f, 1}); | ||
expand(x, Point{0, 0.5f}); | ||
expand(x, Point{1, 0.5f}); | ||
// unit square corners | ||
BOOST_TEST(intersects(Point{0, 0}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
BOOST_TEST(intersects(Point{1, 0}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
BOOST_TEST(intersects(Point{0, 1}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
BOOST_TEST(intersects(Point{1, 1}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
// rombus corners | ||
BOOST_TEST(intersects(Point{0.5f, 0}, x)); | ||
BOOST_TEST(intersects(Point{0.5f, 1}, x)); | ||
BOOST_TEST(intersects(Point{0, 0.5f}, x)); | ||
BOOST_TEST(intersects(Point{1, 0.5f}, x)); | ||
// unit square center | ||
BOOST_TEST(intersects(Point{0.5f, 0.5f}, x)); | ||
// mid rombus diagonals | ||
BOOST_TEST(intersects(Point{0.75f, 0.25f}, x)); | ||
BOOST_TEST(intersects(Point{0.25f, 0.25f}, x)); | ||
BOOST_TEST(intersects(Point{0.25f, 0.75f}, x)); | ||
BOOST_TEST(intersects(Point{0.75f, 0.75f}, x)); | ||
// slightly outside of the diagonals | ||
BOOST_TEST(intersects(Point{0.8f, 0.2f}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
BOOST_TEST(intersects(Point{0.2f, 0.2f}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
BOOST_TEST(intersects(Point{0.2f, 0.8f}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
BOOST_TEST(intersects(Point{0.8f, 0.8f}, x) == | ||
(std::is_same_v<KDOP_t, KDOP<2, 4>>)); | ||
} | ||
} | ||
|
||
using KDOP_3D_types = | ||
std::tuple<KDOP<3, 6>, KDOP<3, 14>, KDOP<3, 18>, KDOP<3, 26>>; | ||
|
||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_kdop_kdop_3D, KDOP_t, KDOP_3D_types) | ||
{ | ||
using ArborX::Point; | ||
|
||
KDOP_t x; | ||
BOOST_TEST(!intersects(x, x)); | ||
expand(x, Point{1, 0, 0}); | ||
|
@@ -38,8 +100,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_KDOP, KDOP_t, KDOP_types) | |
BOOST_TEST(!intersects(x, KDOP_t{})); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_box, KDOP_t, KDOP_types) | ||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_kdop_box_3D, KDOP_t, KDOP_3D_types) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to myself that the ordering kdop_box here is accurate even though at first sight it looked inconsistent with point_kdop below. |
||
{ | ||
using ArborX::Box; | ||
using ArborX::Point; | ||
|
||
KDOP_t x; | ||
BOOST_TEST(!intersects(x, Box{})); | ||
BOOST_TEST(!intersects(x, Box{{0, 0, 0}, {1, 1, 1}})); | ||
|
@@ -50,8 +115,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_box, KDOP_t, KDOP_types) | |
BOOST_TEST(intersects(x, Box{{0, 0, 0}, {1, 1, 1}})); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_point, KDOP_t, KDOP_types) | ||
BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_point_kdop, KDOP_t, KDOP_3D_types) | ||
{ | ||
using ArborX::Point; | ||
{ | ||
KDOP_t x; | ||
BOOST_TEST(!intersects(Point{1, 1, 1}, x)); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test for intersection with regular 2D box?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess I could add it. I'm not sure if it adds much.Nevermind. Not only it was a good idea, it also uncovered a bug.