UnstructGrid: Set vector settings on a loaded model

The vector result can be configured to make a better visual appearance of your result data, for instance settings such as scaling and coloring.

This example will show the vector result on the model, and set some vector settings for demonstration.

  • Set the relative scaling to 0.2.

  • Set single vector color to yellow.

The demo model file (10x10x10.vtf) contains a simple geometry and a vector result.

void TutorialRunnerMainWindow::setVectorSettings()
    // Load a UnstructGridModel from file and set a vector result
    // Apply some vector settings

    // Create the model and data source
    cee::PtrRef<cee::ug::UnstructGridModel> ugModel = new cee::ug::UnstructGridModel();
    cee::PtrRef<cee::ug::DataSourceVTF> source = new cee::ug::DataSourceVTF(42);

    // Open the vtf file
    cee::Str vtfFile = TutorialUtils::testDataDir() + "10x10x10.vtf";
    if (!source->open(vtfFile))
        // VTF file not found

    // Add the data source to the model

    // Set the first state as current
    std::vector<cee::ug::StateInfo> stateInfos = source->directory()->stateInfos();
    int stateId = stateInfos[0].id();

    // Show the vector result on the model
    std::vector<cee::ug::ResultInfo> vectorResultInfos = source->directory()->vectorResultInfos();
    int vectorId = vectorResultInfos[0].id();

    // Set vector visible for all parts
    cee::ug::PartSettingsIterator it(ugModel.get());
    while (it.hasNext())
        cee::ug::PartSettings* partSettings = it.next();

    // Get vector settings for the current vector result
    cee::ug::VectorSettings* settings = ugModel->vectorSettings(vectorId);

    // Set relative scaling to 0.2
    settings->setScaleFactor(cee::ug::VectorSettings::RELATIVE_SCALING, 0.2);

    // Set single vector coloring to yellow for all vectors
    settings->setSingleVectorColor(cee::Color3f(1.0, 1.0, 0.0));
    // Add model to view. Ensure that old models are removed first
    cee::vis::View* gcView = getTutorialView();


    cee::BoundingBox bb = gcView->boundingBox();
    gcView->camera().fitView(bb, cee::Vec3d(0, 0, -1), cee::Vec3d(0, 1, 0));