6.8.2. Texture Preprocessor

The texture preprocessor class, SoTVizTexturePreprocessor , is able to read and process multiple and different image file formats. This class requires that each input file have geo-referencing data. This information can be embedded in formats like GeoTiff, but must be provided for classic raster formats. In this case, the geo-reference data is passed using the addFile() method.

The supported input image file formats are: GeoTiff and Tiff-Tfw. The classic raster formats (RGB, SGI, TIFF, ...) must have separate geo-referencing information in a geodetic coordinate system. Geodetic is the horizontal and vertical position. The positions are commonly UTM x/y/z or latitude, longitude, elevation triplets.

Texture preprocessing

Figure 6.13. Texture preprocessing



Overlay textures

Overlay textures can be useful for adding linear information like roads, rivers... and surface information like specific zones, lakes... These textures act like transparent layers. As PNG is a graphic format supporting transparency, it can be used to save overlays. These overlays are mapped on every texture of the resulting quadtree. Therefore, for good quality at every level, you should use the same resolution as the highest resolution input texture for overlays.

Texture files can cover overlapping geographic zones, but there is no need for them to be of same resolution because the preprocessor will generate a quadtree of textures, each level having different resolution files. If a texture to be generated has partial information (pixels) only, the missing part will be black.

This class outputs a quadtree of textures saved as PNG files. It also fills the XML file with the information related with all textures. Then this XML file can be loaded by an SoTVizRender node.

Classic raster files need geo-referencing to be processed.

Preprocessing

Figure 6.14. Preprocessing



Example 6.6. A simple example using preprocessors

// Define region of interest in radians (geodetic system)
  SbBox2d roi = SbBox2d(0.1186839, 0.8003812, 0.1256317, 0.8049435);
  SoTVizDataPreprocessor *dataPreProc = new SoTVizDataPreprocessor;
  dataPreProc->setDestDirectory(SbString("preprocessing/results"));
  dataPreProc->setRegion(roi, SoTVizPreprocessor::TVIZ_RADIANS);

// Add Dted level 1 files
  dataPreProc->addFile(SbString("dted1/E005/N42.DT1"));
  dataPreProc->addFile(SbString("dted1/E005/N43.DT1"));
  dataPreProc->addFile(SbString("dted1/E005/N44.DT1"));
  dataPreProc->addFile(SbString("dted1/E006/N42.DT1"));

// Run elevation preprocessing
  dataPreProc->process();

// Update the xml file for data
  dataPreProc->writeToXML(SbString("preproc.xml"));

  SoTVizTexturePreprocessor *texPreProc = new SoTVizTexturePreprocessor;
  texPreProc->setDestDirectory(SbString("preprocessing /results"));
  texPreProc->setRegion(roi, SoTVizPreprocessor::TVIZ_RADIANS);

// Add geotiff files (geo-referenced)
  texPreProc->addFile(SbString("geotiff/gtif101.tif"));
  texPreProc->addFile(SbString("geotiff/gtif201.tif"));
  texPreProc->addFile(SbString("geotiff/gtif301.tif"));

// Add classic raster files + geo-referencing in degrees (geodetic system)
  texPreProc->addFile(SbString("raster/img0.jpg"),
  SbVec2d(6.7879773919169, 45.9273822525406), SbVec2d(1., 0.),
  SbVec2d(0.00013358093905113, 0.00013376360517160),
  SoTVizPreprocessor::TVIZ_DEGREES);
  texPreProc->addFile(SbString("raster/img1.bmp"),
  SbVec2d(7.0879773919169, 43.073822525406), SbVec2d(1., 0.),
  SbVec2d(6.6757841059749E-05, 6.6759532379977E-05),
  SoTVizPreprocessor::TVIZ_DEGREES);

// Add overlay raster file (patterns with transparency) + geo-referencing
// in degrees (geodetic system)
  texPreProc->addOverlayFile(SbString("raster/overlay.png"),
  SbVec2d(6.9, 45.9), SbVec2d(1., 0.),
  SbVec2d(1./1024., 1./1024.),
  SoTVizPreprocessor::TVIZ_DEGREES);

// Do not allow resulting textures to be greater than 2048*2048 (pixels)
  texPreProc->setMaxTextureSize(2048);

// Run texture preprocessing
  texPreProc->process();

// Update the xml file for texture quadtree
  texPreProc->writeToXML(SbString("preproc.xml"));