Pointwise Plugin SDK
CaeUnsVertex.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * CaeUnsVertex class
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 #if !defined(PWGM_HIDE_UNSTRUCTURED_API)
10 
11 #ifndef _CAEUNSVERTEX_H_
12 #define _CAEUNSVERTEX_H_
13 
14 #include <stdio.h>
15 
16 #include "apiGridModel.h"
17 #include "apiPWP.h"
18 #include "CaeUnsGridModel.h"
19 
20 
57 class CaeUnsVertex {
58 public:
59 
61 
67  PWGM_HVERTEX_SET_INVALID(h_);
68  }
69 
71 
75  CaeUnsVertex(PWGM_HVERTEX vertex) : h_(vertex) {
76  }
77 
79 
83  CaeUnsVertex(const CaeUnsVertex &src) {
84  h_ = src.h_;
85  }
86 
88 
95  moveTo(model, ndx);
96  }
97 
100  }
101 
105  }
106 
108 
111  PWP_UINT32 index() const {
112  return PWGM_HVERTEX_ID(h_);
113  }
114 
116 
120  bool dataMod(PWGM_VERTDATA &data) const {
121  return 0 != PwVertDataMod(h_, &data);
122  }
123 
125 
129  bool indexMod(PWP_UINT32 &ndx) const {
130  return 0 != PwVertIndexMod(h_, &ndx);
131  }
132 
134 
139  bool xyzVal(PWGM_ENUM_XYZ which, PWGM_XYZVAL &val) const {
140  return 0 != PwVertXyzVal(h_, which, &val);
141  }
142 
144 
147  PWGM_XYZVAL x() const {
148  PWGM_XYZVAL val;
149  return xyzVal(PWGM_XYZ_X, val) ? val : 0;
150  }
151 
153 
156  PWGM_XYZVAL y() const {
157  PWGM_XYZVAL val;
158  return xyzVal(PWGM_XYZ_Y, val) ? val : 0;
159  }
160 
162 
165  PWGM_XYZVAL z() const {
166  PWGM_XYZVAL val;
167  return xyzVal(PWGM_XYZ_Z, val) ? val : 0;
168  }
169 
172  bool isValid() const {
173  return PWGM_HVERTEX_ISVALID(h_);
174  }
175 
177 
183  h_ = rhs.h_;
184  return *this;
185  }
186 
188 
194  h_ = vertex;
195  return *this;
196  }
197 
199 
207  h_ = PwModEnumVertices(model, ndx);
208  return *this;
209  }
210 
212 
219  return moveTo(model, 0);
220  }
221 
223 
229  h_ = moveTo(PWGM_HVERTEX_H(h_), index() + 1);
230  return *this;
231  }
232 
234 
240  CaeUnsVertex& operator++() { // pre incr to next vertex
241  return moveNext();
242  }
243 
245 
250  CaeUnsVertex operator++(int) { // post incr to next vertex
251  CaeUnsVertex ret = *this;
252  operator++();
253  return ret;
254  }
255 
257 
262  CaeUnsVertex& movePrev() { // move to previous vertex
263  h_ = moveTo(PWGM_HVERTEX_H(h_), index() - 1);
264  return *this;
265  }
266 
268 
274  CaeUnsVertex& operator--() { // pre decr to previous vertex
275  return movePrev();
276  }
277 
279 
284  CaeUnsVertex operator--(int) { // post decr to previous vertex
285  CaeUnsVertex ret = *this;
286  operator--();
287  return ret;
288  }
289 
291  operator PWGM_HVERTEX() const {
292  return h_;
293  }
294 
296 
303  const char * toString(char *buf = 0, const char *delimiter = 0,
304  const char *prefix = 0, const char *suffix = 0) const {
305  PWGM_VERTDATA data;
306  dataMod(data);
307  return toString(data, buf, delimiter, prefix, suffix);
308  }
309 
311 
330  static const char * toString(const PWGM_VERTDATA &data, char *buf = 0,
331  const char *delimiter = 0, const char *prefix = 0,
332  const char *suffix = 0) {
333  if (0 == buf) {
334  // buf contents only valid until next call
335  static char singleUseBuf[512];
336  buf = singleUseBuf;
337  }
338  if (0 == delimiter) {
339  delimiter = " ";
340  }
341  if (0 == prefix) {
342  prefix = "";
343  }
344  if (0 == suffix) {
345  suffix = "";
346  }
347  sprintf(buf, "%s%g%s%g%s%g%s", prefix, data.x, delimiter, data.y,
348  delimiter, data.z, suffix);
349  return buf;
350  }
351 
352 protected:
353 
355 };
356 
357 #endif // _CAEUNSVERTEX_H_
358 #endif // PWGM_HIDE_UNSTRUCTURED_API
PwModEnumVertices
PWGM_HVERTEX PwModEnumVertices(PWGM_HGRIDMODEL model, PWP_UINT32 ndx)
Sequentially enumerate the model vertex elements.
Definition: apiGridModel.cxx:242
PwVertIndexMod
PWP_BOOL PwVertIndexMod(PWGM_HVERTEX vertex, PWP_UINT32 *pIndex)
Get the vertex index relative to the model's index space.
Definition: apiGridModel.cxx:359
CaeUnsVertex::operator--
CaeUnsVertex operator--(int)
Postfix decrement to the previous vertex in a model.
Definition: CaeUnsVertex.h:284
CaeUnsVertex::moveNext
CaeUnsVertex & moveNext()
Rebinds an instance to the next vertex in a model.
Definition: CaeUnsVertex.h:228
CaeUnsVertex::x
PWGM_XYZVAL x() const
Get the vertex's x component.
Definition: CaeUnsVertex.h:147
PWGM_HVERTEX_H
#define PWGM_HVERTEX_H(h)
gets the element's parent PWGM_HGRIDMODEL handle
Definition: apiGridModel.h:414
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
CaeUnsVertex::h_
PWGM_HVERTEX h_
The bound PWGM_HVERTEX.
Definition: CaeUnsVertex.h:354
CaeUnsGridModel
The unstructured grid model class.
Definition: CaeUnsGridModel.h:176
PWGM_HVERTEX_ID
#define PWGM_HVERTEX_ID(h)
gets the vertex's guid from the handle
Definition: apiGridModel.h:416
CaeUnsVertex::movePrev
CaeUnsVertex & movePrev()
Rebinds an instance to the previous vertex in a model.
Definition: CaeUnsVertex.h:262
PWGM_VERTDATA::x
PWGM_XYZVAL x
x-component
Definition: apiGridModel.h:608
CaeUnsVertex::~CaeUnsVertex
~CaeUnsVertex()
Destructor.
Definition: CaeUnsVertex.h:99
CaeUnsVertex::moveFirst
CaeUnsVertex & moveFirst(const CaeUnsGridModel &model)
Rebinds an instance to the first vertex in a model.
Definition: CaeUnsVertex.h:218
CaeUnsVertex::dataMod
bool dataMod(PWGM_VERTDATA &data) const
Get the vertex data relative to the model's index space.
Definition: CaeUnsVertex.h:120
apiGridModel.h
Pointwise Grid Model API Specification (PWGM-API)
CaeUnsVertex::xyzVal
bool xyzVal(PWGM_ENUM_XYZ which, PWGM_XYZVAL &val) const
Get one of the vertex's x, y, or z components.
Definition: CaeUnsVertex.h:139
CaeUnsVertex::operator=
CaeUnsVertex & operator=(const CaeUnsVertex &rhs)
Assignment operator.
Definition: CaeUnsVertex.h:182
PWGM_HVERTEX_ISVALID
#define PWGM_HVERTEX_ISVALID(h)
returns non-zero value if handle is valid
Definition: apiGridModel.h:400
CaeUnsVertex::index
PWP_UINT32 index() const
Get the vertex's index.
Definition: CaeUnsVertex.h:111
CaeUnsVertex::isValid
bool isValid() const
Determines a vertex's validity.
Definition: CaeUnsVertex.h:172
CaeUnsVertex
The unstructured vertex class.
Definition: CaeUnsVertex.h:57
CaeUnsVertex::operator=
CaeUnsVertex & operator=(PWGM_HVERTEX vertex)
Assignment operator.
Definition: CaeUnsVertex.h:193
PWGM_VERTDATA
Vertex descriptor data type.
Definition: apiGridModel.h:607
PWGM_XYZ_Y
@ PWGM_XYZ_Y
Y-component id.
Definition: apiGridModel.h:852
PWGM_XYZ_Z
@ PWGM_XYZ_Z
Z-component id.
Definition: apiGridModel.h:853
CaeUnsVertex::indexMod
bool indexMod(PWP_UINT32 &ndx) const
Get the vertex index relative to the model's index space.
Definition: CaeUnsVertex.h:129
PwVertXyzVal
PWP_BOOL PwVertXyzVal(PWGM_HVERTEX vertex, PWGM_ENUM_XYZ which, PWGM_XYZVAL *pVal)
Get a vertex's x, y, or z component value.
Definition: apiGridModel.cxx:368
PWGM_VERTDATA::y
PWGM_XYZVAL y
y-component
Definition: apiGridModel.h:609
PWGM_VERTDATA::z
PWGM_XYZVAL z
z-component
Definition: apiGridModel.h:610
CaeUnsVertex::y
PWGM_XYZVAL y() const
Get the vertex's y component.
Definition: CaeUnsVertex.h:156
PwVertDataMod
PWP_BOOL PwVertDataMod(PWGM_HVERTEX vertex, PWGM_VERTDATA *pVertData)
Get the vertex data relative to the model's index space.
Definition: apiGridModel.cxx:350
CaeUnsGridModel.h
CaeUnsVertex::model
CaeUnsGridModel model() const
Gets the unstructured grid model of which this vertex is a member.
Definition: CaeUnsVertex.h:103
CaeUnsVertex::z
PWGM_XYZVAL z() const
Get the vertex's z component.
Definition: CaeUnsVertex.h:165
CaeUnsVertex::CaeUnsVertex
CaeUnsVertex(const CaeUnsVertex &src)
Copy constructor.
Definition: CaeUnsVertex.h:83
PWGM_XYZVAL
PWP_REAL PWGM_XYZVAL
XYZ component data type.
Definition: apiGridModel.h:600
CaeUnsVertex::operator++
CaeUnsVertex operator++(int)
Postfix increment to the next vertex in a model.
Definition: CaeUnsVertex.h:250
CaeUnsVertex::moveTo
CaeUnsVertex & moveTo(const CaeUnsGridModel &model, PWP_UINT32 ndx)
Rebinds an instance to a specific model vertex.
Definition: CaeUnsVertex.h:206
PWGM_HVERTEX
An opaque handle to a grid vertex element.
Definition: apiGridModel.h:398
CaeUnsVertex::toString
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.
Definition: CaeUnsVertex.h:303
apiPWP.h
Pointwise Plugin API (PWP-API)
CaeUnsVertex::CaeUnsVertex
CaeUnsVertex(const CaeUnsGridModel &model, PWP_UINT32 ndx=0)
Model and vertex index constructor.
Definition: CaeUnsVertex.h:94
CaeUnsVertex::toString
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.
Definition: CaeUnsVertex.h:330
CaeUnsVertex::operator++
CaeUnsVertex & operator++()
Prefix increment to the next vertex in a model.
Definition: CaeUnsVertex.h:240
PWGM_ENUM_XYZ
PWGM_ENUM_XYZ
XYZ component type ids.
Definition: apiGridModel.h:850
CaeUnsVertex::CaeUnsVertex
CaeUnsVertex()
Default constructor.
Definition: CaeUnsVertex.h:66
CaeUnsVertex::CaeUnsVertex
CaeUnsVertex(PWGM_HVERTEX vertex)
Vertex handle constructor.
Definition: CaeUnsVertex.h:75
CaeUnsVertex::operator--
CaeUnsVertex & operator--()
Prefix decrement to the previous vertex in a model.
Definition: CaeUnsVertex.h:274
PWGM_XYZ_X
@ PWGM_XYZ_X
X-component id.
Definition: apiGridModel.h:851