cee::ug::ModelSpec

class ModelSpec

The model specification.

The model specification describes the visual content of the model. Each model owns a model specification object which can be accessed through UnstructGridModel::modelSpec().

The model specification may, for instance, contain the following settings for the model:

  • An array of state ids. (Must always be at least one state set in the model specification.)

  • A fringes result

  • A contour lines result

  • An array of vector results

  • A displacement result

  • A transformation result

  • A visibility result

  • Mode shape animation

  • An array of visible sets. (And the option to show the complement of these sets.)

  • A model color source (Color by part, set or element type.)

../_images/uml_modelspec.png

See the topic: Model

See the tutorials: UnstructGrid: A Simple Model with Results and UnstructGrid: Load Model from File and Set Up Model Specification

All settings in the model specification have a set and a get function, for instance: setFringesResultId() and fringesResultId(). In addition to all set and get functions, there is also the clear() function for resetting the model specification.

Use the metadata found in the data source directory to see available states and results.

There must always be at least one state current in the models specification. To set up an animation, all states included in the animation must be added to the model specification.

To visualize a result that has been set in the model specification, the results visibility must be toggled on in the part settings for all affected parts. Each part has its own part settings where fringes, vector and/or displacement result visibility is toggled. The transformation result does not have a visibility toggle in part settings and will always be applied to all parts as long as use transformation result is chosen in the model specification. Use PartSettings for individual parts or use the PartSettingsIterator easily iterating over all parts.

Example

Example on setting model specification based on metadata. The test model is read from a VTF file and contains multiple states, scalar results, vector results and a displacement result.

Create the model and VTFx file interface data source.

Give the data source a unique id.

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

Open the test file (contact.vtfx) included in the tutorial data files. The open() function will return true if the file was opened successfully.

Set the data source in the model.

cee::Str vtfxFile = TutorialUtils::testDataDir() + "contact.vtfx";
if (!source->open(vtfxFile))
{
    // VTFx file not found
    return;
}
ugModel->setDataSource(source.get());

After opening the file, the metadata will be available through the data source’s directory.

Get metadata for all states and set the last state as current in the model specification.

std::vector<cee::ug::StateInfo> stateInfos = source->directory()->stateInfos();
if (stateInfos.size() > 0)
{
    int lastStateId = stateInfos[stateInfos.size() - 1].id();
    ugModel->modelSpec().setStateId(lastStateId);
}

Get metadata for all available scalar results and set the first scalar to show as fringes in the model specification.

std::vector<cee::ug::ResultInfo> scalarResultInfos = source->directory()->scalarResultInfos();
if (scalarResultInfos.size() > 0)
{
    int scalarId = scalarResultInfos[0].id();
    ugModel->modelSpec().setFringesResultId(scalarId);
}

Get metadata for all available vector results and set the first vector in the model specification.

std::vector<cee::ug::ResultInfo> vectorResultInfos = source->directory()->vectorResultInfos();
if (vectorResultInfos.size() > 0)
{
    int vectorId = vectorResultInfos[0].id();
    ugModel->modelSpec().setVectorResultId(vectorId);
}

Get metadata for all available displacement results and set the first displacement in the model specification.

std::vector<cee::ug::ResultInfo> dispResultInfos = source->directory()->displacementResultInfos();
if (dispResultInfos.size() > 0)
{
    int dispId = dispResultInfos[0].id();
    ugModel->modelSpec().setDisplacementResultId(dispId);
}

Toggle on result visibility for all parts for the selected result types.

cee::ug::PartSettingsIterator it(ugModel.get());
while (it.hasNext())
{
    cee::ug::PartSettings* partSettings = it.next();
    partSettings->setFringesVisible(true);
    partSettings->setVectorsVisible(true);
    partSettings->setDisplacementVisible(true);
}

See the complete source code at: UnstructGrid: Load Model from File and Set Up Model Specification

Public Types

enum ModelColorSource

Model color source. This will determine how to color each face of the model if no fringes results are used.

Values:

enumerator PART

Use part colors (default)

enumerator SET

Use set colors.

enumerator ELEMENT_TYPE

Color by element types.

enumerator USER_PROPERY_0

Color by the first user property (index 0)

enumerator USER_PROPERY_1

Color by the second user property (index 1)

enumerator USER_PROPERY_2

Color by the third user property (index 2)

Public Functions

std::vector<int> stateIds() const

Returns an array of all current states.

See also

DataState

void setStateIds(const std::vector<int> &stateIds)

Sets the id(s) of the current state(s).

State ids must be zero or greater.

If only one state should be current, setStateId() can be used instead.

See also

DataState

void setStateId(int stateId)

Sets the id of the current state (single state).

State id must be zero or greater.

If more than one state should be current, use setStateIds() instead.

See also

DataState

int fringesResultId() const

Returns the current fringes result.

Returns -1 if no result are set as fringes.

void setFringesResultId(int fringesId)

Specifies the scalar result to show as fringes.

Specify -1 to not show any fringes.

int effectiveFringesResultId(size_t globalGeometryIndex, int partId) const

Returns the effective fringes result for the given part.

If part fringes is overridden using setOverridePartFringesResultId(), this result will be returned. Otherwise, the result set using setFringesResultId() will be returned. If no fringes are set, -1 is returned.

std::vector<int> allFringesResultIds() const

Returns an array of all fringes results set up in this model spec.

Contains both normal fringes result set by setFringesResultId() and override fringes results set using setOverridePartFringesResultId().

int overridePartFringesResultId(size_t globalGeometryIndex, int partId) const

Returns the override fringes results for this part.

Returns -1 if an override fringes result is not set.

void setOverridePartFringesResultId(size_t globalGeometryIndex, int partId, int fringesId)

Sets a fringes to override for a given part.

This will be used on this part instead of the general fringes result set by setFringesResultId().

void removeAllOverridePartFringesResultIds()

Removes all override part fringes results.

int contourLinesResultId() const

Returns the current contour lines result.

Returns -1 if no result are set as contour lines.

void setContourLinesResultId(int contourLinesId)

Specifies the scalar result to show as contour lines.

Specify -1 to not show any contour lines.

std::vector<int> vectorResultIds() const

Returns an array of current vector results.

Returns an empty array if no vector results are current.

void setVectorResultIds(const std::vector<int> &vectorIds)

Specifies the vector result(s) to show.

If only vector results should be shown, setVectorResultId() can be used instead.

void setVectorResultId(int vectorId)

Specifies the vector result to show.

If multiple vector results should be shown, use setVectorResultIds() instead.

Specify -1 to not show any vectors.

int displacementResultId() const

Returns the current displacement result.

Returns -1 if no displacements are set.

void setDisplacementResultId(int displacementId)

Specifies the displacement result to show.

Specify -1 to not show any displacements.

bool transformationResult() const

Returns true if the transformation result is set to be shown.

void setTransformationResult(bool useTransformationResult)

Specifies if the transformation result should be shown.

std::vector<int> visibleSetIds() const

Returns an array with the ids of all the visible element sets.

Returns an empty array if element filtering is not in use (default).

void setVisibleSetIds(const std::vector<int> &setIds)

Sets which element sets that will be used to determine if an element is visible or not.

If the array is non-empty, only the elements that are in one (or more) of the visible sets will be visible (assuming the showComplementOfVisibleSets() is false).

If the array is empty, all elements will be visible (default).

See also

DataElementSet

void setVisibleSetId(int setId)

Sets which element set that will be used to determine if an element is visible or not.

If setId >= 0, then only the elements that are in the visible set will be visible (assuming the showComplementOfVisibleSets() is false).

If -1, all elements will be visible.

See also

DataElementSet

bool showComplementOfVisibleSets() const

Returns true if the complement of the visible sets will be shown.

void setShowComplementOfVisibleSets(bool showComplement)

Specifies that the complement of the current visible sets will be shown.

If this option is enabled, only the elements that are NOT present in any of the visible sets will be shown.

See also

setVisibleSetIds

bool visibilityResult() const

Returns true if the visibility result is set to be shown.

void setVisibilityResult(bool useVisibilityResult)

Specifies if the visibility result should be shown.

ModelColorSource modelColorSource() const

Returns the current model color source. Default: PART (part colors)

void setModelColorSource(ModelColorSource colorSource)

Sets the model color source.

This will determine how to color each face of the model if no fringesResults are used. Default is PART (use part colors).

ModeShapeAnimation &modeShapeAnimation()

Returns the settings for mode shape animation.

const ModeShapeAnimation &modeShapeAnimation() const

Returns the settings for mode shape animation.

void clear()

Clears the model specification back to the default state.

void setDefaultResults()

Sets up the default results to load.

This will enable transformation results if present, and also load the displacement result if this is set to be loaded default by the current data source.

void removeInvalidSpecifications()

Removes specifications that are not valid.