Skip to content

Commit

Permalink
Add test/cap_closestPoint
Browse files Browse the repository at this point in the history
- Test a few points on a square face and edge.

Signed-off-by: Aiden Woodruff <[email protected]>
  • Loading branch information
bobpaw committed Oct 3, 2024
1 parent 5abc2b9 commit 32c22af
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ if(ENABLE_CAPSTONE)
util_exe_func(capVol capVol.cc)
target_include_directories(capVol PRIVATE "${PROJECT_SOURCE_DIR}/capstone_clis")
test_exe_func(cap_inClosureOf cap_inClosureOf.cc)
test_exe_func(cap_closestPoint cap_closestPoint.cc)
endif()

# send all the newly added utility executable targets
Expand Down
39 changes: 39 additions & 0 deletions test/cap_closestPoint.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <apf.h>
#include <apfCAP.h>
#include <gmi_cap.h>
#include <lionPrint.h>
#include <pcu_util.h>
#include <CapstoneModule.h>
#include <PCU.h>

int main (int argc, char* argv[]) {
MPI_Init(&argc, &argv);
PCU_Comm_Init();
lion_set_verbosity(1);
gmi_register_cap();

PCU_ALWAYS_ASSERT(argc == 2);
std::string creFile(argv[1]);
// 1. Load model.
CapstoneModule cs("cap_inClosureOf", "Geometry Database : SMLIB",
"Mesh Database : Create", "Attribution Database : Create");
cs.load_files(v_string(1, creFile));
// 2. CreateMesh.
apf::Mesh2* m = apf::createMesh(cs.get_mesh(), cs.get_geometry());

PCU_ALWAYS_ASSERT(m->canGetClosestPoint());

apf::ModelEntity* face = m->findModelEntity(2, 1);
apf::Vector3 from(0.3, 0.4, -0.8), to, p;
m->getClosestPoint(face, from, to, p);
PCU_ALWAYS_ASSERT((to - apf::Vector3(0.3, 0.4, -0.5)).getLength() < 0.0001);

apf::ModelEntity* edge = m->findModelEntity(1, 1);
from = apf::Vector3(0.6, 0.34, 0.6);
m->getClosestPoint(edge, from, to, p);
PCU_ALWAYS_ASSERT((to - apf::Vector3(0.5, 0.34, 0.5)).getLength() < 0.0001);

apf::destroyMesh(m);
PCU_Comm_Free();
MPI_Finalize();
}
1 change: 1 addition & 0 deletions test/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -896,4 +896,5 @@ if(ENABLE_CAPSTONE)
mpi_test(capVolCube 1 ./capVol -vg 3 ${MESHES}/cap/cube_surf_only.cre)
mpi_test(capVolCyl2 1 ./capVol -vg 4 ${MESHES}/cap/cyl_surf_only.cre)
mpi_test(cap_inClosureOf 1 ./cap_inClosureOf ${MESHES}/cap/cube_surf_only.cre)
mpi_test(cap_closestPoint 1 ./cap_closestPoint ${MESHES}/cap/cube_surf_only.cre)
endif()

0 comments on commit 32c22af

Please sign in to comment.