cee::ug::DataSourceDirectory

class DataSourceDirectory : public RefCountedObject

Metadata directory for a data source.

The data source directory contains metadata all available results (scalar, vector, displacement, transformation and visibility), geometries and parts for a data source. Each data source owns a directory object containing the metadata for the given part.

The directory contains metadata for:

  • States: stateInfos() returns an array of StateInfo for each state. A state info contains an id, a name and a reference value.

  • State Groups: stateGroupInfos() returns an array of StateGroupInfo for each state group if any. A state group info contains an id, a name and the ids of the states in it.

  • Scalar results: scalarResultInfos() return an array of ResultInfo for each available scalar results. A result info contains an id, a name and a mapping type.

  • Vector results: vectorResultInfos() returns an array of ResultInfo for each vector result. A result info contains an id, a name and a mapping type.

  • Displacement results: displacementResultInfos() returns and array of ResultInfo for each displacement result. A result info contains an id and a name. The mapping type is not used for displacement results and will be ignored.

  • Symmetric Tensor results: symmetricTensorResultInfos() returns and array of ResultInfo for each symmetric tensor result. A result info contains an id and a name.

  • Transformation result: transformationResult() returns true if a transformation result exists.

  • Visibility result: visibilityResult() returns true if a visibility result exists.

  • Parts: partInfos() returns an array of PartInfo for each part. A part info contains an id and a name.

  • Sets: setInfos() returns an array of SetInfo for each element set. A set info contains an id, a name and a description.

In addition, the data source directory also applies a query for number of geometries per state, geometryCountPerState().

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

Tutorials UnstructGrid: Load Model from File and Set Up Model Specification

See also

DataSource

Public Functions

void clear()

Clears the data source directory. Remove all result infos.

size_t geometryCountPerState() const

Returns the number of geometries per state.

SimulationInfo simulationInfo() const

Returns the ModelInfo of the DataSource.

std::vector<StateInfo> stateInfos() const

Returns an array of state info from the DataSourceDirectory.

std::vector<StateGroupInfo> stateGroupInfos() const

Returns an array of state group info from the DataSourceDirectory.

std::vector<StateInfo> ungroupedStateInfos() const

Returns the state infos that are not in any state group from the DataSourceDirectory.

std::vector<ResultInfo> scalarResultInfos() const

Returns an array of scalar result info (ResultInfo) from metadata.

std::vector<ResultInfo> vectorResultInfos() const

Returns an array of vector result info (ResultInfo) from metadata.

std::vector<ResultInfo> displacementResultInfos() const

Returns an array of displacement result info (ResultInfo) from metadata.

std::vector<ResultInfo> symmetricTensorResultInfos() const

Returns an array of the available symmetric tensor result info (ResultInfo) in the data source.

std::vector<PartInfo> partInfos(size_t globalGeometryIndex) const

Returns an array of part info (PartInfo) from metadata.

bool transformationResult() const

Returns true if a transformation result exists.

bool visibilityResult() const

Returns true if a visibility result exists.

std::vector<SetInfo> setInfos() const

Returns an array of sets from metadata.

std::vector<SectionInfo> sectionInfos() const

Returns an array of section infos from the DataSourceDirectory.

std::vector<SectionCategoryInfo> sectionCategoryInfos() const

Returns an array of section category infos from the DataSourceDirectory.

std::vector<SectionGroupInfo> sectionGroupInfos() const

Returns an array of reference section infos from the DataSourceDirectory.

A reference SectionGroup combines section from different categories to display result in all elements

std::vector<ResultInfo> resultInfos(ResultType resultType) const

Returns all the results of a given type.

std::vector<Str> resultNatures(ResultType resultType) const

Returns a vector of unique result natures found for the given resultType.

StateInfo findStateInfo(int stateId) const

Returns the state info for the state with id stateId.

If not found, will return a StateInfo object with id == -1

StateGroupInfo findStateGroupInfo(int stateGroupId) const

Returns the state group info for the state with id stateGroupId.

If not found, will return a StateInfo object with id == -1

ResultInfo findResultInfo(ResultType resultType, int resultId) const

Returns the result info for the given result type and that has id resultId.

If not found, will return an invalid ResultInfo object with id == -1

ResultInfo findScalarResultInfo(int resultId) const

Returns the result info for the scalar result with id resultId.

If not found, will return a ResultInfo object with id == -1

ResultInfo findVectorResultInfo(int resultId) const

Returns the result info for the vector result with id resultId.

If not found, will return a ResultInfo object with id == -1

ResultInfo findDisplacementResultInfo(int resultId) const

Returns the result info for the displacement result with id resultId.

If not found, will return a ResultInfo object with id == -1

ResultInfo findSymmetricTensorResultInfo(int resultId) const

Returns the result info of the specified symmetric tensor result.

Returns a result info with id = -1 if not found.

ResultInfo findResultInfo(ResultType resultType, const Str &resultIdString) const

Returns the result info for the given result type and that has an id string equal to resultIdString.

If not found, will return an invalid ResultInfo object with id == -1

ResultInfo findScalarResultInfo(const Str &resultIdString) const

Returns the result info for the scalar result that has an id string equal to resultIdString.

If not found, will return a ResultInfo object with id == -1

ResultInfo findVectorResultInfo(const Str &resultIdString) const

Returns the result info for the vector result that has an id string equal to resultIdString.

If not found, will return a ResultInfo object with id == -1

ResultInfo findDisplacementResultInfo(const Str &resultIdString) const

Returns the result info for the displacement result that has an id string equal to resultIdString.

If not found, will return a ResultInfo object with id == -1

ResultInfo findSymmetricTensorResultInfo(const Str &resultIdString) const

Returns the result info of the symmetric tensor result that has an id string equal to resultIdString.

Returns a result info with id = -1 if not found.

PartInfo findPartInfo(size_t globalGeometryIndex, int partId) const

Returns the part info for the part with id partId at geometry index globalGeometryIndex.

If not found, returns a PartInfo object with id == -1.

SetInfo findSetInfo(int setId) const

Returns the set info for the set with id setId.

If not found, returns a SetInfo object with id == -1.

SectionInfo findSectionInfo(int sectiondId) const

Returns the section info for the section with id sectionId.

If not found, returns a SectionInfo object with id == -1.

SectionCategoryInfo findSectionCategoryInfo(int categoryId) const

Returns the section category info given its id.

If not found, returns a SectionCategoryInfo object with id == -1.

SectionGroupInfo findSectionGroupInfo(int sectiondGroupId) const

Returns the section info for the section with id sectionGroupId.

If not found, returns a SectionInfo object with id == -1.

std::vector<ResultInfo> derivedScalarResultInfos(int resultId) const

Returns the list of scalar results that derive from the given result id.

std::vector<ResultInfo> derivedVectorResultInfos(int resultId) const

Returns the list of vector results that derive from the given result id.

bool hasResult(int stateId, ResultInfo info) const

Returns true if the given result exists for the given state stateId.

bool hasScalarResult(int stateId, int resultId) const

Returns true if the scalar result resultId exists for the given state stateId.

bool hasVectorResult(int stateId, int resultId) const

Returns true if the vector result resultId exists for the given state stateId.

bool hasSymmetricTensorResult(int stateId, int resultId) const

Returns true if the symmetric tensor result resultId exists for the given state stateId.

bool hasDisplacementResult(int stateId, int resultId) const

Returns true if the displacement result resultId exists for the given state stateId.

void setStateGroupInfo(StateGroupInfo info)

Sets or adds the given group info.

Assumes group’s states are valid ones.

void removeAllStateGroupInfos()

Removes all state info groups.

void setStateInfo(StateInfo info)

Updates/adds state info.

Sets or adds depending on the id of the state info.

If the id of info already exists in the state info array, the corresponding state info will be updated. Otherwise, a new state info will be added.

void addStateInfo(StateInfo info)

Adds state info.

Ensure that the state id is unique before using this function.

This function skips the check for if the state already exists to provide increased performance when adding a large number of states. If the state id is not guaranteed unique, you must use the normal setStateInfo() function!

void removeAllStateInfos()

Removes all state infos.

void setResultInfo(ResultInfo resultInfo)

Updates/adds a result info to the list of the result infos of the same type.

If the id of resultInfo already exists in the info array of the same type, the corresponding result info will be updated. Otherwise, a new result info will be added.

void removeAllResultInfos(ResultType resultType)

Removes all result infos of the given type.

void setPartInfo(size_t globalGeometryIndex, PartInfo partInfo)

Updates/adds part info.

Sets or adds depending on the id of the part info.

If the id of partInfo for the geometry given by globalGeometryIndex already exists in the part info array, the corresponding part info will be updated. Otherwise, a new part info will be added.

void removeAllPartInfos(size_t globalGeometryIndex)

Removes all part infos.

void setSetInfo(SetInfo setInfo)

Updates/adds set info.

Sets or adds depending on the id of the set info.

If the id of setInfo exists in the set info array, the corresponding set info will be updated. Otherwise, a new set info will be added.

void removeSetInfo(int setId)

Removes set info with given id.

void removeAllSetInfos()

Removes all set infos.

void setTransformationResult(bool hasTransformationResult)

Sets a transformation result.

void setVisibilityResult(bool hasVisibilityResult)

Sets a visibility result.

ElementUserPropertyInfo elementUserPropertyInfo(int index) const

Gets the element user property info for the property with the given index.

If no property info is defined for the given index, an ElementUserPropertyInfo with propertyIndex = -1 will be returned.

void setElementUserPropertyInfo(const ElementUserPropertyInfo &userPropertyInfo)

Sets information about a given element user property.

User properties are integer values that can be assigned to elements. They are used to store information about the elements that is not available in the model. For example, the user property can be used to store the the element material. The user property can be used to color the elements in the model by using the ModelSpec::setModelColorSource() method.

Each element can have up to 3 user properties, so the should be maximum 3 objects in the returned array.

See DataElements::setUserProperty() for more information.

std::vector<ResultInfo> customResultInfos() const

Returns an array of custom result infos.

void setCustomResultInfo(ResultInfo resultInfo)

Sets custom result info.

void removeCustomResultInfo(ResultInfo resultInfo)

Removes a custom result info.

std::vector<ResultInfo> customResultBaseDependencies(ResultInfo resultInfo) const

Returns an array of custom result infos.