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... | |
![]() | |
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... | |
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.
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 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!
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.
Add the nodes and elements to the part object
See the complete source code at: UnstructGrid: Simple model with two triangles
cee::ug::DataNodes::DataNodes | ( | bool | hasNodeIds | ) |
Constructs an empty DataNodes object.
Usage of node ids needs to be decided at construction of the object.
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.
void cee::ug::DataNodes::setNodeId | ( | size_t | nodeIndex, |
int | nodeId | ||
) |
Sets the id of the node at the given index.
void cee::ug::DataNodes::setNodeIds | ( | const std::vector< int > & | nodeIds | ) |
Sets the node ids from a std::vector of integers.
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.
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