netgen/py_tutorials/csg_first_example.py

66 lines
1.7 KiB
Python
Raw Normal View History

2014-10-06 20:44:06 +06:00
from netgen.csg import *
import netgen.meshing as meshing
2014-10-01 19:52:58 +06:00
2015-01-23 16:01:04 +05:00
#from OpenGL.GL import *
#from OpenGL.GLU import *
#from OpenGL.GLUT import *
2014-10-01 19:52:58 +06:00
2014-10-07 02:01:44 +06:00
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)
2015-01-23 16:01:04 +05:00
all = sp1+sp2+sp3+sp4
2014-10-01 19:52:58 +06:00
geom = CSGeometry()
geom.Add (all)
2014-10-10 17:18:51 +06:00
2015-01-23 16:01:04 +05:00
#vis = VS(geom)
2014-10-07 02:01:44 +06:00
# vis.Draw()
2015-01-23 16:01:04 +05:00
#window = 0 # glut window number
#width, height = 500, 500
2014-10-07 02:01:44 +06:00
2015-01-23 16:01:04 +05:00
#def mydraw():
# glViewport(0, 0, width, height);
# glMatrixMode(GL_PROJECTION);
# glLoadIdentity();
# pnear = 0.1;
# pfar = 10;
# gluPerspective(20.0, 1.0*width / height, pnear, pfar);
# glMatrixMode(GL_MODELVIEW);
# glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
2014-10-07 02:01:44 +06:00
# glLoadIdentity()
# gluLookAt (0, 0, 6, 0, 0, 0, 0, 1, 0);
## glBegin(GL_QUADS)
## glColor4d(0.0, 1.0, 0.0, 0.0);
## glVertex3d(0.0,0.0,0.7)
## glVertex3d(1.0,0.0,2.1)
## glColor4d(1.0, 1.0, 1.0, 0.0);
## glVertex3d(1.0,1.0,0.2)
## glVertex3d(0.0,1.0,0.5)
## glEnd()
2015-01-23 16:01:04 +05:00
# vis.Draw()
# glutSwapBuffers()
#glutInit("mainwin") # initialize glut
#glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
#glutInitWindowSize(width, height) # set window size
#glutInitWindowPosition(0, 0) # set window position
#window = glutCreateWindow(b"ngs") # create window with title
2014-10-07 02:01:44 +06:00
#glutDisplayFunc(vis.Draw) # set draw function callback
2015-01-23 16:01:04 +05:00
#glutIdleFunc(mydraw) # draw all the time
#glutMainLoop()
2014-10-01 19:52:58 +06:00
2015-01-23 16:01:04 +05:00
param = meshing.MeshingParameters(maxh=0.2)
mesh = GenerateMesh (geom, param)
mesh.Save ("test.vol")