Re: Clipping Elevation surfaces -- Cutting planes

Hi Mohamad,
> The plane-layer intersection lines could be useful too.  But since
> what we have is a stack of flatfields of (x, y) --> z then "clipping"
> the layers by some plane(s) could be a useful operation and
> visualization.  So the result of clipping a layer by one or more planes
> would be a new layer which is like the original layer but minus some
> part of it.
You may want to merge your stack of FlatFields of ((x, y) -> z) into
a single 3-D FlatField with MathType ((x, y, z) -> layer) and then
take plane slices through it.  Given an array "FlatField[] layers"
in ascending or descending order and with domain Gridded2DSets all of
the same size, they can be merged by:
  int lengthZ = layers.length;
  Gridded2DSet domain2d = (Gridded2DSet) layers[0].getDomainSet();
  int lengthX = domain2d.getlength(0);
  int lengthY = domain2d.getlength(1);
  // construct array for new Gridded3DSet locations
  float[][] samples = new float[3][lengthX * lengthY * lengthZ];
  // construct array for new FlatField values
  float[][] range = new float[1][lengthX * lengthY * lengthZ];
  int offset = 0;
  for (int i=0; i<lengthZ; i++) {
    domain2d = (GriddedSet) layers[i].getDomainSet();
    float[][] dvalues = domain2d.getSamples(false); // don't copy
    float[][] rvalues = layers[i].getFloats(false); // don't copy
    // copy (x, y) locations into new Gridded3DSet locations
    System.arraycopy(dvalues[0], 0, samples[0], offset,
                     lengthX * lengthY);
    System.arraycopy(dvalues[1], 0, samples[1], offset,
                     lengthX * lengthY);
    // copy z locations into new Gridded3DSet locations
    System.arraycopy(rvalues[0], 0, samples[2], offset,
                     lengthX * lengthY);
    // set layer values for new FlatField
    for (int j=0; j<lengthX * lengthY; j++) {
      range[0][offset + j] = (float) i;
    offset += lengthX * lengthY;
  RealTupleType xyz = new RealTupleType(x, y, z);
  RealType layer = new RealType("layer");
  FunctionType ftype = new FunctionType(xyz, layer);
  Gridded3DSet dset
    new Gridded3DSet(xyz, samples, lengthX, lengthY, lengthZ);
  FlatField layers3d = new FlatField(ftype, dset);
Now layers3d is a Field that maps (x, y, z) locations to layer numbers.
You can construct a 2-D plane (constant z values, a vertical plane, or
whatever) as "Gridded3DSet plane" with manifold dimension = 2, and then
  FlatField slice
    layers3d.resample(plane, Data.WEIGHTED_AVERAGE, Data.NO_ERRORS);
will create a slice whose display will show layer numbers (interpolated
and hence fractional).  You could add this ScalarMap to the display:
  new ScalarMap(layer, Display.IsoContour)
and set it's ContourControl base = 0.0, interval = 1.0, lowlimit = -0.1
and hilimit = lengthZ - 0.9 to see the
locations of layers on "slice".

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