Skip to content

Commit

Permalink
Added test for MEFISTO2 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
trelau authored May 30, 2021
1 parent a277738 commit fd12010
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions ci/conda/run_test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ cd tests
test_Catch.exe
test_StdMeshers.exe
test_NETGENPlugin.exe
test_MEFISTO2.exe
1 change: 1 addition & 0 deletions ci/conda/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ then
else
./test_StdMeshers
./test_NETGENPlugin
./test_MEFISTO2
fi
10 changes: 10 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ catch_discover_tests(test_StdMeshers)
set(test_Execs ${test_Execs} test_StdMeshers)


# --------------------------------------------------------------------------- #
# Test MEFISTO2
# --------------------------------------------------------------------------- #
add_executable(test_MEFISTO2 src/MEFISTO2.t.cpp)
target_link_libraries(test_MEFISTO2 Catch2::Catch2 ${SMESH_LIBRARIES})
catch_discover_tests(test_MEFISTO2)

set(test_Execs ${test_Execs} test_MEFISTO2)


# --------------------------------------------------------------------------- #
# Test NETGENPlugin
# --------------------------------------------------------------------------- #
Expand Down
50 changes: 50 additions & 0 deletions test/src/MEFISTO2.t.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#define CATCH_CONFIG_MAIN

#include <catch2/catch.hpp>

#include <BRepPrimAPI_MakeBox.hxx>
#include <TopoDS_Solid.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs_ShapeEnum.hxx>

#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <StdMeshers_LocalLength.hxx>
#include <StdMeshers_Regular_1D.hxx>
#include <StdMeshers_MEFISTO_2D.hxx>
#include <StdMeshers_QuadranglePreference.hxx>

TEST_CASE("Mesh the faces of a box.", "[MEFISTO2][Box]") {

TopoDS_Solid box = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Solid();

SMESH_Gen* gen = new SMESH_Gen();
SMESH_Mesh* mesh = gen->CreateMesh(true);

StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(0, gen);
hyp1d->SetLength(1.0);
StdMeshers_Regular_1D* algo1d = new StdMeshers_Regular_1D(1, gen);

StdMeshers_QuadranglePreference* hyp2d = new StdMeshers_QuadranglePreference(2, gen);
StdMeshers_MEFISTO_2D* algo2d = new StdMeshers_MEFISTO_2D(3, gen);

mesh->ShapeToMesh(box);
mesh->AddHypothesis(box, 0);
mesh->AddHypothesis(box, 1);
mesh->AddHypothesis(box, 2);
mesh->AddHypothesis(box, 3);

bool success = gen->Compute(*mesh, box);
REQUIRE(success == true);

REQUIRE(mesh->NbNodes() == 1244);
REQUIRE(mesh->NbTriangles() == 2484);
REQUIRE(mesh->NbQuadrangles() == 0);

delete hyp1d;
delete algo1d;
delete hyp2d;
delete algo2d;
delete mesh;
delete gen;
}

0 comments on commit fd12010

Please sign in to comment.