File: csg_first_example.py

package info (click to toggle)
netgen 6.2.2501%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,980 kB
  • sloc: cpp: 165,197; tcl: 6,310; python: 2,804; sh: 522; makefile: 87
file content (65 lines) | stat: -rw-r--r-- 1,779 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from netgen.csg import *
import netgen.meshing as meshing

#from OpenGL.GL import *
#from OpenGL.GLU import *
#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)

all = sp1+sp2+sp3+sp4


geom = CSGeometry()
geom.Add (all)



#vis = VS(geom)
# vis.Draw()


#window = 0                                             # glut window number
#width, height = 500, 500



#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)
#    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()
#    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
#glutDisplayFunc(vis.Draw)                                 # set draw function callback
#glutIdleFunc(mydraw)                                     # draw all the time
#glutMainLoop()        

param = meshing.MeshingParameters(maxh=0.2)
mesh = GenerateMesh (geom, param)
mesh.Save ("test.vol")