Pointwise Plugin SDK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CaeGridModel.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * CaeGridModel class
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 
10 #ifndef _CAEGRIDMODEL_H_
11 #define _CAEGRIDMODEL_H_
12 
20 #include "apiGridModel.h"
21 #include "apiPWP.h"
22 
23 
46 class CaeGridModel {
47 protected:
49 
55 
57 
61  CaeGridModel(const CaeGridModel &src);
62 
64  ~CaeGridModel();
65 
66 public:
68  PWP_UINT32 blockCount() const;
69 
72 
95  bool getAttribute(const char *name, const char *&val, const char *defVal) const;
96  bool getAttribute(const char *name, PWP_UINT &val, PWP_UINT defVal) const;
97  bool getAttribute(const char *name, PWP_UINT32 &val, PWP_UINT32 defVal) const;
98  bool getAttribute(const char *name, PWP_INT &val, PWP_INT defVal) const;
99  bool getAttribute(const char *name, PWP_INT32 &val, PWP_INT32 defVal) const;
100  bool getAttribute(const char *name, PWP_REAL &val, PWP_REAL defVal) const;
101  bool getAttribute(const char *name, PWP_FLOAT &val, PWP_FLOAT defVal) const;
102  bool getAttribute(const char *name, bool &val, bool defVal) const;
103  bool getAttributeEnum(const char *name, const char *&val, const char *defVal) const;
105 
107 
125  template< typename T >
126  bool getAttribute(const char *name, T &val) const
127  {
128  return getAttribute(name, val, val);
129  }
130 
132 
137  CaeGridModel & operator= (const CaeGridModel &rhs);
138 
140  operator PWGM_HGRIDMODEL() const {
141  return model_;
142  }
143 
144 protected:
146 };
147 
148 
149 //***************************************************************************
150 //***************************************************************************
151 //***************************************************************************
152 
154 bool operator==(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2);
155 bool operator!=(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2);
156 bool operator<(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2);
157 bool operator>(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2);
159 
160 
161 //***************************************************************************
162 //***************************************************************************
163 //***************************************************************************
164 
174 class CaeBlock {
175 protected:
176 
178 
182  CaeBlock(const CaeBlock &src) {
183  block_ = src.block_;
184  }
185 
188  }
189 
190 public:
191 
193 
197  PWP_UINT32 index() const {
198  return PWGM_HBLOCK_ID(block_);
199  }
200 
202 
215  bool condition(PWGM_CONDDATA &condData) const {
216  return 0 != PwBlkCondition(block_, &condData);
217  }
218 
220 
226  return 0 != PwBlock(block_, &data);
227  }
228 
231 
236  bool setExportName(const char *name) {
237  return 0 != PwBlkSetExportName(block_, name);
238  }
239 
242  bool isValid() const {
243  return PWGM_HBLOCK_ISVALID(block_);
244  }
245 
247 
252  CaeBlock& operator=(const CaeBlock& rhs) {
253  block_ = rhs.block_;
254  return *this;
255  }
256 
258 
264  block_ = block;
265  return *this;
266  }
267 
269 
277  block_ = PwModEnumBlocks(model, ndx);
278  return *this;
279  }
280 
282 
289  return moveTo(model, 0);
290  }
291 
293 
300  PWGM_HBLOCK_ID(block_) + 1);
301  return *this;
302  }
303 
305 
311  CaeBlock& operator++() { // pre incr to next block
312  return moveNext();
313  }
314 
316 
321  CaeBlock operator++(int) { // post incr to next block
322  CaeBlock ret = *this;
323  operator++();
324  return ret;
325  }
326 
328 
333  CaeBlock& movePrev() { // move to previous block
335  PWGM_HBLOCK_ID(block_) - 1);
336  return *this;
337  }
338 
340 
346  CaeBlock& operator--() { // pre decr to previous block
347  return movePrev();
348  }
349 
351 
356  CaeBlock operator--(int) { // post decr to previous block
357  CaeBlock ret = *this;
358  operator--();
359  return ret;
360  }
361 
363  friend bool operator==(const PWGM_HBLOCK &b1, const PWGM_HBLOCK &b2);
365 
367 
371  bool operator==(const CaeBlock &rhs) const {
372  return rhs.block_ == block_;
373  }
374 
376  operator PWGM_HBLOCK() const {
377  return block_;
378  }
379 
380 protected:
381 
383 
389  PWGM_HBLOCK badBlk = PWGM_HBLOCK_INIT;
390  block_ = badBlk;
391  }
392 
394 
399  CaeBlock(PWGM_HBLOCK block) : block_(block) {
400  }
401 
403 
410  moveTo(model, ndx);
411  }
412 
413 protected:
414 
416 };
417 
418 
419 //***************************************************************************
420 //***************************************************************************
421 //***************************************************************************
422 
451 public:
452 
455 
458 
459 public:
460 
462 
467  {
468  cd_.name = 0;
469  cd_.id = UnspecifiedId;
470  cd_.type = 0;
472  }
473 
474 
477  {
478  cd_ = src.cd_;
479  }
480 
481 
484  {
485  cd_ = cd;
486  }
487 
488 
491  {
492  }
493 
494 
496  inline const char *
497  name() const
498  {
499  return cd_.name;
500  }
501 
502 
504  inline PWP_UINT32
505  id() const
506  {
507  return cd_.id;
508  }
509 
510 
512  inline const char *
513  typeName() const
514  {
515  return cd_.type;
516  }
517 
518 
520  inline PWP_UINT32
521  typeId() const
522  {
523  return cd_.tid;
524  }
525 
526 
528  inline bool
529  isOfType(PWP_UINT32 tid) const
530  {
531  return cd_.tid == tid;
532  }
533 
534 
536  inline bool
538  {
539  return UnspecifiedId == cd_.id;
540  }
541 
542 
544  inline bool
546  {
547  return UnspecifiedTypeId == cd_.tid;
548  }
549 
550 
552 
556  inline bool
558  {
559  return hasUnspecifiedId() || hasUnspecifiedType();
560  }
561 
562 
565  {
566  cd_ = src.cd_;
567  return *this;
568  }
569 
570 
573  {
574  cd_ = cd;
575  return *this;
576  }
577 
578 
580  operator PWGM_CONDDATA&()
581  {
582  return cd_;
583  }
584 
585 
587  operator const PWGM_CONDDATA&() const
588  {
589  return cd_;
590  }
591 
592 
593 private:
596 };
597 
598 #endif
PWP_UINT32 blockCount() const
Get the number of blocks in the model.
CaeBlock & operator=(PWGM_HBLOCK block)
Assignment operator.
Definition: CaeGridModel.h:263
#define PWGM_HBLOCK_ID(h)
gets the block&#39;s guid from the handle
Definition: apiGridModel.h:366
#define PWGM_UNSPECIFIED_COND_ID
The id of the global, Unspecified condition descriptor.
Definition: apiGridModel.h:655
PWP_UINT32 id
grid-defined condition id
Definition: apiGridModel.h:646
PWGM_CONDDATA cd_
The condition data struct.
Definition: CaeGridModel.h:595
CaeCondition & operator=(const PWGM_CONDDATA &cd)
Assignment operator.
Definition: CaeGridModel.h:572
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
CaeBlock & moveNext()
Rebinds an instance to the next block in a model.
Definition: CaeGridModel.h:298
CaeBlock & moveFirst(PWGM_HGRIDMODEL model)
Rebinds an instance to the first block in a model.
Definition: CaeGridModel.h:288
bool operator==(const CaeBlock &rhs) const
Compares two CaeBlock instances for equality.
Definition: CaeGridModel.h:371
Pointwise Plugin API (PWP-API)
bool operator==(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
CaeBlock & movePrev()
Rebinds an instance to the previous block in a model.
Definition: CaeGridModel.h:333
PWGM_HGRIDMODEL model_
The bound PWGM_HGRIDMODEL.
Definition: CaeGridModel.h:145
Pointwise Grid Model API Specification (PWGM-API)
CaeGridModel(PWGM_HGRIDMODEL model)
Constructor.
PWGM_HBLOCK block_
The bound PWGM_HBLOCK.
Definition: CaeGridModel.h:415
static const PWP_UINT32 UnspecifiedId
The reserved &quot;unspecified&quot; condition Id value.
Definition: CaeGridModel.h:454
PWP_BOOL PwBlkCondition(PWGM_HBLOCK block, PWGM_CONDDATA *pCondData)
Get the block condition data.
CaeCondition()
Default constructor.
Definition: CaeGridModel.h:466
The grid block base class.
Definition: CaeGridModel.h:174
PWP_UINT32 typeId() const
Gets the solver defined condition type id value.
Definition: CaeGridModel.h:521
bool hasUnspecifiedType() const
Returns true if the condition&#39;s type id is UnspecifiedTypeId.
Definition: CaeGridModel.h:545
bool getAttribute(const char *name, const char *&val, const char *defVal) const
Block data type.
Definition: apiGridModel.h:976
~CaeBlock()
Destructor.
Definition: CaeGridModel.h:187
CaeBlock(PWGM_HBLOCK block)
Block handle constructor.
Definition: CaeGridModel.h:399
float PWP_FLOAT
32-bit real
Definition: apiPWP.h:261
CaeBlock & moveTo(PWGM_HGRIDMODEL model, PWP_UINT32 ndx)
Rebinds an instance to a specific model block.
Definition: CaeGridModel.h:276
bool operator!=(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
PWP_UINT32 tid
cae-defined condition id
Definition: apiGridModel.h:648
PWP_UINT32 index() const
Get a block&#39;s index.
Definition: CaeGridModel.h:197
bool getAttribute(const char *name, T &val) const
Templated method that gets the value of a published plugin attribute.
Definition: CaeGridModel.h:126
bool isUnspecified() const
Returns true if either or both of the condition&#39;s types is unspecified.
Definition: CaeGridModel.h:557
bool isOfType(PWP_UINT32 tid) const
Returns true if condition is of the specified type id.
Definition: CaeGridModel.h:529
CaeBlock & operator++()
Prefix increment to the next block in a model.
Definition: CaeGridModel.h:311
const char * name
grid-defined condition name
Definition: apiGridModel.h:645
CaeBlock()
Default constructor.
Definition: CaeGridModel.h:388
CaeBlock(const CaeBlock &src)
Copy constructor.
Definition: CaeGridModel.h:182
The grid model base class.
Definition: CaeGridModel.h:46
bool setExportName(const char *name)
Set the name used to identify the block or group of blocks in the exported grid.
Definition: CaeGridModel.h:236
~CaeGridModel()
Destructor.
CaeBlock operator++(int)
Postfix increment to the next block in a model.
Definition: CaeGridModel.h:321
const char * typeName() const
Gets the solver defined condition type name.
Definition: CaeGridModel.h:513
const char * type
cae-defined condition physical type name
Definition: apiGridModel.h:647
CaeCondition(const PWGM_CONDDATA &cd)
Cast/Copy constructor.
Definition: CaeGridModel.h:483
PWP_BOOL PwBlock(PWGM_HBLOCK block, PWGM_BLOCKDATA *pBlockData)
Get the block data.
static const PWP_UINT32 UnspecifiedTypeId
The reserved &quot;unspecified&quot; condition TypeId value.
Definition: CaeGridModel.h:457
CaeBlock & operator--()
Prefix decrement to the previous block in a model.
Definition: CaeGridModel.h:346
bool isValid() const
Determines a block&#39;s validity.
Definition: CaeGridModel.h:242
bool data(PWGM_BLOCKDATA &data)
Get the block data.
Definition: CaeGridModel.h:225
PWP_UINT32 id() const
Gets the user assigned condition id value.
Definition: CaeGridModel.h:505
CaeBlock & operator=(const CaeBlock &rhs)
Assignment operator.
Definition: CaeGridModel.h:252
CaeCondition(const CaeCondition &src)
Copy constructor.
Definition: CaeGridModel.h:476
bool hasUnspecifiedId() const
Returns true if the condition&#39;s user id is UnspecifiedId.
Definition: CaeGridModel.h:537
bool condition(PWGM_CONDDATA &condData) const
Gets the block&#39;s condition data.
Definition: CaeGridModel.h:215
PWP_UINT32 PWP_UINT
unsigned integer same size as void*
Definition: apiPWP.h:285
Condition descriptor data type.
Definition: apiGridModel.h:644
CaeBlock(PWGM_HGRIDMODEL model, PWP_UINT32 ndx=0)
Model and block index constructor.
Definition: CaeGridModel.h:409
#define PWGM_HBLOCK_H(h)
gets the element&#39;s parent PWGM_HGRIDMODEL handle
Definition: apiGridModel.h:364
bool getAttributeEnum(const char *name, const char *&val, const char *defVal) const
PWP_BOOL PwBlkSetExportName(PWGM_HBLOCK block, const char *name)
Set the name used to identify the block or group of blocks in the exported grid.
const char * name() const
Gets the user assigned condition name.
Definition: CaeGridModel.h:497
~CaeCondition()
Destructor.
Definition: CaeGridModel.h:490
PWP_INT32 PWP_INT
integer same size as void*
Definition: apiPWP.h:282
An opaque handle to a grid model.
Definition: apiGridModel.h:326
The volume and boundary condition data class.
Definition: CaeGridModel.h:450
CaeCondition & operator=(const CaeCondition &src)
Assignment operator.
Definition: CaeGridModel.h:564
bool operator>(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
An opaque handle to a grid block element.
Definition: apiGridModel.h:345
PWGM_HBLOCK PwModEnumBlocks(PWGM_HGRIDMODEL model, PWP_UINT32 ndx)
Sequentially enumerate the model block elements.
bool operator<(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
double PWP_REAL
64-bit real
Definition: apiPWP.h:264
CaeBlock operator--(int)
Postfix decrement to the previous block in a model.
Definition: CaeGridModel.h:356
int PWP_INT32
32-bit integer
Definition: apiPWP.h:207
#define PWGM_HBLOCK_ISVALID(h)
Returns non-zero value if handle is valid.
Definition: apiGridModel.h:348
CaeGridModel & operator=(const CaeGridModel &rhs)
The assignment operator.
#define PWGM_UNSPECIFIED_TYPE_ID
The Unspecified physical type id.
Definition: apiGridModel.h:661