cee::ug::DataPartVector
-
class DataPartVector : public RefCountedObject
Vector result values for a part.
A vector result is a three dimensional value specifying direction and magnitude. DataPartVector contains an array of Vec3d’s which can be set with single precision (float) or double precision (double). Internal storage is in double precision.
DataPartVector object contains the vector result values corresponding to a DataPart. This means that the number of result values in each vector part must match the number of nodes/elements in the corresponding part (depending on mapping type). For instance, a node mapped result will need the same number of result values in the vector part as there are nodes in the part.
A DataPartVector is a child of a DataResultVector in the same way as a DataPart is a child of a DataGeometry. The DataResultVector must have the same number of child parts as the DataGeometry.
Values are inserted using setValue(), setValues() or setValuesFloat(). Get the number of values with count() and query a specific value using value() with an index.
Note! The class is reference counted and can be shared between multiple results. Remember that since this object is reference counted it should never be created on the stack.
Example
Example of how to add a node based vector result to a geometry consisting of only one triangle.
Create the DataResultVector object with a unique id and node based result mapping.
int vectorResultId = 1; cee::PtrRef<cee::ug::DataResultVector> vectorResult = new cee::ug::DataResultVector(vectorResultId, cee::ug::PER_NODE);
The result array must have one value for each node in the triangle. Resize the array before inserting the results.
cee::PtrRef<cee::ug::DataPartVector> vectorPart = new cee::ug::DataPartVector(); vectorPart->resize(3); vectorPart->setValue(0, cee::Vec3d(1.0, 0.0, 0.0)); vectorPart->setValue(1, cee::Vec3d(1.0, 1.0, 0.0)); vectorPart->setValue(2, cee::Vec3d(0.0, 2.0, 0.0));
Add the vector part to the result vector.
The number of result values in each vector part
must match the number of nodes/elements in the part (depending on mapping type). Here the result is a single triangle with node based mapping, so the scalar part must contain three vector result values.
vectorResult->addPart(vectorPart.get());
Add the result vector to the state (DataState) for the corresponding geometry (DataGeometry) geo.
state->results(geo.get())->addVector(vectorResult.get());
See the complete source code at: UnstructGrid: A Simple Model with Results
Tutorials UnstructGrid: A Simple Model with Results
See also
Public Functions
-
DataPartVector()
Constructs an empty object.
-
size_t count() const
Returns the number of result values.
-
const double *rawValuePointer() const
Returns a raw pointer to the value array.
-
double *rawValuePointer()
Returns a modifiable raw pointer to the value array.
-
void resize(size_t count)
Sets the number of values in the object.
The current values in the object will be kept up to the given count (if shrinking).
-
void setValue(size_t index, const Vec3d &value)
Sets the value at the given index.
See also
Warning
The specified index must be a valid index. Either call one of the setValues() methods or call resize() prior to calling this method.
-
void setValueUndefined(size_t index)
Sets an undefined value at the given index.
See also
Warning
The specified index must be a valid index. Either call one of the setValues() methods or call resize() prior to calling this method.
-
void setValues(const std::vector<Vec3d> &values)
Sets the vector values from a std::vector of Vec3ds.
-
void setValues(const double values[], size_t vectorCount)
Sets the vector values from an array of doubles.
The array must be at least vectorCount*3 items long, as vectorCount is the number of result values, not the number of floats in the array.
-
void setValuesFloat(const float values[], size_t vectorCount)
Sets the vector values from an array of floats.
The array must be at least vectorCount*3 items long, as vectorCount is the number of result values, not the number of floats in the array.
Note that this is only provided for convenience, and that the nodes will internally be stored as doubles
-
bool magnitudeRange(double *min, double *max) const
Gets minimum and maximum vector magnitude.
-
DataPartVector()