cee::ug::DataNodes Class Reference

Collection of coordinates (and optionally ids) of the element nodes in a part. More...

Public Member Functions

 DataNodes (bool hasNodeIds)
 Constructs an empty DataNodes object. More...
 
size_t nodeCount () const
 Returns the number of nodes in the object. More...
 
Vec3d node (size_t index) const
 Returns the node coordinates at the given index. More...
 
void resize (size_t nodeCount)
 Sets the number of nodes in the object. More...
 
void setNode (size_t index, const Vec3d &node)
 Sets node coordinate at specified index. More...
 
void setNodes (const std::vector< Vec3d > &nodes)
 Sets the node coordinates from a std::vector of Vec3d. More...
 
void setNodes (const double nodes[], size_t nodeCount)
 Sets the node coordinates from an array of doubles. More...
 
void setNodesFloat (const float nodes[], size_t nodeCount)
 Sets the node coordinates from an array of floats. More...
 
bool hasNodeIds () const
 Returns true if this object has node collection has node ids. More...
 
int nodeId (size_t index) const
 Returns the id for the node at the given index. More...
 
size_t nodeIndex (int nodeId) const
 Returns the index for the node with the given Id. More...
 
void setNodeId (size_t index, int nodeId)
 Sets the id of the node at the given index. More...
 
void setNodeIds (const std::vector< int > &nodeIds)
 Sets the node ids from a std::vector of integers. More...
 
void setNodeIds (const int nodeIds[], size_t nodeCount)
 Sets the node ids from an array of integers. More...
 
const double * rawNodesPointer () const
 Returns a raw pointer on the node coordinates array. More...
 
const int * rawIdsPointer () const
 Returns a raw pointer on the node id's array. 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::DataNodes:
cee::RefCountedObject

Detailed Description

Collection of coordinates (and optionally ids) of the element nodes in a part.

The DataElements object describes the connectivities for all the elements in a DataPart. The node positions are stored in the DataNodes object. All connectivity indices must refer to a valid index in the node array in the corresponding data nodes. A DataElements object and a DataNodes object together defines a DataPart.

The nodes are stored in double precision, and the ids are stored as integers.

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

Nodes are inserted using setNode(), setNodes() or setNodesFloat(). If DataNodes are set to use ids, these are set using setNodeId() or setNodeIds(). Call hasNodeIds() on the DataNodes object to check if ids are expected. Whether node ids are used or not is specified upon construction of the DataNodes object. Get the number of nodes in the existing node array with nodeCount() and query individual nodes with node() and nodeId().

Example

Example of a simple part containing two triangles.

Create a DataNodes object which is a collection of nodes used for building the part. In this example you will use 4 nodes to create two triangles. Important! The nodes object must be set to the correct size before setting the actual node coordinates!

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

In addition to the node coordinates, the part need to know about the connectivities. Create a DataElements object describing the connectivities for the two triangle elements.

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

Add the nodes and elements to the part object

int partId = 1;
part->setNodes(nodes.get());
part->setElements(elements.get());

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

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

Constructor & Destructor Documentation

cee::ug::DataNodes::DataNodes ( bool  hasNodeIds)

Constructs an empty DataNodes object.

Usage of node ids needs to be decided at construction of the object.

Member Function Documentation

bool cee::ug::DataNodes::hasNodeIds ( ) const

Returns true if this object has node collection has node ids.

This is the case if the model was read from a file with node ids or if the object was constructed with hasNodeIds=true in the constructor.

Vec3d cee::ug::DataNodes::node ( size_t  nodeIndex) const

Returns the node coordinates at the given index.

The method will assert if the index is out of range.

size_t cee::ug::DataNodes::nodeCount ( ) const

Returns the number of nodes in the object.

int cee::ug::DataNodes::nodeId ( size_t  nodeIndex) const

Returns the id for the node at the given index.

The method will assert if the index is out of range.

size_t cee::ug::DataNodes::nodeIndex ( int  nodeId) const

Returns the index for the node with the given Id.

The method will assert if there are no ids defined. It will return cee::UNDEFINED_SIZE_T if the the given id is not found

const int * cee::ug::DataNodes::rawIdsPointer ( ) const

Returns a raw pointer on the node id's array.

const double * cee::ug::DataNodes::rawNodesPointer ( ) const

Returns a raw pointer on the node coordinates array.

void cee::ug::DataNodes::resize ( size_t  nodeCount)

Sets the number of nodes in the object.

The current nodes in the object will be kept up to the given count (if shrinking). It is necessary to use this method to allocate space before calling the single value set function setNode().

void cee::ug::DataNodes::setNode ( size_t  nodeIndex,
const Vec3d node 
)

Sets node coordinate at specified index.

Warning
The specified index must be a valid index. Either call one of the setNodes() methods or call resize() prior to calling this method.
See also
resize()
void cee::ug::DataNodes::setNodeId ( size_t  nodeIndex,
int  nodeId 
)

Sets the id of the node at the given index.

Warning
The method will assert if the index is out of range.
void cee::ug::DataNodes::setNodeIds ( const std::vector< int > &  nodeIds)

Sets the node ids from a std::vector of integers.

Warning
Node coordinates must already be specified or resize() must have been called. The number of elements in the nodeIds array must be equal to the current node count.
void cee::ug::DataNodes::setNodeIds ( const int  nodeIds[],
size_t  nodeCount 
)

Sets the node ids from an array of integers.

The array must be at least nodeCount items long.

Warning
Node coordinates must already be specified or resize() must have been called. The number of elements in the nodeIds array must be equal to the current node count.
void cee::ug::DataNodes::setNodes ( const std::vector< Vec3d > &  nodes)

Sets the node coordinates from a std::vector of Vec3d.

Calling this function will allocate memory for the node coordinates (and node ids if configured) and will completely replace any existing node coordinates.

void cee::ug::DataNodes::setNodes ( const double  nodes[],
size_t  nodeCount 
)

Sets the node coordinates from an array of doubles.

The array must be at least nodeCount*3 items long, as nodeCount is the number of nodes, not the number of doubles in the array.

Calling this function will allocate memory for the node coordinates (and node ids if configured) and will completely replace any existing node coordinates.

void cee::ug::DataNodes::setNodesFloat ( const float  nodes[],
size_t  nodeCount 
)

Sets the node coordinates from an array of floats.

The array must be at least nodeCount*3 items long, as nodeCount is the number of nodes, not the number of floats in the array.

Calling this function will allocate memory for the node coordinates (and node ids if configured) and will completely replace any existing node coordinates.

Note that this is only provided for convenience, and that the nodes will internally be stored as doubles