cee::ug::DataGeometry Class Reference

The geometry of the model for a certain state. More...

Public Member Functions

 DataGeometry ()
 Constructs an empty DataGeometry. More...
 
int id () const
 Returns the id of the geometry. The ids are autoassigned by Ceetron Desktop Components. More...
 
size_t partCount () const
 Returns number of parts in geometry. More...
 
const DataPartpart (size_t partIndex) const
 Returns the part at the given part index. More...
 
DataPartpart (size_t partIndex)
 Returns the part at the given part index. More...
 
size_t partIndex (int partId) const
 Returns the index of the part with the specified id. More...
 
void addPart (DataPart *part)
 Adds a part to the geometry. More...
 
void removeAllParts ()
 Removes all parts. More...
 
void removeEmptyParts ()
 Removes parts which either DataElements*or DataNodes* are NULL ptr. 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::DataGeometry:
cee::RefCountedObject

Detailed Description

The geometry of the model for a certain state.

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;
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;
state->setGeometry(geometryIndex, geo.get());

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

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

See also
DataPart
DataState
Tutorials
UnstructGrid: Simple model with two triangles
UnstructGrid: A simple model with results

Constructor & Destructor Documentation

cee::ug::DataGeometry::DataGeometry ( )

Constructs an empty DataGeometry.

Member Function Documentation

void cee::ug::DataGeometry::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!
int cee::ug::DataGeometry::id ( ) const

Returns the id of the geometry. The ids are autoassigned by Ceetron Desktop Components.

The id is used e.g. in DataElementSetItems

const DataPart * cee::ug::DataGeometry::part ( size_t  partIndex) const

Returns the part at the given part index.

DataPart * cee::ug::DataGeometry::part ( size_t  partIndex)

Returns the part at the given part index.

size_t cee::ug::DataGeometry::partCount ( ) const

Returns number of parts in geometry.

size_t cee::ug::DataGeometry::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 cee::ug::DataGeometry::removeAllParts ( )

Removes all parts.

void cee::ug::DataGeometry::removeEmptyParts ( )

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