py visualization

This commit is contained in:
Joachim Schoeberl 2014-10-10 11:18:51 +00:00
parent 34b90d5254
commit c1935691e2
3 changed files with 36 additions and 8 deletions

View File

@ -21,6 +21,7 @@ geom = CSGeometry()
geom.Add (all)
vis = VS(geom)
# vis.Draw()

View File

@ -1,5 +1,6 @@
from netgen.csg import *
import netgen.meshing as meshing
import libvisual
from OpenGL.GL import *
from OpenGL.GLU import *
@ -9,18 +10,22 @@ from OpenGL.GLUT import *
sp1 = Sphere (Pnt(0,0,0), 0.2)
sp2 = Sphere (Pnt(0.5,0,0), 0.2)
sp3 = Sphere (Pnt(0,0,0.5), 0.2)
sp4 = Sphere (Pnt(0,0.2,0.7), 0.2)
sp5 = Sphere (Pnt(0,0,0.3), 0.2)
all = sp1+sp2+sp3+sp4+sp5
all = sp1+sp2
geom = CSGeometry()
geom.Add (all)
param = meshing.MeshingParameters()
param.maxh = 0.1
m1 = GenerateMesh (geom, param)
vismesh = libvisual.meshvis.VS(m1)
vis = VS(geom)
# vis.Draw()
@ -44,7 +49,8 @@ def myMotionHandler( x, y ):
MouseMove(vis,xold,yold, x,y, mode) # 'm','z'
xold = x
yold = y
mydraw()
glutPostRedisplay()
# mydraw()
def myPassiveMotionHandler( x, y ):
global xold, yold
@ -87,7 +93,17 @@ glMatrixMode(GL_MODELVIEW);
glutMainLoop()
glutMainLoop()
# import threading
# threading.start_new_thread (glutMainLoop, [])
# from threading import Thread
# thread = Thread(target = glutMainLoop)
# thread.start()
# thread.join()

View File

@ -2,7 +2,8 @@ from netgen import __platform
if __platform.startswith('linux') or __platform.startswith('darwin'):
# Linux or Mac OS X
from libcsg.csg import *
from libcsgvis.csgvis import *
import libcsgvis.csgvis as csgvis
from libcsgvis.csgvis import MouseMove
import libmesh.meshing
# from libmesh.meshing import *
if __platform.startswith('win'):
@ -10,3 +11,13 @@ if __platform.startswith('win'):
from nglib.csg import *
from nglib.csgvis import *
from nglib.meshing import *
CSGeometry.VS = csgvis.VS
del csgvis
def VS (obj):
return obj.VS()