Tests: Add tests for MeshPart
This commit is contained in:
@@ -101,6 +101,9 @@ endif(BUILD_MATERIAL)
|
||||
if(BUILD_MESH)
|
||||
list (APPEND TestExecutables Mesh_tests_run)
|
||||
endif(BUILD_MESH)
|
||||
if(BUILD_MESH_PART)
|
||||
list (APPEND TestExecutables MeshPart_tests_run)
|
||||
endif(BUILD_MESH_PART)
|
||||
if(BUILD_PART)
|
||||
list (APPEND TestExecutables Part_tests_run)
|
||||
endif(BUILD_PART)
|
||||
|
||||
@@ -7,6 +7,9 @@ endif(BUILD_MATERIAL)
|
||||
if(BUILD_MESH)
|
||||
add_subdirectory(Mesh)
|
||||
endif(BUILD_MESH)
|
||||
if(BUILD_MESH_PART)
|
||||
add_subdirectory(MeshPart)
|
||||
endif(BUILD_MESH_PART)
|
||||
if(BUILD_PART)
|
||||
add_subdirectory(Part)
|
||||
endif(BUILD_PART)
|
||||
|
||||
11
tests/src/Mod/MeshPart/App/CMakeLists.txt
Normal file
11
tests/src/Mod/MeshPart/App/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
target_sources(
|
||||
MeshPart_tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/MeshPart.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
MeshPart_tests_run
|
||||
PUBLIC
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
103
tests/src/Mod/MeshPart/App/MeshPart.cpp
Normal file
103
tests/src/Mod/MeshPart/App/MeshPart.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <TopoDS_Solid.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <QObject>
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_CLANG("-Wextra-semi")
|
||||
QT_WARNING_DISABLE_CLANG("-Woverloaded-virtual")
|
||||
#include <SMESH_Version.h>
|
||||
#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>
|
||||
QT_WARNING_POP
|
||||
|
||||
// NOLINTBEGIN
|
||||
TEST(SMesh, testMefisto)
|
||||
{
|
||||
TopoDS_Solid box = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Solid();
|
||||
|
||||
SMESH_Gen* gen = new SMESH_Gen();
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
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);
|
||||
#else
|
||||
SMESH_Mesh* mesh = gen->CreateMesh(0, true);
|
||||
|
||||
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(0, 0, gen);
|
||||
hyp1d->SetLength(1.0);
|
||||
StdMeshers_Regular_1D* algo1d = new StdMeshers_Regular_1D(1, 0, gen);
|
||||
|
||||
StdMeshers_QuadranglePreference* hyp2d = new StdMeshers_QuadranglePreference(2, 0, gen);
|
||||
StdMeshers_MEFISTO_2D* algo2d = new StdMeshers_MEFISTO_2D(3, 0, gen);
|
||||
#endif
|
||||
|
||||
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);
|
||||
EXPECT_EQ(success, true);
|
||||
|
||||
EXPECT_EQ(mesh->NbNodes(), 1244);
|
||||
EXPECT_EQ(mesh->NbTriangles(), 2484);
|
||||
EXPECT_EQ(mesh->NbQuadrangles(), 0);
|
||||
|
||||
delete hyp1d;
|
||||
delete algo1d;
|
||||
delete hyp2d;
|
||||
delete algo2d;
|
||||
delete mesh;
|
||||
delete gen;
|
||||
}
|
||||
|
||||
TEST(SMesh, testStdMeshers)
|
||||
{
|
||||
TopoDS_Solid box = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Solid();
|
||||
|
||||
TopExp_Explorer exp = TopExp_Explorer(box, TopAbs_EDGE);
|
||||
const TopoDS_Shape& edge = exp.Current();
|
||||
|
||||
SMESH_Gen* gen = new SMESH_Gen();
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
SMESH_Mesh* mesh = gen->CreateMesh(true);
|
||||
|
||||
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(0, gen);
|
||||
hyp1d->SetLength(0.1);
|
||||
StdMeshers_Regular_1D* algo1d = new StdMeshers_Regular_1D(1, gen);
|
||||
#else
|
||||
SMESH_Mesh* mesh = gen->CreateMesh(0, true);
|
||||
|
||||
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(0, 0, gen);
|
||||
hyp1d->SetLength(0.1);
|
||||
StdMeshers_Regular_1D* algo1d = new StdMeshers_Regular_1D(1, 0, gen);
|
||||
#endif
|
||||
|
||||
mesh->ShapeToMesh(box);
|
||||
mesh->AddHypothesis(edge, 0);
|
||||
mesh->AddHypothesis(edge, 1);
|
||||
|
||||
bool success = gen->Compute(*mesh, box);
|
||||
EXPECT_EQ(success, true);
|
||||
|
||||
EXPECT_EQ(mesh->NbNodes(), 107);
|
||||
|
||||
delete hyp1d;
|
||||
delete algo1d;
|
||||
delete mesh;
|
||||
delete gen;
|
||||
}
|
||||
// NOLINTEND
|
||||
17
tests/src/Mod/MeshPart/CMakeLists.txt
Normal file
17
tests/src/Mod/MeshPart/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
target_include_directories(MeshPart_tests_run PUBLIC
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${Python3_INCLUDE_DIRS}
|
||||
${SMESH_INCLUDE_DIR}
|
||||
${VTK_INCLUDE_DIRS}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(MeshPart_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
MeshPart
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
Reference in New Issue
Block a user