6.3. Management of Holes (Undefined Data)

Sometimes when sampling a terrain for altitudes, some regions of the surface are not or cannot be measured. In the resulting elevation file, some values are undefined because there are no measurements for them. Usually these undefined elevations are set to a specific value outside the range of measured values. As these undefined values are not useful, the goal is to not display these areas.

A terrain may drop into the sea, and only the part above water is of interest. As the sea altitude is zero, we might like to avoid displaying the mesh over the water.

Another goal could be to cut off the terrain above or below a certain altitude in order to restrict the terrain to a single slice.

These are all scenarios in which hole management would be helpful. The specific task of hole management is to work with undefined values and/or to remove parts of above/below/at a fixed altitude.

Holes apply to SbTVizData objects.

To set a hole value use: SbTVizData::setHoleValue(float holeValue, Condition cond) where holeValue specifies the hole value, and cond specifies whether values lower, greater, or equal to holeValue are considered to be holes and thus discarded.

The hole contour quality can be adjusted to have precise edges (uses more triangles) or rougher contours (saves triangles for rendering the displayed parts of the terrain).

Use SbTVizData::setHoleEdgePrecision(float holeRes) to specify the contour quality, which can range from 0 to 1 (best quality).

Contour quality can drop very quickly when decreasing the contour quality.

Hole contour qualities (left, quality is 0.5; right, quality is 1.0)

Figure 6.3. Hole contour qualities (left, quality is 0.5; right, quality is 1.0)



Example 6.2. A simple example illustrating hole management

// Loads the elevation data
  SbTVizRegularGridData* data = new SbTVizRegularGridData();
  SbBool loadStatus = data->loadDataFile("data/susanville.dat",
  SbVec3d(1./599., 1./599., 0.2/599.),
  SbVec3d(0., 0., 0.));

// Remove all terrain parts below a value of 10.
  int holeLevel = 10.;
  data->setHoleValue(holeLevel, SbTVizData::TVIZ_LOWER);
  data->setHoleEdgePrecision(1.);

  dtmRender->setData(data);
...