; Procedure "gridlines" to plot 3D gridlines for
; vrml file
;
; "xr", "yr", and "zr" are 2 element vectors of the
; low value and high value of each dimesion of the data
; array
;
; "(x,y,z)stop" are the maximum value of the axes and
; is used to terminate the line length of gridlines
;
; "numxlines", "numylines", "numzlines" are the number
; of gridlines to be plotted for each axis
;
; "mymodel" is the object that the gridlines will be
; added to.

;****************************************************
Pro gridlines, xr, yr, zr, xstop, ystop, zstop, $
 numxlines, numylines, numzlines, $
 xlineloc, ylineloc, zlineloc, mymodel

linecolor = [255,255,255] ;white

For i = 0, numxlines-1 Do Begin
   polyline_x1 = OBJ_NEW('IDLgrPolyline', $
      [xlineloc(i),xlineloc(i)], [0,ystop], [0,0], $
      COLOR=linecolor, $
      XCOORD_CONV = NORM_COORD(xr), $
      YCOORD_CONV = NORM_COORD(yr), $
      ZCOORD_CONV = NORM_COORD(zr))
   mymodel->Add, polyline_x1
EndFor

For i = 0, numxlines-1 Do Begin
   polyline_x2 = OBJ_NEW('IDLgrPolyline', $
      [xlineloc(i),xlineloc(i)], [ystop, ystop], $
      [0, zstop], $
      COLOR=linecolor, $
      XCOORD_CONV = NORM_COORD(xr), $
      YCOORD_CONV = NORM_COORD(yr), $
      ZCOORD_CONV = NORM_COORD(zr))
   mymodel->Add, polyline_x2
EndFor

For i = 0, numylines-1 Do Begin
   polyline_y1 = OBJ_NEW('IDLgrPolyline', $
      [0,xstop], [ylineloc(i),ylineloc(i)], $
      [0,0], COLOR=linecolor, $
      XCOORD_CONV = NORM_COORD(xr), $
      YCOORD_CONV = NORM_COORD(yr), $
      ZCOORD_CONV = NORM_COORD(zr))
   mymodel->Add, polyline_y1
EndFor

For i = 0, numylines-1 Do Begin
   polyline_y2 = OBJ_NEW('IDLgrPolyline', $
      [xstop,xstop], [ylineloc(i),ylineloc(i)], $
      [0, zstop], $
      COLOR=linecolor, $
      XCOORD_CONV = NORM_COORD(xr), $
      YCOORD_CONV = NORM_COORD(yr), $
      ZCOORD_CONV = NORM_COORD(zr))
   mymodel->Add, polyline_y2
EndFor

For i = 0, numzlines-1 Do Begin
   polyline_z1 = OBJ_NEW('IDLgrPolyline', $
      [0,xstop], [ystop, ystop], $
      [zlineloc(i),zlineloc(i)], $
      COLOR=linecolor, $
      XCOORD_CONV = NORM_COORD(xr), $
      YCOORD_CONV = NORM_COORD(yr), $
      ZCOORD_CONV = NORM_COORD(zr))
   mymodel->Add, polyline_z1
EndFor

For i = 0, numzlines-1 Do Begin
   polyline_z2 = OBJ_NEW('IDLgrPolyline', $
      [xstop, xstop], [0, ystop], $
      [zlineloc(i),zlineloc(i)], $
      COLOR=linecolor, $
      XCOORD_CONV = NORM_COORD(xr), $
      YCOORD_CONV = NORM_COORD(yr), $
      ZCOORD_CONV = NORM_COORD(zr))
   mymodel->Add, polyline_z2
EndFor

end