cee::ug::DataElementSet Class Reference

A DataElementSet is a set of unique elements within a DataSource. More...

Public Member Functions

 DataElementSet (int setId)
 Constructs an empty element set. More...
 
 DataElementSet (const DataElementSet &other, int setId)
 Constructs an element set as a copy of /a other. More...
 
bool isEqual (const DataElementSet &rhs) const
 Returns true if the other set has the same items as this set. More...
 
int id () const
 Returns the id of the data element set. More...
 
size_t itemCount () const
 Returns the number of DataElementSetItem's in the set. More...
 
size_t itemIndex (const DataElementSetItem &item) const
 Returns the index of the given item. More...
 
DataElementSetItem item (size_t index) const
 Returns the item at the given index. More...
 
void addItem (const DataElementSetItem &item)
 Adds the given item to the set. More...
 
void addItems (int geometryId, int partId, const std::vector< size_t > &elementIndices)
 Adds a list of elements to the set. More...
 
void removeItem (const DataElementSetItem &item)
 Removes the given item from the set. More...
 
void removeAllItems ()
 Removes all items from the set. More...
 
std::vector< size_t > elementIndicesForPart (int geometryId, int partId) const
 Returns all element indices for the given geometryId and partId. More...
 
void unionWith (const DataElementSet &other)
 Adds all the items in the given "other" set to this set. More...
 
void intersect (const DataElementSet &other)
 Removes any item that is not present in both sets. More...
 
void subtract (const DataElementSet &other)
 Removes all the items in the given "other" set from this set. 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::DataElementSet:
cee::RefCountedObject

Detailed Description

A DataElementSet is a set of unique elements within a DataSource.

This set can be used to filter the visible elements in an UnstructGridModel.

The set items are identified by the DataElementSetItem class, which identifies an element within the data source. The element is identified by:

Creating sets

The contents of the set can be added manually or created by the DataElementSetGenerator.

The sets supports standard boolean set operations: Union, intersect and subtract.

Note
The set stores the items in a sorted order for performance reasons. This means that the indices of the items in the set will change whenever the content of the set is modified. Please keep this in mind when using the itemIndex() and item() methods.
Using sets

In order to use the set, you need to add it to the DataSource of the UnstructGridModel. You add the set with the DataSource::addElementSet() method. When a set is added to the DataSource, it can be used for filtering as described in the next paragraph.

Filtering: Using sets to control visible elements

The main usage of the sets is filtering visible elements within a model. You can specify which set(s) should be visible in the ModelSpec with the ModelSpec::setVisibleSetIds method.

The union of all the sets specified in the ModelSpec::visibleSetIds() will define the visible elements for this model.

See also
DataElementSetItem
DataElementSetGenerator
ModelSpec
DataSource

Constructor & Destructor Documentation

cee::ug::DataElementSet::DataElementSet ( int  setId)

Constructs an empty element set.

Specify a unique id.

cee::ug::DataElementSet::DataElementSet ( const DataElementSet other,
int  setId 
)

Constructs an element set as a copy of /a other.

Specify a unique id.

Member Function Documentation

void cee::ug::DataElementSet::addItem ( const DataElementSetItem item)

Adds the given item to the set.

If the item is already present, the set remains unchanged

void cee::ug::DataElementSet::addItems ( int  geometryId,
int  partId,
const std::vector< size_t > &  elementIndices 
)

Adds a list of elements to the set.

This is a much faster way to add a lot of elements (within one part) to a set than to use the single add method.

As sets contain unique items, only the items that are not already in the set are added.

std::vector< size_t > cee::ug::DataElementSet::elementIndicesForPart ( int  geometryId,
int  partId 
) const

Returns all element indices for the given geometryId and partId.

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

Returns the id of the data element set.

void cee::ug::DataElementSet::intersect ( const DataElementSet other)

Removes any item that is not present in both sets.

This method performs a intersect set operation with the given other set. The result of this operation will be the elements both in this set and the other set.

bool cee::ug::DataElementSet::isEqual ( const DataElementSet other) const

Returns true if the other set has the same items as this set.

Note: Will return true for two sets with the same contents even if their id's are different.

DataElementSetItem cee::ug::DataElementSet::item ( size_t  index) const

Returns the item at the given index.

Note
The order of the items in a set will change if the set is changed. See note in class documentation.
size_t cee::ug::DataElementSet::itemCount ( ) const

Returns the number of DataElementSetItem's in the set.

size_t cee::ug::DataElementSet::itemIndex ( const DataElementSetItem item) const

Returns the index of the given item.

Note
This index is only valid as long as the set is not modified.
void cee::ug::DataElementSet::removeAllItems ( )

Removes all items from the set.

void cee::ug::DataElementSet::removeItem ( const DataElementSetItem item)

Removes the given item from the set.

void cee::ug::DataElementSet::subtract ( const DataElementSet other)

Removes all the items in the given "other" set from this set.

This method performs a subtract set operation. Any set item in the given "other" set that is also present in this set will be removed from this set.

void cee::ug::DataElementSet::unionWith ( const DataElementSet other)

Adds all the items in the given "other" set to this set.

This method performs a union operation with the given set, resulting in all items present in the given other set to be added to this set. As sets store unique items only, the resulting number of items will be less than or equal to the sum of items in this set and the other set.