Pointwise Plugin SDK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CaeGridModel.cxx
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 #include "apiGridModel.h"
10 #include "apiPWP.h"
11 
12 #include "CaeGridModel.h"
13 
14 
15 //***************************************************************************
16 //***************************************************************************
17 //***************************************************************************
18 
20  model_(model)
21 {
22 }
23 
25  model_(src.model_)
26 {
27 }
28 
30 {
31 }
32 
33 
36 {
37  return PwModBlockCount(model_);
38 }
39 
40 
41 bool
42 CaeGridModel::getAttribute(const char *name, const char *&val, const char *defVal) const
43 {
44  val = defVal;
45  return 0 != PwModGetAttributeString(model_, name, &val);
46 }
47 
48 bool
49 CaeGridModel::getAttribute(const char *name, PWP_UINT &val, PWP_UINT defVal) const
50 {
51  val = defVal;
52  return 0 != PwModGetAttributeUINT(model_, name, &val);
53 }
54 
55 bool
56 CaeGridModel::getAttribute(const char *name, PWP_UINT32 &val, PWP_UINT32 defVal) const
57 {
58  val = defVal;
59  return 0 != PwModGetAttributeUINT32(model_, name, &val);
60 }
61 
62 bool
63 CaeGridModel::getAttribute(const char *name, PWP_INT &val, PWP_INT defVal) const
64 {
65  val = defVal;
66  return 0 != PwModGetAttributeINT(model_, name, &val);
67 }
68 
69 bool
70 CaeGridModel::getAttribute(const char *name, PWP_INT32 &val, PWP_INT32 defVal) const
71 {
72  val = defVal;
73  return 0 != PwModGetAttributeINT32(model_, name, &val);
74 }
75 
76 bool
77 CaeGridModel::getAttribute(const char *name, PWP_REAL &val, PWP_REAL defVal) const
78 {
79  val = defVal;
80  return 0 != PwModGetAttributeREAL(model_, name, &val);
81 }
82 
83 bool
84 CaeGridModel::getAttribute(const char *name, PWP_FLOAT &val, PWP_FLOAT defVal) const
85 {
86  val = defVal;
87  return 0 != PwModGetAttributeFLOAT(model_, name, &val);
88 }
89 
90 bool
91 CaeGridModel::getAttribute(const char *name, bool &val, bool defVal) const
92 {
93  val = defVal;
94  PWP_BOOL locBool;
95  bool ret = (0 != PwModGetAttributeBOOL(model_, name, &locBool));
96  if (ret) {
97  val = (0 != locBool);
98  }
99  return ret;
100 }
101 
102 bool
103 CaeGridModel::getAttributeEnum(const char *name, const char *&val, const char *defVal) const
104 {
105  val = defVal;
106  return 0 != PwModGetAttributeEnum(model_, name, &val);
107 }
108 
109 
110 CaeGridModel &
112 {
113  model_ = rhs.model_;
114  return *this;
115 }
116 
117 // data layout for PWGM_HBLOCK:
118 // struct PWGM_HBLOCK {
119 // PWGM_HGRIDMODEL hP;
120 // PWP_UINT32 id;
121 // }
122 
123 bool
124 operator==(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
125 {
126  // for speed, compare ids first. This assumes that most compares will
127  // differ in ids. Only if ids are the same will the remaining, more
128  // expensive compares be performed.
129  return (PWGM_HBLOCK_ID(h1) == PWGM_HBLOCK_ID(h2)) && // .id
130  (PWGM_HBLOCK_OUT_GMIMPL(h1) == PWGM_HBLOCK_OUT_GMIMPL(h2)); // .hP
131 }
132 
133 bool
134 operator!=(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
135 {
136  return !(h1 == h2);
137 }
138 
139 bool
140 operator<(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
141 {
142  // for speed, compare ids first. This assumes that most compares will
143  // differ in ids. Only if ids are the same will the remaining, more
144  // expensive compares be performed.
145  if (PWGM_HBLOCK_ID(h1) < PWGM_HBLOCK_ID(h2)) { // .id
146  return true;
147  }
148  else if (PWGM_HBLOCK_ID(h1) > PWGM_HBLOCK_ID(h2)) { // .id
149  return false;
150  }
151  else if (PWGM_HBLOCK_OUT_GMIMPL(h1) < PWGM_HBLOCK_OUT_GMIMPL(h2)) { // parent.hP
152  return true;
153  }
154  return false; // PWGM_HBLOCK_OUT_GMIMPL(h1) >= PWGM_HBLOCK_OUT_GMIMPL(h2)
155 }
156 
157 bool
158 operator>(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
159 {
160  return (h1 != h2) && !(h1 < h2);
161 }
PWP_UINT32 blockCount() const
Get the number of blocks in the model.
#define PWGM_HBLOCK_ID(h)
gets the block&#39;s guid from the handle
Definition: apiGridModel.h:366
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
Pointwise Plugin API (PWP-API)
bool operator==(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
PWGM_HGRIDMODEL model_
The bound PWGM_HGRIDMODEL.
Definition: CaeGridModel.h:145
Pointwise Grid Model API Specification (PWGM-API)
CaeGridModel(PWGM_HGRIDMODEL model)
Constructor.
PWP_BOOL PwModGetAttributeUINT(PWGM_HGRIDMODEL model, const char *name, PWP_UINT *val)
bool getAttribute(const char *name, const char *&val, const char *defVal) const
float PWP_FLOAT
32-bit real
Definition: apiPWP.h:261
bool operator!=(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
PWP_UINT32 PwModBlockCount(PWGM_HGRIDMODEL model)
Get the number of block elements in the model.
PWP_BOOL PwModGetAttributeString(PWGM_HGRIDMODEL model, const char *name, const char **val)
Get an attribute value as a specific type.
int PWP_BOOL
logical value
Definition: apiPWP.h:303
PWP_BOOL PwModGetAttributeFLOAT(PWGM_HGRIDMODEL model, const char *name, PWP_FLOAT *val)
The grid model base class.
Definition: CaeGridModel.h:46
~CaeGridModel()
Destructor.
PWP_BOOL PwModGetAttributeREAL(PWGM_HGRIDMODEL model, const char *name, PWP_REAL *val)
PWP_UINT32 PWP_UINT
unsigned integer same size as void*
Definition: apiPWP.h:285
bool getAttributeEnum(const char *name, const char *&val, const char *defVal) const
PWP_BOOL PwModGetAttributeINT(PWGM_HGRIDMODEL model, const char *name, PWP_INT *val)
PWP_INT32 PWP_INT
integer same size as void*
Definition: apiPWP.h:282
PWP_BOOL PwModGetAttributeUINT32(PWGM_HGRIDMODEL model, const char *name, PWP_UINT32 *val)
An opaque handle to a grid model.
Definition: apiGridModel.h:326
bool operator>(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
An opaque handle to a grid block element.
Definition: apiGridModel.h:345
PWP_BOOL PwModGetAttributeBOOL(PWGM_HGRIDMODEL model, const char *name, PWP_BOOL *val)
bool operator<(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
double PWP_REAL
64-bit real
Definition: apiPWP.h:264
PWP_BOOL PwModGetAttributeEnum(PWGM_HGRIDMODEL model, const char *name, const char **val)
int PWP_INT32
32-bit integer
Definition: apiPWP.h:207
CaeGridModel & operator=(const CaeGridModel &rhs)
The assignment operator.
PWP_BOOL PwModGetAttributeINT32(PWGM_HGRIDMODEL model, const char *name, PWP_INT32 *val)