Pointwise Plugin SDK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
PWGM_XYZVAL y() const
Get the vertex&#39;s y component.
Definition: CaeUnsVertex.h:156
bool isValid() const
Determines a vertex&#39;s validity.
Definition: CaeUnsVertex.h:172
CaeUnsVertex()
Default constructor.
Definition: CaeUnsVertex.h:66
PWGM_XYZVAL z
z-component
Definition: apiGridModel.h:610
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
CaeUnsVertex & operator++()
Prefix increment to the next vertex in a model.
Definition: CaeUnsVertex.h:240
Pointwise Plugin API (PWP-API)
PWP_BOOL PwVertDataMod(PWGM_HVERTEX vertex, PWGM_VERTDATA *pVertData)
Get the vertex data relative to the model&#39;s index space.
#define PWGM_HVERTEX_H(h)
gets the element&#39;s parent PWGM_HGRIDMODEL handle
Definition: apiGridModel.h:414
CaeUnsVertex & operator=(const CaeUnsVertex &rhs)
Assignment operator.
Definition: CaeUnsVertex.h:182
Pointwise Grid Model API Specification (PWGM-API)
CaeUnsVertex & moveNext()
Rebinds an instance to the next vertex in a model.
Definition: CaeUnsVertex.h:228
An opaque handle to a grid vertex element.
Definition: apiGridModel.h:398
CaeUnsVertex(const CaeUnsVertex &src)
Copy constructor.
Definition: CaeUnsVertex.h:83
bool indexMod(PWP_UINT32 &ndx) const
Get the vertex index relative to the model&#39;s index space.
Definition: CaeUnsVertex.h:129
The unstructured grid model class.
The unstructured vertex class.
Definition: CaeUnsVertex.h:57
CaeUnsVertex(PWGM_HVERTEX vertex)
Vertex handle constructor.
Definition: CaeUnsVertex.h:75
PWGM_ENUM_XYZ
XYZ component type ids.
Definition: apiGridModel.h:821
CaeUnsVertex(const CaeUnsGridModel &model, PWP_UINT32 ndx=0)
Model and vertex index constructor.
Definition: CaeUnsVertex.h:94
bool dataMod(PWGM_VERTDATA &data) const
Get the vertex data relative to the model&#39;s index space.
Definition: CaeUnsVertex.h:120
#define PWGM_HVERTEX_ID(h)
gets the vertex&#39;s guid from the handle
Definition: apiGridModel.h:416
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
~CaeUnsVertex()
Destructor.
Definition: CaeUnsVertex.h:99
CaeUnsVertex & moveFirst(const CaeUnsGridModel &model)
Rebinds an instance to the first vertex in a model.
Definition: CaeUnsVertex.h:218
PWP_BOOL PwVertIndexMod(PWGM_HVERTEX vertex, PWP_UINT32 *pIndex)
Get the vertex index relative to the model&#39;s index space.
Vertex descriptor data type.
Definition: apiGridModel.h:607
Z-component id.
Definition: apiGridModel.h:824
#define PWGM_HVERTEX_ISVALID(h)
returns non-zero value if handle is valid
Definition: apiGridModel.h:400
CaeUnsVertex & moveTo(const CaeUnsGridModel &model, PWP_UINT32 ndx)
Rebinds an instance to a specific model vertex.
Definition: CaeUnsVertex.h:206
Y-component id.
Definition: apiGridModel.h:823
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
PWGM_HVERTEX PwModEnumVertices(PWGM_HGRIDMODEL model, PWP_UINT32 ndx)
Sequentially enumerate the model vertex elements.
PWP_UINT32 index() const
Get the vertex&#39;s index.
Definition: CaeUnsVertex.h:111
PWGM_XYZVAL y
y-component
Definition: apiGridModel.h:609
CaeUnsVertex & operator--()
Prefix decrement to the previous vertex in a model.
Definition: CaeUnsVertex.h:274
CaeUnsVertex & movePrev()
Rebinds an instance to the previous vertex in a model.
Definition: CaeUnsVertex.h:262
PWGM_XYZVAL x
x-component
Definition: apiGridModel.h:608
CaeUnsGridModel model() const
Gets the unstructured grid model of which this vertex is a member.
Definition: CaeUnsVertex.h:103
PWGM_XYZVAL x() const
Get the vertex&#39;s x component.
Definition: CaeUnsVertex.h:147
CaeUnsVertex operator--(int)
Postfix decrement to the previous vertex in a model.
Definition: CaeUnsVertex.h:284
CaeUnsVertex & operator=(PWGM_HVERTEX vertex)
Assignment operator.
Definition: CaeUnsVertex.h:193
CaeUnsVertex operator++(int)
Postfix increment to the next vertex in a model.
Definition: CaeUnsVertex.h:250
PWP_REAL PWGM_XYZVAL
XYZ component data type.
Definition: apiGridModel.h:600
PWGM_XYZVAL z() const
Get the vertex&#39;s z component.
Definition: CaeUnsVertex.h:165
PWGM_HVERTEX h_
The bound PWGM_HVERTEX.
Definition: CaeUnsVertex.h:354
PWP_BOOL PwVertXyzVal(PWGM_HVERTEX vertex, PWGM_ENUM_XYZ which, PWGM_XYZVAL *pVal)
Get a vertex&#39;s x, y, or z component value.
bool xyzVal(PWGM_ENUM_XYZ which, PWGM_XYZVAL &val) const
Get one of the vertex&#39;s x, y, or z components.
Definition: CaeUnsVertex.h:139
X-component id.
Definition: apiGridModel.h:822