Re: Contouring and Flow vector access

Hi Edward,

You can extract geometry data from VisAD scene graphs, and in fact
there is a long discussion thread about this issue in Unidata's
VisAD mailing list archive:

under the subject "Delaunay and Java3D".

Basically, in a DisplayImplJ3D you do something like:

  ScalarMap xmap = new ScalarMap(whatever, Display.XAxis);
  xmap.setRange(-1.0, 1.0); // also need this for any ScalarMaps
                            // to YAxis or ZAxis, to make sure
                            // display values equal data values
  DefaultRendererJ3D contour_renderer = new DefaultRendererJ3D();
  display.addReferences(contour_renderer, contour_data_ref);
  DefaultRendererJ3D flow_renderer = new DefaultRendererJ3D();
  display.addReferences(flow_renderer, contour_data_ref);

  DisplayListener listener = new YourDisplayListenerClass();

Then in the displayChanged() method of listener:

  if (e.getId() == DisplayEvent.TRANSFORM_DONE) {
    BranchGroup contour_branch = contour_renderer.getBranch();
    BranchGroup flow_branch = flow_renderer.getBranch();
    // now the Shape3Ds you want are the children or
    // grandchildren or greatgrandchildren of these branchs
    // (I'm not sure which offhand)
    // then:

    LineArray contour_geometry
      (LineArray) contour_shape.getGeometry();
    int ncontour_vertices = contour_geometry.getVertexCount();
    float[] contour_coordinates = new float[3 * ncontour_vertices];
    contour_shape.getCoordinates(0, contour_coordinates);
    // now each group of six values in contour_coordinates defines
    // a line segment of the contours: x1, y1, z1, x2, y2, z2
    // do not enable contour labels, or your line segments will
    // include the font strokes for the label characters

    // similarly for flow, but note they will include line segments
    // for the little arrow heads in addition to the arrow shafts

Good luck,

Edward Stanford wrote:
> Hello, everyone,
>         I need to use VisAD to generate contours and flow maps of a dataset, 
> and
> then import those contours into a GIS application.  To do this, it would be
> extremely convenient to be able to get the list of vector points describing
> the contours.  My other alternative is to create a display, plot the
> contours, extract a bitmap, set the bitmap background to something
> transparent, and import the result into my GIS application.  This seems
> awkward at best.
>         Looking at the javadoc, I didn't see any obvious accessors.  Looking 
> at
> the source code, I found a static method contour( long parameter list ) in
> which ignores all the type safety restrictions of the VisAD
> data model, but which otherwise appears to give me what I need.  Still, I
> can't help but think that there must be a better way, especially since this
> doesn't extend to flows anyway.
>         I'm perfectly happy to extend the source code myself, if the necessary
> accessors don't exist, but I sure would appreciate any pointers anyone can
> give me as to where/how contours and flows are calculated for a
> display.  greps for contour and flow in the source tree didn't flash any
> obvious neon signs.
>         Edward

Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738

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