UnstructGrid: Create an isosurface

An isosurface is a surface defined of an area with a constant value within a volume of space.

Isosurfaces may be derived based on any scalar variable. In addition, scalar fringes can be mapped onto the isosurface, showing for instance the variation of temperature over a surface of Constant pressure. Any number of isosurfaces can be defined and displayed, and various display attributes can be set separately for each one.

This tutorial shows how to create an isosurface based on a scalar result id and a scalar value. In addition, the scalar result will be shown as fringes on the isosurface.


The demo file (contact.vtfx) contains a geometry with four parts. This tutorial will use the displacement result to define the isosurface.

Load the file and setup the model specification to show the result. For a more thorough explanation on creating a data source from a file interface and setup the model specification, see the Load VFTx tutorial: UnstructGrid: Load model from file and set up model specification


This tutorial expect the application to have a correctly configured cee::vis::View in place. See demo applications on how to set up a cee::vis::View in your application.

Load model

Create the model and a VTFx file interface data source. Open the file and set the created data source in the model.

    cee::PtrRef<cee::ug::UnstructGridModel> ugModel = new cee::ug::UnstructGridModel();
    cee::PtrRef<cee::ug::DataSourceVTFx> source = new cee::ug::DataSourceVTFx(42);

    cee::Str vtfxFile = TutorialUtils::testDataDir() + "contact.vtfx";
    if (!source->open(vtfxFile, 0))
        // VTFx file not found


Set the fourth state as current in the model specification. (The displacement is zero in the first state.)

    std::vector<cee::ug::StateInfo> stateInfos = source->directory()->stateInfos();
    int stateId = stateInfos[3].id();

Create the isosurface

The isosurface is defined by a scalar result id and a iso scalar value.

Create the isosurface object. Remember that the object is reference counted and should not be created on the stack.

    cee::PtrRef<cee::ug::Isosurface> isoSurface = new cee::ug::Isosurface();
    std::vector<cee::ug::ResultInfo> resultInfos = source->directory()->scalarResultInfos();
    int scalarId = resultInfos[0].id();

Set the scalar result to be shown as mapped fringes on the isosurface surface.


Add the isosurface to the model.


To get a better view of the cutting plane inside the model, set all normal parts draw style to LINES.

    cee::ug::PartSettingsIterator it(ugModel.get());
    while (it.hasNext())
        cee::ug::PartSettings* partSettings = it.next();

Set up the created model

The model is ready to use and can be added to the view. Exactly where the view exists depends on the platform and solution. These examples uses Qt and the view is set up in a cee::qt::ViewerWidget.

    cee::vis::View* gcView = getTutorialView();

See the complete source code here:

UnstructGrid: Create an isosurface