Append case to VTFx

This example opens an existing VTFx file in append mode and adds an additional case to it.

The appended case uses the same database, and sets the following properties:

  • Part 1: draw style set to line
  • Part 2: set color and opacity

The VTFx file can now be opened in a viewer supporting multiple cases (for instance Ceetron 3D Viewer). It will contain two cases. The first (unchanged) case and in addition the newly appended case with modified draw style and opacity.

// Create the VTFx file
// -------------------------------------------------------------------------
cee::Str fileName = "ExampleAppend.vtfx";
// Make copy original file
std::ifstream src("../../DemoFiles/SimpleExample.vtfx", std::ios::binary);
if (!src.good())
{
return EXIT_FAILURE;
}
std::ofstream dst(fileName.toStdString().c_str(), std::ios::binary);
dst << src.rdbuf();
src.close();
dst.close();
if (!file->openForAppend(fileName))
{
return EXIT_FAILURE;
}
// Get the first database from file
// Create a single case (could have many)
// -------------------------------------------------------------------------
cee::PtrRef<cee::vtfx::Case> newCase = new cee::vtfx::Case(file.get(), "Appended Case", file->unusedFileCaseId(), db->id());
if (!createProperties(newCase.get()))
{
return EXIT_FAILURE;
}
// Finally close the file
// -------------------------------------------------------------------------
if (!file->close())
{
return EXIT_FAILURE;
}
std::cout << "Exported successfully to file: " << fileName.toStdString() << std::endl;
std::cout << std::endl << "Press enter to exit..." << std::endl;
std::cin.ignore();
return EXIT_SUCCESS;