9.2 Exporting


HOOPS Visualize can export a few different types of file formats. Regardless of the file type, a similar pattern is employed. For this example we will talk about HSF files, as they are the native file format for HOOPS Visualize. See the Programming Guide sections on Exchange integration and Parasolid integration for information on exporting via HOOPS Exchange and Parasolid, respectively.

When exporting data, HSFs can be written from any arbitrary segment. This means that the entire scene can be saved by writing from the window segment. Alternatively, a portion of the scene can be written if only a piece of a model needs to be saved. Note that when saving partial scenes, attributes inherited by the branch root are not saved with the HSF. If you wish to save attributes into the HSF, they must be explicitly set within the branch you are exporting.

The basic method for exporting a model to HSF is shown below:

[snippet 9.2.a]
try
{
exportOptionsKit.SetColorCompression(true, 16);
HPS::Stream::File::Export(filename, mySegmentKey, exportOptionsKit).Wait();
}
catch (IOException ioe)
{
// handle exception
throw;
}
try
{
exportOptionsKit.SetColorCompression(true, 16); // color compression ranges from 0 to 72
HPS.Stream.File.Export(filename, mySegmentKey, exportOptionsKit);
}
catch (HPS.IOException ioe)
{
// handle exception
}

The HPS::Stream::ExportOptionsKit has a variety of lossy compression options. Color compression is enabled in the snippet above as an example of how to specify compression.

IMPORTANT: All file exports are done synchronously, except for HSF stream files. Do not try to export on a separate thread while the scene graph can be modified, because the scene graph must be in a write-locked state during the export.

For HSF files, the HPS::Stream export operation will happen on a separate thread. Do not modify the subtree while the export is occurring. When exporting stream files, you should use a HPS::Stream::ExportNotifier to control the export operation. For example, you can call:

If you cancel a file export, you are responsible for cleaning up the partially exported file on disk.