From 685981d46399888f6296dd2e64481ccbbe8f1f80 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 31 Jan 2017 15:35:56 +0100 Subject: [PATCH] Fixes for non-GUI builds --- ng/CMakeLists.txt | 18 ++++++++++-------- ng/netgenpy.cpp | 10 ++++++---- nglib/CMakeLists.txt | 5 ++++- python/csg.py | 17 ++++++++++------- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/ng/CMakeLists.txt b/ng/CMakeLists.txt index 354851a3..33f0991d 100644 --- a/ng/CMakeLists.txt +++ b/ng/CMakeLists.txt @@ -32,13 +32,15 @@ if(USE_PYTHON) install(TARGETS ngpy ${ng_install_dir}) endif(USE_PYTHON) -install(FILES - dialog.tcl menustat.tcl ngicon.tcl ng.tcl - ngvisual.tcl sockets.tcl nghelp.tcl ngshell.tcl - ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl - occgeom.tcl acisgeom.tcl netgen.ocf - DESTINATION ${ng_install_dir_bin} COMPONENT netgen) +if(USE_GUI) + install(FILES + dialog.tcl menustat.tcl ngicon.tcl ng.tcl + ngvisual.tcl sockets.tcl nghelp.tcl ngshell.tcl + ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl + occgeom.tcl acisgeom.tcl netgen.ocf + DESTINATION ${ng_install_dir_bin} COMPONENT netgen) -add_subdirectory(Togl2.1) -install(FILES drawing.tcl DESTINATION ${ng_install_dir_bin} COMPONENT netgen) + add_subdirectory(Togl2.1) + install(FILES drawing.tcl DESTINATION ${ng_install_dir_bin} COMPONENT netgen) +endif(USE_GUI) diff --git a/ng/netgenpy.cpp b/ng/netgenpy.cpp index 988e14db..e4ea7aac 100644 --- a/ng/netgenpy.cpp +++ b/ng/netgenpy.cpp @@ -23,18 +23,20 @@ PYBIND11_PLUGIN(libngpy) py::module ngpy("libngpy", "pybind netgen module"); py::module meshing = ngpy.def_submodule("_meshing", "pybind meshing module"); ExportNetgenMeshing(meshing); - py::module meshvis = ngpy.def_submodule("meshvis", "pybind meshvis module"); - ExportMeshVis(meshvis); py::module csg = ngpy.def_submodule("_csg", "pybind csg module"); ExportCSG(csg); - py::module csgvis = ngpy.def_submodule("csgvis", "pybind csgvis module"); - ExportCSGVis(csgvis); py::module geom2d = ngpy.def_submodule("_geom2d", "pybind geom2d module"); ExportGeom2d(geom2d); py::module stl = ngpy.def_submodule("_stl", "pybind stl module"); ExportSTL(stl); +#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); +#endif // OPENGL return ngpy.ptr(); } diff --git a/nglib/CMakeLists.txt b/nglib/CMakeLists.txt index 8b854ad4..eb18a638 100644 --- a/nglib/CMakeLists.txt +++ b/nglib/CMakeLists.txt @@ -22,7 +22,10 @@ endif(WIN32) add_library(nglib SHARED nglib.cpp ${nglib_objects}) if(NOT WIN32) - target_link_libraries( nglib mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis ) + target_link_libraries( nglib mesh stl interface geom2d csg stl visual) + if(USE_GUI) + target_link_libraries( nglib stlvis geom2dvis csgvis ) + endif(USE_GUI) endif(NOT WIN32) target_link_libraries( nglib ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} ) diff --git a/python/csg.py b/python/csg.py index 6e7f5232..f0e7823c 100644 --- a/python/csg.py +++ b/python/csg.py @@ -1,19 +1,22 @@ import libngpy from libngpy._csg import * -import libngpy.csgvis as csgvis -from libngpy.csgvis import MouseMove from libngpy._meshing import MeshingParameters from libngpy._meshing import Pnt from libngpy._meshing import Vec -CSGeometry.VS = csgvis.VS -SetBackGroundColor = csgvis.SetBackGroundColor -del csgvis +try: + import libngpy.csgvis as csgvis + from libngpy.csgvis import MouseMove + CSGeometry.VS = csgvis.VS + SetBackGroundColor = csgvis.SetBackGroundColor + del csgvis -def VS (obj): - return obj.VS() + def VS (obj): + return obj.VS() +except: + pass def csg_meshing_func (geom, **args):