cee::ug::DataElementSet

class DataElementSet : public RefCountedObject

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.

Public Functions

DataElementSet(int setId)

Constructs an empty element set.

Specify a unique id.

DataElementSet(const DataElementSet &other, int setId)

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

Specify a unique id.

bool isEqual(const DataElementSet &rhs) 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.

int id() const

Returns the id of the data element set.

size_t itemCount() const

Returns the number of DataElementSetItem’s in the set.

size_t 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.

DataElementSetItem 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.

void addItem(const DataElementSetItem &item)

Adds the given item to the set.

If the item is already present, the set remains unchanged

void 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.

void removeItem(const DataElementSetItem &item)

Removes the given item from the set.

void removeAllItems()

Removes all items from the set.

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

Returns all element indices for the given geometryId and partId.

void 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.

void 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.

void 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.