Pointwise Plugin SDK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CaeUnsElement.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * CaeUnsElement 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 _CAEUNSELEMENT_H_
12 #define _CAEUNSELEMENT_H_
13 
14 #include <algorithm>
15 
16 #include "apiGridModel.h"
17 #include "apiPWP.h"
18 #include "CaeUnsElementGroup.h"
19 #include "CaeUnsGridModel.h"
20 
21 
22 //***************************************************************************
23 //***************************************************************************
24 //***************************************************************************
25 
59 public:
60 
63 
65 
73  enum ElementType {
82 
83  NumTypes = PWGM_ELEMTYPE_SIZE,
86  };
87 
88 
89 public:
90 
92 
97  {
99  eed_.elemData.vertCnt = 0;
100  static const PWGM_HVERTEX bad = PWGM_HVERTEX_INIT;
101  std::fill(eed_.elemData.vert, eed_.elemData.vert + MaxNumVerts, bad);
102  std::fill(eed_.elemData.index, eed_.elemData.index + MaxNumVerts, 0);
103  PWGM_HELEMENT_SET_INVALID(eed_.hBlkElement);
104  }
105 
106 
109  {
110  eed_ = src.eed_;
111  }
112 
113 
116  {
117  eed_.elemData = ed;
118  PWGM_HELEMENT_SET_INVALID(eed_.hBlkElement);
119  }
120 
121 
124  {
125  }
126 
127 
129  inline ElementType
130  type() const
131  {
132  return static_cast<ElementType>(eed_.elemData.type);
133  }
134 
135 
137  inline PWP_UINT32
138  vertCount() const
139  {
140  return eed_.elemData.vertCnt;
141  }
142 
143 
145  inline PWGM_HVERTEX
146  vertAt(PWP_UINT32 ndx) const
147  {
148  return eed_.elemData.vert[ndx];
149  }
150 
151 
153  inline PWP_UINT32
154  indexAt(PWP_UINT32 ndx) const
155  {
156  return eed_.elemData.index[ndx];
157  }
158 
159 
161  inline bool
163  {
164  return eed_.elemData.type == type;
165  }
166 
167 
169  inline bool
171  {
172  return static_cast<ElementType>(eed_.elemData.type) == type;
173  }
174 
175 
177  inline bool
178  isValid() const
179  {
180  return static_cast<ElementType>(eed_.elemData.type) != Invalid;
181  }
182 
183 
186  {
187  return eed_.elemData;
188  }
189 
190 
192  inline const PWGM_ELEMDATA& elementData() const
193  {
194  return eed_.elemData;
195  }
196 
197 
199  inline CaeUnsElementData&
201  {
202  eed_ = src.eed_;
203  return *this;
204  }
205 
206 
208  inline CaeUnsElementData&
210  {
211  eed_.elemData = ed;
212  PWGM_HELEMENT_SET_INVALID(eed_.hBlkElement);
213  return *this;
214  }
215 
216 
218  inline operator PWGM_ELEMDATA&()
219  {
220  return eed_.elemData;
221  }
222 
223 
225  inline operator const PWGM_ELEMDATA&() const
226  {
227  return eed_.elemData;
228  }
229 
230 
231 protected:
232 
235  {
236  eed_.elemData = ed;
237  eed_.hBlkElement = he;
238  }
239 
240 
241 protected:
242 
245 };
246 
247 
248 //***************************************************************************
249 //***************************************************************************
250 //***************************************************************************
251 
288 public:
289 
291 
297  {
298  }
299 
300 
303  CaeUnsElementData(src.eed_.elemData, src.eed_.hBlkElement)
304  {
305  }
306 
307 
310  CaeUnsElementData(eed.elemData, eed.hBlkElement)
311  {
312  }
313 
314 
317  {
318  }
319 
321  inline CaeUnsEnumElementData&
323  {
324  eed_ = src.eed_;
325  return *this;
326  }
327 
328 
330  inline CaeUnsEnumElementData&
332  {
333  eed_ = eed;
334  return *this;
335  }
336 
337 
340  {
341  return eed_;
342  }
343 
344 
346  inline const PWGM_ENUMELEMDATA& enumElementData() const
347  {
348  return eed_;
349  }
350 
351 
354  {
355  return eed_.hBlkElement;
356  }
357 
358 
360  inline const PWGM_HELEMENT& blockElement() const
361  {
362  return eed_.hBlkElement;
363  }
364 
365 
367 
380  inline PWP_UINT32 blockId() const
381  {
383  }
384 
385 
387  inline operator PWGM_ENUMELEMDATA&()
388  {
389  return eed_;
390  }
391 
392 
394  inline operator const PWGM_ENUMELEMDATA&() const
395  {
396  return eed_;
397  }
398 
399 
401  inline operator PWGM_HELEMENT&()
402  {
403  return eed_.hBlkElement;
404  }
405 
406 
408  inline operator const PWGM_HELEMENT&() const
409  {
410  return eed_.hBlkElement;
411  }
412 };
413 
414 
415 //***************************************************************************
416 //***************************************************************************
417 //***************************************************************************
418 
444 public:
445 
447 
453  PWGM_HELEMENT_SET_INVALID(h_);
454  }
455 
457 
464  CaeUnsElement(const CaeUnsElementGroup &group, PWP_UINT32 ndx = 0) :
465  group_(&group) {
466  h_ = group_->enumElements(ndx);
467  }
468 
470 
475  group_ = src.group_;
476  h_ = src.h_;
477  }
478 
480  virtual ~CaeUnsElement() {
481  }
482 
486  }
487 
489 
492  PWP_UINT32 index() const {
493  return PWGM_HELEMENT_ID(h_);
494  }
495 
497 
501  bool data(PWGM_ELEMDATA &data) const {
502  return 0 != PwElemDataMod(h_, &data);
503  }
504 
506 
510  bool data(CaeUnsElementData &data) const {
511  return 0 != PwElemDataMod(h_, &data.elementData());
512  }
513 
515 
519  bool data(PWGM_ENUMELEMDATA &data) const {
520  return 0 != PwElemDataModEnum(h_, &data);
521  }
522 
524 
529  return 0 != PwElemDataModEnum(h_, &data.enumElementData());
530  }
531 
534  bool isValid() const {
535  return PWGM_HELEMENT_ISVALID(h_);
536  }
537 
539 
545  group_ = rhs.group_;
546  h_ = rhs.h_;
547  return *this;
548  }
549 
551 
560  group_ = &group;
561  h_ = group_->enumElements(ndx);
562  return *this;
563  }
564 
566 
574  group_ = &group;
575  h_ = group_->enumElements(0);
576  return *this;
577  }
578 
580 
586  if (0 != group_) {
587  h_ = group_->enumElements(index() + 1);
588  }
589  return *this;
590  }
591 
593 
599  CaeUnsElement& operator++() { // pre incr to next element
600  if (0 != group_) {
601  h_ = group_->enumElements(index() + 1);
602  }
603  return *this;
604  }
605 
607 
612  CaeUnsElement operator++(int) { // post incr to next element
613  CaeUnsElement ret = *this;
614  if (0 != group_) {
615  h_ = group_->enumElements(index() + 1);
616  }
617  return ret;
618  }
619 
621 
626  CaeUnsElement& movePrev() { // move to previous element
627  if (0 != group_) {
628  h_ = group_->enumElements(index() - 1);
629  }
630  return *this;
631  }
632 
634 
640  CaeUnsElement& operator--() { // pre decr to previous element
641  if (0 != group_) {
642  h_ = group_->enumElements(index() - 1);
643  }
644  return *this;
645  }
646 
648 
653  CaeUnsElement operator--(int) { // post decr to previous element
654  CaeUnsElement ret = *this;
655  if (0 != group_) {
656  h_ = group_->enumElements(index() - 1);
657  }
658  return ret;
659  }
660 
662  friend bool operator==(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2);
663  friend bool operator<(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2);
665 
667 
671  bool operator==(const CaeUnsElement &rhs) const {
672  return (rhs.group_ == group_) && (rhs.h_ == h_);
673  }
674 
676 
680  bool operator!=(const CaeUnsElement &rhs) const {
681  return !(rhs == *this);
682  }
683 
685 
688  bool operator<(const CaeUnsElement &rhs) const {
689  if (rhs.group_ < group_) {
690  return true;
691  }
692  else if (rhs.group_ > group_) {
693  return false;
694  }
695  return h_ < rhs.h_;
696  }
697 
699 
702  bool operator>(const PWGM_HELEMENT &rhs)
703  {
704  return !(*this == rhs) && !(*this < rhs);
705  }
706 
708  operator PWGM_HELEMENT() const {
709  return h_;
710  }
711 
712 private:
713 
716 };
717 
718 #endif // _CAEUNSELEMENT_H_
719 
720 #endif // PWGM_HIDE_UNSTRUCTURED_API
#define PWGM_ELEMDATA_VERT_SIZE
Maximum number of verts allowed per element.
Definition: apiGridModel.h:728
CaeUnsElement operator--(int)
Postfix decrement to the previous element in an element group.
3D, 6-sided (block) grid element
Definition: apiGridModel.h:674
bool operator>(const PWGM_HELEMENT &rhs)
Compares the relative order of two CaeUnsElement instances.
CaeUnsElement & moveNext()
Rebinds an instance to the next element in an element group.
PWP_UINT32 vertCnt
Number of vertices in the face.
Definition: apiGridModel.h:737
The unstructured element group class.
Grid element handle declaration.
Definition: apiGridModel.h:427
CaeUnsEnumElementData & operator=(const PWGM_ENUMELEMDATA &eed)
Assignment operator.
The last element type id.
Definition: CaeUnsElement.h:84
CaeUnsElementData & operator=(const CaeUnsElementData &src)
Assignment operator.
~CaeUnsElementData()
Destructor.
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
PWGM_HELEMENT h_
The bound PWGM_HELEMENT.
virtual ~CaeUnsElement()
Destructor.
2D, 4-sided grid element
Definition: apiGridModel.h:675
2D, 3-sided grid
Definition: CaeUnsElement.h:77
Pointwise Plugin API (PWP-API)
CaeUnsElement operator++(int)
Postfix increment to the next element in an element group.
CaeUnsElement & movePrev()
Rebinds an instance to the previous element in an element group.
3D, 4-sided (tetrahedral) grid element
Definition: apiGridModel.h:677
bool isOfType(ElementType type) const
Returns true if element is of the specified ElementType.
bool data(CaeUnsElementData &data) const
Get the element&#39;s connectivity data.
PWP_UINT32 index[8]
The vertex indices.
Definition: apiGridModel.h:739
PWGM_ENUM_ELEMTYPE type
One of the PWGM_ELEMTYPE_XXX values.
Definition: apiGridModel.h:736
CaeUnsElement & operator--()
Prefix decrement to the previous element in an element group.
2D, 3-sided grid element
Definition: apiGridModel.h:676
CaeUnsElementData(const PWGM_ELEMDATA &ed)
Cast/Copy constructor.
Pointwise Grid Model API Specification (PWGM-API)
CaeUnsEnumElementData(const CaeUnsEnumElementData &src)
Copy constructor.
3D, 4-sided (tetrahedral) grid
Definition: CaeUnsElement.h:78
ElementType
The valid element type id values.
Definition: CaeUnsElement.h:73
CaeUnsElement & operator=(const CaeUnsElement &rhs)
Assignment operator.
CaeUnsElement & operator++()
Prefix increment to the next element in an element group.
An opaque handle to a grid vertex element.
Definition: apiGridModel.h:398
The unstructured element class.
const PWGM_ELEMDATA & elementData() const
Gets a const ref to the underlying PWGM_ELEMDATA struct.
PWP_BOOL PwElemDataMod(PWGM_HELEMENT element, PWGM_ELEMDATA *pElemData)
Get the element data relative to the model&#39;s index space.
PWGM_HELEMENT hBlkElement
The owning block&#39;s locally indexed element handle.
Definition: apiGridModel.h:749
bool operator!=(const CaeUnsElement &rhs) const
Compares two CaeUnsElement instances for inequality.
#define PWGM_HELEMENT_ID(h)
gets the element&#39;s guid from the handle
Definition: apiGridModel.h:450
PWGM_HELEMENT enumElements(PWP_UINT32 ndx) const
Get an element in the group.
2D, 4-sided grid
Definition: CaeUnsElement.h:76
The unstructured grid model class.
PWGM_HELEMENT & blockElement()
Gets a non-const ref to the owning block&#39;s element handle.
bool data(PWGM_ELEMDATA &data) const
Get the element&#39;s connectivity data.
PWP_UINT32 blockId() const
Gets the id (index) of the element&#39;s owning block.
1D, linear grid element
Definition: apiGridModel.h:673
Element descriptor data type.
Definition: apiGridModel.h:735
PWGM_ELEMDATA elemData
Element descriptor data.
Definition: apiGridModel.h:748
PWGM_HVERTEX vertAt(PWP_UINT32 ndx) const
Gets the handle of ndx&#39;th vertex.
The model unstructured element data class.
const PWGM_ENUMELEMDATA & enumElementData() const
Gets a const ref to the underlying PWGM_ENUMELEMDATA struct.
#define PWGM_HELEMENT_MODEL(h)
gets the element&#39;s PWGM_HGRIDMODEL handle
Definition: apiGridModel.h:452
CaeUnsGridModel model() const
Gets the unstructured grid model of which this element is a member.
#define PWGM_HELEMENT_PID(h)
gets the element&#39;s parent id
Definition: apiGridModel.h:446
CaeUnsElement()
Default constructor.
The unstructured element data class.
Definition: CaeUnsElement.h:58
bool isValid() const
Returns true if element type is not Invalid.
PWGM_ENUMELEMDATA eed_
The element data.
The &quot;invalid&quot; type id.
Definition: CaeUnsElement.h:85
PWGM_ENUM_ELEMTYPE
Element type ids.
Definition: apiGridModel.h:672
PWP_UINT32 index() const
Get the element&#39;s index.
3D, 5-sided, quad-based grid element
Definition: apiGridModel.h:679
const PWGM_HELEMENT & blockElement() const
Gets a const ref to the owning block&#39;s element handle.
0D, point grid element
Definition: apiGridModel.h:680
PWP_UINT32 indexAt(PWP_UINT32 ndx) const
Gets the global index of ndx&#39;th vertex.
CaeUnsEnumElementData & operator=(const CaeUnsEnumElementData &src)
Assignment operator.
CaeUnsElementData(const CaeUnsElementData &src)
Copy constructor.
PWGM_ENUMELEMDATA & enumElementData()
Gets a non-const ref to the underlying PWGM_ENUMELEMDATA struct.
3D, extruded, tri/quad grid element
Definition: apiGridModel.h:678
#define PWGM_HELEMENT_ISVALID(h)
returns non-zero value if handle is valid
Definition: apiGridModel.h:429
const CaeUnsElementGroup * group_
The owning element group.
bool data(CaeUnsEnumElementData &data) const
Get the element&#39;s connectivity data.
~CaeUnsEnumElementData()
Destructor.
PWGM_ELEMDATA & elementData()
Gets a non-const ref to the underlying PWGM_ELEMDATA struct.
bool data(PWGM_ENUMELEMDATA &data) const
Get the element&#39;s connectivity data.
bool isValid() const
Determines an element&#39;s validity.
1D, linear grid
Definition: CaeUnsElement.h:74
3D, extruded, tri/quad grid
Definition: CaeUnsElement.h:79
bool operator<(const CaeUnsElement &rhs) const
Compares the relative order of two CaeUnsElement instances.
Enumerated model element descriptor data type.
Definition: apiGridModel.h:747
CaeUnsElement(const CaeUnsElement &src)
Copy constructor.
CaeUnsEnumElementData(const PWGM_ENUMELEMDATA &eed)
Cast/Copy constructor.
ElementType type() const
Gets the element type.
CaeUnsElementData(const PWGM_ELEMDATA &ed, const PWGM_HELEMENT &he)
Protected constructor used by the CaeUnsEnumElementData subclass.
PWGM_HVERTEX vert[8]
The vertex handles.
Definition: apiGridModel.h:738
static const PWP_UINT32 MaxNumVerts
The maximum number of vertices per element.
Definition: CaeUnsElement.h:62
CaeUnsElement & moveFirst(const CaeUnsElementGroup &group)
Rebinds an instance to the first element in an element group.
CaeUnsElement(const CaeUnsElementGroup &group, PWP_UINT32 ndx=0)
Group and element index constructor.
CaeUnsElementData & operator=(const PWGM_ELEMDATA &ed)
Assignment operator.
bool isOfType(PWGM_ENUM_ELEMTYPE type) const
Returns true if element is of the specified PWGM_ENUM_ELEMTYPE.
bool operator==(const CaeUnsElement &rhs) const
Compares two CaeUnsElement instances for equality.
PWP_UINT32 vertCount() const
Gets the number of vertices in the element.
CaeUnsElementData()
Default constructor.
Definition: CaeUnsElement.h:96
The number of defined element types.
Definition: CaeUnsElement.h:83
3D, 6-sided (block) grid
Definition: CaeUnsElement.h:75
CaeUnsEnumElementData()
Default constructor.
CaeUnsElement & moveTo(const CaeUnsElementGroup &group, PWP_UINT32 ndx)
Rebinds an instance to a specific model element.
3D, 5-sided, quad-based grid
Definition: CaeUnsElement.h:80
PWP_BOOL PwElemDataModEnum(PWGM_HELEMENT element, PWGM_ENUMELEMDATA *pEnumElemData)
Get the enumerated element data relative to the model&#39;s index space.