In the past I used Matlab or Octave for visualisation of the meshes [see 3]. However, this often is a waste of time since it takes ages to display the meshes (graphics) - my laptop at home is not up to date. Using OpenGL is amazingly (very) fast. Moreover, I can use it under Windows and Linux [see 4]. The example below shows a simple mesh.
Questions
1.) How can I make the mesh visible, i.e. a black outline for each element; 2.) assure that the aspect ratio is update automatically when the user resize.
winapp
PROGRAM Triangle
INCLUDE <clearwin.ins>,nolist
INCLUDE <opengl.ins>,nolist
INTEGER i, ctrl, j
type fpl_type
integer :: NELM,NNODE
real,dimension(3,10) :: ITYPE
integer,dimension(3,10) :: NODE
real,dimension(50) :: x,y
end type fpl_type
type(fpl_type) :: fpl
double precision :: x,y
i=winio@('%es%ca[Triagular meshes with OpenGL]&')
i=winio@('%sp%ww[no_border]%og[static]%lw',
& 0, 0, 500, 500, ctrl)
!
! 1----------2
! |\\ /|
! | \\ / |
! | \\ / |
! | \\ / |
! | \\/ |
! 3----4-----5
! | /\\ |
! | / \\ |
! | / \\ |
! | / \\ |
! |/ \\|
! 6----------7
!
fpl%nelm = 6
fpl%nnode = 7
fpl%node(1:3,1) = (/1,3,4/)
fpl%node(1:3,2) = (/1,4,2/)
fpl%node(1:3,3) = (/2,4,5/)
fpl%node(1:3,4) = (/6,4,3/)
fpl%node(1:3,5) = (/6,7,4/)
fpl%node(1:3,6) = (/7,5,4/)
fpl%itype(1:3,1) = (/1.0, 0.0, 0.0/)
fpl%itype(1:3,2) = (/0.0, 1.0, 0.0/)
fpl%itype(1:3,3) = (/0.0, 0.0, 1.0/)
fpl%itype(1:3,4) = (/0.0, 0.0, 1.0/)
fpl%itype(1:3,5) = (/0.0, 1.0, 0.0/)
fpl%itype(1:3,6) = (/1.0, 0.0, 0.0/)
fpl%x(1) = 0.0d0; fpl%y(1) = 1.0d0
fpl%x(2) = 1.0d0; fpl%y(2) = 1.0d0
fpl%x(3) = 0.0d0; fpl%y(3) = 0.5d0
fpl%x(4) = 0.5d0; fpl%y(4) = 0.5d0
fpl%x(5) = 1.0d0; fpl%y(5) = 0.5d0
fpl%x(6) = 0.0d0; fpl%y(6) = 0.0d0
fpl%x(7) = 1.0d0; fpl%y(7) = 0.0d0
CALL glClearColor(0.0, 0.0, 0.0, 0.0)
CALL glClear(GL_COLOR_BUFFER_BIT)
CALL glColor3f(1.0, 1.0, 1.0)
CALL glMatrixMode(GL_PROJECTION)
CALL glLoadIdentity()
CALL glOrtho(-0.5d0, 1.5d0, -0.5d0, 1.5d0, -0.5d0, 1.5d0)
do i=1,fpl%nelm
CALL glBegin(GL_TRIANGLES)
CALL glColor3f(fpl%itype(1,i),fpl%itype(2,i),fpl%itype(3,i))
CALL glVertex2f(fpl%x(fpl%node(1,i)),fpl%y(fpl%node(1,i)))
CALL glVertex2f(fpl%x(fpl%node(2,i)),fpl%y(fpl%node(2,i)))
CALL glVertex2f(fpl%x(fpl%node(3,i)),fpl%y(fpl%node(3,i)))
CALL glEnd()
enddo
CALL glFlush()
END
References
[/URL]
[/URL]
[/URL]
[/URL]