nglib-python restructuring

This commit is contained in:
Joachim Schöberl 2015-10-20 11:09:29 +02:00
parent c2517bdef5
commit e6157eecd8
10 changed files with 37 additions and 57 deletions

View File

@ -13,15 +13,15 @@ if(USE_GUI)
endif(USE_GUI) endif(USE_GUI)
if(USE_PYTHON) if(USE_PYTHON)
add_library(pynglib SHARED netgenpy.cpp) add_library(ngpy SHARED netgenpy.cpp)
target_link_libraries( pynglib nglib ) target_link_libraries( ngpy nglib )
if(APPLE) if(APPLE)
set_target_properties( pynglib PROPERTIES SUFFIX ".so") set_target_properties( ngpy PROPERTIES SUFFIX ".so")
elseif(WIN32) elseif(WIN32)
set_target_properties( pynglib PROPERTIES SUFFIX ".pyd") set_target_properties( ngpy PROPERTIES SUFFIX ".pyd")
endif() endif()
set_target_properties( pynglib PROPERTIES OUTPUT_NAME "nglib") # set_target_properties( ngpy PROPERTIES OUTPUT_NAME "nglib")
install(TARGETS pynglib ${ng_install_dir}) install(TARGETS ngpy ${ng_install_dir})
endif(USE_PYTHON) endif(USE_PYTHON)
install(FILES install(FILES

View File

@ -1,18 +1,22 @@
#ifdef WIN32
// a wrapper to load netgen-dll into python // a wrapper to load netgen-dll into python
#include <iostream> #include <iostream>
#include <boost/python.hpp> #include <boost/python.hpp>
void __declspec(dllimport) ExportNetgenMeshing(); #ifdef WIN32
void __declspec(dllimport) ExportMeshVis(); #define DLL_HEADER __declspec(dllimport)
void __declspec(dllimport) ExportCSG(); #else
void __declspec(dllimport) ExportCSGVis(); #define DLL_HEADER
void __declspec(dllimport) ExportGeom2d(); #endif
BOOST_PYTHON_MODULE(nglib)
void DLL_HEADER ExportNetgenMeshing();
void DLL_HEADER ExportMeshVis();
void DLL_HEADER ExportCSG();
void DLL_HEADER ExportCSGVis();
void DLL_HEADER ExportGeom2d();
BOOST_PYTHON_MODULE(libngpy)
{ {
ExportCSG(); ExportCSG();
ExportCSGVis(); ExportCSGVis();
@ -21,5 +25,3 @@ BOOST_PYTHON_MODULE(nglib)
ExportGeom2d(); ExportGeom2d();
} }
#endif

View File

@ -1959,6 +1959,7 @@ namespace netgen
int w = Togl_Width (togl); int w = Togl_Width (togl);
int h = Togl_Height (togl); int h = Togl_Height (togl);
cout << "togl h x w = " << h << " x " << w << endl;
glViewport(0, 0, w, h); glViewport(0, 0, w, h);

View File

@ -20,6 +20,9 @@ if(WIN32)
endif(WIN32) endif(WIN32)
add_library(nglib SHARED nglib.cpp ${nglib_objects}) 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 )
endif(NOT WIN32)
target_link_libraries( nglib ${LIBPTHREAD} ${OCC_LIBRARIES} ${LIBTOGL} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ) target_link_libraries( nglib ${LIBPTHREAD} ${OCC_LIBRARIES} ${LIBTOGL} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} )

View File

@ -35,13 +35,10 @@ win_geom = Window( name=b"ngs", drawfunc=mydraw, mousefunc=mymouse)
########################################### ###########################################
# press ctrl+c to break loop # press ctrl+c to break loop
try: while(True):
while(True):
for i in range(10000): for i in range(10000):
glutMainLoopEvent() glutMainLoopEvent()
print('press ctrl+c to create second window!') print('press ctrl+c to create second window!')
except:
pass
########################################### ###########################################
# create second window (transformation matrices are shared) # create second window (transformation matrices are shared)

View File

@ -15,7 +15,7 @@ class Window():
self.drawfunc() self.drawfunc()
def __init__( self, name=b"Window", width=500, height=500, drawfunc=None, mousefunc=None ): def __init__( self, name=b"Window", width=500, height=500, drawfunc=None, mousefunc=None ):
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS) # glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS)
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height) # set window size glutInitWindowSize(width, height) # set window size
glutInitWindowPosition(0, 0) # set window position glutInitWindowPosition(0, 0) # set window position

View File

@ -6,6 +6,9 @@ if __platform.startswith('linux') or __platform.startswith('darwin'):
if __platform.startswith('win'): if __platform.startswith('win'):
path.append(environ['NETGENDIR']) path.append(environ['NETGENDIR'])
from libngpy import *
from . import csg from . import csg
from . import meshing from . import meshing

View File

@ -1,16 +1,7 @@
from netgen import __platform from libngpy.csg import *
if __platform.startswith('linux') or __platform.startswith('darwin'): import libngpy.csgvis as csgvis
# Linux or Mac OS X from libngpy.csgvis import MouseMove
from libcsg.csg import * from libngpy.meshing import *
import libcsgvis.csgvis as csgvis
from libcsgvis.csgvis import MouseMove
from libmesh.meshing import *
if __platform.startswith('win'):
# Windows
from nglib.csg import *
import nglib.csgvis as csgvis
from nglib.csgvis import MouseMove
from nglib.meshing import *
CSGeometry.VS = csgvis.VS CSGeometry.VS = csgvis.VS

View File

@ -1,16 +1,5 @@
from netgen import __platform from libngpy.geom2d import *
if __platform.startswith('linux') or __platform.startswith('darwin'): from libngpy.meshing import *
# Linux or Mac OS X
from libgeom2d.geom2d import *
# import libcsgvis.csgvis as csgvis
# from libcsgvis.csgvis import MouseMove
from libmesh.meshing import *
if __platform.startswith('win'):
# Windows
from nglib.geom2d import *
# import nglib.csgvis as csgvis
# from nglib.csgvis import MouseMove
from nglib.meshing import *

View File

@ -1,7 +1 @@
from netgen import __platform from libngpy.meshing import *
if __platform.startswith('linux') or __platform.startswith('darwin'):
# Linux or Mac OS X
from libmesh.meshing import *
if __platform.startswith('win'):
# Windows
from nglib.meshing import *