diff --git a/libsrc/include/nginterface.h b/libsrc/include/nginterface.h index 2d76aa7c..4ded8217 100644 --- a/libsrc/include/nginterface.h +++ b/libsrc/include/nginterface.h @@ -12,6 +12,7 @@ /**************************************************************************/ #include "mydefs.hpp" +#include /* Application program interface to Netgen @@ -451,15 +452,6 @@ extern "C" { return value is number of nodes */ DLL_HEADER int Ng_GetElementClosureNodes (int dim, int elementnr, int nodeset, int * nodes); - - - struct Ng_Tcl_Interp; - typedef int (Ng_Tcl_CmdProc) (Ng_Tcl_Interp *interp, int argc, const char *argv[]); - - DLL_HEADER void Ng_Tcl_CreateCommand (Ng_Tcl_Interp * interp, - const char * cmdName, Ng_Tcl_CmdProc * proc); - - void Ng_Tcl_SetResult (Ng_Tcl_Interp * interp, const char * result); } diff --git a/libsrc/meshing/visual_interface.cpp b/libsrc/meshing/visual_interface.cpp index 818bc215..cdb2a0ca 100644 --- a/libsrc/meshing/visual_interface.cpp +++ b/libsrc/meshing/visual_interface.cpp @@ -13,6 +13,9 @@ void Ng_Redraw (bool blocking) { if(Ptr_Ng_Redraw) Ptr_Ng_Redraw(blocking); } namespace netgen { + void (*Ptr_Ng_Tcl_SetResult)(Tcl_Interp *interp, char *result, const int freeProc) = nullptr; + void (*Ptr_Ng_Tcl_CreateCommand)(Tcl_Interp *interp, + const char *cmdName, Tcl_CmdProc *proc) = nullptr; void (*Ptr_Render)(bool) = nullptr; void (*Ptr_UpdateVisSurfaceMeshData)(int, shared_ptr>>, @@ -20,3 +23,4 @@ namespace netgen shared_ptr>> ) = nullptr; } // namespace netgen + diff --git a/libsrc/meshing/visual_interface.hpp b/libsrc/meshing/visual_interface.hpp index 120c7809..286cf82a 100644 --- a/libsrc/meshing/visual_interface.hpp +++ b/libsrc/meshing/visual_interface.hpp @@ -3,6 +3,7 @@ #include #include +#include class Ng_SolutionData; @@ -13,7 +14,25 @@ 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); +// Tcl wrapper functions +class Tcl_Interp; +typedef int (Tcl_CmdProc) (void * clientData, Tcl_Interp *interp, + int argc, const char *argv[]); namespace netgen { + + inline constexpr int NG_TCL_VOLATILE = 1; + inline constexpr int NG_TCL_STATIC = 0; + inline constexpr int NG_TCL_DYNAMIC = 3; + + inline constexpr int NG_TCL_OK = 0; + inline constexpr int NG_TCL_ERROR = 1; + inline constexpr int NG_TCL_RETURN = 2; + inline constexpr int NG_TCL_BREAK = 3; + inline constexpr int NG_TCL_CONTINUE = 4; + DLL_HEADER extern void (*Ptr_Ng_Tcl_SetResult)(Tcl_Interp *interp, char *result, const int freeProc); + DLL_HEADER extern void (*Ptr_Ng_Tcl_CreateCommand)(Tcl_Interp *interp, + const char *cmdName, Tcl_CmdProc *proc); + DLL_HEADER extern void (*Ptr_Render)(bool); DLL_HEADER extern void (*Ptr_UpdateVisSurfaceMeshData)(int, shared_ptr>>, @@ -29,6 +48,17 @@ namespace netgen { ) { if(Ptr_UpdateVisSurfaceMeshData) Ptr_UpdateVisSurfaceMeshData(oldnl, locpointsptr, loclinesptr, plainpointsptr); } + + inline void Ng_Tcl_SetResult(Tcl_Interp *interp, char *result, const int freeProc) + { + if(Ptr_Ng_Tcl_SetResult) + Ptr_Ng_Tcl_SetResult(interp, result, freeProc); + } + inline void Ng_Tcl_CreateCommand(Tcl_Interp *interp, const char *cmdName, Tcl_CmdProc *proc) + { + if(Ptr_Ng_Tcl_CreateCommand) + Ptr_Ng_Tcl_CreateCommand(interp, cmdName, proc); + } } #endif // VISUAL_INTERFACE_HPP_INCLUDED diff --git a/ng/CMakeLists.txt b/ng/CMakeLists.txt index 7571ec9e..58e34e2f 100644 --- a/ng/CMakeLists.txt +++ b/ng/CMakeLists.txt @@ -15,7 +15,7 @@ target_sources(nglib PRIVATE onetcl.cpp) if(USE_GUI) target_sources(nggui PRIVATE - gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp ngtcl.cpp + gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp ) if(NOT BUILD_FOR_CONDA) @@ -71,9 +71,5 @@ if(USE_GUI) endif() add_subdirectory(Togl2.1) - install(FILES - ngtcl.hpp - DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel - ) endif(USE_GUI) diff --git a/ng/ngtcl.cpp b/ng/ngtcl.cpp index 367228cb..125afa89 100644 --- a/ng/ngtcl.cpp +++ b/ng/ngtcl.cpp @@ -1,16 +1,9 @@ -#include "ngtcl.hpp" +#include "../libsrc/meshing/visual_interface.hpp" #include -namespace netgen -{ - void Ng_Tcl_SetResult(Tcl_Interp *interp, char *result, const int freeProc) - { - Tcl_SetResult(interp, result, (Tcl_FreeProc*)freeProc); - } - - void Ng_Tcl_CreateCommand(Tcl_Interp *interp, const char *cmdName, Tcl_CmdProc *proc) - { - Tcl_CreateCommand(interp, cmdName, proc, nullptr, nullptr); - } -} +static bool dummy_init_pointers = [](){ + Ptr_Ng_Tcl_SetResult = Tcl_SetResult; + Ptr_Ng_Tcl_CreateCommand = Tcl_CreateCommand; + return true; +}(); diff --git a/ng/ngtcl.hpp b/ng/ngtcl.hpp deleted file mode 100644 index a548cad9..00000000 --- a/ng/ngtcl.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef FILE_NG_TCL_HPP -#define FILE_NG_TCL_HPP - -#include - -class Tcl_Interp; -class Tcl_cmdProc; - -namespace netgen -{ - typedef int (Tcl_CmdProc) (void * clientData, Tcl_Interp *interp, - int argc, const char *argv[]); - - inline constexpr int NG_TCL_VOLATILE = 1; - inline constexpr int NG_TCL_STATIC = 0; - inline constexpr int NG_TCL_DYNAMIC = 3; - - inline constexpr int NG_TCL_OK = 0; - inline constexpr int NG_TCL_ERROR = 1; - inline constexpr int NG_TCL_RETURN = 2; - inline constexpr int NG_TCL_BREAK = 3; - inline constexpr int NG_TCL_CONTINUE = 4; - - DLL_HEADER void Ng_Tcl_SetResult(Tcl_Interp *interp, char *result, const int freeProc); - DLL_HEADER void Ng_Tcl_CreateCommand(Tcl_Interp *interp, - const char *cmdName, Tcl_CmdProc *proc); - -} - -#endif // FILE_NG_TCL_HPP