From b694b4667a2af9bd95db41c2a1602f63a6b5d4a4 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 27 Apr 2022 13:42:04 +0200 Subject: [PATCH] rework build system, separate gui and non-gui code move fieldlines code to meshing dir move visualization function pointers to meshing directory DLL_HEADER -> NGGUI_API in visualization lib move soldata.hpp to meshing update occ, no freetype necessary anymore --- CMakeLists.txt | 84 +-- cmake/SuperBuild.cmake | 33 +- libsrc/CMakeLists.txt | 25 +- libsrc/core/CMakeLists.txt | 4 +- libsrc/csg/CMakeLists.txt | 25 +- libsrc/csg/csgpkg.cpp | 1 - libsrc/csg/genmesh.cpp | 2 +- libsrc/csg/python_csg.cpp | 6 +- libsrc/csg/specpoin.cpp | 2 +- libsrc/csg/vscsg.cpp | 8 +- libsrc/csg/vscsg.hpp | 2 +- libsrc/general/CMakeLists.txt | 24 +- libsrc/general/gzstream.h | 6 +- libsrc/general/hashtabl.hpp | 8 +- libsrc/general/mpi_interface.hpp | 2 +- libsrc/general/ngbitarray.hpp | 12 +- libsrc/general/table.hpp | 6 +- libsrc/geom2d/CMakeLists.txt | 23 +- libsrc/geom2d/geometry2d.hpp | 18 +- libsrc/geom2d/python_geom2d.cpp | 10 +- libsrc/geom2d/vsgeom2d.hpp | 2 +- libsrc/gprim/CMakeLists.txt | 17 +- libsrc/gprim/geom3d.hpp | 10 +- libsrc/gprim/geomfuncs.hpp | 4 +- libsrc/gprim/splinegeometry.hpp | 12 +- libsrc/include/mydefs.hpp | 2 +- libsrc/include/nginterface.h | 2 +- libsrc/interface/CMakeLists.txt | 11 +- libsrc/interface/nginterface.cpp | 7 - libsrc/linalg/CMakeLists.txt | 10 +- libsrc/meshing/CMakeLists.txt | 37 +- libsrc/meshing/curvedelems.hpp | 18 +- libsrc/meshing/debugging.hpp | 2 +- .../{visualization => meshing}/fieldlines.cpp | 0 .../{visualization => meshing}/fieldlines.hpp | 0 libsrc/meshing/meshclass.hpp | 46 +- libsrc/meshing/meshing2.cpp | 490 +----------------- libsrc/meshing/meshtype.cpp | 4 +- libsrc/meshing/meshtype.hpp | 14 +- libsrc/{visualization => meshing}/soldata.hpp | 0 libsrc/meshing/topology.hpp | 12 +- libsrc/meshing/visual_interface.cpp | 22 + libsrc/meshing/visual_interface.hpp | 34 ++ libsrc/occ/CMakeLists.txt | 29 +- libsrc/occ/occgeom.cpp | 2 +- libsrc/stlgeom/CMakeLists.txt | 19 +- libsrc/stlgeom/stlgeom.hpp | 138 ++--- libsrc/stlgeom/stltopology.hpp | 2 +- libsrc/stlgeom/vsstl.cpp | 2 +- libsrc/stlgeom/vsstl.hpp | 4 +- libsrc/visualization/CMakeLists.txt | 27 +- libsrc/visualization/importsolution.cpp | 5 +- libsrc/visualization/meshdoc.hpp | 20 +- libsrc/visualization/mvdraw.cpp | 242 ++++++++- libsrc/visualization/mvdraw.hpp | 93 ++-- libsrc/visualization/vispar.hpp | 2 +- libsrc/visualization/visual.hpp | 4 +- libsrc/visualization/visual_api.hpp | 10 + libsrc/visualization/visual_dummy.cpp | 15 - libsrc/visualization/visualpkg.cpp | 2 +- libsrc/visualization/vsfieldlines.cpp | 1 + libsrc/visualization/vsmesh.cpp | 2 +- libsrc/visualization/vssolution.cpp | 42 +- libsrc/visualization/vssolution.hpp | 23 +- ng/CMakeLists.txt | 43 +- ng/Togl2.1/CMakeLists.txt | 35 +- ng/netgenpy.cpp | 23 - ng/ng.tcl | 2 +- ng/ngguipy.cpp | 23 + ng/ngpkg.cpp | 33 -- ng/onetcl.cpp | 2 +- nglib/CMakeLists.txt | 48 +- nglib/nglib.cpp | 212 +------- nglib/nglib.h | 65 +-- nglib/nglib_occ.cpp | 212 ++++++++ nglib/nglib_occ.h | 50 ++ python/__init__.py | 5 +- rules/CMakeLists.txt | 29 ++ tests/pytest/test_mpi4py.py | 1 + 79 files changed, 1119 insertions(+), 1405 deletions(-) rename libsrc/{visualization => meshing}/fieldlines.cpp (100%) rename libsrc/{visualization => meshing}/fieldlines.hpp (100%) rename libsrc/{visualization => meshing}/soldata.hpp (100%) create mode 100644 libsrc/meshing/visual_interface.cpp create mode 100644 libsrc/meshing/visual_interface.hpp create mode 100644 libsrc/visualization/visual_api.hpp delete mode 100644 libsrc/visualization/visual_dummy.cpp create mode 100644 ng/ngguipy.cpp create mode 100644 nglib/nglib_occ.cpp create mode 100644 nglib/nglib_occ.h create mode 100644 rules/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 59fefd5b..7437b771 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,22 +2,20 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING INTERNAL) endif(NOT CMAKE_BUILD_TYPE) -if(WIN32) - # we are linking to object libraries on Windows - cmake_minimum_required(VERSION 3.12) -else(WIN32) - cmake_minimum_required(VERSION 3.8) -endif(WIN32) - -cmake_policy(VERSION 3.12) +cmake_minimum_required(VERSION 3.13) +cmake_policy(VERSION 3.13) option( USE_NATIVE_ARCH "build for native cpu architecture" ON) -option( USE_GUI "don't build netgen with GUI" ON ) +option( USE_GUI "build with GUI" ON ) option( USE_PYTHON "build with python interface" ON ) option( USE_MPI "enable mpi parallelization" OFF ) option( USE_MPI4PY "enable mpi4py interface" ON ) -option( USE_OCC "(not supported) compile with OpenCascade geometry kernel" OFF) +option( USE_OCC "build with OpenCascade geometry kernel interface" OFF) +option( USE_STLGEOM "build with STL geometry support" ON) +option( USE_CSG "build with CSG kernel" ON) +option( USE_INTERFACE "build nginterface" ON) +option( USE_GEOM2D "build 2d geometry kernels" ON) option( USE_JPEG "enable snapshots using library libjpeg" OFF ) option( USE_MPEG "enable video recording with FFmpeg, uses libavcodec" OFF ) option( USE_CGNS "enable CGNS file read/write support" OFF ) @@ -34,11 +32,15 @@ option( CHECK_RANGE "Check array range access, automatically enabled if built in option( BUILD_STUB_FILES "Build stub files for better autocompletion" ON) option( BUILD_FOR_CONDA "Link python libraries only to executables" OFF) -option( USE_SUPERBUILD "use ccache" ON) +option( USE_SUPERBUILD "build dependencies automatically" ON) option( TRACE_MEMORY "Enable memory tracing" OFF) set(NG_COMPILE_FLAGS "" CACHE STRING "Additional compile flags") +set(NGLIB_LIBRARY_TYPE SHARED CACHE STRING "nglib library type") +set(NGCORE_LIBRARY_TYPE SHARED CACHE STRING "ngcore library type") +set(NGGUI_LIBRARY_TYPE SHARED CACHE STRING "nggui library type") + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_modules") if(APPLE) @@ -220,24 +222,33 @@ macro(get_dll_from_lib dll_path lib_path) get_filename_component(lib_name ${lib} name) endmacro() +set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_CXX_STANDARD 17) if(WIN32) set(CMAKE_MFC_FLAG 0) - # build convenience (aka object) libraries in windows) - set(NG_LIB_TYPE OBJECT) -else(WIN32) - # build shared libraries - set(NG_LIB_TYPE SHARED) endif(WIN32) if(APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup") endif(APPLE) +####################################################################### +add_library(nglib ${NGLIB_LIBRARY_TYPE}) +if(USE_GUI) + add_library(nggui ${NGGUI_LIBRARY_TYPE}) + if(WIN32) + set_target_properties( nggui PROPERTIES OUTPUT_NAME "libnggui") + endif(WIN32) +endif(USE_GUI) + ####################################################################### if(NOT ZLIB_INCLUDE_DIRS) find_package(ZLIB REQUIRED) endif(NOT ZLIB_INCLUDE_DIRS) -include_directories(${ZLIB_INCLUDE_DIRS}) +target_include_directories(nglib PRIVATE ${ZLIB_INCLUDE_DIRS}) +if(USE_GUI) + target_include_directories(nggui PRIVATE ${ZLIB_INCLUDE_DIRS}) +endif(USE_GUI) +target_link_libraries(nglib PUBLIC ${ZLIB_LIBRARIES}) ####################################################################### if (USE_GUI) @@ -246,30 +257,32 @@ if (USE_GUI) find_package(Threads REQUIRED) if(APPLE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AppKit") + target_link_libraries(nggui PUBLIC "-framework AppKit") else(APPLE) find_package(X11 REQUIRED) + target_link_libraries( nggui PUBLIC ${X11_Xmu_LIB} ${X11_X11_LIB}) endif(APPLE) find_package(OpenGL REQUIRED) - add_definitions(-DTCL -DOPENGL -DUSE_TOGL_2 -DUSE_TCL_STUBS -DUSE_TK_STUBS) - include_directories(${TCL_INCLUDE_PATH}) - include_directories(${TK_INCLUDE_PATH}) + target_compile_definitions(nggui PUBLIC -DTCL -DOPENGL -DUSE_TOGL_2 PRIVATE -DUSE_TCL_STUBS -DUSE_TK_STUBS) + target_include_directories(nggui PUBLIC ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH}) if(NOT EXISTS ${TK_INCLUDE_PATH}/tkWin.h AND EXISTS ${TK_INCLUDE_PATH}/../win/tkWin.h) - include_directories(${TK_INCLUDE_PATH}/../win) + target_include_directories(nggui PUBLIC ${TK_INCLUDE_PATH}/../win) endif() if(NOT EXISTS ${TK_INCLUDE_PATH}/x11/Xlib.h AND EXISTS ${TK_INCLUDE_PATH}/../xlib/X11/Xlib.h) - include_directories(${TK_INCLUDE_PATH}/../xlib) + target_include_directories(nggui PUBLIC ${TK_INCLUDE_PATH}/../xlib) endif() - set(LIBTOGL togl) + target_link_libraries(nggui PUBLIC nglib togl + PRIVATE "$" ) if(WIN32) - add_definitions(-DTOGL_WGL) + target_compile_definitions(nggui PUBLIC -DTOGL_WGL) else(WIN32) if(APPLE) - ADD_DEFINITIONS(-DTOGL_NSOPENGL) + target_compile_definitions(nggui PUBLIC -DTOGL_NSOPENGL) else(APPLE) - ADD_DEFINITIONS(-DTOGL_X11) + target_compile_definitions(nggui PUBLIC -DTOGL_X11) endif(APPLE) endif(WIN32) endif (USE_GUI) @@ -291,6 +304,7 @@ if (USE_PYTHON) endif( PYBIND_INCLUDE_DIR ) target_include_directories(netgen_python INTERFACE ${PYBIND_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) + target_include_directories(nglib PRIVATE ${PYBIND_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) if(NOT ${BUILD_FOR_CONDA} OR WIN32) # Don't link python libraries in conda environments target_link_libraries(netgen_python INTERFACE ${PYTHON_LIBRARIES}) @@ -366,14 +380,18 @@ if (USE_OCC) ) include_directories(${OpenCASCADE_INCLUDE_DIR}) if(NOT OpenCASCADE_BUILD_SHARED_LIBS) - find_library( FREETYPE NAMES freetype HINTS ${OpenCASCADE_INSTALL_PREFIX}/lib) - list(APPEND OCC_LIBRARIES ${FREETYPE}) + if(OpenCASCADE_WITH_FREETYPE) + find_library( FREETYPE NAMES freetype HINTS ${OpenCASCADE_INSTALL_PREFIX}/lib) + list(APPEND OCC_LIBRARIES ${FREETYPE}) + if(UNIX AND NOT APPLE) + find_package(Fontconfig REQUIRED) + list(APPEND OCC_LIBRARIES ${Fontconfig_LIBRARIES}) + endif() + endif(OpenCASCADE_WITH_FREETYPE) if(UNIX AND NOT APPLE) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) list(APPEND OCC_LIBRARIES Threads::Threads) - find_package(Fontconfig REQUIRED) - list(APPEND OCC_LIBRARIES ${Fontconfig_LIBRARIES}) list(PREPEND OCC_LIBRARIES -Wl,--start-group) list(APPEND OCC_LIBRARIES -Wl,--end-group) endif() @@ -382,6 +400,9 @@ if (USE_OCC) endif() endif() message(STATUS "OCC DIRS ${OpenCASCADE_INCLUDE_DIR}") + if(WIN32) + target_link_libraries(nggui PRIVATE ${OCC_LIBRARIES}) + endif(WIN32) endif (USE_OCC) ####################################################################### @@ -483,6 +504,9 @@ endif(USE_CGNS) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/netgen_version.hpp ${CMAKE_CURRENT_BINARY_DIR}/netgen_config.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel) +# include instead of add_subdirectory to recognize the generated source files properly +include(rules/CMakeLists.txt) + add_subdirectory(windows) add_subdirectory(libsrc) add_subdirectory(ng) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index e25676b2..13d6915a 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -81,27 +81,9 @@ if(USE_OCC) if(BUILD_OCC) set(OCC_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/occ) - ExternalProject_Add(project_freetype - URL https://github.com/freetype/freetype/archive/refs/tags/VER-2-11-0.zip - URL_MD5 f58ef6a7affb7794c4f125d98e0e6a25 - DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies - ${SUBPROJECT_ARGS} - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${OCC_DIR} - -DBUILD_SHARED_LIBS:BOOL=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=TRUE - -DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE - -DCMAKE_DISABLE_FIND_PACKAGE_PNG=TRUE - -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE - -DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE - ${SUBPROJECT_CMAKE_ARGS} - UPDATE_COMMAND "" - ) - ExternalProject_Add(project_occ - DEPENDS project_freetype - URL https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_6_0.zip - URL_MD5 37519251c99cb3469ccfa82a9241d528 + URL https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_6_1.zip + URL_MD5 e891d85cad61c5cc7ccba3d0110f0c8c DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies ${SUBPROJECT_ARGS} CMAKE_ARGS @@ -111,11 +93,14 @@ if(BUILD_OCC) -DBUILD_MODULE_FoundationClasses:BOOL=ON -DBUILD_MODULE_ModelingData:BOOL=ON -DBUILD_MODULE_ModelingAlgorithms:BOOL=ON - -DBUILD_MODULE_Visualization:BOOL=ON -DBUILD_MODULE_DataExchange:BOOL=ON + -DBUILD_MODULE_Visualization:BOOL=OFF -DBUILD_MODULE_ApplicationFramework:BOOL=OFF -DBUILD_MODULE_Draw:BOOL=OFF - -DUSE_FREETYPE=ON + -DUSE_FREETYPE:BOOL=OFF + -DUSE_OPENGL:BOOL=OFF + -DUSE_XLIB:BOOL=OFF + -DBUILD_DOC_Overview:BOOL=OFF ${SUBPROJECT_CMAKE_ARGS} UPDATE_COMMAND "" ) @@ -258,6 +243,10 @@ set_vars( NETGEN_CMAKE_ARGS OpenCascade_ROOT ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES + + NGLIB_LIBRARY_TYPE + NGCORE_LIBRARY_TYPE + NGGUI_LIBRARY_TYPE ) # propagate all variables set on the command line using cmake -DFOO=BAR diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt index eb67d688..9ee2a855 100644 --- a/libsrc/CMakeLists.txt +++ b/libsrc/CMakeLists.txt @@ -4,10 +4,21 @@ add_subdirectory(gprim) add_subdirectory(linalg) add_subdirectory(include) add_subdirectory(meshing) -add_subdirectory(visualization) -add_subdirectory(csg) -add_subdirectory(geom2d) -add_subdirectory(occ) -add_subdirectory(stlgeom) -add_subdirectory(interface) - +if(USE_OCC) + add_subdirectory(occ) +endif(USE_OCC) +if(USE_STLGEOM) + add_subdirectory(stlgeom) +endif(USE_STLGEOM) +if(USE_GUI) + add_subdirectory(visualization) +endif(USE_GUI) +if(USE_INTERFACE) + add_subdirectory(interface) +endif(USE_INTERFACE) +if(USE_CSG) + add_subdirectory(csg) +endif(USE_CSG) +if(USE_GEOM2D) + add_subdirectory(geom2d) +endif(USE_GEOM2D) diff --git a/libsrc/core/CMakeLists.txt b/libsrc/core/CMakeLists.txt index b80b97b2..ee89b4f6 100644 --- a/libsrc/core/CMakeLists.txt +++ b/libsrc/core/CMakeLists.txt @@ -1,5 +1,5 @@ -add_library(ngcore SHARED +add_library(ngcore ${NGCORE_LIBRARY_TYPE} archive.cpp bitarray.cpp exception.cpp @@ -34,8 +34,6 @@ if(WIN32) get_WIN32_WINNT(ver) target_compile_definitions(ngcore PUBLIC _WIN32_WINNT=${ver} WNT WNT_WINDOW NOMINMAX MSVC_EXPRESS _CRT_SECURE_NO_WARNINGS HAVE_STRUCT_TIMESPEC WIN32) target_link_options(ngcore PUBLIC /ignore:4273 /ignore:4217 /ignore:4049) -else(WIN32) - target_compile_options(ngcore PRIVATE -fvisibility=hidden) endif(WIN32) target_compile_definitions(ngcore PRIVATE NGCORE_EXPORTS) diff --git a/libsrc/csg/CMakeLists.txt b/libsrc/csg/CMakeLists.txt index 52514038..d20c12d5 100644 --- a/libsrc/csg/CMakeLists.txt +++ b/libsrc/csg/CMakeLists.txt @@ -1,33 +1,14 @@ -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(csg ${NG_LIB_TYPE} +target_sources(nglib PRIVATE algprim.cpp brick.cpp bspline2d.cpp csgeom.cpp csgparser.cpp curve2d.cpp edgeflw.cpp explicitcurve2d.cpp extrusion.cpp gencyl.cpp genmesh.cpp identify.cpp manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp zrefine.cpp python_csg.cpp splinesurface.cpp - ) -if(APPLE) - set_target_properties( csg PROPERTIES SUFFIX ".so") -endif(APPLE) - -target_link_libraries(csg PUBLIC mesh PRIVATE "$") -if(NOT WIN32) - install( TARGETS csg ${NG_INSTALL_DIR}) -endif(NOT WIN32) - -target_link_libraries(csg PUBLIC ngcore) +) if(USE_GUI) - add_library(csgvis ${NG_LIB_TYPE} vscsg.cpp ) - target_link_libraries(csgvis PRIVATE "$" PUBLIC ngcore) - if(NOT WIN32) - target_link_libraries(csgvis PUBLIC csg visual) - if(APPLE) - set_target_properties( csgvis PROPERTIES SUFFIX ".so") - endif(APPLE) - install( TARGETS csgvis ${NG_INSTALL_DIR}) - endif(NOT WIN32) + target_sources(nggui PRIVATE vscsg.cpp csgpkg.cpp) endif(USE_GUI) install(FILES diff --git a/libsrc/csg/csgpkg.cpp b/libsrc/csg/csgpkg.cpp index 488d7bc2..ced6b626 100644 --- a/libsrc/csg/csgpkg.cpp +++ b/libsrc/csg/csgpkg.cpp @@ -17,7 +17,6 @@ extern "C" int Ng_CSG_Init (Tcl_Interp * interp); namespace netgen { - // extern DLL_HEADER NetgenGeometry * ng_geometry; extern DLL_HEADER shared_ptr ng_geometry; extern DLL_HEADER shared_ptr mesh; diff --git a/libsrc/csg/genmesh.cpp b/libsrc/csg/genmesh.cpp index be872b03..da790fc4 100644 --- a/libsrc/csg/genmesh.cpp +++ b/libsrc/csg/genmesh.cpp @@ -11,7 +11,7 @@ namespace netgen { - NgArray global_specpoints; // for visualization + DLL_HEADER NgArray global_specpoints; // for visualization //static NgArray spoints; #define TCL_OK 0 diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 14a4bfef..676e249a 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -1,8 +1,8 @@ #ifdef NG_PYTHON -#include <../general/ngpython.hpp> -#include -#include +#include "../general/ngpython.hpp" +#include "../core/python_ngcore.hpp" +#include "csg.hpp" #include "../meshing/python_mesh.hpp" #include "../general/gzstream.h" diff --git a/libsrc/csg/specpoin.cpp b/libsrc/csg/specpoin.cpp index 6eca64ba..286115a3 100644 --- a/libsrc/csg/specpoin.cpp +++ b/libsrc/csg/specpoin.cpp @@ -21,7 +21,7 @@ namespace netgen { - NgArray > boxes; // for visualizaton + DLL_HEADER NgArray > boxes; // for visualizaton void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp); diff --git a/libsrc/csg/vscsg.cpp b/libsrc/csg/vscsg.cpp index 4178e4bb..ed511e79 100644 --- a/libsrc/csg/vscsg.cpp +++ b/libsrc/csg/vscsg.cpp @@ -17,11 +17,11 @@ namespace netgen /* *********************** Draw Geometry **************** */ - extern shared_ptr mesh; - extern NgArray global_specpoints; + DLL_HEADER extern shared_ptr mesh; + DLL_HEADER extern NgArray global_specpoints; NgArray & specpoints = global_specpoints; - extern NgArray > boxes; + DLL_HEADER extern NgArray > boxes; @@ -500,7 +500,7 @@ namespace netgen #ifdef NG_PYTHON #include <../general/ngpython.hpp> -DLL_HEADER void ExportCSGVis(py::module &m) +NGGUI_API void ExportCSGVis(py::module &m) { using namespace netgen; diff --git a/libsrc/csg/vscsg.hpp b/libsrc/csg/vscsg.hpp index 4805a246..1a18295e 100644 --- a/libsrc/csg/vscsg.hpp +++ b/libsrc/csg/vscsg.hpp @@ -10,7 +10,7 @@ namespace netgen { - class DLL_HEADER VisualSceneGeometry : public VisualScene + class NGGUI_API VisualSceneGeometry : public VisualScene { class CSGeometry * geometry; NgArray trilists; diff --git a/libsrc/general/CMakeLists.txt b/libsrc/general/CMakeLists.txt index cf1f4c63..e17f63cd 100644 --- a/libsrc/general/CMakeLists.txt +++ b/libsrc/general/CMakeLists.txt @@ -1,12 +1,18 @@ -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(gen INTERFACE) -set(sdir ${CMAKE_CURRENT_SOURCE_DIR}) -target_sources(gen INTERFACE - ${sdir}/ngarray.cpp ${sdir}/ngbitarray.cpp ${sdir}/dynamicmem.cpp - ${sdir}/hashtabl.cpp ${sdir}/mystring.cpp ${sdir}/optmem.cpp ${sdir}/parthreads.cpp - ${sdir}/seti.cpp ${sdir}/sort.cpp ${sdir}/spbita2d.cpp ${sdir}/table.cpp - ${sdir}/mpi_interface.cpp ${sdir}/gzstream.cpp - ) +target_sources(nglib PRIVATE + dynamicmem.cpp + gzstream.cpp + hashtabl.cpp + mpi_interface.cpp + mystring.cpp + ngarray.cpp + ngbitarray.cpp + optmem.cpp + parthreads.cpp + seti.cpp + sort.cpp + spbita2d.cpp + table.cpp +) install(FILES ngarray.hpp autodiff.hpp autoptr.hpp ngbitarray.hpp diff --git a/libsrc/general/gzstream.h b/libsrc/general/gzstream.h index 6f0c8060..7528b5f0 100644 --- a/libsrc/general/gzstream.h +++ b/libsrc/general/gzstream.h @@ -71,13 +71,13 @@ public: virtual int sync(); }; -class gzstreambase : virtual public std::ios { +class DLL_HEADER gzstreambase : virtual public std::ios { protected: gzstreambuf buf; public: gzstreambase() { init(&buf); } - DLL_HEADER gzstreambase( const filesystem::path & name, int open_mode); - DLL_HEADER ~gzstreambase(); + gzstreambase( const filesystem::path & name, int open_mode); + ~gzstreambase(); void open( const filesystem::path & name, int open_mode); void close(); gzstreambuf* rdbuf() { return &buf; } diff --git a/libsrc/general/hashtabl.hpp b/libsrc/general/hashtabl.hpp index bac32651..0a1df2d1 100644 --- a/libsrc/general/hashtabl.hpp +++ b/libsrc/general/hashtabl.hpp @@ -688,7 +688,7 @@ protected: size_t mask; public: /// - BASE_INDEX_2_CLOSED_HASHTABLE (size_t size); + DLL_HEADER BASE_INDEX_2_CLOSED_HASHTABLE (size_t size); int Size() const { return hash.Size(); } bool UsedPos0 (int pos) const { return ! (hash[pos].I1() == invalid); } @@ -738,9 +738,9 @@ public: protected: /// - int Position2 (const INDEX_2 & ind) const; - bool PositionCreate2 (const INDEX_2 & ind, int & apos); - void BaseSetSize (int asize); + DLL_HEADER int Position2 (const INDEX_2 & ind) const; + DLL_HEADER bool PositionCreate2 (const INDEX_2 & ind, int & apos); + DLL_HEADER void BaseSetSize (int asize); }; diff --git a/libsrc/general/mpi_interface.hpp b/libsrc/general/mpi_interface.hpp index 2c490053..df1bf5c8 100644 --- a/libsrc/general/mpi_interface.hpp +++ b/libsrc/general/mpi_interface.hpp @@ -253,7 +253,7 @@ namespace netgen [[deprecated("do we still send commands?")]] - extern void MyMPI_SendCmd (const char * cmd); + DLL_HEADER void MyMPI_SendCmd (const char * cmd); [[deprecated("do we still send commands?")]] extern string MyMPI_RecvCmd (); diff --git a/libsrc/general/ngbitarray.hpp b/libsrc/general/ngbitarray.hpp index 77e07f17..637d1814 100644 --- a/libsrc/general/ngbitarray.hpp +++ b/libsrc/general/ngbitarray.hpp @@ -29,14 +29,14 @@ class NgBitArray unsigned char * data; public: - NgBitArray (); + DLL_HEADER NgBitArray (); /// - NgBitArray (INDEX asize); + DLL_HEADER NgBitArray (INDEX asize); /// - ~NgBitArray (); + DLL_HEADER ~NgBitArray (); /// - void SetSize (INDEX asize); + DLL_HEADER void SetSize (INDEX asize); /// INDEX Size () const { @@ -44,14 +44,14 @@ public: } /// - void Set (); + DLL_HEADER void Set (); /// void Set (INDEX i) { data[Addr(i)] |= Mask(i); } - void Clear (); + DLL_HEADER void Clear (); void Clear (INDEX i) diff --git a/libsrc/general/table.hpp b/libsrc/general/table.hpp index 12d0ff38..535d0212 100644 --- a/libsrc/general/table.hpp +++ b/libsrc/general/table.hpp @@ -40,11 +40,11 @@ public: table2.oneblock = nullptr; } - BASE_TABLE (int size); + DLL_HEADER BASE_TABLE (int size); /// - BASE_TABLE (const NgFlatArray & entrysizes, int elemsize); + DLL_HEADER BASE_TABLE (const NgFlatArray & entrysizes, int elemsize); /// - ~BASE_TABLE (); + DLL_HEADER ~BASE_TABLE (); BASE_TABLE & operator= (BASE_TABLE && table2) { diff --git a/libsrc/geom2d/CMakeLists.txt b/libsrc/geom2d/CMakeLists.txt index 26fe62fc..0766c698 100644 --- a/libsrc/geom2d/CMakeLists.txt +++ b/libsrc/geom2d/CMakeLists.txt @@ -1,21 +1,12 @@ -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(geom2d ${NG_LIB_TYPE} csg2d.cpp genmesh2d.cpp geometry2d.cpp python_geom2d.cpp ) -if(APPLE) - set_target_properties( geom2d PROPERTIES SUFFIX ".so") -endif(APPLE) - -target_link_libraries(geom2d PUBLIC ngcore mesh PRIVATE "$") -if(NOT WIN32) - install( TARGETS geom2d ${NG_INSTALL_DIR}) -endif(NOT WIN32) +target_sources(nglib PRIVATE + csg2d.cpp + genmesh2d.cpp + geometry2d.cpp + python_geom2d.cpp +) if(USE_GUI) - add_library(geom2dvis ${NG_LIB_TYPE} vsgeom2d.cpp) - target_link_libraries(geom2dvis PUBLIC ngcore) - if(NOT WIN32) - target_link_libraries(geom2dvis PUBLIC geom2d) - install( TARGETS geom2dvis ${NG_INSTALL_DIR}) - endif(NOT WIN32) + target_sources(nggui PRIVATE vsgeom2d.cpp geom2dpkg.cpp) endif(USE_GUI) install(FILES diff --git a/libsrc/geom2d/geometry2d.hpp b/libsrc/geom2d/geometry2d.hpp index a399d103..d6b62b88 100644 --- a/libsrc/geom2d/geometry2d.hpp +++ b/libsrc/geom2d/geometry2d.hpp @@ -128,7 +128,7 @@ namespace netgen - class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry + class DLL_HEADER SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry { protected: NgArray materials; @@ -141,13 +141,13 @@ namespace netgen public: - DLL_HEADER virtual ~SplineGeometry2d(); + virtual ~SplineGeometry2d(); - DLL_HEADER void Load (const filesystem::path & filename); + void Load (const filesystem::path & filename); - DLL_HEADER void LoadData( ifstream & infile ); - DLL_HEADER void LoadDataNew ( ifstream & infile ); - DLL_HEADER void LoadDataV2 ( ifstream & infile ); + void LoadData( ifstream & infile ); + void LoadDataNew ( ifstream & infile ); + void LoadDataV2 ( ifstream & infile ); void TestComment ( ifstream & infile ) ; @@ -196,7 +196,7 @@ namespace netgen } - DLL_HEADER int GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) override; + int GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) override; void PartitionBoundary (MeshingParameters & mp, double h, Mesh & mesh2d); @@ -204,8 +204,8 @@ namespace netgen size_t GetNDomains() const { return materials.Size(); } - DLL_HEADER void GetMaterial (int domnr, char* & material ); - DLL_HEADER void SetMaterial (int domnr, const string & material); + void GetMaterial (int domnr, char* & material ); + void SetMaterial (int domnr, const string & material); double GetDomainMaxh ( const int domnr ); void SetDomainMaxh ( const int domnr, double maxh ); diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index dc14bd67..ab232f13 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -1,12 +1,12 @@ #ifdef NG_PYTHON -#include <../general/ngpython.hpp> -#include +#include "../general/ngpython.hpp" +#include "../core/python_ngcore.hpp" #include "../meshing/python_mesh.hpp" -#include -#include -#include +#include "../include/meshing.hpp" +#include "../include/geometry2d.hpp" +#include "csg2d.hpp" using namespace netgen; using namespace pybind11::literals; diff --git a/libsrc/geom2d/vsgeom2d.hpp b/libsrc/geom2d/vsgeom2d.hpp index c7cd034e..190c386b 100644 --- a/libsrc/geom2d/vsgeom2d.hpp +++ b/libsrc/geom2d/vsgeom2d.hpp @@ -10,7 +10,7 @@ namespace netgen { - class DLL_HEADER VisualSceneGeometry2d : public VisualScene + class NGGUI_API VisualSceneGeometry2d : public VisualScene { const class SplineGeometry2d * geometry2d; public: diff --git a/libsrc/gprim/CMakeLists.txt b/libsrc/gprim/CMakeLists.txt index 4944858e..b23480a4 100644 --- a/libsrc/gprim/CMakeLists.txt +++ b/libsrc/gprim/CMakeLists.txt @@ -1,10 +1,13 @@ -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(gprim INTERFACE) -set(sdir ${CMAKE_CURRENT_SOURCE_DIR}) -target_sources(gprim INTERFACE - ${sdir}/adtree.cpp ${sdir}/geom2d.cpp ${sdir}/geom3d.cpp ${sdir}/geomfuncs.cpp - ${sdir}/geomtest3d.cpp ${sdir}/transform3d.cpp ${sdir}/spline.cpp ${sdir}/splinegeometry.cpp - ) +target_sources(nglib PRIVATE + adtree.cpp + geom2d.cpp + geom3d.cpp + geomfuncs.cpp + geomtest3d.cpp + spline.cpp + splinegeometry.cpp + transform3d.cpp +) install(FILES adtree.hpp geom2d.hpp geom3d.hpp geomfuncs.hpp diff --git a/libsrc/gprim/geom3d.hpp b/libsrc/gprim/geom3d.hpp index 9a01b529..068848d5 100644 --- a/libsrc/gprim/geom3d.hpp +++ b/libsrc/gprim/geom3d.hpp @@ -302,7 +302,7 @@ namespace netgen friend inline void Cross (const Vec3d & v1, const Vec3d & v2, Vec3d & prod); /// Returns one normal-vector to n - void GetNormal (Vec3d & n) const; + DLL_HEADER void GetNormal (Vec3d & n) const; /// friend double Angle (const Vec3d & v); /// @@ -578,15 +578,15 @@ namespace netgen /// Box3d () { }; /// - Box3d ( double aminx, double amaxx, + DLL_HEADER Box3d ( double aminx, double amaxx, double aminy, double amaxy, double aminz, double amaxz ); /// - Box3d ( const Box3d & b2 ); + DLL_HEADER Box3d ( const Box3d & b2 ); /// - Box3d (const Point3d& p1, const Point3d& p2); + DLL_HEADER Box3d (const Point3d& p1, const Point3d& p2); /// - Box3d (const Box<3> & b2); + DLL_HEADER Box3d (const Box<3> & b2); /// double MinX () const { return minx[0]; } /// diff --git a/libsrc/gprim/geomfuncs.hpp b/libsrc/gprim/geomfuncs.hpp index c85e0dc6..2a647b25 100644 --- a/libsrc/gprim/geomfuncs.hpp +++ b/libsrc/gprim/geomfuncs.hpp @@ -177,8 +177,8 @@ namespace netgen double Det (const Mat<3,3> & m); // eigenvalues of a symmetric matrix - void EigenValues (const Mat<3,3> & m, Vec<3> & ev); - void EigenValues (const Mat<2,2> & m, Vec<3> & ev); + DLL_HEADER void EigenValues (const Mat<3,3> & m, Vec<3> & ev); + DLL_HEADER void EigenValues (const Mat<2,2> & m, Vec<3> & ev); template diff --git a/libsrc/gprim/splinegeometry.hpp b/libsrc/gprim/splinegeometry.hpp index 140f618e..bf9978ba 100644 --- a/libsrc/gprim/splinegeometry.hpp +++ b/libsrc/gprim/splinegeometry.hpp @@ -22,7 +22,7 @@ namespace netgen template < int D > - class SplineGeometry + class DLL_HEADER SplineGeometry { // protected: public: @@ -30,16 +30,16 @@ namespace netgen NgArray < SplineSeg* > splines; SplineGeometry() : geompoints{}, splines{} { ; } - virtual DLL_HEADER ~SplineGeometry(); + virtual ~SplineGeometry(); - DLL_HEADER int Load (const NgArray & raw_data, const int startpos = 0); + int Load (const NgArray & raw_data, const int startpos = 0); virtual void DoArchive(Archive& ar) { ar & geompoints & splines; } - DLL_HEADER void GetRawData (NgArray & raw_data) const; + void GetRawData (NgArray & raw_data) const; const NgArray*> & GetSplines () const @@ -50,7 +50,7 @@ namespace netgen SplineSeg & GetSpline (const int i) {return *splines[i];} const SplineSeg & GetSpline (const int i) const {return *splines[i];} - DLL_HEADER void GetBoundingBox (Box & box) const; + void GetBoundingBox (Box & box) const; Box GetBoundingBox () const { Box box; GetBoundingBox (box); return box; } @@ -58,7 +58,7 @@ namespace netgen const GeomPoint & GetPoint(int i) const { return geompoints[i]; } // void SetGrading (const double grading); - DLL_HEADER void AppendPoint (const Point & p, const double reffac = 1., const bool hpref = false); + void AppendPoint (const Point & p, const double reffac = 1., const bool hpref = false); void AppendSegment(SplineSeg * spline) { diff --git a/libsrc/include/mydefs.hpp b/libsrc/include/mydefs.hpp index 41369e6a..c0fd99e6 100644 --- a/libsrc/include/mydefs.hpp +++ b/libsrc/include/mydefs.hpp @@ -16,7 +16,7 @@ // #define DEBUG -#if defined(NGINTERFACE_EXPORTS) || ( defined(WIN32) && (defined(NGLIB_EXPORTS) || defined(nglib_EXPORTS)) ) +#if defined(nglib_EXPORTS) #define DLL_HEADER NGCORE_API_EXPORT #else #define DLL_HEADER NGCORE_API_IMPORT diff --git a/libsrc/include/nginterface.h b/libsrc/include/nginterface.h index 6f57ba9f..2d76aa7c 100644 --- a/libsrc/include/nginterface.h +++ b/libsrc/include/nginterface.h @@ -281,7 +281,7 @@ extern "C" { int NgPar_GetDistantNodeNums ( int nodetype, int locnum, int * pnums ); int NgPar_GetNDistantNodeNums ( int nodetype, int locnum ); - int NgPar_GetGlobalNodeNum (int nodetype, int locnum); + DLL_HEADER int NgPar_GetGlobalNodeNum (int nodetype, int locnum); #endif diff --git a/libsrc/interface/CMakeLists.txt b/libsrc/interface/CMakeLists.txt index 47661a0c..caf93017 100644 --- a/libsrc/interface/CMakeLists.txt +++ b/libsrc/interface/CMakeLists.txt @@ -1,17 +1,10 @@ -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(interface ${NG_LIB_TYPE} +target_sources(nglib PRIVATE nginterface.cpp nginterface_v2.cpp read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp writedolfin.cpp writeelmer.cpp writefeap.cpp writefluent.cpp writegmsh.cpp writejcm.cpp writepermas.cpp writetecplot.cpp writetet.cpp writetochnog.cpp writeuser.cpp wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp rw_cgns.cpp - ) - -target_link_libraries(interface PUBLIC mesh csg geom2d stl visual PRIVATE netgen_cgns) - -if(NOT WIN32) - install( TARGETS interface ${NG_INSTALL_DIR}) -endif(NOT WIN32) +) install(FILES writeuser.hpp diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index 7e55d42d..d98b797c 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -2371,13 +2371,6 @@ void Ng_GetArgs (int & argc, char ** &argv) -void LinkFunction () -{ - Ng_Redraw(); -} - - - void Ng_TclCmd(string cmd) { lock_guard guard(tcl_todo_mutex); diff --git a/libsrc/linalg/CMakeLists.txt b/libsrc/linalg/CMakeLists.txt index a8ab1b5a..b757b2a9 100644 --- a/libsrc/linalg/CMakeLists.txt +++ b/libsrc/linalg/CMakeLists.txt @@ -1,7 +1,9 @@ -add_library( la INTERFACE ) -set(sdir ${CMAKE_CURRENT_SOURCE_DIR}) -target_sources( la INTERFACE - ${sdir}/densemat.cpp ${sdir}/polynomial.cpp ${sdir}/bfgs.cpp ${sdir}/linopt.cpp ${sdir}/linsearch.cpp +target_sources(nglib PRIVATE + bfgs.cpp + densemat.cpp + linopt.cpp + linsearch.cpp + polynomial.cpp ) install(FILES diff --git a/libsrc/meshing/CMakeLists.txt b/libsrc/meshing/CMakeLists.txt index dfef71f7..bcccea69 100644 --- a/libsrc/meshing/CMakeLists.txt +++ b/libsrc/meshing/CMakeLists.txt @@ -1,21 +1,4 @@ -# generate .cpp files containing the string of the .rls meshing rule files -add_executable(makerls ${CMAKE_CURRENT_SOURCE_DIR}/../../rules/makerlsfile.cpp) - -set(rules hexrules prismrules2 pyramidrules pyramidrules2 quadrules tetrules triarules) - -foreach(rule ${rules}) - list(APPEND rules_sources rule_${rule}.cpp) - set(rule_file ${CMAKE_CURRENT_SOURCE_DIR}/../../rules/${rule}.rls) - - add_custom_command(OUTPUT rule_${rule}.cpp - COMMAND makerls ${rule_file} rule_${rule}.cpp ${rule} - DEPENDS makerls ${rule_file} - ) -endforeach() - - -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(mesh ${NG_LIB_TYPE} +target_sources(nglib PRIVATE adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp geomsearch.cpp global.cpp hprefinement.cpp improve2.cpp @@ -28,21 +11,10 @@ add_library(mesh ${NG_LIB_TYPE} topology.cpp validate.cpp bcfunctions.cpp parallelmesh.cpp paralleltop.cpp basegeom.cpp python_mesh.cpp surfacegeom.cpp - ../../ng/onetcl.cpp debugging.cpp - ${rules_sources} - ${mesh_object_libs} - ) + debugging.cpp fieldlines.cpp visual_interface.cpp +) -if(APPLE) - set_target_properties( mesh PROPERTIES SUFFIX ".so") -endif(APPLE) - -target_link_libraries( mesh PUBLIC ngcore PRIVATE gprim la gen ) - -target_link_libraries( mesh PRIVATE netgen_metis "$" ${ZLIB_LIBRARIES} ) -if(NOT WIN32) - install( TARGETS mesh ${NG_INSTALL_DIR}) -endif(NOT WIN32) +target_link_libraries( nglib PRIVATE netgen_metis "$" ${ZLIB_LIBRARIES} ) install(FILES adfront2.hpp adfront3.hpp basegeom.hpp bcfunctions.hpp bisect.hpp @@ -54,5 +26,6 @@ install(FILES meshing.hpp meshtool.hpp meshtype.hpp msghandler.hpp paralleltop.hpp ruler2.hpp ruler3.hpp specials.hpp topology.hpp validate.hpp python_mesh.hpp surfacegeom.hpp delaunay2d.hpp + fieldlines.hpp soldata.hpp visual_interface.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/meshing COMPONENT netgen_devel ) diff --git a/libsrc/meshing/curvedelems.hpp b/libsrc/meshing/curvedelems.hpp index 36bf5c41..59fbb86d 100644 --- a/libsrc/meshing/curvedelems.hpp +++ b/libsrc/meshing/curvedelems.hpp @@ -57,10 +57,10 @@ public: & edgeweight & order & rational & ishighorder; } - bool IsSegmentCurved (SegmentIndex segnr) const; - bool IsSurfaceElementCurved (SurfaceElementIndex sei) const; - bool IsElementCurved (ElementIndex ei) const; - bool IsElementHighOrder (ElementIndex ei) const; + DLL_HEADER bool IsSegmentCurved (SegmentIndex segnr) const; + DLL_HEADER bool IsSurfaceElementCurved (SurfaceElementIndex sei) const; + DLL_HEADER bool IsElementCurved (ElementIndex ei) const; + DLL_HEADER bool IsElementHighOrder (ElementIndex ei) const; void CalcSegmentTransformation (double xi, SegmentIndex segnr, @@ -135,7 +135,7 @@ public: T * x, size_t sx, T * dxdxi, size_t sdxdxi); - void CalcMultiPointSurfaceTransformation (NgArray< Point<2> > * xi, SurfaceElementIndex elnr, + DLL_HEADER void CalcMultiPointSurfaceTransformation (NgArray< Point<2> > * xi, SurfaceElementIndex elnr, NgArray< Point<3> > * x, NgArray< Mat<3,2> > * dxdxi); @@ -145,7 +145,7 @@ public: T * x, size_t sx, T * dxdxi, size_t sdxdxi); - void CalcMultiPointElementTransformation (NgArray< Point<3> > * xi, ElementIndex elnr, + DLL_HEADER void CalcMultiPointElementTransformation (NgArray< Point<3> > * xi, ElementIndex elnr, NgArray< Point<3> > * x, NgArray< Mat<3,3> > * dxdxi); @@ -161,13 +161,13 @@ public: private: template - void CalcSegmentTransformation (const T & xi, SegmentIndex segnr, + DLL_HEADER void CalcSegmentTransformation (const T & xi, SegmentIndex segnr, Point<3,T> * x = NULL, Vec<3,T> * dxdxi = NULL, bool * curved = NULL); - void CalcSurfaceTransformation (Point<2> xi, SurfaceElementIndex elnr, + DLL_HEADER void CalcSurfaceTransformation (Point<2> xi, SurfaceElementIndex elnr, Point<3> * x = NULL, Mat<3,2> * dxdxi = NULL, bool * curved = NULL); - void CalcElementTransformation (Point<3> xi, ElementIndex elnr, + DLL_HEADER void CalcElementTransformation (Point<3> xi, ElementIndex elnr, Point<3> * x = NULL, Mat<3,3> * dxdxi = NULL, // bool * curved = NULL, void * buffer = NULL, bool valid = 0); diff --git a/libsrc/meshing/debugging.hpp b/libsrc/meshing/debugging.hpp index 87d83e11..726fb203 100644 --- a/libsrc/meshing/debugging.hpp +++ b/libsrc/meshing/debugging.hpp @@ -1,4 +1,4 @@ -#include +#include "meshclass.hpp" namespace netgen diff --git a/libsrc/visualization/fieldlines.cpp b/libsrc/meshing/fieldlines.cpp similarity index 100% rename from libsrc/visualization/fieldlines.cpp rename to libsrc/meshing/fieldlines.cpp diff --git a/libsrc/visualization/fieldlines.hpp b/libsrc/meshing/fieldlines.hpp similarity index 100% rename from libsrc/visualization/fieldlines.hpp rename to libsrc/meshing/fieldlines.hpp diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 1ea06adb..8fe6647a 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -160,16 +160,16 @@ namespace netgen public: - void BuildBoundaryEdges(bool rebuild=true); + DLL_HEADER void BuildBoundaryEdges(bool rebuild=true); - bool PointContainedIn2DElement(const Point3d & p, + DLL_HEADER bool PointContainedIn2DElement(const Point3d & p, double lami[3], const int element, bool consider3D = false) const; - bool PointContainedIn3DElement(const Point3d & p, + DLL_HEADER bool PointContainedIn3DElement(const Point3d & p, double lami[3], const int element) const; - bool PointContainedIn3DElementOld(const Point3d & p, + DLL_HEADER bool PointContainedIn3DElementOld(const Point3d & p, double lami[3], const int element) const; @@ -628,22 +628,22 @@ namespace netgen void SetPointSearchStartElement(const int el) const {ps_startelement = el;} /// gives element of point, barycentric coordinates - int GetElementOfPoint (const netgen::Point<3> & p, + DLL_HEADER int GetElementOfPoint (const netgen::Point<3> & p, double * lami, bool build_searchtree = 0, const int index = -1, const bool allowindex = true) const; - int GetElementOfPoint (const netgen::Point<3> & p, + DLL_HEADER int GetElementOfPoint (const netgen::Point<3> & p, double * lami, const NgArray * const indices, bool build_searchtree = 0, const bool allowindex = true) const; - int GetSurfaceElementOfPoint (const netgen::Point<3> & p, + DLL_HEADER int GetSurfaceElementOfPoint (const netgen::Point<3> & p, double * lami, bool build_searchtree = 0, const int index = -1, const bool allowindex = true) const; - int GetSurfaceElementOfPoint (const netgen::Point<3> & p, + DLL_HEADER int GetSurfaceElementOfPoint (const netgen::Point<3> & p, double * lami, const NgArray * const indices, bool build_searchtree = 0, @@ -775,27 +775,27 @@ namespace netgen /// bool HasIdentifications() const { return ident != nullptr; } - void InitPointCurve(double red = 1, double green = 0, double blue = 0) const; - void AddPointCurvePoint(const Point3d & pt) const; - int GetNumPointCurves(void) const; - int GetNumPointsOfPointCurve(int curve) const; - Point3d & GetPointCurvePoint(int curve, int n) const; - void GetPointCurveColor(int curve, double & red, double & green, double & blue) const; + DLL_HEADER void InitPointCurve(double red = 1, double green = 0, double blue = 0) const; + DLL_HEADER void AddPointCurvePoint(const Point3d & pt) const; + DLL_HEADER int GetNumPointCurves(void) const; + DLL_HEADER int GetNumPointsOfPointCurve(int curve) const; + DLL_HEADER Point3d & GetPointCurvePoint(int curve, int n) const; + DLL_HEADER void GetPointCurveColor(int curve, double & red, double & green, double & blue) const; /// find number of vertices - void ComputeNVertices (); + DLL_HEADER void ComputeNVertices (); /// number of vertices (no edge-midpoints) - int GetNV () const; + DLL_HEADER int GetNV () const; /// remove edge points - void SetNP (int np); + DLL_HEADER void SetNP (int np); - Table CreatePoint2ElementTable(std::optional points = std::nullopt) const; - Table CreatePoint2SurfaceElementTable( int faceindex=0 ) const; + DLL_HEADER Table CreatePoint2ElementTable(std::optional points = std::nullopt) const; + DLL_HEADER Table CreatePoint2SurfaceElementTable( int faceindex=0 ) const; DLL_HEADER bool PureTrigMesh (int faceindex = 0) const; DLL_HEADER bool PureTetMesh () const; @@ -908,8 +908,8 @@ namespace netgen { return *paralleltop; } /// distributes the master-mesh to local meshes - void Distribute (); - void Distribute (NgArray & volume_weights, NgArray & surface_weights, + DLL_HEADER void Distribute (); + DLL_HEADER void Distribute (NgArray & volume_weights, NgArray & surface_weights, NgArray & segment_weights); @@ -920,8 +920,8 @@ namespace netgen // void FindExchangeFaces (); /// use metis to decompose master mesh - void ParallelMetis (int nproc); // NgArray & neloc ); - void ParallelMetis (NgArray & volume_weights, NgArray & surface_weights, + DLL_HEADER void ParallelMetis (int nproc); // NgArray & neloc ); + DLL_HEADER void ParallelMetis (NgArray & volume_weights, NgArray & surface_weights, NgArray & segment_weights); void PartHybridMesh (); // NgArray & neloc ); diff --git a/libsrc/meshing/meshing2.cpp b/libsrc/meshing/meshing2.cpp index 6700b70c..56209458 100644 --- a/libsrc/meshing/meshing2.cpp +++ b/libsrc/meshing/meshing2.cpp @@ -1,11 +1,26 @@ #include #include "meshing.hpp" -#ifdef OPENGL -#include -#endif // OPENGL +#include "visual_interface.hpp" namespace netgen { + static void glrender (int wait) + { + // cout << "plot adfront" << endl; + + if (multithread.drawing) + { + // vssurfacemeshing.DrawScene(); + Render (); + + if (wait || multithread.testmode) + { + multithread.pause = 1; + } + while (multithread.pause); + } + } + ostream& operator << (ostream& ost, const MultiPointGeomInfo& mpgi) { for(auto i : Range(mpgi.GetNPGI())) @@ -14,25 +29,6 @@ namespace netgen } return ost; } - static void glrender (int wait); -#ifdef OPENGL - extern DLL_HEADER void Render(bool blocking = false); - DLL_HEADER extern VisualSceneSurfaceMeshing vssurfacemeshing; - VisualSceneSurfaceMeshing vssurfacemeshing; -#endif // OPENGL - - // global variable for visualization -// static NgArray locpoints; -// static NgArray legalpoints; -// static NgArray plainpoints; -// static NgArray plainzones; -// static NgArray loclines; -// // static int geomtrig; -// //static const char * rname; -// static int cntelem, trials, nfaces; -// static int oldnl; -// static int qualclass; - static Array> global_trig_rules; static Array> global_quad_rules; @@ -287,12 +283,7 @@ namespace netgen int cntelem = 0, trials = 0, nfaces = 0; int oldnl = 0; -#ifdef OPENGL - vssurfacemeshing.oldnl = oldnl; - vssurfacemeshing.loclinesptr = loclinesptr; - vssurfacemeshing.locpointsptr = locpointsptr; - vssurfacemeshing.plainpointsptr = plainpointsptr; -#endif // OPENGL + UpdateVisSurfaceMeshData(oldnl, locpointsptr, loclinesptr, plainpointsptr); int qualclass; @@ -560,9 +551,7 @@ namespace netgen oldnp = locpoints.Size(); oldnl = loclines.Size(); -#ifdef OPENGL - vssurfacemeshing.oldnl = oldnl; -#endif // OPENGL + UpdateVisSurfaceMeshData(oldnl); if (debugflag) (*testout) << "define new transformation" << endl; @@ -1506,9 +1495,7 @@ namespace netgen (*testout) << "old number of lines = " << oldnl << endl; -#ifdef OPENGL - vssurfacemeshing.oldnl = oldnl; -#endif // OPENGL + UpdateVisSurfaceMeshData(oldnl); for (int i = 1; i <= loclines.Size(); i++) { @@ -1624,440 +1611,5 @@ namespace netgen } - - - - - - - } - - - - -#ifdef OPENGL - -/* *********************** Draw Surface Meshing **************** */ - - -#include - -namespace netgen -{ - - extern STLGeometry * stlgeometry; - extern Mesh * mesh; - - - - void glrender (int wait) - { - // cout << "plot adfront" << endl; - - if (multithread.drawing) - { - // vssurfacemeshing.DrawScene(); - Render (); - - if (wait || multithread.testmode) - { - multithread.pause = 1; - } - while (multithread.pause); - } - } - - - - VisualSceneSurfaceMeshing :: VisualSceneSurfaceMeshing () - : VisualScene() - { - ; - } - - VisualSceneSurfaceMeshing :: ~VisualSceneSurfaceMeshing () - { - ; - } - - void VisualSceneSurfaceMeshing :: DrawScene () - { - // int i, j, k; - if(!locpointsptr) - return; - auto& locpoints = *locpointsptr; - auto& loclines = *loclinesptr; - auto& plainpoints = *plainpointsptr; - - if (loclines.Size() != changeval) - { - center = Point<3>(0,0,-5); - rad = 0.1; - - // CalcTransformationMatrices(); - changeval = loclines.Size(); - } - - glClearColor(backcolor, backcolor, backcolor, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - SetLight(); - - // glEnable (GL_COLOR_MATERIAL); - - // glDisable (GL_SHADING); - // glColor3f (0.0f, 1.0f, 1.0f); - // glLineWidth (1.0f); - // glShadeModel (GL_SMOOTH); - - // glCallList (linelists.Get(1)); - - // SetLight(); - - glPushMatrix(); - glMultMatrixd (transformationmat); - - glShadeModel (GL_SMOOTH); - // glDisable (GL_COLOR_MATERIAL); - glEnable (GL_COLOR_MATERIAL); - glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // glEnable (GL_LIGHTING); - - double shine = vispar.shininess; - double transp = vispar.transp; - - glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); - glLogicOp (GL_COPY); - - - - - - float mat_col[] = { 0.2, 0.2, 0.8, 1 }; - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); - - glPolygonOffset (1, 1); - glEnable (GL_POLYGON_OFFSET_FILL); - - float mat_colbl[] = { 0.8, 0.2, 0.2, 1 }; - float mat_cololdl[] = { 0.2, 0.8, 0.2, 1 }; - float mat_colnewl[] = { 0.8, 0.8, 0.2, 1 }; - - - glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - glPolygonOffset (1, -1); - glLineWidth (3); - - for (int i = 1; i <= loclines.Size(); i++) - { - if (i == 1) - { - glEnable (GL_POLYGON_OFFSET_FILL); - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbl); - } - else if (i <= oldnl) - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_cololdl); - else - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colnewl); - - int pi1 = loclines.Get(i).I1(); - int pi2 = loclines.Get(i).I2(); - - if (pi1 >= 1 && pi2 >= 1) - { - Point3d p1 = locpoints.Get(pi1); - Point3d p2 = locpoints.Get(pi2); - - glBegin (GL_LINES); - glVertex3f (p1.X(), p1.Y(), p1.Z()); - glVertex3f (p2.X(), p2.Y(), p2.Z()); - glEnd(); - } - - glDisable (GL_POLYGON_OFFSET_FILL); - } - - - glLineWidth (1); - - - glPointSize (5); - float mat_colp[] = { 1, 0, 0, 1 }; - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); - glBegin (GL_POINTS); - for (int i = 1; i <= locpoints.Size(); i++) - { - Point3d p = locpoints.Get(i); - glVertex3f (p.X(), p.Y(), p.Z()); - } - glEnd(); - - - glPopMatrix(); - - - // float mat_colp[] = { 1, 0, 0, 1 }; - - float mat_col2d1[] = { 1, 0.5, 0.5, 1 }; - float mat_col2d[] = { 1, 1, 1, 1 }; - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d); - - glBegin (GL_LINES); - for (int i = 1; i <= loclines.Size(); i++) - { - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d); - if (i == 1) - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d1); - - int pi1 = loclines.Get(i).I1(); - int pi2 = loclines.Get(i).I2(); - - if (pi1 >= 1 && pi2 >= 1) - { - const auto& p1 = plainpoints.Get(pi1); - const auto& p2 = plainpoints.Get(pi2); - - glBegin (GL_LINES); - glVertex3f (scalex * p1[0] + shiftx, scaley * p1[1] + shifty, -5); - glVertex3f (scalex * p2[0] + shiftx, scaley * p2[1] + shifty, -5); - glEnd(); - } - } - glEnd (); - - - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); - glBegin (GL_POINTS); - for (int i = 1; i <= plainpoints.Size(); i++) - { - const auto& p = plainpoints.Get(i); - glVertex3f (scalex * p[0] + shiftx, scaley * p[1] + shifty, -5); - } - glEnd(); - - - - - - - glDisable (GL_POLYGON_OFFSET_FILL); - - glPopMatrix(); - DrawCoordinateCross (); - DrawNetgenLogo (); - glFinish(); - - /* - glDisable (GL_POLYGON_OFFSET_FILL); - - // cout << "draw surfacemeshing" << endl; - // - // if (changeval != stlgeometry->GetNT()) - // BuildScene(); - // changeval = stlgeometry->GetNT(); - - - glClearColor(backcolor, backcolor, backcolor, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - SetLight(); - - glPushMatrix(); - glLoadMatrixf (transmat); - glMultMatrixf (rotmat); - - glShadeModel (GL_SMOOTH); - glDisable (GL_COLOR_MATERIAL); - glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - float mat_spec_col[] = { 1, 1, 1, 1 }; - glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, mat_spec_col); - - double shine = vispar.shininess; - double transp = vispar.transp; - - glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); - glLogicOp (GL_COPY); - - - float mat_col[] = { 0.2, 0.2, 0.8, transp }; - float mat_colrt[] = { 0.2, 0.8, 0.8, transp }; - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); - - glPolygonOffset (1, 1); - glEnable (GL_POLYGON_OFFSET_FILL); - - glColor3f (1.0f, 1.0f, 1.0f); - - glEnable (GL_NORMALIZE); - - // glBegin (GL_TRIANGLES); - // for (j = 1; j <= stlgeometry -> GetNT(); j++) - // { - // glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); - // if (j == geomtrig) - // glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colrt); - - - // const STLReadTriangle & tria = stlgeometry -> GetReadTriangle(j); - // glNormal3f (tria.normal.X(), - // tria.normal.Y(), - // tria.normal.Z()); - - // for (k = 0; k < 3; k++) - // { - // glVertex3f (tria.pts[k].X(), - // tria.pts[k].Y(), - // tria.pts[k].Z()); - // } - // } - // glEnd (); - - - - glDisable (GL_POLYGON_OFFSET_FILL); - - float mat_colbl[] = { 0.8, 0.2, 0.2, 1 }; - float mat_cololdl[] = { 0.2, 0.8, 0.2, 1 }; - float mat_colnewl[] = { 0.8, 0.8, 0.2, 1 }; - - - glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - glPolygonOffset (1, -1); - glLineWidth (3); - - for (i = 1; i <= loclines.Size(); i++) - { - if (i == 1) - { - glEnable (GL_POLYGON_OFFSET_FILL); - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbl); - } - else if (i <= oldnl) - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_cololdl); - else - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colnewl); - - int pi1 = loclines.Get(i).I1(); - int pi2 = loclines.Get(i).I2(); - - if (pi1 >= 1 && pi2 >= 1) - { - Point3d p1 = locpoints.Get(pi1); - Point3d p2 = locpoints.Get(pi2); - - glBegin (GL_LINES); - glVertex3f (p1.X(), p1.Y(), p1.Z()); - glVertex3f (p2.X(), p2.Y(), p2.Z()); - glEnd(); - } - - glDisable (GL_POLYGON_OFFSET_FILL); - } - - - glLineWidth (1); - - - glPointSize (5); - float mat_colp[] = { 1, 0, 0, 1 }; - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); - glBegin (GL_POINTS); - for (i = 1; i <= locpoints.Size(); i++) - { - Point3d p = locpoints.Get(i); - glVertex3f (p.X(), p.Y(), p.Z()); - } - glEnd(); - - - glPopMatrix(); - - - float mat_col2d1[] = { 1, 0.5, 0.5, 1 }; - float mat_col2d[] = { 1, 1, 1, 1 }; - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d); - - double scalex = 0.1, scaley = 0.1; - - glBegin (GL_LINES); - for (i = 1; i <= loclines.Size(); i++) - { - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d); - if (i == 1) - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d1); - - int pi1 = loclines.Get(i).I1(); - int pi2 = loclines.Get(i).I2(); - - if (pi1 >= 1 && pi2 >= 1) - { - Point2d p1 = plainpoints.Get(pi1); - Point2d p2 = plainpoints.Get(pi2); - - glBegin (GL_LINES); - glVertex3f (scalex * p1.X(), scaley * p1.Y(), -5); - glVertex3f (scalex * p2.X(), scaley * p2.Y(), -5); - glEnd(); - } - } - glEnd (); - - - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); - glBegin (GL_POINTS); - for (i = 1; i <= plainpoints.Size(); i++) - { - Point2d p = plainpoints.Get(i); - glVertex3f (scalex * p.X(), scaley * p.Y(), -5); - } - glEnd(); - - glFinish(); -*/ - } - - - void VisualSceneSurfaceMeshing :: BuildScene (int zoomall) - { - // int i, j, k; - /* - center = stlgeometry -> GetBoundingBox().Center(); - rad = stlgeometry -> GetBoundingBox().Diam() / 2; - - CalcTransformationMatrices(); - */ - } - -} - - -#else -namespace netgen -{ - void glrender (int wait) - { ; - /* - if (multithread.drawing) - { - // vssurfacemeshing.Render(); - // Render (); - - if (wait || multithread.testmode) - { - multithread.pause = 1; - } - while (multithread.pause); - } - */ - } -} -#endif diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 3ae05e57..1ea9d220 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -2253,8 +2253,8 @@ namespace netgen template void Element2d::GetDShapeNew> (const Point<2,SIMD> &, MatrixFixWidth<2,SIMD> &) const; - template void Element :: GetShapeNew (const Point<3,double> & p, TFlatVector shape) const; - template void Element :: GetShapeNew (const Point<3,SIMD> & p, TFlatVector> shape) const; + template DLL_HEADER void Element :: GetShapeNew (const Point<3,double> & p, TFlatVector shape) const; + template DLL_HEADER void Element :: GetShapeNew (const Point<3,SIMD> & p, TFlatVector> shape) const; template void Element::GetDShapeNew (const Point<3> &, MatrixFixWidth<3> &) const; template void Element::GetDShapeNew> (const Point<3,SIMD> &, MatrixFixWidth<3,SIMD> &) const; diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index fb1bdf43..abe2440c 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -615,13 +615,13 @@ namespace netgen class DenseMatrix & trans) const; void GetShape (const Point<2> & p, class Vector & shape) const; - void GetShapeNew (const Point<2> & p, class FlatVector & shape) const; + DLL_HEADER void GetShapeNew (const Point<2> & p, class FlatVector & shape) const; template - void GetShapeNew (const Point<2,T> & p, TFlatVector shape) const; + DLL_HEADER void GetShapeNew (const Point<2,T> & p, TFlatVector shape) const; /// matrix 2 * np - void GetDShape (const Point<2> & p, class DenseMatrix & dshape) const; + DLL_HEADER void GetDShape (const Point<2> & p, class DenseMatrix & dshape) const; template - void GetDShapeNew (const Point<2,T> & p, class MatrixFixWidth<2,T> & dshape) const; + DLL_HEADER void GetDShapeNew (const Point<2,T> & p, class MatrixFixWidth<2,T> & dshape) const; /// matrix 2 * np void GetPointMatrix (const NgArray> & points, @@ -918,7 +918,7 @@ namespace netgen void GetNodesLocalNew (NgArray > & points) const; /// split surface into 3 node trigs - void GetSurfaceTriangles (NgArray & surftrigs) const; + DLL_HEADER void GetSurfaceTriangles (NgArray & surftrigs) const; /// get number of 'integration points' @@ -933,7 +933,7 @@ namespace netgen void GetShape (const Point<3> & p, class Vector & shape) const; // void GetShapeNew (const Point<3> & p, class FlatVector & shape) const; template - void GetShapeNew (const Point<3,T> & p, TFlatVector shape) const; + DLL_HEADER void GetShapeNew (const Point<3,T> & p, TFlatVector shape) const; /// matrix 2 * np void GetDShape (const Point<3> & p, class DenseMatrix & dshape) const; template @@ -1567,7 +1567,7 @@ namespace netgen } /// - void GetPairs (int identnr, NgArray & identpairs) const; + DLL_HEADER void GetPairs (int identnr, NgArray & identpairs) const; /// int GetMaxNr () const { return maxidentnr; } diff --git a/libsrc/visualization/soldata.hpp b/libsrc/meshing/soldata.hpp similarity index 100% rename from libsrc/visualization/soldata.hpp rename to libsrc/meshing/soldata.hpp diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index 0afaa54d..c13a305e 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -80,7 +80,7 @@ public: static inline short int GetNEdges (ELEMENT_TYPE et); static inline short int GetNFaces (ELEMENT_TYPE et); - static const Point3d * GetVertices (ELEMENT_TYPE et); + DLL_HEADER static const Point3d * GetVertices (ELEMENT_TYPE et); inline static const ELEMENT_EDGE * GetEdges1 (ELEMENT_TYPE et); inline static const ELEMENT_EDGE * GetEdges0 (ELEMENT_TYPE et); inline static FlatArray GetEdges (ELEMENT_TYPE et); @@ -135,14 +135,14 @@ public: int GetSegmentEdgeOrientation (int elnr) const; // old style - void GetFaceVertices (int fnr, NgArray & vertices) const; - void GetFaceVertices (int fnr, int * vertices) const; - void GetEdgeVertices (int enr, int & v1, int & v2) const; - void GetEdgeVertices (int enr, PointIndex & v1, PointIndex & v2) const; + DLL_HEADER void GetFaceVertices (int fnr, NgArray & vertices) const; + DLL_HEADER void GetFaceVertices (int fnr, int * vertices) const; + DLL_HEADER void GetEdgeVertices (int enr, int & v1, int & v2) const; + DLL_HEADER void GetEdgeVertices (int enr, PointIndex & v1, PointIndex & v2) const; auto GetEdgeVertices (int enr) const { return tuple(edge2vert[enr][0], edge2vert[enr][1]); } auto GetEdgeVerticesPtr (int enr) const { return &edge2vert[enr][0]; } auto GetFaceVerticesPtr (int fnr) const { return &face2vert[fnr][0]; } - void GetFaceEdges (int fnr, NgArray & edges, bool withorientation = false) const; + DLL_HEADER void GetFaceEdges (int fnr, NgArray & edges, bool withorientation = false) const; ELEMENT_TYPE GetFaceType (int fnr) const // { return (face2vert.Get(fnr)[3] == 0) ? TRIG : QUAD; } diff --git a/libsrc/meshing/visual_interface.cpp b/libsrc/meshing/visual_interface.cpp new file mode 100644 index 00000000..818bc215 --- /dev/null +++ b/libsrc/meshing/visual_interface.cpp @@ -0,0 +1,22 @@ +#include "visual_interface.hpp" +#include "../include/nginterface.h" + +void (*Ptr_Ng_ClearSolutionData) () = nullptr; +void (*Ptr_Ng_InitSolutionData) (Ng_SolutionData*) = nullptr; +void (*Ptr_Ng_SetSolutionData) (Ng_SolutionData*) = nullptr; +void (*Ptr_Ng_Redraw) (bool blocking) = nullptr; + +void Ng_ClearSolutionData () { if(Ptr_Ng_ClearSolutionData) Ptr_Ng_ClearSolutionData(); } +void Ng_InitSolutionData (Ng_SolutionData * soldata) { if(Ptr_Ng_InitSolutionData) Ptr_Ng_InitSolutionData(soldata); } +void Ng_SetSolutionData (Ng_SolutionData * soldata) { if(Ptr_Ng_SetSolutionData) Ptr_Ng_SetSolutionData(soldata); } +void Ng_Redraw (bool blocking) { if(Ptr_Ng_Redraw) Ptr_Ng_Redraw(blocking); } + +namespace netgen +{ + void (*Ptr_Render)(bool) = nullptr; + void (*Ptr_UpdateVisSurfaceMeshData)(int, + shared_ptr>>, + shared_ptr>, + shared_ptr>> + ) = nullptr; +} // namespace netgen diff --git a/libsrc/meshing/visual_interface.hpp b/libsrc/meshing/visual_interface.hpp new file mode 100644 index 00000000..120c7809 --- /dev/null +++ b/libsrc/meshing/visual_interface.hpp @@ -0,0 +1,34 @@ +#ifndef VISUAL_INTERFACE_HPP_INCLUDED +#define VISUAL_INTERFACE_HPP_INCLUDED + +#include +#include + +class Ng_SolutionData; + +// Function pointers for visualization purposed, all set to nullptr by default and initialized correctly when the GUI library is loaded + +DLL_HEADER extern void (*Ptr_Ng_ClearSolutionData) (); +DLL_HEADER extern void (*Ptr_Ng_InitSolutionData) (Ng_SolutionData * soldata); +DLL_HEADER extern void (*Ptr_Ng_SetSolutionData) (Ng_SolutionData * soldata); +DLL_HEADER extern void (*Ptr_Ng_Redraw) (bool blocking); + +namespace netgen { + DLL_HEADER extern void (*Ptr_Render)(bool); + DLL_HEADER extern void (*Ptr_UpdateVisSurfaceMeshData)(int, + shared_ptr>>, + shared_ptr>, + shared_ptr>> + ); + + inline void Render(bool blocking = false) { if(Ptr_Render) Ptr_Render(blocking); } + inline void UpdateVisSurfaceMeshData(int oldnl, + shared_ptr>> locpointsptr = nullptr, + shared_ptr> loclinesptr = nullptr, + shared_ptr>> plainpointsptr = nullptr + ) { + if(Ptr_UpdateVisSurfaceMeshData) Ptr_UpdateVisSurfaceMeshData(oldnl, locpointsptr, loclinesptr, plainpointsptr); + } +} + +#endif // VISUAL_INTERFACE_HPP_INCLUDED diff --git a/libsrc/occ/CMakeLists.txt b/libsrc/occ/CMakeLists.txt index 68eaf33f..aeec0d85 100644 --- a/libsrc/occ/CMakeLists.txt +++ b/libsrc/occ/CMakeLists.txt @@ -1,38 +1,17 @@ -if(USE_OCC) - -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(occ ${NG_LIB_TYPE} +target_sources(nglib PRIVATE Partition_Inter2d.cxx Partition_Inter3d.cxx Partition_Loop.cxx Partition_Loop2d.cxx Partition_Loop3d.cxx Partition_Spliter.cxx occgenmesh.cpp occgeom.cpp occmeshsurf.cpp python_occ.cpp python_occ_basic.cpp python_occ_shapes.cpp occ_face.cpp occ_edge.cpp occ_vertex.cpp occ_utils.cpp - ) +) + if(USE_GUI) - add_library(occvis ${NG_LIB_TYPE} vsocc.cpp) - target_link_libraries(occvis PUBLIC ngcore) + target_sources(nggui PRIVATE vsocc.cpp occpkg.cpp) endif(USE_GUI) -target_link_libraries(occ PUBLIC ngcore PRIVATE "$") - -if(NOT WIN32) - target_link_libraries( occ PRIVATE ${OCC_LIBRARIES} ) - if(APPLE) - # Link AppKit in case OCE was built as static libraries - find_library(AppKit AppKit) - target_link_libraries( occ PRIVATE ${AppKit} ) - endif(APPLE) - install( TARGETS occ ${NG_INSTALL_DIR}) - if (USE_GUI) - target_link_libraries( occvis PUBLIC occ ) - install( TARGETS occvis ${NG_INSTALL_DIR}) - endif(USE_GUI) -endif(NOT WIN32) - install(FILES occgeom.hpp occmeshsurf.hpp vsocc.hpp occ_utils.hpp occ_vertex.hpp occ_edge.hpp occ_face.hpp occ_solid.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/occ COMPONENT netgen_devel ) - -endif(USE_OCC) diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index a4800c02..11fdae3e 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -12,6 +12,7 @@ #include "occ_face.hpp" #include "occ_solid.hpp" #include "occgeom.hpp" +#include "Partition_Spliter.hxx" #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/libsrc/stlgeom/CMakeLists.txt b/libsrc/stlgeom/CMakeLists.txt index 8efefbca..11b23912 100644 --- a/libsrc/stlgeom/CMakeLists.txt +++ b/libsrc/stlgeom/CMakeLists.txt @@ -1,23 +1,10 @@ -add_definitions(-DNGINTERFACE_EXPORTS) -add_library(stl ${NG_LIB_TYPE} +target_sources(nglib PRIVATE meshstlsurface.cpp stlgeom.cpp stlgeomchart.cpp stlgeommesh.cpp stlline.cpp stltool.cpp stltopology.cpp python_stl.cpp - ) - -if(NOT WIN32) - target_link_libraries( stl PUBLIC mesh ) - install( TARGETS stl ${NG_INSTALL_DIR}) -endif(NOT WIN32) - -target_link_libraries( stl PUBLIC ngcore PRIVATE "$" ) +) if(USE_GUI) - add_library(stlvis ${NG_LIB_TYPE} vsstl.cpp) - target_link_libraries(stlvis PRIVATE "$" PUBLIC ngcore) - if(NOT WIN32) - target_link_libraries( stlvis PUBLIC stl ) - install( TARGETS stlvis ${NG_INSTALL_DIR}) - endif(NOT WIN32) + target_sources(nggui PRIVATE vsstl.cpp stlpkg.cpp) endif(USE_GUI) install(FILES diff --git a/libsrc/stlgeom/stlgeom.hpp b/libsrc/stlgeom/stlgeom.hpp index c6c3e676..8cc5739e 100644 --- a/libsrc/stlgeom/stlgeom.hpp +++ b/libsrc/stlgeom/stlgeom.hpp @@ -101,7 +101,7 @@ namespace netgen - class STLGeometry : public NetgenGeometry, public STLTopology + class DLL_HEADER STLGeometry : public NetgenGeometry, public STLTopology { // edges to be meshed: NgArray edges; @@ -210,19 +210,19 @@ namespace netgen - DLL_HEADER void STLInfo(double* data); + void STLInfo(double* data); //stldoctor: - DLL_HEADER void SmoothNormals(const STLParameters& stlparam); - DLL_HEADER void MarkNonSmoothNormals(const STLParameters& stlparam); + void SmoothNormals(const STLParameters& stlparam); + void MarkNonSmoothNormals(const STLParameters& stlparam); - DLL_HEADER void CalcEdgeData(); - DLL_HEADER void CalcEdgeDataAngles(); + void CalcEdgeData(); + void CalcEdgeDataAngles(); const STLEdgeDataList& EdgeDataList() const {return *edgedata;} - DLL_HEADER void UndoEdgeChange(); - DLL_HEADER void StoreEdgeData(); - DLL_HEADER void RestoreEdgeData(); + void UndoEdgeChange(); + void StoreEdgeData(); + void RestoreEdgeData(); //void ClearSelectedMultiEdge() {selectedmultiedge.SetSize(0);} //void AddSelectedMultiEdge(twoint ep) {selectedmultiedge.Append(ep);} @@ -233,63 +233,63 @@ namespace netgen void BuildSelectedEdge(twoint ep); void BuildSelectedCluster(twoint ep); - DLL_HEADER void ImportEdges(); - DLL_HEADER void AddEdges(const NgArray >& eps); - DLL_HEADER void ExportEdges(); - DLL_HEADER void LoadEdgeData(const filesystem::path & file); - DLL_HEADER void SaveEdgeData(const filesystem::path & file); + void ImportEdges(); + void AddEdges(const NgArray >& eps); + void ExportEdges(); + void LoadEdgeData(const filesystem::path & file); + void SaveEdgeData(const filesystem::path & file); // void SetEdgeAtSelected(int mode); - DLL_HEADER void STLDoctorConfirmEdge(); - DLL_HEADER void STLDoctorCandidateEdge(); - DLL_HEADER void STLDoctorExcludeEdge(); - DLL_HEADER void STLDoctorUndefinedEdge(); + void STLDoctorConfirmEdge(); + void STLDoctorCandidateEdge(); + void STLDoctorExcludeEdge(); + void STLDoctorUndefinedEdge(); - DLL_HEADER void STLDoctorSetAllUndefinedEdges(); - DLL_HEADER void STLDoctorEraseCandidateEdges(); - DLL_HEADER void STLDoctorConfirmCandidateEdges(); - DLL_HEADER void STLDoctorConfirmedToCandidateEdges(); + void STLDoctorSetAllUndefinedEdges(); + void STLDoctorEraseCandidateEdges(); + void STLDoctorConfirmCandidateEdges(); + void STLDoctorConfirmedToCandidateEdges(); - DLL_HEADER void STLDoctorDirtyEdgesToCandidates(); - DLL_HEADER void STLDoctorLongLinesToCandidates(); + void STLDoctorDirtyEdgesToCandidates(); + void STLDoctorLongLinesToCandidates(); - DLL_HEADER void UndoExternalEdges(); - DLL_HEADER void StoreExternalEdges(); - DLL_HEADER void RestoreExternalEdges(); + void UndoExternalEdges(); + void StoreExternalEdges(); + void RestoreExternalEdges(); - DLL_HEADER void ImportExternalEdges(const char * filename); // Flame edges, JS + void ImportExternalEdges(const char * filename); // Flame edges, JS // void LoadExternalEdges(); - DLL_HEADER void BuildExternalEdgesFromEdges(); - DLL_HEADER void SaveExternalEdges(); - DLL_HEADER void AddExternalEdgeAtSelected(); - DLL_HEADER void AddClosedLinesToExternalEdges(); - DLL_HEADER void AddLongLinesToExternalEdges(); - DLL_HEADER void AddAllNotSingleLinesToExternalEdges(); - DLL_HEADER void STLDoctorBuildEdges(const STLParameters& stlparam); - DLL_HEADER void AddExternalEdgesFromGeomLine(); - DLL_HEADER void DeleteDirtyExternalEdges(); - DLL_HEADER void DeleteExternalEdgeAtSelected(); - DLL_HEADER void DeleteExternalEdgeInVicinity(); + void BuildExternalEdgesFromEdges(); + void SaveExternalEdges(); + void AddExternalEdgeAtSelected(); + void AddClosedLinesToExternalEdges(); + void AddLongLinesToExternalEdges(); + void AddAllNotSingleLinesToExternalEdges(); + void STLDoctorBuildEdges(const STLParameters& stlparam); + void AddExternalEdgesFromGeomLine(); + void DeleteDirtyExternalEdges(); + void DeleteExternalEdgeAtSelected(); + void DeleteExternalEdgeInVicinity(); void AddExternalEdge(int p1, int p2); void DeleteExternalEdge(int p1, int p2); int IsExternalEdge(int p1, int p2); int NOExternalEdges() const {return externaledges.Size();} twoint GetExternalEdge(int i) const {return externaledges.Get(i);} - DLL_HEADER void DestroyDirtyTrigs(); - DLL_HEADER void CalcNormalsFromGeometry(); - DLL_HEADER void MoveSelectedPointToMiddle(); - DLL_HEADER void NeighbourAnglesOfSelectedTrig(); - DLL_HEADER void PrintSelectInfo(); - DLL_HEADER void ShowSelectedTrigChartnum(); - DLL_HEADER void ShowSelectedTrigCoords(); - DLL_HEADER void SmoothGeometry (); + void DestroyDirtyTrigs(); + void CalcNormalsFromGeometry(); + void MoveSelectedPointToMiddle(); + void NeighbourAnglesOfSelectedTrig(); + void PrintSelectInfo(); + void ShowSelectedTrigChartnum(); + void ShowSelectedTrigCoords(); + void SmoothGeometry (); - DLL_HEADER void LoadMarkedTrigs(); - DLL_HEADER void SaveMarkedTrigs(); + void LoadMarkedTrigs(); + void SaveMarkedTrigs(); void ClearMarkedSegs() {markedsegs.SetSize(0);} void AddMarkedSeg(const Point<3> & ap1, const Point<3> & ap2) { @@ -302,26 +302,26 @@ namespace netgen ap2=markedsegs.Get(i*2); } int GetNMarkedSegs() {return markedsegs.Size()/2;} - DLL_HEADER void CalcVicinity(int starttrig); - DLL_HEADER void GetVicinity(int starttrig, int size, NgArray& vic); + void CalcVicinity(int starttrig); + void GetVicinity(int starttrig, int size, NgArray& vic); - DLL_HEADER int Vicinity(int trig) const; + int Vicinity(int trig) const; - DLL_HEADER void InitMarkedTrigs(); - DLL_HEADER void MarkDirtyTrigs(const STLParameters& stlparam); - DLL_HEADER void SmoothDirtyTrigs(const STLParameters& stlparam); - DLL_HEADER void GeomSmoothRevertedTrigs(const STLParameters& stlparam); - DLL_HEADER void MarkRevertedTrigs(const STLParameters& stlparam); - DLL_HEADER double CalcTrigBadness(int i); - DLL_HEADER int IsMarkedTrig(int trig) const; - DLL_HEADER void SetMarkedTrig(int trig, int num); - DLL_HEADER void MarkTopErrorTrigs (); + void InitMarkedTrigs(); + void MarkDirtyTrigs(const STLParameters& stlparam); + void SmoothDirtyTrigs(const STLParameters& stlparam); + void GeomSmoothRevertedTrigs(const STLParameters& stlparam); + void MarkRevertedTrigs(const STLParameters& stlparam); + double CalcTrigBadness(int i); + int IsMarkedTrig(int trig) const; + void SetMarkedTrig(int trig, int num); + void MarkTopErrorTrigs (); //Selected triangle - DLL_HEADER void SetSelectTrig(int trig); - DLL_HEADER int GetSelectTrig() const; - DLL_HEADER void SetNodeOfSelTrig(int n); - DLL_HEADER int GetNodeOfSelTrig() const; + void SetSelectTrig(int trig); + int GetSelectTrig() const; + void SetNodeOfSelTrig(int n); + int GetNodeOfSelTrig() const; int AddNormal(const Vec3d& n) { normals.Append(n); return normals.Size(); } @@ -409,14 +409,14 @@ namespace netgen int TrigIsInOC(int tn, int ocn) const; //get chart number of a trig or 0 if unmarked - DLL_HEADER ChartId GetChartNr(STLTrigId i) const; + ChartId GetChartNr(STLTrigId i) const; ChartId GetMarker(STLTrigId i) const { return chartmark[i]; } void SetMarker(STLTrigId nr, ChartId m); size_t GetNOCharts() const { return atlas.Size(); } //get a chart from atlas const STLChart& GetChart(ChartId nr) const { return *atlas[nr];}; STLChart & GetChart(ChartId nr) { return *atlas[nr];}; - DLL_HEADER int AtlasMade() const; + int AtlasMade() const; void GetInnerChartLimes(NgArray& limes, ChartId chartnum); @@ -465,7 +465,7 @@ namespace netgen int LineEndPointsSet() const {return lineendpoints.Size() == GetNP();} void ClearLineEndPoints(); - DLL_HEADER void RestrictLocalH(class Mesh & mesh, double gh, const STLParameters& stlparam, const MeshingParameters& mparam); + void RestrictLocalH(class Mesh & mesh, double gh, const STLParameters& stlparam, const MeshingParameters& mparam); void RestrictLocalHCurv(class Mesh & mesh, double gh, const STLParameters& stlparam); void RestrictHChartDistOneChart(ChartId chartnum, NgArray& acttrigs, class Mesh & mesh, double gh, double fact, double minh, const STLParameters& stlparam); @@ -475,7 +475,7 @@ namespace netgen int GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) override; // Add additional Point to chart to close the surface and write the resulting stl to a file - DLL_HEADER void WriteChartToFile( ChartId chartnumber, filesystem::path filename="chart.slb" ); + void WriteChartToFile( ChartId chartnumber, filesystem::path filename="chart.slb" ); }; diff --git a/libsrc/stlgeom/stltopology.hpp b/libsrc/stlgeom/stltopology.hpp index 5b9ba058..101cde53 100644 --- a/libsrc/stlgeom/stltopology.hpp +++ b/libsrc/stlgeom/stltopology.hpp @@ -364,7 +364,7 @@ public: int GetNTE() const { return topedges.Size(); } const STLTopEdge & GetTopEdge (int nr) const { return topedges.Get(nr); } STLTopEdge & GetTopEdge (int nr) { return topedges.Elem(nr); } - int GetTopEdgeNum (int pi1, int pi2) const; + DLL_HEADER int GetTopEdgeNum (int pi1, int pi2) const; int NOTrigsPerPoint(int pn) { return trigsperpoint.EntrySize(pn); } diff --git a/libsrc/stlgeom/vsstl.cpp b/libsrc/stlgeom/vsstl.cpp index 63202fdb..854909d8 100644 --- a/libsrc/stlgeom/vsstl.cpp +++ b/libsrc/stlgeom/vsstl.cpp @@ -22,7 +22,7 @@ namespace netgen /* *********************** Draw STL Geometry **************** */ extern STLGeometry * stlgeometry; -extern shared_ptr mesh; +DLL_HEADER extern shared_ptr mesh; // #include "../../ngtcltk/mvdraw.hpp" diff --git a/libsrc/stlgeom/vsstl.hpp b/libsrc/stlgeom/vsstl.hpp index f36dcac2..6d4a6490 100644 --- a/libsrc/stlgeom/vsstl.hpp +++ b/libsrc/stlgeom/vsstl.hpp @@ -10,7 +10,7 @@ namespace netgen { - class DLL_HEADER VisualSceneSTLGeometry : public VisualScene + class NGGUI_API VisualSceneSTLGeometry : public VisualScene { NgArray trilists; class STLGeometry * stlgeometry; @@ -25,7 +25,7 @@ namespace netgen }; - class DLL_HEADER VisualSceneSTLMeshing : public VisualScene + class NGGUI_API VisualSceneSTLMeshing : public VisualScene { NgArray trilists; int selecttrig, nodeofseltrig; diff --git a/libsrc/visualization/CMakeLists.txt b/libsrc/visualization/CMakeLists.txt index b534501d..9ddd9dbd 100644 --- a/libsrc/visualization/CMakeLists.txt +++ b/libsrc/visualization/CMakeLists.txt @@ -1,19 +1,16 @@ -add_definitions(-DNGINTERFACE_EXPORTS) -install(FILES soldata.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel ) - -if(USE_GUI) - set( LIB_VISUAL_SOURCES meshdoc.cpp mvdraw.cpp vsfieldlines.cpp fieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp ) -else(USE_GUI) - set( LIB_VISUAL_SOURCES visual_dummy.cpp fieldlines.cpp) -endif(USE_GUI) - -add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES}) - -target_link_libraries( visual PUBLIC ngcore PRIVATE "$" ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ) -install( TARGETS visual ${NG_INSTALL_DIR}) +target_sources(nggui PRIVATE + importsolution.cpp + meshdoc.cpp + mvdraw.cpp + vsfieldlines.cpp + vsmesh.cpp + vssolution.cpp + visualpkg.cpp +) +target_link_libraries( nggui PUBLIC "$" ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ) install(FILES - meshdoc.hpp mvdraw.hpp - vispar.hpp visual.hpp vssolution.hpp fieldlines.hpp + meshdoc.hpp mvdraw.hpp visual_api.hpp + vispar.hpp visual.hpp vssolution.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/visualization COMPONENT netgen_devel ) diff --git a/libsrc/visualization/importsolution.cpp b/libsrc/visualization/importsolution.cpp index 9ccb9253..dade1529 100644 --- a/libsrc/visualization/importsolution.cpp +++ b/libsrc/visualization/importsolution.cpp @@ -2,6 +2,7 @@ // Read solution file // +#include "visual_api.hpp" #include @@ -16,9 +17,9 @@ namespace netgen { - extern shared_ptr mesh; + DLL_HEADER extern shared_ptr mesh; -DLL_HEADER void ImportSolution2 (const char * filename) +NGGUI_API void ImportSolution2 (const char * filename) { ifstream inf (filename); char buf[100], name[1000]; diff --git a/libsrc/visualization/meshdoc.hpp b/libsrc/visualization/meshdoc.hpp index 6cdb1d8c..7fce2772 100644 --- a/libsrc/visualization/meshdoc.hpp +++ b/libsrc/visualization/meshdoc.hpp @@ -17,17 +17,17 @@ class VisualSceneMeshDoctor : public VisualScene public: - DLL_HEADER VisualSceneMeshDoctor (); - DLL_HEADER virtual ~VisualSceneMeshDoctor (); + NGGUI_API VisualSceneMeshDoctor (); + NGGUI_API virtual ~VisualSceneMeshDoctor (); - DLL_HEADER virtual void BuildScene (int zoomall = 0); - DLL_HEADER virtual void DrawScene (); - DLL_HEADER virtual void MouseDblClick (int px, int py); + NGGUI_API virtual void BuildScene (int zoomall = 0); + NGGUI_API virtual void DrawScene (); + NGGUI_API virtual void MouseDblClick (int px, int py); - DLL_HEADER void SetMarkEdgeDist (int dist); - DLL_HEADER void ClickElement (int elnr); - DLL_HEADER void UpdateTables (); - DLL_HEADER int IsSegmentMarked (int segnr) const; + NGGUI_API void SetMarkEdgeDist (int dist); + NGGUI_API void ClickElement (int elnr); + NGGUI_API void UpdateTables (); + NGGUI_API int IsSegmentMarked (int segnr) const; }; class MeshDoctorParameters @@ -37,6 +37,6 @@ public: }; -DLL_HEADER extern MeshDoctorParameters meshdoctor; +NGGUI_API extern MeshDoctorParameters meshdoctor; } diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 69643ddb..8da32396 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -22,11 +22,11 @@ namespace netgen { - DLL_HEADER Point3d VisualScene :: center; - DLL_HEADER double VisualScene :: rad; - DLL_HEADER GLdouble VisualScene :: backcolor; - DLL_HEADER VisualScene visual_scene_cross; - DLL_HEADER VisualScene *visual_scene = &visual_scene_cross; + NGGUI_API Point3d VisualScene :: center; + NGGUI_API double VisualScene :: rad; + NGGUI_API GLdouble VisualScene :: backcolor; + NGGUI_API VisualScene visual_scene_cross; + NGGUI_API VisualScene *visual_scene = &visual_scene_cross; /* #if TOGL_MAJOR_VERSION!=2 @@ -115,18 +115,6 @@ namespace netgen } - extern DLL_HEADER void Render(bool blocking); - DLL_HEADER void Render (bool blocking) - { - if (blocking && multithread.running) - { - multithread.redraw = 2; - while (multithread.redraw == 2) ; - } - else - multithread.redraw = 1; - } - void VisualScene :: BuildScene (int zoomall) { @@ -861,6 +849,226 @@ namespace netgen return buffer; } + VisualSceneSurfaceMeshing :: VisualSceneSurfaceMeshing () + : VisualScene() + { + ; + } + + VisualSceneSurfaceMeshing :: ~VisualSceneSurfaceMeshing () + { + ; + } + + void VisualSceneSurfaceMeshing :: DrawScene () + { + // int i, j, k; + if(!locpointsptr) + return; + auto& locpoints = *locpointsptr; + auto& loclines = *loclinesptr; + auto& plainpoints = *plainpointsptr; + + if (loclines.Size() != changeval) + { + center = Point<3>(0,0,-5); + rad = 0.1; + + // CalcTransformationMatrices(); + changeval = loclines.Size(); + } + + glClearColor(backcolor, backcolor, backcolor, 1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + SetLight(); + + // glEnable (GL_COLOR_MATERIAL); + + // glDisable (GL_SHADING); + // glColor3f (0.0f, 1.0f, 1.0f); + // glLineWidth (1.0f); + // glShadeModel (GL_SMOOTH); + + // glCallList (linelists.Get(1)); + + // SetLight(); + + glPushMatrix(); + glMultMatrixd (transformationmat); + + glShadeModel (GL_SMOOTH); + // glDisable (GL_COLOR_MATERIAL); + glEnable (GL_COLOR_MATERIAL); + glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); + + glEnable (GL_BLEND); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // glEnable (GL_LIGHTING); + + double shine = vispar.shininess; + double transp = vispar.transp; + + glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); + glLogicOp (GL_COPY); + + + + + + float mat_col[] = { 0.2, 0.2, 0.8, 1 }; + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); + + glPolygonOffset (1, 1); + glEnable (GL_POLYGON_OFFSET_FILL); + + float mat_colbl[] = { 0.8, 0.2, 0.2, 1 }; + float mat_cololdl[] = { 0.2, 0.8, 0.2, 1 }; + float mat_colnewl[] = { 0.8, 0.8, 0.2, 1 }; + + + glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); + glPolygonOffset (1, -1); + glLineWidth (3); + + for (int i = 1; i <= loclines.Size(); i++) + { + if (i == 1) + { + glEnable (GL_POLYGON_OFFSET_FILL); + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbl); + } + else if (i <= oldnl) + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_cololdl); + else + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colnewl); + + int pi1 = loclines.Get(i).I1(); + int pi2 = loclines.Get(i).I2(); + + if (pi1 >= 1 && pi2 >= 1) + { + Point3d p1 = locpoints.Get(pi1); + Point3d p2 = locpoints.Get(pi2); + + glBegin (GL_LINES); + glVertex3f (p1.X(), p1.Y(), p1.Z()); + glVertex3f (p2.X(), p2.Y(), p2.Z()); + glEnd(); + } + + glDisable (GL_POLYGON_OFFSET_FILL); + } + + + glLineWidth (1); + + + glPointSize (5); + float mat_colp[] = { 1, 0, 0, 1 }; + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); + glBegin (GL_POINTS); + for (int i = 1; i <= locpoints.Size(); i++) + { + Point3d p = locpoints.Get(i); + glVertex3f (p.X(), p.Y(), p.Z()); + } + glEnd(); + + + glPopMatrix(); + + + // float mat_colp[] = { 1, 0, 0, 1 }; + + float mat_col2d1[] = { 1, 0.5, 0.5, 1 }; + float mat_col2d[] = { 1, 1, 1, 1 }; + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d); + + glBegin (GL_LINES); + for (int i = 1; i <= loclines.Size(); i++) + { + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d); + if (i == 1) + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d1); + + int pi1 = loclines.Get(i).I1(); + int pi2 = loclines.Get(i).I2(); + + if (pi1 >= 1 && pi2 >= 1) + { + const auto& p1 = plainpoints.Get(pi1); + const auto& p2 = plainpoints.Get(pi2); + + glBegin (GL_LINES); + glVertex3f (scalex * p1[0] + shiftx, scaley * p1[1] + shifty, -5); + glVertex3f (scalex * p2[0] + shiftx, scaley * p2[1] + shifty, -5); + glEnd(); + } + } + glEnd (); + + + glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); + glBegin (GL_POINTS); + for (int i = 1; i <= plainpoints.Size(); i++) + { + const auto& p = plainpoints.Get(i); + glVertex3f (scalex * p[0] + shiftx, scaley * p[1] + shifty, -5); + } + glEnd(); + + + + + + + glDisable (GL_POLYGON_OFFSET_FILL); + + glPopMatrix(); + DrawCoordinateCross (); + DrawNetgenLogo (); + glFinish(); + + } + + + void VisualSceneSurfaceMeshing :: BuildScene (int zoomall) + { + } + + VisualSceneSurfaceMeshing vssurfacemeshing; + + void Impl_Render (bool blocking) + { + if (blocking && multithread.running) + { + multithread.redraw = 2; + while (multithread.redraw == 2) ; + } + else + multithread.redraw = 1; + } + + void Impl_UpdateVisSurfaceMeshData(int oldnl, + shared_ptr>> locpointsptr, + shared_ptr> loclinesptr, + shared_ptr>> plainpointsptr) + { + vssurfacemeshing.oldnl = oldnl; + if(locpointsptr) vssurfacemeshing.locpointsptr = locpointsptr; + if(loclinesptr) vssurfacemeshing.loclinesptr = loclinesptr; + if(plainpointsptr) vssurfacemeshing.plainpointsptr = plainpointsptr; + } + + static bool set_function_pointers = []() + { + Ptr_Render = Impl_Render; + Ptr_UpdateVisSurfaceMeshData = Impl_UpdateVisSurfaceMeshData; + return true; + }(); + + #ifdef PARALLELGL void VisualScene :: InitParallelGL () diff --git a/libsrc/visualization/mvdraw.hpp b/libsrc/visualization/mvdraw.hpp index e76444bb..d3581724 100644 --- a/libsrc/visualization/mvdraw.hpp +++ b/libsrc/visualization/mvdraw.hpp @@ -9,27 +9,27 @@ namespace netgen class VisualScene { protected: - static DLL_HEADER Point3d center; - static DLL_HEADER double rad; + static NGGUI_API Point3d center; + static NGGUI_API double rad; static double lookatmat[16]; static double transmat[16]; static double rotmat[16]; static double centermat[16]; - static DLL_HEADER double transformationmat[16]; + static NGGUI_API double transformationmat[16]; GLdouble clipplane[4]; int changeval; - static DLL_HEADER GLdouble backcolor; + static NGGUI_API GLdouble backcolor; - static int DLL_HEADER selface; + static int NGGUI_API selface; static int selelement; - static PointIndex DLL_HEADER selpoint; + static PointIndex NGGUI_API selpoint; static PointIndex selpoint2; static int locpi; - static int DLL_HEADER seledge; + static int NGGUI_API seledge; static int selecttimestamp; static optional> marker; @@ -42,51 +42,51 @@ namespace netgen public: - DLL_HEADER VisualScene (); - DLL_HEADER virtual ~VisualScene(); + NGGUI_API VisualScene (); + NGGUI_API virtual ~VisualScene(); - DLL_HEADER virtual void BuildScene (int zoomall = 0); - DLL_HEADER virtual void DrawScene (); + NGGUI_API virtual void BuildScene (int zoomall = 0); + NGGUI_API virtual void DrawScene (); - DLL_HEADER void CalcTransformationMatrices(); - DLL_HEADER void StandardRotation (const char * dir); - DLL_HEADER void ArbitraryRotation (const NgArray & alpha, const NgArray & vec); - DLL_HEADER void ArbitraryRotation (const double alpha, const Vec3d & vec); + NGGUI_API void CalcTransformationMatrices(); + NGGUI_API void StandardRotation (const char * dir); + NGGUI_API void ArbitraryRotation (const NgArray & alpha, const NgArray & vec); + NGGUI_API void ArbitraryRotation (const double alpha, const Vec3d & vec); - DLL_HEADER virtual void MouseMove(int oldx, int oldy, + NGGUI_API virtual void MouseMove(int oldx, int oldy, int newx, int newy, char mode); - DLL_HEADER void LookAt (const Point<3> & cam, const Point<3> & obj, + NGGUI_API void LookAt (const Point<3> & cam, const Point<3> & obj, const Point<3> & camup); - DLL_HEADER void SetClippingPlane (); + NGGUI_API void SetClippingPlane (); - DLL_HEADER virtual void MouseDblClick (int px, int py); + NGGUI_API virtual void MouseDblClick (int px, int py); - DLL_HEADER void SetLight (); + NGGUI_API void SetLight (); static void SetBackGroundColor (double col) { backcolor = col; } - DLL_HEADER void CreateTexture (int ncols, int linear, double alpha, int typ); - DLL_HEADER void DrawColorBar (double minval, double maxval, int logscale = 0, bool linear = 1); - DLL_HEADER void DrawCoordinateCross (); - DLL_HEADER void DrawMarker(); - DLL_HEADER void DrawNetgenLogo (); - DLL_HEADER void SetOpenGlColor(double val, double valmin, double valmax, int logscale = 0); + NGGUI_API void CreateTexture (int ncols, int linear, double alpha, int typ); + NGGUI_API void DrawColorBar (double minval, double maxval, int logscale = 0, bool linear = 1); + NGGUI_API void DrawCoordinateCross (); + NGGUI_API void DrawMarker(); + NGGUI_API void DrawNetgenLogo (); + NGGUI_API void SetOpenGlColor(double val, double valmin, double valmax, int logscale = 0); #ifdef PARALLELGL - DLL_HEADER void InitParallelGL (); - DLL_HEADER void Broadcast (); + NGGUI_API void InitParallelGL (); + NGGUI_API void Broadcast (); #endif }; - DLL_HEADER extern void MyOpenGLText (const char * text); - DLL_HEADER extern void Set_OpenGLText_Callback ( void (*fun) (const char * text) ); - DLL_HEADER extern VisualScene visual_scene_cross; - DLL_HEADER extern VisualScene *visual_scene; + NGGUI_API extern void MyOpenGLText (const char * text); + NGGUI_API extern void Set_OpenGLText_Callback ( void (*fun) (const char * text) ); + NGGUI_API extern VisualScene visual_scene_cross; + NGGUI_API extern VisualScene *visual_scene; @@ -111,10 +111,11 @@ namespace netgen void BuildScene (int zoomall = 0) override; void DrawScene () override; - void MouseMove(int oldx, int oldy, int newx, int newy, + NGGUI_API void MouseMove(int oldx, int oldy, int newx, int newy, char mode) override; }; + NGGUI_API extern VisualSceneSurfaceMeshing vssurfacemeshing; @@ -171,12 +172,12 @@ namespace netgen // weak_ptr wp_mesh; public: - DLL_HEADER VisualSceneMesh (); - DLL_HEADER virtual ~VisualSceneMesh (); + NGGUI_API VisualSceneMesh (); + NGGUI_API virtual ~VisualSceneMesh (); - DLL_HEADER virtual void BuildScene (int zoomall = 0); - DLL_HEADER virtual void DrawScene (); - DLL_HEADER virtual void MouseDblClick (int px, int py); + NGGUI_API virtual void BuildScene (int zoomall = 0); + NGGUI_API virtual void DrawScene (); + NGGUI_API virtual void MouseDblClick (int px, int py); // void SetMesh (shared_ptr mesh) { wp_mesh = mesh; } // shared_ptr GetMesh () { return shared_ptr(wp_mesh); } @@ -186,16 +187,16 @@ namespace netgen { user_me_handler = handler; } - DLL_HEADER int SelectedFace () const + NGGUI_API int SelectedFace () const { return selface; } - DLL_HEADER void SetSelectedFace (int asf); + NGGUI_API void SetSelectedFace (int asf); // { selface = asf; selecttimestamp = GetTimeStamp(); } - DLL_HEADER int SelectedEdge () const + NGGUI_API int SelectedEdge () const { return seledge; } - DLL_HEADER int SelectedElement () const + NGGUI_API int SelectedElement () const { return selelement; } - DLL_HEADER int SelectedPoint () const + NGGUI_API int SelectedPoint () const { return selpoint; } void BuildFilledList (bool names); // private: @@ -215,10 +216,10 @@ namespace netgen bool Unproject (int px, int py, Point<3> &p); }; - DLL_HEADER extern VisualSceneMesh vsmesh; + NGGUI_API extern VisualSceneMesh vsmesh; - class DLL_HEADER VisualSceneSpecPoints : public VisualScene + class NGGUI_API VisualSceneSpecPoints : public VisualScene { public: VisualSceneSpecPoints (); @@ -253,7 +254,7 @@ namespace netgen PointIndex & selpoint2, int & locpi); - DLL_HEADER std::vector Snapshot( int w, int h ); + NGGUI_API std::vector Snapshot( int w, int h ); } diff --git a/libsrc/visualization/vispar.hpp b/libsrc/visualization/vispar.hpp index 94026440..93d4425d 100644 --- a/libsrc/visualization/vispar.hpp +++ b/libsrc/visualization/vispar.hpp @@ -120,7 +120,7 @@ public: public: VisualizationParameters(); }; -DLL_HEADER extern VisualizationParameters vispar; +NGGUI_API extern VisualizationParameters vispar; } #endif diff --git a/libsrc/visualization/visual.hpp b/libsrc/visualization/visual.hpp index 493cb739..94dcf87d 100644 --- a/libsrc/visualization/visual.hpp +++ b/libsrc/visualization/visual.hpp @@ -17,10 +17,12 @@ Visualization // #define PARALLELGL // #endif +#include "visual_api.hpp" #include "../include/incopengl.hpp" +#include "../meshing/visual_interface.hpp" +#include "../meshing/soldata.hpp" #include "vispar.hpp" -#include "soldata.hpp" #include "mvdraw.hpp" #include diff --git a/libsrc/visualization/visual_api.hpp b/libsrc/visualization/visual_api.hpp new file mode 100644 index 00000000..8873f8da --- /dev/null +++ b/libsrc/visualization/visual_api.hpp @@ -0,0 +1,10 @@ +#ifndef VISUAL_API_HPP_INCLUDED +#define VISUAL_API_HPP_INCLUDED + +#ifdef nggui_EXPORTS +#define NGGUI_API NGCORE_API_EXPORT +#else +#define NGGUI_API NGCORE_API_IMPORT +#endif + +#endif // VISUAL_API_HPP_INCLUDED diff --git a/libsrc/visualization/visual_dummy.cpp b/libsrc/visualization/visual_dummy.cpp deleted file mode 100644 index 8d82f8d6..00000000 --- a/libsrc/visualization/visual_dummy.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#include -#include "../include/nginterface.h" - -void Ng_ClearSolutionData () { ; } -void Ng_InitSolutionData (Ng_SolutionData * soldata) { ; } -void Ng_SetSolutionData (Ng_SolutionData * soldata) { ; } -void Ng_Redraw (bool blocking) { ; } - - - - - - diff --git a/libsrc/visualization/visualpkg.cpp b/libsrc/visualization/visualpkg.cpp index c5c35ab7..42670769 100644 --- a/libsrc/visualization/visualpkg.cpp +++ b/libsrc/visualization/visualpkg.cpp @@ -377,7 +377,7 @@ namespace netgen } VisualSceneMeshDoctor vsmeshdoc; - DLL_HEADER extern shared_ptr mesh; + DLL_HEADER shared_ptr mesh; int Ng_MeshDoctor(ClientData clientData, Tcl_Interp * interp, diff --git a/libsrc/visualization/vsfieldlines.cpp b/libsrc/visualization/vsfieldlines.cpp index ebccc223..19c86167 100644 --- a/libsrc/visualization/vsfieldlines.cpp +++ b/libsrc/visualization/vsfieldlines.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace netgen diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index 6b0783c3..40b5ca3a 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -3540,7 +3540,7 @@ namespace netgen #include <../general/ngpython.hpp> #include "../include/nginterface.h" -DLL_HEADER void ExportMeshVis(py::module &m) +NGGUI_API void ExportMeshVis(py::module &m) { using namespace netgen; vispar.drawcolorbar = true; diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index 46efcaa2..2a7a192c 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -9,11 +9,12 @@ // #include #include #include + namespace netgen { - DLL_HEADER VisualSceneSolution & GetVSSolution() + VisualSceneSolution & GetVSSolution() { static VisualSceneSolution vssolution; return vssolution; @@ -23,19 +24,6 @@ namespace netgen // extern shared_ptr mesh; extern VisualSceneMesh vsmesh; - - DLL_HEADER void AddUserVisualizationObject (UserVisualizationObject * vis) - { - // vssolution.AddUserVisualizationObject (vis); - GetVSSolution().AddUserVisualizationObject (vis); - } - DLL_HEADER void DeleteUserVisualizationObject (UserVisualizationObject * vis) - { - // vssolution.AddUserVisualizationObject (vis); - GetVSSolution().DeleteUserVisualizationObject (vis); - } - - VisualSceneSolution :: SolData :: SolData () : data (0), solclass(0) { ; } @@ -4984,7 +4972,7 @@ namespace netgen #include "../include/nginterface.h" -void Ng_ClearSolutionData () +void Impl_Ng_ClearSolutionData () { #ifdef OPENGL // if (nodisplay) return; @@ -4993,7 +4981,7 @@ void Ng_ClearSolutionData () #endif } -void Ng_InitSolutionData (Ng_SolutionData * soldata) +void Impl_Ng_InitSolutionData (Ng_SolutionData * soldata) { // soldata -> name = NULL; soldata -> data = NULL; @@ -5007,7 +4995,7 @@ void Ng_InitSolutionData (Ng_SolutionData * soldata) soldata -> solclass = 0; } -void Ng_SetSolutionData (Ng_SolutionData * soldata) +void Impl_Ng_SetSolutionData (Ng_SolutionData * soldata) { #ifdef OPENGL // if (nodisplay) return; @@ -5033,12 +5021,7 @@ void Ng_SetSolutionData (Ng_SolutionData * soldata) -namespace netgen -{ - extern void Render (bool blocking); -} - -void Ng_Redraw (bool blocking) +void Impl_Ng_Redraw (bool blocking) { #ifdef OPENGL //netgen::vssolution.UpdateSolutionTimeStamp(); @@ -5065,7 +5048,7 @@ void (*glGenRenderbuffers) (GLsizei n, GLuint *renderbuffers); void (*glRenderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); void (*glFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -DLL_HEADER void LoadOpenGLFunctionPointers() { +NGGUI_API void LoadOpenGLFunctionPointers() { #ifdef USE_BUFFERS glBindBuffer = (decltype(glBindBuffer)) wglGetProcAddress("glBindBuffer"); glBufferSubData = (decltype(glBufferSubData)) wglGetProcAddress("glBufferSubData"); @@ -5086,6 +5069,15 @@ DLL_HEADER void LoadOpenGLFunctionPointers() { glFramebufferRenderbuffer = (decltype(glFramebufferRenderbuffer )) wglGetProcAddress("glFramebufferRenderbuffer"); } #else // WIN32 -DLL_HEADER void LoadOpenGLFunctionPointers() { } +NGGUI_API void LoadOpenGLFunctionPointers() { } #endif // WIN32 #endif // OPENGL + +// set function pointers +static bool dummy_init = [](){ + Ptr_Ng_ClearSolutionData = Impl_Ng_ClearSolutionData; + Ptr_Ng_InitSolutionData = Impl_Ng_InitSolutionData; + Ptr_Ng_SetSolutionData = Impl_Ng_SetSolutionData; + Ptr_Ng_Redraw = Impl_Ng_Redraw; + return true; +}(); diff --git a/libsrc/visualization/vssolution.hpp b/libsrc/visualization/vssolution.hpp index c1d9629b..e9a406be 100644 --- a/libsrc/visualization/vssolution.hpp +++ b/libsrc/visualization/vssolution.hpp @@ -1,7 +1,8 @@ #ifndef FILE_VSSOLUTION #define FILE_VSSOLUTION -#include "fieldlines.hpp" +#include "visual_api.hpp" +#include "mvdraw.hpp" typedef void * ClientData; struct Tcl_Interp; @@ -10,7 +11,7 @@ struct Tcl_Interp; namespace netgen { -DLL_HEADER extern void ImportSolution (const char * filename); +NGGUI_API extern void ImportSolution (const char * filename); extern int Ng_Vis_Set (ClientData clientData, @@ -19,7 +20,7 @@ DLL_HEADER extern void ImportSolution (const char * filename); -class DLL_HEADER VisualSceneSolution : public VisualScene +class NGGUI_API VisualSceneSolution : public VisualScene { friend class FieldLineCalc; @@ -355,15 +356,17 @@ public: }; +NGGUI_API VisualSceneSolution & GetVSSolution(); +inline void AddUserVisualizationObject (UserVisualizationObject * vis) +{ + GetVSSolution().AddUserVisualizationObject (vis); +} - - - - - - // DLL_HEADER extern VisualSceneSolution vssolution; -DLL_HEADER extern VisualSceneSolution & GetVSSolution(); +inline void DeleteUserVisualizationObject (UserVisualizationObject * vis) +{ + GetVSSolution().DeleteUserVisualizationObject (vis); +} } diff --git a/ng/CMakeLists.txt b/ng/CMakeLists.txt index 060fbb0a..53221d1f 100644 --- a/ng/CMakeLists.txt +++ b/ng/CMakeLists.txt @@ -11,27 +11,19 @@ if(WIN32) set_directory_properties(PROPERTIES RULE_LAUNCH_COMPILE "") endif(WIN32) -if(USE_GUI) +target_sources(nglib PRIVATE onetcl.cpp) - add_library(gui SHARED +if(USE_GUI) + target_sources(nggui PRIVATE gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp ngtcl.cpp - ../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp - ../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp - ../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp ) - target_link_libraries( gui PUBLIC nglib ) - target_link_libraries( gui PRIVATE ${LIBTOGL} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_Xmu_LIB} ${X11_X11_LIB} ${OCC_LIBRARIES} ) - target_link_libraries( gui PRIVATE ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY}) - if(NOT BUILD_FOR_CONDA) - add_executable(netgen ngappinit.cpp) + add_executable(netgen ngappinit.cpp) if(WIN32) target_sources(netgen PRIVATE ../windows/netgen.rc) - else(WIN32) - target_link_libraries( netgen mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis ) endif(WIN32) - target_link_libraries( netgen nglib gui netgen_python ${MPI_mpi_LIBRARY} ${MPI_CXX_LIBRARIES} ${LIBTOGL} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_Xmu_LIB} ${X11_X11_LIB} ${OCC_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY}) + target_link_libraries( netgen nglib nggui netgen_python ${TK_LIBRARY} ${TCL_LIBRARY}) install(TARGETS netgen ${NG_INSTALL_DIR}) if(APPLE) set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen) @@ -39,17 +31,7 @@ if(USE_GUI) target_link_libraries( netgen ${PYTHON_LIBRARIES}) endif(NOT BUILD_FOR_CONDA) - if(NOT WIN32) - target_link_libraries( gui PUBLIC mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis ) - endif(NOT WIN32) - - install(TARGETS gui ${NG_INSTALL_DIR}) - - if(WIN32) - set_target_properties( gui PROPERTIES OUTPUT_NAME libgui ) - endif(WIN32) - target_link_libraries( gui PRIVATE "$" ) - + install(TARGETS nggui ${NG_INSTALL_DIR}) endif(USE_GUI) if(USE_PYTHON) @@ -63,6 +45,19 @@ if(USE_PYTHON) endif() set_target_properties(ngpy PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}") install(TARGETS ngpy DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX} COMPONENT netgen) + + if(USE_GUI) + add_library(ngguipy SHARED ngguipy.cpp) + target_link_libraries( ngguipy PUBLIC nglib nggui PRIVATE "$" ) + if(APPLE) + set_target_properties( ngguipy PROPERTIES SUFFIX ".so") + elseif(WIN32) + set_target_properties( ngguipy PROPERTIES SUFFIX ".pyd") + set_target_properties( ngguipy PROPERTIES OUTPUT_NAME "libngguipy") + endif() + set_target_properties(ngguipy PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}") + install(TARGETS ngguipy DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX} COMPONENT netgen) + endif(USE_GUI) endif(USE_PYTHON) if(USE_GUI) diff --git a/ng/Togl2.1/CMakeLists.txt b/ng/Togl2.1/CMakeLists.txt index b299664c..99fb3026 100644 --- a/ng/Togl2.1/CMakeLists.txt +++ b/ng/Togl2.1/CMakeLists.txt @@ -5,13 +5,30 @@ if(APPLE) endif(APPLE) if(WIN32) - add_definitions("-DBUILD_togl -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADERS -DSTDC_HEADER") - add_library(togl SHARED togl.c toglProcAddr.c toglStubInit.c) - install(TARGETS togl DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen) - target_link_libraries(togl ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY}) + set(TOGL_LIBRARY_TYPE SHARED) else(WIN32) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -Wno-implicit-int") - add_definitions("-DPACKAGE_NAME=\"Togl\" -DPACKAGE_TARNAME=\"togl\" -DPACKAGE_VERSION=\"2.1\" -DPACKAGE_STRING=\"Togl\ 2.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=0 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 -DAUTOSTEREOD=\"\"") + set(TOGL_LIBRARY_TYPE STATIC) +endif(WIN32) + +add_library(togl ${TOGL_LIBRARY_TYPE} togl.c toglProcAddr.c toglStubInit.c) +if(WIN32) + target_compile_definitions(togl PUBLIC -DTOGL_WGL) +else(WIN32) + if(APPLE) + target_compile_definitions(togl PUBLIC -DTOGL_NSOPENGL) + else(APPLE) + target_compile_definitions(togl PUBLIC -DTOGL_X11) + endif(APPLE) +endif(WIN32) +target_link_libraries(togl PUBLIC ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY}) + +target_compile_definitions(togl PRIVATE -DBUILD_togl=1 -DSTDC_HEADERS=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1) + +if(WIN32) + target_compile_definitions(togl PRIVATE -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADER) +else(WIN32) + target_compile_options(togl PRIVATE -fomit-frame-pointer -Wno-implicit-int) + target_compile_definitions(togl PRIVATE -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=0 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DTCL_THREADS=1 -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1) include_directories(BEFORE "${TCL_INCLUDE_PATH}/tcl-private/generic" "${TCL_INCLUDE_PATH}/tcl-private/unix") include_directories(BEFORE "${TK_INCLUDE_PATH}/tk-private/generic" "${TK_INCLUDE_PATH}/tk-private/unix" "${TK_INCLUDE_PATH}/tk-private") @@ -20,9 +37,9 @@ else(WIN32) include_directories(BEFORE "${TCL_INCLUDE_PATH}") include_directories(BEFORE "${TK_INCLUDE_PATH}") - add_library(togl togl.c toglProcAddr.c toglStubInit.c) - target_link_libraries(togl ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY}) endif(WIN32) -target_link_libraries(togl ${OPENGL_LIBRARIES}) +target_include_directories(togl PUBLIC ${OPENGL_INCLUDE_DIR}) +target_link_libraries(togl PUBLIC ${OPENGL_LIBRARY}) set_target_properties(togl PROPERTIES POSITION_INDEPENDENT_CODE ON ) +install(TARGETS togl DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen) diff --git a/ng/netgenpy.cpp b/ng/netgenpy.cpp index 08aca5db..8b6fa121 100644 --- a/ng/netgenpy.cpp +++ b/ng/netgenpy.cpp @@ -14,10 +14,6 @@ void NGCORE_API_IMPORT ExportSTLVis(py::module &m); #ifdef OCCGEOMETRY void NGCORE_API_IMPORT ExportNgOCC(py::module &m); #endif // OCCGEOMETRY -namespace netgen -{ - std::vector NGCORE_API_IMPORT Snapshot( int w, int h ); -} PYBIND11_MODULE(libngpy, ngpy) { @@ -34,23 +30,4 @@ PYBIND11_MODULE(libngpy, ngpy) py::module NgOCC = ngpy.def_submodule("_NgOCC", "pybind NgOCC module"); ExportNgOCC(NgOCC); #endif // OCCGEOMETRY -#ifdef OPENGL - py::module meshvis = ngpy.def_submodule("meshvis", "pybind meshvis module"); - ExportMeshVis(meshvis); - py::module csgvis = ngpy.def_submodule("csgvis", "pybind csgvis module"); - ExportCSGVis(csgvis); - py::module stlvis = ngpy.def_submodule("stlvis", "pybind stlvis module"); - ExportSTLVis(stlvis); - ngpy.def("Snapshot", netgen::Snapshot); -#endif // OPENGL -} - -// Force linking libnglib to libnetgenpy -namespace netgen -{ - void MyBeep (int i); - void MyDummyToForceLinkingNGLib() - { - MyBeep(0); - } } diff --git a/ng/ng.tcl b/ng/ng.tcl index 7343eae0..73b8eb6d 100644 --- a/ng/ng.tcl +++ b/ng/ng.tcl @@ -2,7 +2,7 @@ catch {lappend auto_path $env(NETGENDIR) } catch {lappend auto_path $env(NETGENDIR)/../lib } if {[catch {Ng_GetCommandLineParameter batchmode} result ]} { - load libgui[info sharedlibextension] gui + load libnggui[info sharedlibextension] gui } set batchmode [Ng_GetCommandLineParameter batchmode] diff --git a/ng/ngguipy.cpp b/ng/ngguipy.cpp new file mode 100644 index 00000000..3bcd11b3 --- /dev/null +++ b/ng/ngguipy.cpp @@ -0,0 +1,23 @@ +#include +#include <../general/ngpython.hpp> +#include + +void NGCORE_API_IMPORT ExportMeshVis(py::module &m); +void NGCORE_API_IMPORT ExportCSGVis(py::module &m); +void NGCORE_API_IMPORT ExportSTLVis(py::module &m); +namespace netgen +{ + std::vector NGCORE_API_IMPORT Snapshot( int w, int h ); +} + +PYBIND11_MODULE(libngguipy, ngpy) +{ + py::module::import("pyngcore"); + py::module meshvis = ngpy.def_submodule("meshvis", "pybind meshvis module"); + ExportMeshVis(meshvis); + py::module csgvis = ngpy.def_submodule("csgvis", "pybind csgvis module"); + ExportCSGVis(csgvis); + py::module stlvis = ngpy.def_submodule("stlvis", "pybind stlvis module"); + ExportSTLVis(stlvis); + ngpy.def("Snapshot", netgen::Snapshot); +} diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index 3cacf04c..96ef4ea1 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -124,39 +124,6 @@ namespace netgen -#ifndef SMALLLIB -// // Destination for messages, errors, ... -#ifndef WIN32 - DLL_HEADER void Ng_PrintDest(const char * s) - { - /* -#ifdef PARALLEL - int id, ntasks; - MPI_Comm_size(MPI_COMM_WORLD, &ntasks); - MPI_Comm_rank(MPI_COMM_WORLD, &id); -#else - int id = 0; int ntasks = 1; -#endif - */ - - if (id == 0) - (*mycout) << s << flush; - - /* - if ( ntasks == 1 ) - (*mycout) << s << flush; - else - (*mycout) << "p" << id << ": " << s << flush ; - */ - } -#endif - void MyError2(const char * ch) - { - cout << ch; - (*testout) << "Error !!! " << ch << endl << flush; - } -#endif - static clock_t starttimea; void ResetTime2 () { diff --git a/ng/onetcl.cpp b/ng/onetcl.cpp index 6d788b16..bc3ba224 100644 --- a/ng/onetcl.cpp +++ b/ng/onetcl.cpp @@ -3,7 +3,7 @@ DLL_HEADER const char * ngscript[] = {"" ,"catch {lappend auto_path $env(NETGENDIR) }\n" ,"catch {lappend auto_path $env(NETGENDIR)/../lib }\n" ,"if {[catch {Ng_GetCommandLineParameter batchmode} result ]} {\n" -,"load libgui[info sharedlibextension] gui\n" +,"load libnggui[info sharedlibextension] gui\n" ,"}\n" ,"set batchmode [Ng_GetCommandLineParameter batchmode]\n" ,"if {$batchmode==\"undefined\"} {\n" diff --git a/nglib/CMakeLists.txt b/nglib/CMakeLists.txt index a8b4bac5..370b670b 100644 --- a/nglib/CMakeLists.txt +++ b/nglib/CMakeLists.txt @@ -1,47 +1,13 @@ -add_definitions(-DNGLIB_EXPORTS) +target_sources(nglib PRIVATE nglib.cpp) -if(WIN32) - set(nglib_objects - $ - $ - $ - $ - $ +if(USE_OCC) + target_sources(nglib PRIVATE nglib_occ.cpp) + install(FILES nglib_occ.h DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel) +endif(USE_OCC) - $ - ) - if(USE_GUI) - set(nglib_objects ${nglib_objects} - $ - $ - $ - ) - endif(USE_GUI) - if(USE_OCC) - set(nglib_objects ${nglib_objects} $) - endif(USE_OCC) -endif(WIN32) - -add_library(nglib SHARED nglib.cpp ${nglib_objects}) -if(NOT WIN32) - target_link_libraries( nglib PUBLIC mesh interface geom2d csg stl visual) - if(USE_GUI) - target_link_libraries( nglib PUBLIC stlvis geom2dvis csgvis ) - endif(USE_GUI) -endif(NOT WIN32) - -# target_link_libraries(nglib PRIVATE gen la gprim PUBLIC ngcore) target_link_libraries(nglib PUBLIC ngcore) -target_link_libraries( nglib PRIVATE ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} netgen_cgns ) +target_link_libraries( nglib PRIVATE ${MPI_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} netgen_cgns ) -if(USE_OCC AND NOT WIN32) - target_link_libraries(nglib PUBLIC occ) -endif(USE_OCC AND NOT WIN32) - -if(USE_PYTHON) - target_link_libraries(nglib PRIVATE netgen_python) -endif(USE_PYTHON) - -install(TARGETS nglib ${NG_INSTALL_DIR}) +install(TARGETS nglib netgen_cgns ${NG_INSTALL_DIR}) install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel) diff --git a/nglib/nglib.cpp b/nglib/nglib.cpp index a17f4064..c72e067b 100644 --- a/nglib/nglib.cpp +++ b/nglib/nglib.cpp @@ -17,15 +17,7 @@ #include #include #include -#include <../visualization/soldata.hpp> - -#ifdef OCCGEOMETRY -#include -namespace netgen -{ - DLL_HEADER extern OCCParameters occparam; -} // namespace netgen -#endif // OCCGEOMETRY +#include <../meshing/soldata.hpp> #include @@ -774,194 +766,6 @@ namespace nglib -#ifdef OCCGEOMETRY - // --------------------- OCC Geometry / Meshing Utility Functions ------------------- - // Create new OCC Geometry Object - NGLIB_API Ng_OCC_Geometry * Ng_OCC_NewGeometry () - { - return (Ng_OCC_Geometry*)(void*)new OCCGeometry; - } - - - - - // Delete the OCC Geometry Object - NGLIB_API Ng_Result Ng_OCC_DeleteGeometry(Ng_OCC_Geometry * geom) - { - if (geom != NULL) - { - delete (OCCGeometry*)geom; - geom = NULL; - return NG_OK; - } - - return NG_ERROR; - } - - - - - // Loads geometry from STEP File - NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename) - { - // Call the STEP File Load function. Note.. the geometry class - // is created and instantiated within the load function - OCCGeometry * occgeo = LoadOCC_STEP(filename); - - return ((Ng_OCC_Geometry *)occgeo); - } - - - - - // Loads geometry from IGES File - NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename) - { - // Call the IGES File Load function. Note.. the geometry class - // is created and instantiated within the load function - OCCGeometry * occgeo = LoadOCC_IGES(filename); - - return ((Ng_OCC_Geometry *)occgeo); - } - - - - - // Loads geometry from BREP File - NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename) - { - // Call the BREP File Load function. Note.. the geometry class - // is created and instantiated within the load function - OCCGeometry * occgeo = LoadOCC_BREP(filename); - - return ((Ng_OCC_Geometry *)occgeo); - } - - - - - // Locally limit the size of the mesh to be generated at various points - // based on the topology of the geometry - NGLIB_API Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh, - Ng_Meshing_Parameters * mp) - { - OCCGeometry * occgeom = (OCCGeometry*)geom; - Mesh * me = (Mesh*)mesh; - me->SetGeometry( shared_ptr(occgeom, &NOOP_Deleter) ); - - me->geomtype = Mesh::GEOM_OCC; - - mp->Transfer_Parameters(); - - if(mp->closeedgeenable) - mparam.closeedgefac = mp->closeedgefact; - - // Delete the mesh structures in order to start with a clean - // slate - me->DeleteMesh(); - - OCCSetLocalMeshSize(*occgeom, *me, mparam, occparam); - - return(NG_OK); - } - - - - - // Mesh the edges and add Face descriptors to prepare for surface meshing - NGLIB_API Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh, - Ng_Meshing_Parameters * mp) - { - OCCGeometry * occgeom = (OCCGeometry*)geom; - Mesh * me = (Mesh*)mesh; - me->SetGeometry( shared_ptr(occgeom, &NOOP_Deleter) ); - - mp->Transfer_Parameters(); - - occgeom->FindEdges(*me, mparam); - - if((me->GetNP())) - { - return NG_OK; - } - else - { - return NG_ERROR; - } - } - - - - - // Mesh the edges and add Face descriptors to prepare for surface meshing - NGLIB_API Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh, - Ng_Meshing_Parameters * mp) - { - int numpoints = 0; - - OCCGeometry * occgeom = (OCCGeometry*)geom; - Mesh * me = (Mesh*)mesh; - me->SetGeometry( shared_ptr(occgeom, &NOOP_Deleter) ); - - // Set the internal meshing parameters structure from the nglib meshing - // parameters structure - mp->Transfer_Parameters(); - - numpoints = me->GetNP(); - - // Initially set up only for surface meshing without any optimisation - int perfstepsend = MESHCONST_MESHSURFACE; - - // Check and if required, enable surface mesh optimisation step - if(mp->optsurfmeshenable) - { - perfstepsend = MESHCONST_OPTSURFACE; - } - - occgeom->MeshSurface(*me, mparam); - occgeom->OptimizeSurface(*me, mparam); - - me->CalcSurfacesOfNode(); - - if(me->GetNP() <= numpoints) - return NG_ERROR; - - if(me->GetNSE() <= 0) - return NG_ERROR; - - return NG_OK; - } - - - - - // Extract the face map from the OCC geometry - // The face map basically gives an index to each face in the geometry, - // which can be used to access a specific face - NGLIB_API Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom, - Ng_OCC_TopTools_IndexedMapOfShape * FMap) - { - OCCGeometry* occgeom = (OCCGeometry*)geom; - TopTools_IndexedMapOfShape *occfmap = (TopTools_IndexedMapOfShape *)FMap; - - // Copy the face map from the geometry to the given variable - occfmap->Assign(occgeom->fmap); - - if(occfmap->Extent()) - { - return NG_OK; - } - else - { - return NG_ERROR; - } - } - - // ------------------ End - OCC Geometry / Meshing Utility Functions ---------------- -#endif @@ -1119,13 +923,6 @@ namespace nglib -#ifdef OCCGEOMETRY - NGLIB_API void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh) - { - ((OCCGeometry*)geom )->GetRefinement().MakeSecondOrder(*(Mesh*) mesh); - } -#endif // ------------------ End - Second Order Mesh generation functions ------------------ @@ -1168,13 +965,6 @@ namespace nglib -#ifdef OCCGEOMETRY - NGLIB_API void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh) - { - ( (OCCGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh ); - } -#endif // ------------------ End - Uniform Mesh Refinement functions ----------------------- } // End of namespace nglib diff --git a/nglib/nglib.h b/nglib/nglib.h index 511c62bf..0e7c59e7 100644 --- a/nglib/nglib.h +++ b/nglib/nglib.h @@ -7,6 +7,8 @@ /* Date: 7. May. 2000 */ /**************************************************************************/ +#include + /*! \file nglib.h \brief Library interface to the netgen meshing kernel @@ -23,9 +25,8 @@ // Philippose - 14.02.2009 // Modifications for creating a DLL in Windows -#ifndef NGLIB_API #ifdef WIN32 - #ifdef NGLIB_EXPORTS || nglib_EXPORTS + #ifdef nglib_EXPORTS #define NGLIB_API __declspec(dllexport) #else #define NGLIB_API __declspec(dllimport) @@ -33,7 +34,6 @@ #else #define NGLIB_API __attribute__((visibility("default"))) #endif -#endif // ** Constants used within Netgen ********************* @@ -58,11 +58,6 @@ typedef void * Ng_Geometry_2D; /// Data type for NETGEN STL geometry typedef void * Ng_STL_Geometry; -#ifdef OCCGEOMETRY -/// Data type for NETGEN OpenCascade geometry -typedef void * Ng_OCC_Geometry; -typedef void * Ng_OCC_TopTools_IndexedMapOfShape; -#endif // *** Special Enum types used within Netgen *********** @@ -650,47 +645,6 @@ NGLIB_API Ng_Result Ng_ACIS_GenerateSurfaceMesh (Ng_ACIS_Geometry * geom, -#ifdef OCCGEOMETRY - -// ********************************************************** -// ** OpenCascade Geometry / Meshing Utilities ** -// ********************************************************** - -// Create new OCC Geometry Object -NGLIB_API Ng_OCC_Geometry * Ng_OCC_NewGeometry (); - -// Delete an OCC Geometry Object -NGLIB_API Ng_Result Ng_OCC_DeleteGeometry (Ng_OCC_Geometry * geom); - -// Loads geometry from STEP file -NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename); - -// Loads geometry from IGES file -NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename); - -// Loads geometry from BREP file -NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename); - -// Set the local mesh size based on geometry / topology -NGLIB_API Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh, - Ng_Meshing_Parameters * mp); - -// Mesh the edges and add Face descriptors to prepare for surface meshing -NGLIB_API Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh, - Ng_Meshing_Parameters * mp); - -// Mesh the surfaces of an OCC geometry -NGLIB_API Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh, - Ng_Meshing_Parameters * mp); - -// Get the face map of an already loaded OCC geometry -NGLIB_API Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom, - Ng_OCC_TopTools_IndexedMapOfShape * FMap); - -#endif // OCCGEOMETRY @@ -713,10 +667,6 @@ NGLIB_API void Ng_STL_Uniform_Refinement (Ng_STL_Geometry * geom, NGLIB_API void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry * geom, Ng_Mesh * mesh); -#ifdef OCCGEOMETRY -NGLIB_API void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh); -#endif @@ -739,10 +689,9 @@ NGLIB_API void Ng_STL_Generate_SecondOrder (Ng_STL_Geometry * geom, NGLIB_API void Ng_CSG_Generate_SecondOrder (Ng_CSG_Geometry * geom, Ng_Mesh * mesh); + #ifdef OCCGEOMETRY -NGLIB_API void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom, - Ng_Mesh * mesh); -#endif - - +#include "nglib_occ.h" +#endif // OCCGEOMETRY + // #endif // NGLIB diff --git a/nglib/nglib_occ.cpp b/nglib/nglib_occ.cpp new file mode 100644 index 00000000..58ee4d8f --- /dev/null +++ b/nglib/nglib_occ.cpp @@ -0,0 +1,212 @@ +#include +#include +#include + +#define OCCGEOMETRY 1 +namespace nglib { +#include "nglib.h" +} + + +namespace netgen +{ + inline void NOOP_Deleter(void *) { ; } + extern MeshingParameters mparam; + DLL_HEADER extern OCCParameters occparam; +} // namespace netgen + +using namespace netgen; + +namespace nglib +{ + + // --------------------- OCC Geometry / Meshing Utility Functions ------------------- + // Create new OCC Geometry Object + NGLIB_API Ng_OCC_Geometry * Ng_OCC_NewGeometry () + { + return (Ng_OCC_Geometry*)(void*)new OCCGeometry; + } + + + // Delete the OCC Geometry Object + NGLIB_API Ng_Result Ng_OCC_DeleteGeometry(Ng_OCC_Geometry * geom) + { + if (geom != NULL) + { + delete (OCCGeometry*)geom; + geom = NULL; + return NG_OK; + } + + return NG_ERROR; + } + + + // Loads geometry from STEP File + NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename) + { + // Call the STEP File Load function. Note.. the geometry class + // is created and instantiated within the load function + OCCGeometry * occgeo = LoadOCC_STEP(filename); + + return ((Ng_OCC_Geometry *)occgeo); + } + + + // Loads geometry from IGES File + NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename) + { + // Call the IGES File Load function. Note.. the geometry class + // is created and instantiated within the load function + OCCGeometry * occgeo = LoadOCC_IGES(filename); + + return ((Ng_OCC_Geometry *)occgeo); + } + + + // Loads geometry from BREP File + NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename) + { + // Call the BREP File Load function. Note.. the geometry class + // is created and instantiated within the load function + OCCGeometry * occgeo = LoadOCC_BREP(filename); + + return ((Ng_OCC_Geometry *)occgeo); + } + + + // Locally limit the size of the mesh to be generated at various points + // based on the topology of the geometry + NGLIB_API Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh, + Ng_Meshing_Parameters * mp) + { + OCCGeometry * occgeom = (OCCGeometry*)geom; + Mesh * me = (Mesh*)mesh; + me->SetGeometry( shared_ptr(occgeom, &NOOP_Deleter) ); + + me->geomtype = Mesh::GEOM_OCC; + + mp->Transfer_Parameters(); + + if(mp->closeedgeenable) + mparam.closeedgefac = mp->closeedgefact; + + // Delete the mesh structures in order to start with a clean + // slate + me->DeleteMesh(); + + OCCSetLocalMeshSize(*occgeom, *me, mparam, occparam); + + return(NG_OK); + } + + + + + // Mesh the edges and add Face descriptors to prepare for surface meshing + NGLIB_API Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh, + Ng_Meshing_Parameters * mp) + { + OCCGeometry * occgeom = (OCCGeometry*)geom; + Mesh * me = (Mesh*)mesh; + me->SetGeometry( shared_ptr(occgeom, &NOOP_Deleter) ); + + mp->Transfer_Parameters(); + + occgeom->FindEdges(*me, mparam); + + if((me->GetNP())) + { + return NG_OK; + } + else + { + return NG_ERROR; + } + } + + + + + // Mesh the edges and add Face descriptors to prepare for surface meshing + NGLIB_API Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh, + Ng_Meshing_Parameters * mp) + { + int numpoints = 0; + + OCCGeometry * occgeom = (OCCGeometry*)geom; + Mesh * me = (Mesh*)mesh; + me->SetGeometry( shared_ptr(occgeom, &NOOP_Deleter) ); + + // Set the internal meshing parameters structure from the nglib meshing + // parameters structure + mp->Transfer_Parameters(); + + numpoints = me->GetNP(); + + // Initially set up only for surface meshing without any optimisation + int perfstepsend = MESHCONST_MESHSURFACE; + + // Check and if required, enable surface mesh optimisation step + if(mp->optsurfmeshenable) + { + perfstepsend = MESHCONST_OPTSURFACE; + } + + occgeom->MeshSurface(*me, mparam); + occgeom->OptimizeSurface(*me, mparam); + + me->CalcSurfacesOfNode(); + + if(me->GetNP() <= numpoints) + return NG_ERROR; + + if(me->GetNSE() <= 0) + return NG_ERROR; + + return NG_OK; + } + + + + + // Extract the face map from the OCC geometry + // The face map basically gives an index to each face in the geometry, + // which can be used to access a specific face + NGLIB_API Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom, + Ng_OCC_TopTools_IndexedMapOfShape * FMap) + { + OCCGeometry* occgeom = (OCCGeometry*)geom; + TopTools_IndexedMapOfShape *occfmap = (TopTools_IndexedMapOfShape *)FMap; + + // Copy the face map from the geometry to the given variable + occfmap->Assign(occgeom->fmap); + + if(occfmap->Extent()) + { + return NG_OK; + } + else + { + return NG_ERROR; + } + } + + // ------------------ End - OCC Geometry / Meshing Utility Functions ---------------- + + NGLIB_API void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh) + { + ((OCCGeometry*)geom )->GetRefinement().MakeSecondOrder(*(Mesh*) mesh); + } + + NGLIB_API void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh) + { + ( (OCCGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh ); + } + +} // namespace nglib diff --git a/nglib/nglib_occ.h b/nglib/nglib_occ.h new file mode 100644 index 00000000..ebb75a4f --- /dev/null +++ b/nglib/nglib_occ.h @@ -0,0 +1,50 @@ +#ifndef NGLIB_OCC_HPP_INCLUDED +#define NGLIB_OCC_HPP_INCLUDED + +/// Data type for NETGEN OpenCascade geometry +typedef void * Ng_OCC_Geometry; +typedef void * Ng_OCC_TopTools_IndexedMapOfShape; + +// ********************************************************** +// ** OpenCascade Geometry / Meshing Utilities ** +// ********************************************************** + +// Create new OCC Geometry Object +NGLIB_API Ng_OCC_Geometry * Ng_OCC_NewGeometry (); + +// Delete an OCC Geometry Object +NGLIB_API Ng_Result Ng_OCC_DeleteGeometry (Ng_OCC_Geometry * geom); + +// Loads geometry from STEP file +NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename); + +// Loads geometry from IGES file +NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename); + +// Loads geometry from BREP file +NGLIB_API Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename); + +// Set the local mesh size based on geometry / topology +NGLIB_API Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh, + Ng_Meshing_Parameters * mp); + +// Mesh the edges and add Face descriptors to prepare for surface meshing +NGLIB_API Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh, + Ng_Meshing_Parameters * mp); + +// Mesh the surfaces of an OCC geometry +NGLIB_API Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh, + Ng_Meshing_Parameters * mp); + +// Get the face map of an already loaded OCC geometry +NGLIB_API Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom, + Ng_OCC_TopTools_IndexedMapOfShape * FMap); + +NGLIB_API void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh); +NGLIB_API void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom, + Ng_Mesh * mesh); +#endif // NGLIB_OCC_HPP_INCLUDED diff --git a/python/__init__.py b/python/__init__.py index 41c03908..41aa36f9 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -17,12 +17,13 @@ del os from . import libngpy if config.USE_GUI: + from . import libngguipy global _Redraw, Redraw - _Redraw = libngpy.meshvis._Redraw + _Redraw = libngguipy.meshvis._Redraw def RedrawWithEventHandling(*args, **kwargs): try: - if libngpy.meshvis._Redraw(*args, **kwargs): + if libngguipy.meshvis._Redraw(*args, **kwargs): import netgen import tkinter cnt = 0 diff --git a/rules/CMakeLists.txt b/rules/CMakeLists.txt new file mode 100644 index 00000000..82dad7e7 --- /dev/null +++ b/rules/CMakeLists.txt @@ -0,0 +1,29 @@ +# this file is included from the parent directory (otherwise generated source files are not recognized properly by cmake) + +# generate .cpp files containing the string of the .rls meshing rule files +add_executable(makerls rules/makerlsfile.cpp) + +set(rules + hexrules + prismrules2 + pyramidrules + pyramidrules2 + quadrules + tetrules + triarules +) + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/rules/) + +foreach(rule ${rules}) + list(APPEND rules_sources ${CMAKE_CURRENT_BINARY_DIR}/rules/rule_${rule}.cpp) + set(rule_file ${CMAKE_CURRENT_SOURCE_DIR}/rules/${rule}.rls) + set(rule_cpp ${CMAKE_CURRENT_BINARY_DIR}/rules/rule_${rule}.cpp) + + add_custom_command(OUTPUT ${rule_cpp} + COMMAND makerls ${rule_file} ${rule_cpp} ${rule} + DEPENDS makerls ${rule_file} + ) +endforeach() + +target_sources(nglib PRIVATE ${rules_sources}) diff --git a/tests/pytest/test_mpi4py.py b/tests/pytest/test_mpi4py.py index b4c85902..4d68eda6 100644 --- a/tests/pytest/test_mpi4py.py +++ b/tests/pytest/test_mpi4py.py @@ -2,6 +2,7 @@ import pytest import netgen.meshing mpi4py = pytest.importorskip("mpi4py") +_ = pytest.importorskip("pytest_mpi") @pytest.mark.mpi def test_mpi4py():