Re: How can I display Grid and Cells ???

Hi David,

> I want to display 2d geometric cells having properties.
> The cells are represented by a scotich grid .
> the coordinates of the grid point depend on indices i and j.
> 
> (i,j)  -> (x ,y) where x = i*d[i]   y = j*dy[j]
> 
> i integer between 0 and n
> j integer between 0 and m
> 
> dx[] and dy[] floats array
> 
> first Question:
> how can I display the grid ? :  Plot a straight line between the points
> 
> 
> (X[i] , Y[j]) - ( X[i+1], Y[j] )
> (X[i] , Y[j]) - ( X[i], Y[j+1] )
> 
> 
> where X[i] = i*dx[i]
> where Y[j] = i*dy[j]
> 
> 
> 
> 
> Y
> ^
> |
> x---x-x-------x-----x--------x
> |   | |       |     |        |
> |   | |       |     |        |
> |   | |       |     |        |
> |   | |       |     |        |
> x---x-x-------x-----x--------x
> |   | |       |     |        |
> x---x-x-------x-----x--------x
> |   | |       |     |        |
> |   | |       |     |        |
> x---x-x-------x-----x--------x--> X
> 
>     Scotich Grid Displayed

The grid could be created as a Gridded2DSet, and a display
with mode.setPolygonMode(DisplayImplJ3D.POLYGON_LINE) where
mode is the GraphicsModeControlJ3D, would I think display
the grid lines. See Ugo's tutorial for more about
GraphicsModeControl.

However, you may want to draw the lines explicitly by creating
a UnionSet of Gridded3DSets or Gridded2DSets(either with manifold
dimension = 1), as in the 3-D case of visad/examples/DelaunayTest.java
(note this is a display from IrregularSets - you would need to
adapt it to your Gridded2DSet).

> The cell (i,j) is defined by points:
>     (X[i] , Y[j])  ( X[i+1], Y[j] )
>     (X[i] , Y[j+1])  ( X[i+1], Y[j+1] )
> 
> It has floats properties : (i,j) - > property
> 
> 
> Second Question:
> ===============
> How can I colorized the cells of the grid defined above according to the 
> property.
> Colorized surface enters the points:
> (X[i] , Y[j])  ( X[i+1], Y[j] ) (X[i] , Y[j+1])  ( X[i+1], Y[j+1] )
> 
> 
> p(10,10)--------------p(11,10)--------p(12,10)
> |                     |                |
> |    color 1          |    color 2     |
> |                     |                |
> p(10,09)--------------p(11,09)--------p(12,09

You may be able to do this as a texture map display
of your Gridded2DSet. This would be similar to section
3.1 of Ugo's tutorial, but with your Gridded2DSet
substituted for the Integer2DSet in the tutorial.

Another approach is to use something similar to the
approach in visad/examples/DelaunayTest.java, except that
you will construct a FieldImpl with MathType like:

  (index -> ((x, y) -> (red, green, blue)))

Where the FlatFields ((x, y) -> (red, green, blue)) have
Gridded2DSet domains, each with only 4 = 2 x 2 points (one
for each grid cell). The ScalarMaps are the usual:

  x -> XAxis
  y -> YAxis
  z -> ZAxis
  red -> Red
  green -> Green
  blue -> Blue

Good luck,
Bill


  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: