Pointwise Plugin SDK
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members

The unstructured vertex class. More...

#include <CaeUnsVertex.h>

+ Collaboration diagram for CaeUnsVertex:

Public Member Functions

 CaeUnsVertex ()
 Default constructor. More...
 
 CaeUnsVertex (const CaeUnsGridModel &model, PWP_UINT32 ndx=0)
 Model and vertex index constructor. More...
 
 CaeUnsVertex (const CaeUnsVertex &src)
 Copy constructor. More...
 
 CaeUnsVertex (PWGM_HVERTEX vertex)
 Vertex handle constructor. More...
 
bool dataMod (PWGM_VERTDATA &data) const
 Get the vertex data relative to the model's index space. More...
 
PWP_UINT32 index () const
 Get the vertex's index. More...
 
bool indexMod (PWP_UINT32 &ndx) const
 Get the vertex index relative to the model's index space. More...
 
bool isValid () const
 Determines a vertex's validity. More...
 
CaeUnsGridModel model () const
 Gets the unstructured grid model of which this vertex is a member. More...
 
CaeUnsVertexmoveFirst (const CaeUnsGridModel &model)
 Rebinds an instance to the first vertex in a model. More...
 
CaeUnsVertexmoveNext ()
 Rebinds an instance to the next vertex in a model. More...
 
CaeUnsVertexmovePrev ()
 Rebinds an instance to the previous vertex in a model. More...
 
CaeUnsVertexmoveTo (const CaeUnsGridModel &model, PWP_UINT32 ndx)
 Rebinds an instance to a specific model vertex. More...
 
 operator PWGM_HVERTEX () const
 The PWGM_HVERTEX cast operator. More...
 
CaeUnsVertexoperator++ ()
 Prefix increment to the next vertex in a model. More...
 
CaeUnsVertex operator++ (int)
 Postfix increment to the next vertex in a model. More...
 
CaeUnsVertexoperator-- ()
 Prefix decrement to the previous vertex in a model. More...
 
CaeUnsVertex operator-- (int)
 Postfix decrement to the previous vertex in a model. More...
 
CaeUnsVertexoperator= (const CaeUnsVertex &rhs)
 Assignment operator. More...
 
CaeUnsVertexoperator= (PWGM_HVERTEX vertex)
 Assignment operator. More...
 
const char * toString (char *buf=0, const char *delimiter=0, const char *prefix=0, const char *suffix=0) const
 Get a string representation of the vertex. More...
 
PWGM_XYZVAL x () const
 Get the vertex's x component. More...
 
bool xyzVal (PWGM_ENUM_XYZ which, PWGM_XYZVAL &val) const
 Get one of the vertex's x, y, or z components. More...
 
PWGM_XYZVAL y () const
 Get the vertex's y component. More...
 
PWGM_XYZVAL z () const
 Get the vertex's z component. More...
 
 ~CaeUnsVertex ()
 Destructor. More...
 

Static Public Member Functions

static const char * toString (const PWGM_VERTDATA &data, char *buf=0, const char *delimiter=0, const char *prefix=0, const char *suffix=0)
 Get a string representation of the vertex data. More...
 

Protected Attributes

PWGM_HVERTEX h_
 The bound PWGM_HVERTEX. More...
 

Detailed Description

The unstructured vertex class.

The CaeUnsVertex class represents a single, xyz point in an unstructured grid model. The grid model vertices are indexed from 0 to CaeUnsGridModel::vertexCount() - 1. The vertices are shared among all grid model elements.

A CaeUnsVertex object is aware of its relative position in the grid model. As a result, a given vertex object can be moved (iterated) to its previous or next neighbor vertex. It can also be moved to the first vertex or to a vertex at a given index. After being moved, a vertex will return information about the vertex at its current position.

Sample Usage

The following snippets are extracted from the unstructured XML sample plugin (CaeUnsXMLCPP).

During the execution of the CaeUnsXMLCPP::write() method, the CaeUnsXMLCPP plugin writes the grid model vertices with a call to its CaeUnsXMLCPP::writeVertices() method. First, it writes an XML <vertices> tag. Then it moves through the vertices one by one and calls the CaeUnsXMLCPP::writeVertex() method. Finally, a closing </vertices> tag is written. If only boundary conditions are being written or if the export is aborted, vertices are not written.

void
CaeUnsXMLCPP::writeVertices()
{
if (!conditionsOnly() && !aborted()) {
PWP_UINT32 cnt = model_.vertexCount();
if (progressBeginStep(cnt)) {
writeComment("*************** GRID VERTICES ***************");
fprintf(fp(), "%s<vertices count='%lu'>\n", tabs(),
(unsigned long)cnt);
++tabs_;
CaeUnsVertex vertex(model_);
while (writeVertex(vertex++)) {
progressIncrement();
}
--tabs_;
fprintf(fp(), "%s</vertices>\n", tabs());
}
progressEndStep();
}
}

CaeUnsXMLCPP::writeVertex() writes a self-closed XML <vertex /> tag. If the export dimensionality is 3D, the x, y, and z components are written. If the export dimensionality is 2D, only the x and y components are written. In both cases, the numeric precision is set to either 8 or 16 depending on the call to CaePlugin::isSinglePrecision().

bool
CaeUnsXMLCPP::writeVertex(const CaeUnsVertex &vertex)
{
bool ret = vertex.isValid() && !aborted();
if (ret) {
int prec = isSinglePrecision() ? 8 : 16;
vertex.dataMod(vdata);
if (isDimension3D()) {
fprintf(fp(), "%s<vertex i='%lu' x='%.*g' y='%.*g' z='%.*g' />\n",
tabs(), (unsigned long)vdata.i, prec, vdata.x, prec, vdata.y,
prec, vdata.z);
}
else {
fprintf(fp(), "%s<vertex i='%lu' x='%.*g' y='%.*g' />\n", tabs(),
(unsigned long)vdata.i, prec, vdata.x, prec, vdata.y);
}
}
return ret;
}

Definition at line 57 of file CaeUnsVertex.h.

Constructor & Destructor Documentation

◆ CaeUnsVertex() [1/4]

CaeUnsVertex::CaeUnsVertex ( )
inline

Default constructor.

Constructs an invalid vertex.

Note
The vertex can be made valid using moveTo() or moveFirst().
See also
moveTo(), moveFirst(), moveNext(), movePrev()

Definition at line 66 of file CaeUnsVertex.h.

References h_.

◆ CaeUnsVertex() [2/4]

CaeUnsVertex::CaeUnsVertex ( PWGM_HVERTEX  vertex)
inline

Vertex handle constructor.

Constructs an unstructured vertex object bound to the specified vertex.

Parameters
vertexThe vertex handle to bind.

Definition at line 75 of file CaeUnsVertex.h.

◆ CaeUnsVertex() [3/4]

CaeUnsVertex::CaeUnsVertex ( const CaeUnsVertex src)
inline

Copy constructor.

Binds this vertex to the same vertex as src.

Parameters
srcA vertex instance.

Definition at line 83 of file CaeUnsVertex.h.

References h_.

◆ CaeUnsVertex() [4/4]

CaeUnsVertex::CaeUnsVertex ( const CaeUnsGridModel model,
PWP_UINT32  ndx = 0 
)
inline

Model and vertex index constructor.

Constructs an unstructured vertex object bound to the vertex at the specified index.

Parameters
modelThe unstructured grid model.
ndxThe vertex's index.

Definition at line 94 of file CaeUnsVertex.h.

References model(), and moveTo().

◆ ~CaeUnsVertex()

CaeUnsVertex::~CaeUnsVertex ( )
inline

Destructor.

Definition at line 99 of file CaeUnsVertex.h.

Member Function Documentation

◆ dataMod()

bool CaeUnsVertex::dataMod ( PWGM_VERTDATA data) const
inline

Get the vertex data relative to the model's index space.

Parameters
dataThe PWGM_VERTDATA buffer.
Returns
true if successful.

Definition at line 120 of file CaeUnsVertex.h.

References h_, and PwVertDataMod().

Referenced by toString().

◆ index()

PWP_UINT32 CaeUnsVertex::index ( ) const
inline

Get the vertex's index.

Returns
The vertex's grid model index.

Definition at line 111 of file CaeUnsVertex.h.

References h_, and PWGM_HVERTEX_ID.

Referenced by moveNext(), and movePrev().

◆ indexMod()

bool CaeUnsVertex::indexMod ( PWP_UINT32 ndx) const
inline

Get the vertex index relative to the model's index space.

Parameters
ndxThe index buffer.
Returns
true if successful.

Definition at line 129 of file CaeUnsVertex.h.

References h_, and PwVertIndexMod().

◆ isValid()

bool CaeUnsVertex::isValid ( ) const
inline

Determines a vertex's validity.

Returns
true if the vertex is valid.

Definition at line 172 of file CaeUnsVertex.h.

References h_, and PWGM_HVERTEX_ISVALID.

◆ model()

CaeUnsGridModel CaeUnsVertex::model ( ) const
inline

Gets the unstructured grid model of which this vertex is a member.

Definition at line 103 of file CaeUnsVertex.h.

References h_, and PWGM_HVERTEX_H.

Referenced by CaeUnsVertex(), moveFirst(), and moveTo().

◆ moveFirst()

CaeUnsVertex& CaeUnsVertex::moveFirst ( const CaeUnsGridModel model)
inline

Rebinds an instance to the first vertex in a model.

Parameters
modelThe unstructured grid model.
Returns
A self reference.
Note
Equivalent to calling moveTo(model, 0).
See also
moveTo(), movePrev(), moveNext()

Definition at line 218 of file CaeUnsVertex.h.

References model(), and moveTo().

◆ moveNext()

CaeUnsVertex& CaeUnsVertex::moveNext ( )
inline

Rebinds an instance to the next vertex in a model.

Returns
A self reference.
Note
If already on the last vertex, the vertex will become invalid.
See also
moveTo(), moveFirst(), movePrev(), isValid()

Definition at line 228 of file CaeUnsVertex.h.

References h_, index(), moveTo(), and PWGM_HVERTEX_H.

Referenced by operator++().

◆ movePrev()

CaeUnsVertex& CaeUnsVertex::movePrev ( )
inline

Rebinds an instance to the previous vertex in a model.

Returns
A self reference.
Note
If already on the first vertex, the vertex will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 262 of file CaeUnsVertex.h.

References h_, index(), moveTo(), and PWGM_HVERTEX_H.

Referenced by operator--().

◆ moveTo()

CaeUnsVertex& CaeUnsVertex::moveTo ( const CaeUnsGridModel model,
PWP_UINT32  ndx 
)
inline

Rebinds an instance to a specific model vertex.

Parameters
modelThe unstructured grid model.
ndxThe vertex's index.
Returns
A self reference.
Note
If ndx is not a valid index, the vertex will become invalid.
See also
moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 206 of file CaeUnsVertex.h.

References h_, model(), and PwModEnumVertices().

Referenced by CaeUnsVertex(), moveFirst(), moveNext(), and movePrev().

◆ operator PWGM_HVERTEX()

CaeUnsVertex::operator PWGM_HVERTEX ( ) const
inline

The PWGM_HVERTEX cast operator.

Definition at line 291 of file CaeUnsVertex.h.

References h_.

◆ operator++() [1/2]

CaeUnsVertex& CaeUnsVertex::operator++ ( )
inline

Prefix increment to the next vertex in a model.

Returns
A self reference.
Note
Equivalent to calling moveNext().
If already on the last vertex, the vertex will become invalid.
See also
moveTo(), moveFirst(), movePrev(), isValid()

Definition at line 240 of file CaeUnsVertex.h.

References moveNext().

Referenced by operator++().

◆ operator++() [2/2]

CaeUnsVertex CaeUnsVertex::operator++ ( int  )
inline

Postfix increment to the next vertex in a model.

Returns
A copy of the vertex before it was moved.
Note
If already on the last vertex, the vertex will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 250 of file CaeUnsVertex.h.

References operator++().

◆ operator--() [1/2]

CaeUnsVertex& CaeUnsVertex::operator-- ( )
inline

Prefix decrement to the previous vertex in a model.

Returns
A self reference.
Note
Equivalent to calling movePrev().
If already on the first vertex, the vertex will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 274 of file CaeUnsVertex.h.

References movePrev().

Referenced by operator--().

◆ operator--() [2/2]

CaeUnsVertex CaeUnsVertex::operator-- ( int  )
inline

Postfix decrement to the previous vertex in a model.

Returns
A copy of the vertex before it was moved.
Note
If already on the first vertex, the vertex will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 284 of file CaeUnsVertex.h.

References operator--().

◆ operator=() [1/2]

CaeUnsVertex& CaeUnsVertex::operator= ( const CaeUnsVertex rhs)
inline

Assignment operator.

Rebind this instance to the same vertex as rhs.

Parameters
rhsA vertex instance.
Returns
A self reference.

Definition at line 182 of file CaeUnsVertex.h.

References h_.

◆ operator=() [2/2]

CaeUnsVertex& CaeUnsVertex::operator= ( PWGM_HVERTEX  vertex)
inline

Assignment operator.

Rebind this instance to the specified vertex handle.

Parameters
vertexThe vertex handle.
Returns
A self reference.

Definition at line 193 of file CaeUnsVertex.h.

References h_.

◆ toString() [1/2]

const char* CaeUnsVertex::toString ( char *  buf = 0,
const char *  delimiter = 0,
const char *  prefix = 0,
const char *  suffix = 0 
) const
inline

Get a string representation of the vertex.

Calls the static overload of this method using the vertex data obtained with a call to dataMod(). See the static overload for parameter usage.

See also
toString()
toString(const PWGM_VERTDATA &, char *, const char *, const char *, const char *)

Definition at line 303 of file CaeUnsVertex.h.

References dataMod().

◆ toString() [2/2]

static const char* CaeUnsVertex::toString ( const PWGM_VERTDATA data,
char *  buf = 0,
const char *  delimiter = 0,
const char *  prefix = 0,
const char *  suffix = 0 
)
inlinestatic

Get a string representation of the vertex data.

Parameters
dataThe vertex data.
bufPointer to a string buffer. If null, a static, internal buffer is used.
delimiterPointer to a delimiter string. If null, a single space is used.
prefixPointer to a prefix string. If null, prefix is ignored.
suffixPointer to a suffix string. If null, suffix is ignored.
Returns
buf if provided or a pointer to the internal, static buffer if buf is null.
Note
The string format is "[prefix]X[delimiter]Y[delimiter]Z[suffix]"
If provided, buf size must be at least 64 chars plus room for the prefix, 2 delimiters, and the suffix.
The contents of the internal, static buffer will only be valid until the next call to this method.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 330 of file CaeUnsVertex.h.

References PWGM_VERTDATA::x, PWGM_VERTDATA::y, and PWGM_VERTDATA::z.

◆ x()

PWGM_XYZVAL CaeUnsVertex::x ( ) const
inline

Get the vertex's x component.

Returns
the x component.

Definition at line 147 of file CaeUnsVertex.h.

References PWGM_XYZ_X, and xyzVal().

◆ xyzVal()

bool CaeUnsVertex::xyzVal ( PWGM_ENUM_XYZ  which,
PWGM_XYZVAL val 
) const
inline

Get one of the vertex's x, y, or z components.

Parameters
whichThe XYZ component id.
valThe PWGM_XYZVAL buffer.
Returns
true if successful.

Definition at line 139 of file CaeUnsVertex.h.

References h_, and PwVertXyzVal().

Referenced by x(), y(), and z().

◆ y()

PWGM_XYZVAL CaeUnsVertex::y ( ) const
inline

Get the vertex's y component.

Returns
the y component.

Definition at line 156 of file CaeUnsVertex.h.

References PWGM_XYZ_Y, and xyzVal().

◆ z()

PWGM_XYZVAL CaeUnsVertex::z ( ) const
inline

Get the vertex's z component.

Returns
the z component.

Definition at line 165 of file CaeUnsVertex.h.

References PWGM_XYZ_Z, and xyzVal().

Member Data Documentation

◆ h_

PWGM_HVERTEX CaeUnsVertex::h_
protected

The documentation for this class was generated from the following file:
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
PWGM_VERTDATA::x
PWGM_XYZVAL x
x-component
Definition: apiGridModel.h:608
CaeUnsVertex::dataMod
bool dataMod(PWGM_VERTDATA &data) const
Get the vertex data relative to the model's index space.
Definition: CaeUnsVertex.h:120
CaeUnsVertex::isValid
bool isValid() const
Determines a vertex's validity.
Definition: CaeUnsVertex.h:172
CaeUnsVertex
The unstructured vertex class.
Definition: CaeUnsVertex.h:57
PWGM_VERTDATA
Vertex descriptor data type.
Definition: apiGridModel.h:607
PWGM_VERTDATA::y
PWGM_XYZVAL y
y-component
Definition: apiGridModel.h:609
PWGM_VERTDATA::z
PWGM_XYZVAL z
z-component
Definition: apiGridModel.h:610
PWGM_VERTDATA::i
PWP_UINT32 i
vertex index in parent's model-space
Definition: apiGridModel.h:611