Pointwise Plugin SDK
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 }
PWGM_HBLOCK_ID
#define PWGM_HBLOCK_ID(h)
gets the block's guid from the handle
Definition: apiGridModel.h:366
CaeGridModel.h
operator>
bool operator>(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
Definition: CaeGridModel.cxx:158
CaeGridModel::blockCount
PWP_UINT32 blockCount() const
Get the number of blocks in the model.
Definition: CaeGridModel.cxx:35
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
CaeGridModel::getAttributeEnum
bool getAttributeEnum(const char *name, const char *&val, const char *defVal) const
Definition: CaeGridModel.cxx:103
CaeGridModel::CaeGridModel
CaeGridModel(PWGM_HGRIDMODEL model)
Constructor.
Definition: CaeGridModel.cxx:19
PWP_INT32
int PWP_INT32
32-bit integer
Definition: apiPWP.h:207
operator<
bool operator<(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
Definition: CaeGridModel.cxx:140
PWGM_HGRIDMODEL
An opaque handle to a grid model.
Definition: apiGridModel.h:326
PWP_UINT
PWP_UINT32 PWP_UINT
unsigned integer same size as void*
Definition: apiPWP.h:285
CaeGridModel
The grid model base class.
Definition: CaeGridModel.h:46
PwModGetAttributeUINT32
PWP_BOOL PwModGetAttributeUINT32(PWGM_HGRIDMODEL model, const char *name, PWP_UINT32 *val)
Definition: apiGridModel.cxx:152
PwModGetAttributeFLOAT
PWP_BOOL PwModGetAttributeFLOAT(PWGM_HGRIDMODEL model, const char *name, PWP_FLOAT *val)
Definition: apiGridModel.cxx:194
apiGridModel.h
Pointwise Grid Model API Specification (PWGM-API)
PwModBlockCount
PWP_UINT32 PwModBlockCount(PWGM_HGRIDMODEL model)
Get the number of block elements in the model.
Definition: apiGridModel.cxx:83
operator==
bool operator==(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
Definition: CaeGridModel.cxx:124
PWP_REAL
double PWP_REAL
64-bit real
Definition: apiPWP.h:264
PWGM_HBLOCK
An opaque handle to a grid block element.
Definition: apiGridModel.h:345
PwModGetAttributeREAL
PWP_BOOL PwModGetAttributeREAL(PWGM_HGRIDMODEL model, const char *name, PWP_REAL *val)
Definition: apiGridModel.cxx:186
PwModGetAttributeBOOL
PWP_BOOL PwModGetAttributeBOOL(PWGM_HGRIDMODEL model, const char *name, PWP_BOOL *val)
Definition: apiGridModel.cxx:207
PWP_FLOAT
float PWP_FLOAT
32-bit real
Definition: apiPWP.h:261
PwModGetAttributeINT
PWP_BOOL PwModGetAttributeINT(PWGM_HGRIDMODEL model, const char *name, PWP_INT *val)
Definition: apiGridModel.cxx:165
CaeGridModel::getAttribute
bool getAttribute(const char *name, const char *&val, const char *defVal) const
Definition: CaeGridModel.cxx:42
PWP_INT
PWP_INT32 PWP_INT
integer same size as void*
Definition: apiPWP.h:282
PWP_BOOL
int PWP_BOOL
logical value
Definition: apiPWP.h:303
PwModGetAttributeINT32
PWP_BOOL PwModGetAttributeINT32(PWGM_HGRIDMODEL model, const char *name, PWP_INT32 *val)
Definition: apiGridModel.cxx:173
PwModGetAttributeString
PWP_BOOL PwModGetAttributeString(PWGM_HGRIDMODEL model, const char *name, const char **val)
Get an attribute value as a specific type.
Definition: apiGridModel.cxx:136
apiPWP.h
Pointwise Plugin API (PWP-API)
CaeGridModel::operator=
CaeGridModel & operator=(const CaeGridModel &rhs)
The assignment operator.
Definition: CaeGridModel.cxx:111
CaeGridModel::~CaeGridModel
~CaeGridModel()
Destructor.
Definition: CaeGridModel.cxx:29
operator!=
bool operator!=(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
Definition: CaeGridModel.cxx:134
CaeGridModel::model_
PWGM_HGRIDMODEL model_
The bound PWGM_HGRIDMODEL.
Definition: CaeGridModel.h:145
PwModGetAttributeUINT
PWP_BOOL PwModGetAttributeUINT(PWGM_HGRIDMODEL model, const char *name, PWP_UINT *val)
Definition: apiGridModel.cxx:144
PwModGetAttributeEnum
PWP_BOOL PwModGetAttributeEnum(PWGM_HGRIDMODEL model, const char *name, const char **val)
Definition: apiGridModel.cxx:215