cee::ug::DataSource Class Referenceabstract

The data source of the model. For instance a file interface or custom built by the user. More...

Public Member Functions

int id () const
 Returns the id of the data source. More...
 
size_t stateCount () const
 Returns number of states for the data source. More...
 
size_t stateIndex (int stateId) const
 Returns the index of the state with id stateId. More...
 
size_t geometryCountPerState () const
 Returns the number of geometries (per state) in the Datasource. More...
 
const DataStatestate (size_t stateIndex) const
 Returns the state at the given state index. More...
 
DataStatestate (size_t stateIndex)
 Returns the state at the given state index. More...
 
const DataStatecurrentState (const UnstructGridModel *model) const
 Returns the current state (the state in the current frame) in the given model. More...
 
DataStatecurrentState (const UnstructGridModel *model)
 Returns the current state (the state in the current frame) in the given model. More...
 
const DataSourceDirectorydirectory () const
 Returns the data directory of the data source. More...
 
DataSourceDirectorydirectory ()
 Returns the data directory of the data source. More...
 
const DataElementSetelementSet (size_t setIndex) const
 Returns a const ptr to the element set at the given index. More...
 
DataElementSetelementSet (size_t setIndex)
 Returns the element set at the given index. More...
 
size_t elementSetCount () const
 Returns the number of DataElementSets in this data source. More...
 
size_t elementSetIndex (int setId) const
 Returns the index of the element set with the given id. More...
 
void addElementSet (DataElementSet *elementSet)
 Adds an element set to this data source. More...
 
void removeElementSet (const DataElementSet *elementSet)
 Removes an element set from this data source. More...
 
void removeAllElementSets ()
 Removes all element sets from the data source. More...
 
bool isDataSourceValid (Str *failReason) const
 Validates that the data source contents matches the metadata. More...
 
int defaultDispacementResultId () const
 Returns the current state (the state in the current frame) in the given model. More...
 
bool computeCustomResults (int stateId, const DataStateSpec &stateSpec)
 Computes custom results. More...
 
- Public Member Functions inherited from cee::RefCountedObject
void addRef () const
 Increments the reference count for this object. More...
 
void release () const
 Decrements the reference count for this object. More...
 
int refCount () const
 Returns the reference count for this object. More...
 
void setRefCountZero () const
 Sets the ref count to zero, but DOES NOT delete the object. More...
 
Inheritance diagram for cee::ug::DataSource:
cee::RefCountedObject cee::ug::DataSourceInterface cee::ug::DataSourceMemory cee::imp::cae::DataSourceCae cee::ug::DataSourceMerged cee::ug::DataSourceReader cee::ug::DataSourceVTF cee::ug::DataSourceVTFx cee::imp::cae::DataSourcePhaseResponse

Detailed Description

The data source of the model. For instance a file interface or custom built by the user.

The data source contains a collection of all states for one analysis. Each state groups together geometries and results for one time step, load case, frequency etc.

Each unstructured grid model owns one data source.

DataSource is the parent class for all data sources and cannot be instantiated. DataSource contains general functions that applies to all data source types. To create a data source, use one of the subclassed versions. The data source can, for instance, be read from a supported interface or be created "by hand" from within the application.

See DataSourceInterface and DataSourceMemory.

The data source also has a directory describing the metadata for this model (DataSourceDirectory). This metadata is mostly used by the interface system.

The data source is identified with a unique id set upon construction of the object. Use id() to get the id of an existing data source.

States and directory is managed from the inherited data source classes and the main DataSource class only contains const function for querying state and directory. Get number of states using stateCount() and access individual states by calling state() with the requested state index. (For convenience, the stateIndex() function is available to convert from a state id to a state index).

In addition DataSource offers the isDataSourceValid() function to check if the data source content matches the metadata.

A DataSource has a collection of DataElementSet. These element sets are groups of elements from from different parts and geometries within the DataSource. The element sets can be used for specifying which elements that should be visible. The sets to use for filtering are specified in the ModelSpec::setVisibleSetIds() method.

Example - Creating a memory data source

Example on building your data source and geometry.

Create a model and a memory data source. The constructor of the data source takes a unique id and the number of geometries (here 1). Set the data source in the created model.

Create the state. Set number of geometries to 1 in the constructor.

int stateId = 1;
dataSource->addState(state.get());

See the complete source code at: UnstructGrid: Simple model with two triangles

Example - Reading model from file

Example on reading a model from a file interface.

Create the model and VTFx file interface data source.

Give the data source a unique id.

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());

If the file was read successfully, you will now have a complete data source with one or more states.

State info and other metadata will be available through the data source's directory.

See the complete source code at: UnstructGrid: Load model from file and set up model specification

See also
DataSourceInterface
DataSourceMemory
DataState
DataSourceDirectory
Tutorials
UnstructGrid: Simple model with two triangles
UnstructGrid: A simple model with results
UnstructGrid: Load model from file and set up model specification

Member Function Documentation

void cee::ug::DataSource::addElementSet ( DataElementSet elementSet)

Adds an element set to this data source.

A DataElementSet is used to create a group of elements (from different parts and geometries) which can be used for visual filtering (using the ModelSpec::setVisibleSetIds() method).

bool cee::ug::DataSource::computeCustomResults ( int  stateId,
const DataStateSpec stateSpec 
)

Computes custom results.

const DataState * cee::ug::DataSource::currentState ( const UnstructGridModel model) const

Returns the current state (the state in the current frame) in the given model.

Returns NULL if no current state

DataState * cee::ug::DataSource::currentState ( const UnstructGridModel model)

Returns the current state (the state in the current frame) in the given model.

Returns NULL if no current state

int cee::ug::DataSource::defaultDispacementResultId ( ) const

Returns the current state (the state in the current frame) in the given model.

Returns NULL if no current state

const DataSourceDirectory * cee::ug::DataSource::directory ( ) const

Returns the data directory of the data source.

The directory is a table of contents of the data source, indicating (possible) content. If the data source is not of type DataSourceReader, the directory should reflect the current content.

DataSourceDirectory * cee::ug::DataSource::directory ( )

Returns the data directory of the data source.

The directory is a table of contents of the data source, indicating (possible) content. If the data source is not of type DataSourceReader, the directory should reflect the current content.

const DataElementSet * cee::ug::DataSource::elementSet ( size_t  setIndex) const

Returns a const ptr to the element set at the given index.

DataElementSet * cee::ug::DataSource::elementSet ( size_t  setIndex)

Returns the element set at the given index.

size_t cee::ug::DataSource::elementSetCount ( ) const

Returns the number of DataElementSets in this data source.

size_t cee::ug::DataSource::elementSetIndex ( int  setId) const

Returns the index of the element set with the given id.

size_t cee::ug::DataSource::geometryCountPerState ( ) const

Returns the number of geometries (per state) in the Datasource.

int cee::ug::DataSource::id ( ) const

Returns the id of the data source.

bool cee::ug::DataSource::isDataSourceValid ( Str failReason) const

Validates that the data source contents matches the metadata.

The failReason string will contain an error description if validation failed.

void cee::ug::DataSource::removeAllElementSets ( )

Removes all element sets from the data source.

See also
addElementSet
void cee::ug::DataSource::removeElementSet ( const DataElementSet elementSet)

Removes an element set from this data source.

See also
addElementSet
const DataState * cee::ug::DataSource::state ( size_t  stateIndex) const

Returns the state at the given state index.

DataState * cee::ug::DataSource::state ( size_t  stateIndex)

Returns the state at the given state index.

size_t cee::ug::DataSource::stateCount ( ) const

Returns number of states for the data source.

size_t cee::ug::DataSource::stateIndex ( int  stateId) const

Returns the index of the state with id stateId.

Returns cee::UNDEFINED_SIZE_T if the state id was not found.