Re: VisAD polygon generation algorithm(s)

Hi Bob,

> We're (at UNH) interested in learning more about how VisAD renders data.
> We have (among others) a 128 x 128 x 128 data set -the (modified) output
> from a CAT scan of a cadaver head and we've used VisAD to render
> isosurfaces of the 3D data at uniform resolution (128 x 128 x 128). See
> http://www.cs.unh.edu/~rlaramee/pictures/head1.jpg
> for the picture (at a not so great angle).
> 
> More specifically, we're interested in how the VisAD application takes the
> raw data and outputs the polygons, not particularly the projection &
> display algorithm(s), but the polygon generation algorithm(s) itself.
> For example, does VisAD, in this case, use the Marching Cubes algorithm
> for polygon generation?  And if so, which Java classes are responsible for
> this?

Iso-surfaces are computed by the Set.makeIsoSurface() method,
which includes a marching tetrahedra implementation in
Irregular3DSet and something similar to marching cubes in
Gridded3DSet.  So you can supply your own iso-surface algorithm
by extending Gridded3DSet and implementing makeIsoSurface().
Note however that this method is not invoked directly on the
domain Set of your FlatField.  First, the makeSpatial() method
is invoked on the domain Set to get another Set whose sample
locations are in graphics space (as opposed to data space).
The signature is:

  public Set makeSpatial(SetType type, float[][] samples)
         throws VisADException;

You need to implement this method in your extension of
Gridded3DSet to return a Set of the extension class,
otherwise makeIsoSurface() will be invoked on Gridded3DSet.

> In the ideal world, we would like to be able to look at a collaboration
> graph of the Java classes and objects used to generate the polygons.
> However, we do not expect that this kind of elaborate documentation exists
> in publishible format (or perhaps at all).  Do you have any documentation
> of this nature (in any format)?  Or does anyone for that matter?

Set.makeIsoSurface() is invoked from ShadowFunctionOrSetType
and Set.makeSpatial is invoked from ShadowType.  These classes
are in turn constructed from factory methods:

  DataRenderer.makeShadowRealType()
  DataRenderer.makeShadowFunctionType()
  etc

There is a brief discussion of these classes in the Developer's
Guide, as well as some examples in visad.java2d, visad.java3d
and visad.bom (the Australian Bureau of Meteorology has been
quite active in custom DataRenderers, for manipulable wind barbs
and faster image rendering).

One of these days I will create more extensive documentation
about these things.  I am willing to answer questions on this
list if you dig into these classes.

> We are interested in being able to render isosurfaces like these at
> multiple resolutions e.g. 128 cubed, 64 cubed, etc.  And, we've written an
> application to do so.  It stores cube data in an octree data structure and
> uses each level of the octree to store a the cube data at a different
> resolution e.g. the lowest level of the octree, the leaf nodes, store cube
> data at the highest resolution (128 x 128 x 128).  The cube data
> represents the original 3D grid of raw data -stored this way so we can
> generate polygons with the marching cubes algorithm.
> 
> However, what our program lacks is not the polygon generation algorithm(s)
> but the nice display algorithms that VisAD has, e.g. we have no shading
> model implemented, or texture mapping.  So ideally what we like to be able
> to do is add our polygon generation algorithm to VisAD and let VisAD do
> the rest so-to-speak.
> 
> But in order to do that, we need to know how VisAD is generating the
> polygons.  And it's since it's kind of a mammoth of a program, we're not
> sure where to start the investigation.  I've read the VisAD Developers
> Guide, and I could try a brute force approach of looking through the
> classes in an attempt to figure it out from scratch.  However, if I can
> avoid that approach, I will.  Does anyone have any suggestions or other
> documentation like a collaboration diagram of some sort?  Maybe VisAD
> already has an octree data structure somewhere that we can use.  Maybe
> there's already a marching cubes algorithm written here.  Of course the
> online API is excellent.  We're just looking for some guidance to sort
> through it a little bit.

We would be very interested to see octree or multi-resolution
algorithms available for VisAD and so will be happy to advise
you.  I think an extension of Gridded3DSet may be appropriate.
The question is whether values of dependent variables (range
values of Fields) at coarser resolutions are derived from the
high resolution values, and how you want interpolation of
dependent values to work (or if you care about interpolation
and resampling)?

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html