/** * Make a grid with a Linear3DSet for the volume rendering * * @param grid grid to transform * @param cs coordinate system to transform to XYZ * @return transformed grid * @throws RemoteException Java RMI Exception * @throws VisADException problem creating grid */ private FieldImpl makeLinearGrid(FieldImpl grid, CoordinateSystem cs) throws VisADException, RemoteException { Trace.call1("VRC.makeLinearGrid"); GriddedSet domainSet = (GriddedSet) GridUtil.getSpatialDomain(grid); SampledSet ss = null; boolean latLonOrder = GridUtil.isLatLonOrder(domainSet); // System.out.println("grid is latLonOrder " + latLonOrder); Trace.call1("VRC.convertDomain"); if (latLonOrder) { ss = Util.convertDomain(domainSet, RealTupleType.LatitudeLongitudeAltitude, null); } else { ss = Util.convertDomain(domainSet, RealTupleType.SpatialEarth3DTuple, null); } Trace.call2("VRC.convertDomain"); float[][] refVals = ss.getSamples(true); MapProjectionDisplay mpd = (MapProjectionDisplay) getNavigatedDisplay(); MapProjection mp = mpd.getMapProjection(); boolean mapLatLonOrder = mp.isLatLonOrder(); // System.out.println("map is latLonOrder " + mapLatLonOrder); float[][] newVals = (latLonOrder) ? refVals : new float[][] {refVals[1], refVals[0], refVals[2]}; Trace.call1("VRC.toRef"); newVals = cs.toReference(newVals); Trace.call2("VRC.toRef"); Trace.call1("VRC.scaleVerticalValues"); newVals[2] = mpd.scaleVerticalValues(newVals[2]); Trace.call2("VRC.scaleVerticalValues"); int[] lengths = domainSet.getLengths(); // Misc.printArray("lengths",lengths); GriddedSet xyzSet = GriddedSet.create( RealTupleType.SpatialCartesian3DTuple, newVals, domainSet.getLengths(), (CoordinateSystem) null, (Unit[]) null, (ErrorEstimate[]) null, false, true); Trace.call1("VRC.setSpatialDomain"); FieldImpl newGrid = GridUtil.setSpatialDomain(grid, xyzSet); // , true); Trace.call2("VRC.setSpatialDomain"); float[] lows = xyzSet.getLow(); float[] highs = xyzSet.getHi(); // Misc.printArray("lows",lows); // Misc.printArray("highs",highs); Linear3DSet volumeXYZ = new Linear3DSet( RealTupleType.SpatialCartesian3DTuple, lows[0], highs[0], lengths[0], lows[1], highs[1], lengths[1], lows[2], highs[2], lengths[2]); // System.out.println(volumeXYZ); Trace.call1("VRC.resampleGrid"); newGrid = GridUtil.resampleGrid(newGrid, volumeXYZ); Trace.call2("VRC.resampleGrid"); Trace.call2("VRC.makeLinearGrid"); return newGrid; }