cee::ug::DataGeometry

class DataGeometry : public RefCountedObject

The geometry of the model for a certain state.

../_images/uml_datageometry.png

A DataGeometry is a collection of nodes, elements, element connectivity, and aggregations to parts defining the geometry at certain state. A state (DataState) can have several geometries.

Access an existing geometry using DataState::geometry() with the requested geometry index. For convenience, there’s a DataState::firstGeometry() which returns a pointer to the geometry at index = 0.

The DataGeometry object consists of a number of DataPart objects. A geometry is allowed to have zero parts.

A DataPart is added to the geometry using addPart(). Call partCount() to get number of parts in the geometry. To get a specific part, use part() with the requested part index. To get a part index from a part id, use the partIndex() function.

Note! The class is reference counted and can be shared between multiple states. Remember that since this object is reference counted it should never be created on the stack.

Example

Example on creating a simple geometry containing one part with two triangle elements.

Create a state and add it to the current data source. Number of geometries for the state is set in the constructor and cannot be changed later.

int stateId = 1;
cee::PtrRef<cee::ug::DataState> state = new cee::ug::DataState(stateId, 1);
dataSource->addState(state.get());

Create the geometry and add it to the state at index 0 (since there’s only one geometry).

int geometryIndex = 0;
cee::PtrRef<cee::ug::DataGeometry> geo = new cee::ug::DataGeometry();
state->setGeometry(geometryIndex, geo.get());

Create the nodes object and set the node coordinates for this part.

cee::PtrRef<cee::ug::DataNodes> nodes = new cee::ug::DataNodes(false);
nodes->resize(5);
nodes->setNode(0, cee::Vec3d(0, 1, 0));
nodes->setNode(1, cee::Vec3d(0, 0, 0));
nodes->setNode(2, cee::Vec3d(1, 0, 0));
nodes->setNode(3, cee::Vec3d(2, 0, 0));
nodes->setNode(4, cee::Vec3d(2, 1, 0));

Create the elements object and specify the connectivities for this part. This part contains two triangles.

int c[] = { 0, 1, 2, 2, 3, 4 };
std::vector<unsigned int> eltNodes1(c, c + 3);      // First triangle
std::vector<unsigned int> eltNodes2(c + 3, c + 6);  // Second triangle
cee::PtrRef<cee::ug::DataElements> elements = new cee::ug::DataElements(false, 0);
elements->addElement(cee::ug::Element::TRIANGLES, eltNodes1);
elements->addElement(cee::ug::Element::TRIANGLES, eltNodes2);

Create the part object and set newly created nodes and elements objects to this part. Specify a unique id when creating the DataPart.

int partId = 1;
cee::PtrRef<cee::ug::DataPart> part = new cee::ug::DataPart(partId);
part->setNodes(nodes.get());
part->setElements(elements.get());

The part is finished and can be added to the geometry.

geo->addPart(part.get());

See the entire example: UnstructGrid: Simple model with two triangles

Tutorials

See also

DataPart and DataState

Public Functions

DataGeometry()

Constructs an empty DataGeometry.

int id() const

Returns the id of the geometry.

The ids are autoassigned by CEETRON Envision

The id is used e.g. in DataElementSetItems

size_t partCount() const

Returns number of parts in geometry.

const DataPart *part(size_t partIndex) const

Returns the part at the given part index.

DataPart *part(size_t partIndex)

Returns the part at the given part index.

size_t partIndex(int partId) const

Returns the index of the part with the specified id.

Returns cee::UNDEFINED_SIZE_T if no part with the specified id is found

void addPart(DataPart *part)

Adds a part to the geometry.

Note! A DataPart cannot be added to multiple DataGeometry objects.

Warning

The added object is reference counted and should never be created on the stack or deleted!

void removeAllParts()

Removes all parts.

void removeEmptyParts()

Removes parts which either DataElements*or DataNodes* are NULL ptr.