-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding point in volume implementation and tests
- Loading branch information
Showing
8 changed files
with
139 additions
and
24 deletions.
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
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
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
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// for testing | ||
#include <catch2/catch_test_macros.hpp> | ||
|
||
// xdg includes | ||
#include "xdg/mesh_manager_interface.h" | ||
#include "xdg/ray_tracing_interface.h" | ||
|
||
#include "mesh_mock.h" | ||
|
||
using namespace xdg; | ||
|
||
TEST_CASE("Test Point in Volume") | ||
{ | ||
std::shared_ptr<MeshManager> mm = std::make_shared<MeshMock>(); | ||
mm->init(); // this should do nothing, just good practice to call it | ||
REQUIRE(mm->mesh_library() == MeshLibrary::INTERANAL); | ||
std::shared_ptr<RayTracer> rti = std::make_shared<RayTracer>(); | ||
|
||
rti->register_all_volumes(mm); | ||
|
||
MeshID volume = mm->volumes()[0]; | ||
|
||
Position point {0.0, 0.0, 0.0}; | ||
bool result = rti->point_in_volume(volume, point); | ||
REQUIRE(result == true); | ||
|
||
point = {0.0, 0.0, 1000.0}; | ||
result = rti->point_in_volume(volume, point); | ||
REQUIRE(result == false); | ||
|
||
// test a point just inside the positive x boundary | ||
point = {5.0 - 1e-06, 0.0, 0.0}; | ||
result = rti->point_in_volume(volume, point); | ||
REQUIRE(result == true); | ||
|
||
// test a point on the positive x boundary | ||
point = {5.0, 0.0, 0,0}; | ||
result = rti->point_in_volume(volume, point); | ||
REQUIRE(result == false); | ||
|
||
// test a point just outside the positive x boundary | ||
// and provide a direction | ||
point = {5.0, 0.0, 0.0}; | ||
Direction dir = {1.0, 0.0, 0.0}; | ||
result = rti->point_in_volume(volume, point, &dir); | ||
REQUIRE(result == true); | ||
|
||
// test a point just outside the positive x boundary | ||
// and provide a direction | ||
point = {5.1, 0.0, 0.0}; | ||
dir = {1.0, 0.0, 0.0}; | ||
result = rti->point_in_volume(volume, point, &dir); | ||
REQUIRE(result == false); | ||
|
||
// test a point just outside the positive x boundary, | ||
// flip the direction | ||
point = {5.1, 0.0, 0.0}; | ||
dir = {-1.0, 0.0, 0.0}; | ||
result = rti->point_in_volume(volume, point, &dir); | ||
REQUIRE(result == false); | ||
} |