Preserve your model config using VTFx and properties

The Export component in CEETRON Envision for Desktop adds easy sharing of simulation results using the Ceetron VTFx format. With a few lines of code, you can export exactly what you have on the screen to a compact file that can be shown on almost any platform. You can upload the VTFx file to Ceetron Cloud and share and view it directly in the web browser on any device.

If you are working on an UnstructGridModel and want to export your current model configuration to a VTFx file, you can achieve this using properties. Properties are, for instance, which state to show initially, camera setup, which results to load, part settings, cutting planes, +++.

Code Example: Exporting Setup to VTFx

cee::exp::ExportVTFx exporter(cee::exp::ExportVTFx::DISPLAY_MODEL_ONLY, model);

// Add properties from the view and the model
{
    cee::PtrRef<cee::PropertySetCollection> propColl = new cee::PropertySetCollection;
    cee::PtrRef<cee::ImageResources> resources = new cee::ImageResources;
    cee::exp::PropertyBuilderVTFx propBuilder(propColl.get(), resources.get());
    propBuilder.addFromModel(*model);
    propBuilder.addFromView(*view);
    exporter.addProperties(*propColl);
    exporter.addResources(*resources);
}

// Optionally, add a thumbnail image
{
    PtrRef<cee::vis::Image> thumbNailImg = new cee::Image;
    view->renderToImage(640, 480, thumbNailImg.get());
    exporter.setSnapshotImage(thumbNailImg.get());
}

exporter.setVendorNameAndApplication("MyCompany", "MyApp");

exporter.saveCase(myFilename);

Your setup is now preserved, and when you open this VTFx file in any CEETRON viewer on desktop or web, it will look the same as the original.

Opening VTFx Model File with Properties

To open a VTFx model file with properties in your app, use the following code:

cee::PtrRef<cee::PropertySetCollection> propertyCollection = new cee::PropertySetCollection;
cee::PtrRef<cee::ImageResources>        imgResources = new cee::ImageResources;
cee::ug::PropertyApplierVTFx            propApplier(propertyCollection.get(), imgResources.get());
cee::ug::DataSourceVTFx*                vtfxDataSource = NULL;

if (applyPropertiesIfPresent)
{
    cee::ug::DataSource* source = currentModel->dataSource();
    vtfxDataSource = dynamic_cast<cee::ug::DataSourceVTFx*>(source);

    if (vtfxDataSource)
    {
        vtfxDataSource->caseProperties(propertyCollection.get(), imgResources.get());
    }

    if (propertyCollection->count() > 0)
    {
        propApplier.applyToModel(currentModel);
        propApplier.applyToView(currentView);
    }

This will open the VTFx file and load the preset model and view properties.

For instance, from CEETRON Analyzer, export to VTFx:

Open file on the web:

1 Like