NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Error on 3D IsoSurfaces

Im trying to do isosurfaces on 3d data; im following the examples in
test01 and test59;
i get the following VisAD Exception:

java.lang.NullPointerException
        at visad.Irregular3DSet.makeSpatial(Irregular3DSet.java:179)
        at visad.ShadowType.assembleSpatial(ShadowType.java:1678)
        at
visad.ShadowFunctionOrSetType.doTransform(ShadowFunctionOrSetType.java:1
605)
        at
visad.java3d.ShadowFunctionOrSetTypeJ3D.doTransform(ShadowFunctionOrSetT
ypeJ3D.java:102)
        at
visad.java3d.DefaultRendererJ3D.doTransform(DefaultRendererJ3D.java:86)
        at visad.java3d.RendererJ3D.doAction(RendererJ3D.java:180)
        at visad.DisplayImpl.doAction(DisplayImpl.java:852)
        at visad.ActionImpl.run(ActionImpl.java:186)
        at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:86)

here's the jist of the code:

    int sizeX = xaxis.getNumElements();
    int sizeY = yaxis.getNumElements();
    int sizeZ = zaxis.getNumElements();

    int[] index = {0, 0, 0};
    float[][] xyz = new float[3][(int) arr.getSize()];
    float[][] f = new float[1][(int) arr.getSize()];

    long startTime = System.currentTimeMillis();
    for (int k=0; k<sizeZ; k++) {
     for (int j=0; j<sizeY; j++) {
      for (int i=0; i<sizeX; i++) {
        int elem = i + (j + k*sizeY)*sizeX;
        index[0] = k;
        index[1] = j;
        index[2] = i;
        f[0][elem] = arr.getFloat(index);

        xyz[0][elem] = (float) xaxis.getCoordValue(i);
        xyz[1][elem] = (float) yaxis.getCoordValue(j);
        xyz[2][elem] = (float) zaxis.getCoordValue(k);
      }
     }
    }

    RealType xtype = VisUtil.RealTypeFactory(xname);
    RealType ytype = VisUtil.RealTypeFactory(yname);
    RealType ztype = VisUtil.RealTypeFactory(zname);
    RealType ftype = VisUtil.RealTypeFactory(fname);

    RealTupleType xyzType = new RealTupleType(xtype, ytype, ztype);
    FunctionType ft = new FunctionType(xyzType, ftype);

    Gridded3DSet xyzSet = new Gridded3DSet(xyzType, xyz, nx, ny, nz);
    FlatField ffld = new FlatField(ft, xyzSet);
    ffld.setSamples(f);

    // create a DataReference
    DataReference setRef = new DataReferenceImpl("Visad_DataReference");
    setRef.setData(ffld);

    // create a Display using Java3D
    DisplayImpl display = new DisplayImplJ3D("Visad3D_Display");

    // map plot to display coordinates
    display.addMap(new ScalarMap(xtype, Display.XAxis));
    display.addMap(new ScalarMap(ytype, Display.YAxis));
    display.addMap(new ScalarMap(ytype, Display.ZAxis));

    display.addMap(new ScalarMap(ftype, Display.IsoContour));


    // link the Display to the data
    display.addReference(setRef);

    // add axes
    GraphicsModeControl mode = display.getGraphicsModeControl();
    mode.setScaleEnable(true);

    // return a JComponent of preferred size
    JComponent c = (JComponent) display.getComponent();
    c.setPreferredSize(displaySize);
    return c;


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