diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f65d5a..6fd393f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,14 +130,6 @@ jobs: with: submodules: 'recursive' - - name: "MacOS fix" - run: | - sudo chown -R $USER $CONDA - curl -o MacOSX10.9.sdk.tar.xz -L https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.9.sdk.tar.xz - tar xf MacOSX10.9.sdk.tar.xz - sudo mkdir -p /Applications/Xcode_12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs - sudo mv -v MacOSX10.9.sdk /Applications/Xcode_12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ - - name: "Configure conda" shell: pwsh run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index d97d054..929d789 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.3) -project(SMESH VERSION 9.8.0.0 LANGUAGES C CXX) +project(SMESH VERSION 9.8.0.1 LANGUAGES C CXX) # --------------------------------------------------------------------------- # # OPTIONS @@ -15,16 +15,21 @@ set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries") set(SMESH_VERSION_MAJOR 9) set(SMESH_VERSION_MINOR 8) set(SMESH_VERSION_PATCH 0) -set(SMESH_VERSION_TWEAK 0) +set(SMESH_VERSION_TWEAK 1) # Build shared libraries set(BUILD_SHARED_LIBS TRUE) -# Force C++ 11 -set(CMAKE_CXX_STANDARD 11) +# Force C++ 17 +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +# To get std::set_unexpected for Clang +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) +endif() + # Warning and errors if(MSVC) add_compile_options(/W1) diff --git a/ci/conda/conda_build_config.yaml b/ci/conda/conda_build_config.yaml index da787ef..71703e0 100644 --- a/ci/conda/conda_build_config.yaml +++ b/ci/conda/conda_build_config.yaml @@ -1,2 +1,5 @@ -CONDA_BUILD_SYSROOT: - - /Applications/Xcode_12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk # [osx] \ No newline at end of file +# Ref: https://conda-forge.org/docs/maintainer/knowledge_base.html#requiring-newer-macos-sdks +MACOSX_DEPLOYMENT_TARGET: # [osx and x86_64] + - "10.12" # [osx and x86_64] +MACOSX_SDK_VERSION: # [osx and x86_64] + - "10.12" # [osx and x86_64] diff --git a/ci/conda/meta.yaml b/ci/conda/meta.yaml index 26c7a3b..eebc815 100644 --- a/ci/conda/meta.yaml +++ b/ci/conda/meta.yaml @@ -1,6 +1,6 @@ package: name: smesh4pyocct - version: "9.8.0.0" + version: "9.8.0.1" source: path: ../.. @@ -31,6 +31,7 @@ requirements: - boost-cpp - zlib - pthreads-win32 # [win] + - __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.9") }} # [osx and x86_64] test: source_files: diff --git a/cmake/Netgen/CMakeLists.txt b/cmake/Netgen/CMakeLists.txt index 4b55f2b..ca6c6f4 100644 --- a/cmake/Netgen/CMakeLists.txt +++ b/cmake/Netgen/CMakeLists.txt @@ -8,22 +8,27 @@ include_directories(${ZLIB_INCLUDE_DIRS}) # --------------------------------------------------------------------------- # # Netgen # --------------------------------------------------------------------------- # -add_definitions(-DNO_PARALLEL_THREADS -DOCCGEOMETRY) +add_definitions(-DOCCGEOMETRY -D_OCC64) -set(PLATFORM_LIBADD) -if(WIN32) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - add_definitions(-DWNT) - add_definitions(-DPPRO_NT) - add_definitions(-D_USE_MATH_DEFINES) - add_definitions(-D_WIN32_WINNT=0x0501) - set(PLATFORM_LIBADD ${PLATFORM_LIBADD} Ws2_32.lib) - set(PLATFORM_LIBADD ${PLATFORM_LIBADD} Userenv.lib) -else() - set(PLATFORM_LIBADD ${PLATFORM_LIBADD} -ldl) - add_definitions(-DPACKAGE_VERSION="5.3") -endif() +if(APPLE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup") +endif(APPLE) + +# CORE +SET(CORE_SOURCES + ${NETGEN_ROOT_DIR}/libsrc/core/archive.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/bitarray.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/exception.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/localheap.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/logging.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/flags.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/paje_trace.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/profiler.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/table.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/taskmanager.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/utils.cpp + ${NETGEN_ROOT_DIR}/libsrc/core/version.cpp +) # CGS SET(CGS_SOURCES @@ -33,7 +38,7 @@ SET(CGS_SOURCES ${NETGEN_ROOT_DIR}/libsrc/csg/csgeom.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/csgparser.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/curve2d.cpp - ${NETGEN_ROOT_DIR}/libsrc/csg/edgeflw.cpp + ${NETGEN_ROOT_DIR}/libsrc/csg/edgeflw.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/explicitcurve2d.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/extrusion.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/gencyl.cpp @@ -47,36 +52,33 @@ SET(CGS_SOURCES ${NETGEN_ROOT_DIR}/libsrc/csg/solid.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/specpoin.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/spline3d.cpp + ${NETGEN_ROOT_DIR}/libsrc/csg/splinesurface.cpp ${NETGEN_ROOT_DIR}/libsrc/csg/surface.cpp - ${NETGEN_ROOT_DIR}/libsrc/csg/triapprox.cpp) + ${NETGEN_ROOT_DIR}/libsrc/csg/triapprox.cpp + ${NETGEN_ROOT_DIR}/libsrc/csg/zrefine.cpp) # GENERAL SET(GENERAL_SOURCES - ${NETGEN_ROOT_DIR}/libsrc/general/array.cpp - ${NETGEN_ROOT_DIR}/libsrc/general/bitarray.cpp + ${NETGEN_ROOT_DIR}/libsrc/general/ngarray.cpp + ${NETGEN_ROOT_DIR}/libsrc/general/ngbitarray.cpp ${NETGEN_ROOT_DIR}/libsrc/general/dynamicmem.cpp - ${NETGEN_ROOT_DIR}/libsrc/general/flags.cpp ${NETGEN_ROOT_DIR}/libsrc/general/hashtabl.cpp ${NETGEN_ROOT_DIR}/libsrc/general/mystring.cpp - ${NETGEN_ROOT_DIR}/libsrc/general/ngexception.cpp ${NETGEN_ROOT_DIR}/libsrc/general/optmem.cpp ${NETGEN_ROOT_DIR}/libsrc/general/parthreads.cpp - ${NETGEN_ROOT_DIR}/libsrc/general/profiler.cpp ${NETGEN_ROOT_DIR}/libsrc/general/seti.cpp ${NETGEN_ROOT_DIR}/libsrc/general/sort.cpp ${NETGEN_ROOT_DIR}/libsrc/general/spbita2d.cpp - ${NETGEN_ROOT_DIR}/libsrc/general/symbolta.cpp ${NETGEN_ROOT_DIR}/libsrc/general/table.cpp ${NETGEN_ROOT_DIR}/libsrc/general/mpi_interface.cpp ${NETGEN_ROOT_DIR}/libsrc/general/gzstream.cpp) -FILE(GLOB GENERAL_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/general/*.hpp") -LIST(APPEND GENERAL_INCLUDES ${NETGEN_ROOT_DIR}/libsrc/general/gzstream.h) +# FILE(GLOB GENERAL_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/general/*.h*") # GEOM2D SET (GEOM2D_SOURCES - ${NETGEN_ROOT_DIR}/libsrc/geom2d/genmesh2d.cpp - ${NETGEN_ROOT_DIR}/libsrc/geom2d/geom2dmesh.cpp + ${NETGEN_ROOT_DIR}/libsrc/geom2d/csg2d.cpp + ${NETGEN_ROOT_DIR}/libsrc/geom2d/genmesh2d.cpp ${NETGEN_ROOT_DIR}/libsrc/geom2d/geometry2d.cpp) # GPRIM @@ -90,14 +92,14 @@ SET(GPRIM_SOURCES ${NETGEN_ROOT_DIR}/libsrc/gprim/spline.cpp ${NETGEN_ROOT_DIR}/libsrc/gprim/splinegeometry.cpp) -FILE(GLOB GPRIM_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/gprim/*.hpp") +# FILE(GLOB GPRIM_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/gprim/*.h*") # INCLUDE SET(INCLUDE_INCLUDES ${NETGEN_ROOT_DIR}/libsrc/include/nginterface.h ${NETGEN_ROOT_DIR}/libsrc/include/nginterface_v2.hpp - ${NETGEN_ROOT_DIR}/libsrc/include/mystdlib.h - ${NETGEN_ROOT_DIR}/libsrc/include/mydefs.hpp) + ${NETGEN_ROOT_DIR}/libsrc/include/mydefs.hpp + ${NETGEN_ROOT_DIR}/libsrc/include/netgen_version.hpp) # INTERFACE SET(INTERFACE_SOURCES @@ -106,6 +108,7 @@ SET(INTERFACE_SOURCES ${NETGEN_ROOT_DIR}/libsrc/interface/read_fnf_mesh.cpp ${NETGEN_ROOT_DIR}/libsrc/interface/readtetmesh.cpp ${NETGEN_ROOT_DIR}/libsrc/interface/readuser.cpp + ${NETGEN_ROOT_DIR}/libsrc/interface/rw_cgns.cpp ${NETGEN_ROOT_DIR}/libsrc/interface/writeabaqus.cpp ${NETGEN_ROOT_DIR}/libsrc/interface/writediffpack.cpp ${NETGEN_ROOT_DIR}/libsrc/interface/writedolfin.cpp @@ -131,7 +134,7 @@ SET (LINALG_SOURCES ${NETGEN_ROOT_DIR}/libsrc/linalg/linopt.cpp ${NETGEN_ROOT_DIR}/libsrc/linalg/linsearch.cpp) -FILE(GLOB LINALG_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/linalg/*.hpp") +# FILE(GLOB LINALG_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/linalg/*.h*") # MESHING SET(MESHING_SOURCES @@ -166,7 +169,7 @@ SET(MESHING_SOURCES ${NETGEN_ROOT_DIR}/libsrc/meshing/pyramid2rls.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/pyramidrls.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/quadrls.cpp - ${NETGEN_ROOT_DIR}/libsrc/meshing/refine.cpp + ${NETGEN_ROOT_DIR}/libsrc/meshing/refine.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/ruler2.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/ruler3.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/secondorder.cpp @@ -178,14 +181,16 @@ SET(MESHING_SOURCES ${NETGEN_ROOT_DIR}/libsrc/meshing/topology.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/triarls.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/validate.cpp - ${NETGEN_ROOT_DIR}/libsrc/meshing/zrefine.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/bcfunctions.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/parallelmesh.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/paralleltop.cpp ${NETGEN_ROOT_DIR}/libsrc/meshing/paralleltop.hpp - ${NETGEN_ROOT_DIR}/libsrc/meshing/basegeom.cpp) + ${NETGEN_ROOT_DIR}/libsrc/meshing/basegeom.cpp + ${NETGEN_ROOT_DIR}/libsrc/meshing/hexarls.cpp + ${NETGEN_ROOT_DIR}/libsrc/meshing/surfacegeom.cpp) -FILE(GLOB MESHING_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/meshing/*.hpp") +# FILE(GLOB MESHING_INCLUDES "${NETGEN_ROOT_DIR}/libsrc/meshing/meshing.hpp") +SET(MESHING_INCLUDES ${NETGEN_ROOT_DIR}/libsrc/meshing/meshing.hpp) # OCC SET(OCC_SOURCES @@ -200,7 +205,8 @@ SET(OCC_SOURCES ${NETGEN_ROOT_DIR}/libsrc/occ/occgeom.cpp ${NETGEN_ROOT_DIR}/libsrc/occ/occmeshsurf.cpp) -SET(OCC_INCLUDES ${NETGEN_ROOT_DIR}/libsrc/occ/occgeom.hpp ${NETGEN_ROOT_DIR}/libsrc/occ/occmeshsurf.hpp) +SET(OCC_INCLUDES ${NETGEN_ROOT_DIR}/libsrc/occ/occgeom.hpp + ${NETGEN_ROOT_DIR}/libsrc/occ/occmeshsurf.hpp) # STLGEOM SET(STLGEOM_SOURCES @@ -212,19 +218,25 @@ SET(STLGEOM_SOURCES ${NETGEN_ROOT_DIR}/libsrc/stlgeom/stltool.cpp ${NETGEN_ROOT_DIR}/libsrc/stlgeom/stltopology.cpp) +# VISUALIZATION +SET(VISUALIZATION_SOURCES + ${NETGEN_ROOT_DIR}/libsrc/visualization/visual_dummy.cpp) + # NGLIB SET(NGLIB_SOURCES ${NETGEN_ROOT_DIR}/nglib/nglib.cpp) ADD_LIBRARY(nglib4smesh SHARED - ${NGLIB_SOURCES} - ${CGS_SOURCES} + ${CORE_SOURCES} + ${CGS_SOURCES} ${GENERAL_SOURCES} - ${GPRIM_SOURCES} ${GEOM2D_SOURCES} - ${INTERFACE_SOURCES} - ${LINALG_SOURCES} - ${MESHING_SOURCES} + ${GPRIM_SOURCES} + ${INTERFACE_SOURCES} + ${LINALG_SOURCES} + ${MESHING_SOURCES} ${OCC_SOURCES} - ${STLGEOM_SOURCES}) + ${STLGEOM_SOURCES} + ${VISUALIZATION_SOURCES} + ${NGLIB_SOURCES}) # Link SET(OCCLIBS TKernel TKGeomBase TKMath TKG2d TKG3d TKXSBase TKOffset TKFillet TKShHealing) @@ -233,22 +245,32 @@ SET(OCCLIBS ${OCCLIBS} TKSTEPBase TKSTEP TKSTL TKSTEPAttr TKSTEP209 TKXDESTEP TK TARGET_LINK_LIBRARIES(nglib4smesh PUBLIC ${OCCLIBS} ${ZLIB_LIBRARIES} ${PLATFORM_LIBADD}) target_include_directories(nglib4smesh PUBLIC + $ + $ $ $ - $ $ ) if(WIN32) - set_target_properties(nglib4smesh PROPERTIES COMPILE_FLAGS "-DNGLIB_EXPORTS") + set_target_properties(nglib4smesh PROPERTIES COMPILE_FLAGS "-DNGLIB_EXPORTS -DNGCORE_EXPORTS -DNGINTERFACE_EXPORTS") + target_compile_options(nglib4smesh PUBLIC /bigobj /MP /W1 /wd4068) + target_compile_definitions(nglib4smesh PUBLIC _WIN32_WINNT=0x0501 WNT WNT_WINDOW NOMINMAX MSVC_EXPRESS _CRT_SECURE_NO_WARNINGS HAVE_STRUCT_TIMESPEC) + target_link_options(nglib4smesh PUBLIC /ignore:4273 /ignore:4217 /ignore:4049) +else(WIN32) + target_compile_options(nglib4smesh PRIVATE -fvisibility=hidden) endif(WIN32) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(nglib4smesh PUBLIC -fsized-deallocation -faligned-allocation) +endif() + # Install -install(FILES ${GENERAL_INCLUDES} DESTINATION "include/smesh/Netgen") -install(FILES ${GPRIM_INCLUDES} DESTINATION "include/smesh/Netgen") -install(FILES ${INCLUDE_INCLUDES} DESTINATION "include/smesh/Netgen") -install(FILES ${LINALG_INCLUDES} DESTINATION "include/smesh/Netgen") -install(FILES ${MESHING_INCLUDES} DESTINATION "include/smesh/netgen") +# install(FILES ${GENERAL_INCLUDES} DESTINATION "include/smesh/Netgen") +# install(FILES ${GPRIM_INCLUDES} DESTINATION "include/smesh/Netgen") +# install(FILES ${INCLUDE_INCLUDES} DESTINATION "include/smesh/Netgen") +# install(FILES ${LINALG_INCLUDES} DESTINATION "include/smesh/Netgen") +install(FILES ${MESHING_INCLUDES} DESTINATION "include/smesh/Netgen") install(FILES ${OCC_INCLUDES} DESTINATION "include/smesh/Netgen") install(FILES ${NETGEN_ROOT_DIR}/nglib/nglib.h DESTINATION "include/smesh/Netgen") diff --git a/cmake/SMESH/CMakeLists.txt b/cmake/SMESH/CMakeLists.txt index 14cdb44..d0b520c 100644 --- a/cmake/SMESH/CMakeLists.txt +++ b/cmake/SMESH/CMakeLists.txt @@ -202,9 +202,9 @@ if(ENABLE_NETGEN) $ ) if(WIN32) - set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_V5") + set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNETGEN_V6") else() - set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "${NETGEN_CXX_FLAGS} -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_V5") + set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "${NETGEN_CXX_FLAGS} -DNETGEN_V6") endif() set(SMESH_LIBRARIES ${SMESH_LIBRARIES} NETGENPlugin) file(GLOB NETGENPlugin_INCLUDES ${NETGENPlugin_SRC_DIR}/*.h*) diff --git a/external/Netgen b/external/Netgen index 5f98312..5e48931 160000 --- a/external/Netgen +++ b/external/Netgen @@ -1 +1 @@ -Subproject commit 5f98312aa121bd6dff1a33b368775e637e5ea711 +Subproject commit 5e489319c60926daa836cecff39f0e92779032ba diff --git a/extra/Netgen/netgen_version.hpp b/extra/Netgen/netgen_version.hpp new file mode 100644 index 0000000..53b6b5b --- /dev/null +++ b/extra/Netgen/netgen_version.hpp @@ -0,0 +1,9 @@ +#ifndef NETGEN_VERSION_HPP_INCLUDED +#define NETGEN_VERSION_HPP_INCLUDED +#define NETGEN_VERSION "6.2.2101" +#define NETGEN_VERSION_MAJOR 6 +#define NETGEN_VERSION_MINOR 2 +#define NETGEN_VERSION_PATCH 2101 +#define NETGEN_VERSION_TWEAK 0 +#define NETGEN_VERSION_HASH "g5e489319" +#endif // NETGEN_VERSION_HPP_INCLUDED diff --git a/prepare.py b/prepare.py index acc94b3..b60601c 100644 --- a/prepare.py +++ b/prepare.py @@ -18,16 +18,19 @@ def prepare_netgen(): shutil.copytree('external/Netgen/nglib', 'src/Netgen/nglib') # Patch Netgen sources for SALOME - pset = patch.fromfile('external/NETGENPlugin/src/NETGEN/netgen53ForSalome.patch') - pset.apply(strip=1, root='src/Netgen') - - if sys.platform == 'win32': - pset = patch.fromfile('external/NETGENPlugin/src/NETGEN/netgen53ForWindows.patch') - pset.apply(strip=1, root='src/Netgen') + pset = patch.fromfile('external/NETGENPlugin/src/NETGEN/netgen62ForSalome.patch') + success = pset.apply(strip=1, root='src/Netgen') + if not success: + raise RuntimeError('Failed to apply Netgen patch.') # Copy Netgen cmake files into source directory shutil.copytree('cmake/Netgen', 'src/Netgen', dirs_exist_ok=True) + # Copy netgen_version.hpp + # Obtained from distribution at https://anaconda.org/ngsolve/netgen + shutil.copyfile('extra/Netgen/netgen_version.hpp', + 'src/Netgen/libsrc/include/netgen_version.hpp') + def prepare_kernel(): """ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2a8732c..ba7409c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,11 +11,16 @@ option(ENABLE_NETGEN "Enable Netgen" ON) # --------------------------------------------------------------------------- # # SETTINGS # --------------------------------------------------------------------------- # -# Force C++ 11 -set(CMAKE_CXX_STANDARD 11) +# Force C++ 17 +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +# Ref https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_definitions(-D_LIBCPP_DISABLE_AVAILABILITY) +endif() + if(CMAKE_SIZEOF_VOID_P STREQUAL 8) add_definitions(-DSALOME_USE_64BIT_IDS) endif(CMAKE_SIZEOF_VOID_P STREQUAL 8) diff --git a/test/src/NETGENPlugin.t.cpp b/test/src/NETGENPlugin.t.cpp index 81cd0b6..8428934 100644 --- a/test/src/NETGENPlugin.t.cpp +++ b/test/src/NETGENPlugin.t.cpp @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -41,8 +43,8 @@ TEST_CASE("Mesh a box with tetrahedral elements.", "[NETGENPlugin]") { bool success = gen->Compute(*mesh, box); REQUIRE(success == true); - REQUIRE(mesh->NbTetras() == 4671); - REQUIRE(mesh->NbNodes() == 1172); + REQUIRE(mesh->NbTetras() == 5427); + REQUIRE(mesh->NbNodes() == 1290); delete hyp; delete algo; @@ -77,8 +79,8 @@ TEST_CASE("Mesh a box with tetrahedral elements and a local edge length.", "[NET bool success = gen->Compute(*mesh, box); REQUIRE(success == true); - REQUIRE(mesh->NbTetras() == 34068); - REQUIRE(mesh->NbNodes() == 6665); + REQUIRE(mesh->NbTetras() == 36896); + REQUIRE(mesh->NbNodes() == 7201); delete hyp3d; delete algo3d; @@ -127,8 +129,59 @@ TEST_CASE("Mesh a box with tetrahedral elements and split faces.", "[NETGENPlugi bool success = gen->Compute(*mesh, split_box); REQUIRE(success == true); - REQUIRE(mesh->NbTetras() == 4757); - REQUIRE(mesh->NbNodes() == 1194); + REQUIRE(mesh->NbTetras() == 5184); + REQUIRE(mesh->NbNodes() == 1258); + + delete hyp; + delete algo; + delete mesh; + delete gen; +} + +TEST_CASE("Mesh a box with quadrilateral elements and split faces.", "[NETGENPlugin]") { + + TopoDS_Solid box = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Solid(); + + gp_Pnt origin = gp_Pnt(5.0, 0.0, 0.0); + gp_Dir normal = gp_Dir(1.0, 0.0, 0.0); + gp_Pln pln = gp_Pln(origin, normal); + + TopoDS_Face face = BRepBuilderAPI_MakeFace(pln, -5.0, 5.0, -5.0, 5.0).Face(); + + TopTools_ListOfShape args = TopTools_ListOfShape(); + args.Append(box); + + TopTools_ListOfShape tools = TopTools_ListOfShape(); + tools.Append(face); + + BRepAlgoAPI_Splitter splitter = BRepAlgoAPI_Splitter(); + splitter.SetArguments(args); + splitter.SetTools(tools); + splitter.Build(); + REQUIRE(splitter.IsDone() == true); + + TopoDS_Shape split_box = splitter.Shape(); + + SMESH_Gen* gen = new SMESH_Gen(); + SMESH_Mesh* mesh = gen->CreateMesh(true); + + NETGENPlugin_SimpleHypothesis_2D* hyp = new NETGENPlugin_SimpleHypothesis_2D(0, gen); + hyp->SetLocalLength(1.0); + hyp->SetAllowQuadrangles(true); + + NETGENPlugin_NETGEN_2D* algo = new NETGENPlugin_NETGEN_2D(1, gen); + + mesh->ShapeToMesh(split_box); + mesh->AddHypothesis(split_box, 0); + mesh->AddHypothesis(split_box, 1); + + bool success = gen->Compute(*mesh, split_box); + REQUIRE(success == true); + + REQUIRE(mesh->NbFaces() == 625); + REQUIRE(mesh->NbTriangles() == 0); + REQUIRE(mesh->NbQuadrangles() == 625); + REQUIRE(mesh->NbNodes() == 627); delete hyp; delete algo;