Pointwise Plugin SDK
CaeUnsGridModel.cxx
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * CaeUnsGridModel 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 #include "apiGridModel.h"
12 #include "apiPWP.h"
13 
14 #include "CaeGridModel.h"
15 #include "CaeUnsGridModel.h"
16 
17 
18 //***************************************************************************
19 //***************************************************************************
20 //***************************************************************************
21 
23  CaeGridModel(model)
24 {
25 }
26 
27 
29  CaeGridModel(src.model_)
30 {
31 }
32 
33 
35 {
36 }
37 
38 
41 {
42  return PwModDomainCount(model_);
43 }
44 
45 
48 {
49  return PwModVertexCount(model_);
50 }
51 
52 
53 
54 static PWP_UINT32
56 {
58  return handler->streamBegin(*data);
59 }
60 
61 
62 static PWP_UINT32
64 {
66  return handler->streamFace(*data);
67 }
68 
69 
70 static PWP_UINT32
72 {
74  return handler->streamEnd(*data);
75 }
76 
77 
78 bool
80  CaeFaceStreamHandler &handler) const
81 {
82  return 0 != PwModStreamFaces(model_, order, beginCB, faceCB, endCB,
83  &handler);
84 }
85 
86 
87 
88 static PWP_UINT64
89 ndxMapperCB(const PWP_UINT64 pwgmNdx, void *data)
90 {
92  return handler->mapIndex(pwgmNdx);
93 }
94 
95 bool
97 {
98  return 0 != PwModCustomIndexSchemeReady(model_, ndxMapperCB, &handler);
99 }
100 
101 
102 
103 bool
105 {
106  return 0 != PwModAppendEnumElementOrder(model_, order);
107 }
108 
109 
110 PWP_VOID
112 {
114 }
115 
116 
119 {
120  PWP_UINT32 ret = 0;
121  CaeUnsPatch patch(*this);
122  if (nullptr == pDetails) {
123  // no details wanted
124  while (patch.isValid()) {
125  ret += patch.elementCount(nullptr);
126  ++patch;
127  }
128  }
129  else {
130  PWGM_ELEMCOUNTS cnts;
131  while (patch.isValid()) {
132  ret += patch.elementCount(&cnts);
133  PWGM_ECNT_Bar(*pDetails) += PWGM_ECNT_Bar(cnts);
134  PWGM_ECNT_Tri(*pDetails) += PWGM_ECNT_Tri(cnts);
135  PWGM_ECNT_Quad(*pDetails) += PWGM_ECNT_Quad(cnts);
136  PWGM_ECNT_Polygon(*pDetails) += PWGM_ECNT_Polygon(cnts);
137  ++patch;
138  }
139  }
140  return ret;
141 }
142 
143 
146 {
147  model_ = rhs.model_;
148  return *this;
149 }
150 
151 
152 //***************************************************************************
153 //***************************************************************************
154 //***************************************************************************
155 
156 // data layout for PWGM_HELEMENT:
157 // struct PWGM_HELEMENT {
158 // struct PWGM_HELEMENT_BASE parent {
159 // PWGM_HGRIDMODEL hP;
160 // PWP_UINT32 id;
161 // }
162 // unsigned char ptype;
163 // PWP_UINT32 id;
164 // }
165 
166 bool
168 {
169  // for speed, compare ids first. This assumes that most compares will
170  // differ in ids. Only if ids are the same will the remaining, more
171  // expensive compares be performed.
172  return (PWGM_HELEMENT_ID(h1) == PWGM_HELEMENT_ID(h2)) && // .id
173  (PWGM_HELEMENT_PID(h1) == PWGM_HELEMENT_PID(h2)) && // parent.id
174  (PWGM_HELEMENT_PTYPE(h1) == PWGM_HELEMENT_PTYPE(h2)) && // .type
175  (PWGM_HELEMENT_OUT_GMIMPL(h1) == PWGM_HELEMENT_OUT_GMIMPL(h2)); // parent.hP
176 }
177 
178 
179 bool
181 {
182  return !(h1 == h2);
183 }
184 
185 
186 bool
187 operator<(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
188 {
189  // for speed, compare ids first. This assumes that most compares will
190  // differ in ids. Only if ids are the same will the remaining, more
191  // expensive compares be performed.
192  if (PWGM_HELEMENT_ID(h1) < PWGM_HELEMENT_ID(h2)) { // .id
193  return true;
194  }
195  else if (PWGM_HELEMENT_ID(h1) > PWGM_HELEMENT_ID(h2)) { // .id
196  return false;
197  }
198  else if (PWGM_HELEMENT_PID(h1) < PWGM_HELEMENT_PID(h2)) { // parent.id
199  return true;
200  }
201  else if (PWGM_HELEMENT_PID(h1) > PWGM_HELEMENT_PID(h2)) { // parent.id
202  return false;
203  }
204  else if (PWGM_HELEMENT_PTYPE(h1) < PWGM_HELEMENT_PTYPE(h2)) { // .type
205  return true;
206  }
207  else if (PWGM_HELEMENT_PTYPE(h1) > PWGM_HELEMENT_PTYPE(h2)) { // .type
208  return false;
209  }
210  else if (PWGM_HELEMENT_OUT_GMIMPL(h1) < PWGM_HELEMENT_OUT_GMIMPL(h2)) { //parent.hP
211  return true;
212  }
213  return false; // PWGM_HELEMENT_OUT_GMIMPL(h1) >= PWGM_HELEMENT_OUT_GMIMPL(h2)
214 }
215 
216 
217 bool
218 operator>(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
219 {
220  return (h1 != h2) && !(h1 < h2);
221 }
222 
223 
224 //***************************************************************************
225 //***************************************************************************
226 //***************************************************************************
227 
228 // data layout for PWGM_HVERTEX:
229 // struct PWGM_HVERTEX {
230 // PWGM_HGRIDMODEL hP;
231 // PWP_UINT32 id;
232 // }
233 
234 bool
235 operator==(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
236 {
237  // for speed, compare ids first. This assumes that most compares will
238  // differ in ids. Only if ids are the same will the remaining, more
239  // expensive compares be performed.
240  return (PWGM_HVERTEX_ID(h1) == PWGM_HVERTEX_ID(h2)) && // .id
241  (PWGM_HVERTEX_OUT_GMIMPL(h1) == PWGM_HVERTEX_OUT_GMIMPL(h2)); // .hP
242 }
243 
244 
245 bool
246 operator!=(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
247 {
248  return !(h1 == h2);
249 }
250 
251 
252 bool
253 operator<(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
254 {
255  // for speed, compare ids first. This assumes that most compares will
256  // differ in ids. Only if ids are the same will the remaining, more
257  // expensive compares be performed.
258  if (PWGM_HVERTEX_ID(h1) < PWGM_HVERTEX_ID(h2)) { // .id
259  return true;
260  }
261  else if (PWGM_HVERTEX_ID(h1) > PWGM_HVERTEX_ID(h2)) { // .id
262  return false;
263  }
264  else if (PWGM_HVERTEX_OUT_GMIMPL(h1) < PWGM_HVERTEX_OUT_GMIMPL(h2)) { // parent.hP
265  return true;
266  }
267  return false; // PWGM_HVERTEX_OUT_GMIMPL(h1) >= PWGM_HVERTEX_OUT_GMIMPL(h2)
268 }
269 
270 
271 bool
272 operator>(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
273 {
274  return (h1 != h2) && !(h1 < h2);
275 }
276 
277 #endif // PWGM_HIDE_UNSTRUCTURED_API
faceCB
static PWP_UINT32 faceCB(PWGM_FACESTREAM_DATA *data)
Definition: CaeUnsGridModel.cxx:63
CaeGridModel.h
PWGM_ENDSTREAM_DATA::userData
void * userData
The PwModStreamFaces user data ptr.
Definition: apiGridModel.h:1173
PWGM_HELEMENT
Grid element handle declaration.
Definition: apiGridModel.h:427
CaeFaceStreamHandler::streamBegin
virtual PWP_UINT32 streamBegin(const PWGM_BEGINSTREAM_DATA &data)
Virtual begin stream implementation.
Definition: CaeUnsGridModel.h:93
PWGM_BEGINSTREAM_DATA::userData
void * userData
The PwModStreamFaces user data ptr.
Definition: apiGridModel.h:1091
ndxMapperCB
static PWP_UINT64 ndxMapperCB(const PWP_UINT64 pwgmNdx, void *data)
Definition: CaeUnsGridModel.cxx:89
operator==
bool operator==(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:167
CaeUnsElementGroup::elementCount
PWP_UINT32 elementCount(PWGM_ELEMCOUNTS *pDetails=0) const
Get the number of elements in the group.
Definition: CaeUnsElementGroup.h:59
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
PwModVertexCount
PWP_UINT32 PwModVertexCount(PWGM_HGRIDMODEL model)
Get the number of model vertex elements.
Definition: apiGridModel.cxx:250
PwModDomainCount
PWP_UINT32 PwModDomainCount(PWGM_HGRIDMODEL model)
Get the number of domain elements in the model.
Definition: apiGridModel.cxx:226
CaeUnsGridModel
The unstructured grid model class.
Definition: CaeUnsGridModel.h:176
CaeUnsPatch::isValid
bool isValid() const
Determines a patch's validity.
Definition: CaeUnsPatch.h:146
PWGM_HVERTEX_ID
#define PWGM_HVERTEX_ID(h)
gets the vertex's guid from the handle
Definition: apiGridModel.h:416
PWGM_HGRIDMODEL
An opaque handle to a grid model.
Definition: apiGridModel.h:326
PWP_VOID
void PWP_VOID
no value
Definition: apiPWP.h:317
PwModDefaultEnumElementOrder
PWP_VOID PwModDefaultEnumElementOrder(PWGM_HGRIDMODEL model)
Reset the enumElements() ordering sequence to the default (none).
Definition: apiGridModel.cxx:301
PWGM_HELEMENT_PTYPE
#define PWGM_HELEMENT_PTYPE(h)
gets the element's parent handle type
Definition: apiGridModel.h:448
CaeGridModel
The grid model base class.
Definition: CaeGridModel.h:46
CaeUnsPatch
The unstructured patch class.
Definition: CaeUnsPatch.h:69
endCB
static PWP_UINT32 endCB(PWGM_ENDSTREAM_DATA *data)
Definition: CaeUnsGridModel.cxx:71
CaeFaceStreamHandler::streamEnd
virtual PWP_UINT32 streamEnd(const PWGM_ENDSTREAM_DATA &data)
Virtual end stream implementation.
Definition: CaeUnsGridModel.h:126
apiGridModel.h
Pointwise Grid Model API Specification (PWGM-API)
PWGM_ENUM_ELEMORDER
PWGM_ENUM_ELEMORDER
Types of element orderings.
Definition: apiGridModel.h:699
PWGM_ECNT_Tri
#define PWGM_ECNT_Tri(ecs)
Extract the Tri count from a PWGM_ELEMCOUNTS struct.
Definition: apiGridModel.h:812
PWGM_ECNT_Polygon
#define PWGM_ECNT_Polygon(ecs)
Extract the Polygon count from a PWGM_ELEMCOUNTS struct.
Definition: apiGridModel.h:842
operator>
bool operator>(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:218
PWGM_ECNT_Quad
#define PWGM_ECNT_Quad(ecs)
Extract the Quad count from a PWGM_ELEMCOUNTS struct.
Definition: apiGridModel.h:806
PWGM_HELEMENT_ID
#define PWGM_HELEMENT_ID(h)
gets the element's guid from the handle
Definition: apiGridModel.h:450
CaeUnsGridModel::~CaeUnsGridModel
virtual ~CaeUnsGridModel()
Destructor.
Definition: CaeUnsGridModel.cxx:34
PWGM_ELEMCOUNTS
Element count information.
Definition: apiGridModel.h:774
operator<
bool operator<(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:187
PWGM_BEGINSTREAM_DATA
Data passed to a PWGM_BEGINSTREAMCB callback function.
Definition: apiGridModel.h:1084
CaeUnsGridModel::patchElementCount
PWP_UINT32 patchElementCount(PWGM_ELEMCOUNTS *pDetails=nullptr) const
Get the number of patch elements in the model.
Definition: CaeUnsGridModel.cxx:118
PWGM_FACESTREAM_DATA::userData
void * userData
The PwModStreamFaces user data ptr.
Definition: apiGridModel.h:1157
CaeUnsGridModel::customIndexSchemeReady
bool customIndexSchemeReady(CaeUnsCustomIndexHandler &handler) const
Notify export framework that custom index mapper is ready for use.
Definition: CaeUnsGridModel.cxx:96
CaeUnsGridModel::streamFaces
bool streamFaces(PWGM_ENUM_FACEORDER order, CaeFaceStreamHandler &handler) const
Initiate ordered face streaming to the given handler.
Definition: CaeUnsGridModel.cxx:79
CaeUnsCustomIndexHandler
The unstructured grid model index mapper handler class.
Definition: CaeUnsGridModel.h:147
CaeUnsGridModel.h
CaeUnsGridModel::operator=
CaeUnsGridModel & operator=(const CaeUnsGridModel &rhs)
Assignment operator.
Definition: CaeUnsGridModel.cxx:145
PWGM_ENDSTREAM_DATA
Data passed to a PWGM_ENDSTREAMCB callback function.
Definition: apiGridModel.h:1170
PWGM_FACESTREAM_DATA
Data passed to a PWGM_FACESTREAMCB callback function.
Definition: apiGridModel.h:1133
operator!=
bool operator!=(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:180
CaeUnsCustomIndexHandler::mapIndex
virtual PWP_UINT64 mapIndex(const PWP_UINT64 pwgmNdx)=0
Pure virtual index mapping method.
PwModStreamFaces
PWP_BOOL PwModStreamFaces(PWGM_HGRIDMODEL model, PWGM_ENUM_FACEORDER order, PWGM_BEGINSTREAMCB beginCB, PWGM_FACESTREAMCB faceCB, PWGM_ENDSTREAMCB endCB, void *userData)
Stream the grid model's faces to a callback function in the specified order.
Definition: apiGridModel.cxx:266
PWGM_ECNT_Bar
#define PWGM_ECNT_Bar(ecs)
Extract the Bar count from a PWGM_ELEMCOUNTS struct.
Definition: apiGridModel.h:794
CaeFaceStreamHandler
The unstructured grid model face stream handler class.
Definition: CaeUnsGridModel.h:72
PWGM_HVERTEX
An opaque handle to a grid vertex element.
Definition: apiGridModel.h:398
PWGM_HELEMENT_PID
#define PWGM_HELEMENT_PID(h)
gets the element's parent id
Definition: apiGridModel.h:446
CaeUnsGridModel::patchCount
PWP_UINT32 patchCount() const
Get the number of boundary patches in the model.
Definition: CaeUnsGridModel.cxx:40
apiPWP.h
Pointwise Plugin API (PWP-API)
PwModAppendEnumElementOrder
PWP_BOOL PwModAppendEnumElementOrder(PWGM_HGRIDMODEL model, PWGM_ENUM_ELEMORDER order)
Append an element order to the enumElements() ordering sequence.
Definition: apiGridModel.cxx:293
CaeUnsGridModel::vertexCount
PWP_UINT32 vertexCount() const
Get the number of unstructured vertices in the model.
Definition: CaeUnsGridModel.cxx:47
PWP_UINT64
unsigned long long PWP_UINT64
64-bit unsigned integer
Definition: apiPWP.h:243
beginCB
static PWP_UINT32 beginCB(PWGM_BEGINSTREAM_DATA *data)
Definition: CaeUnsGridModel.cxx:55
PWGM_ENUM_FACEORDER
PWGM_ENUM_FACEORDER
The orderings supported by face streaming.
Definition: apiGridModel.h:1059
PwModCustomIndexSchemeReady
PWP_BOOL PwModCustomIndexSchemeReady(PWGM_HGRIDMODEL model, PWGM_INDEXMAPPERCB cb, void *data)
Notifys the Pointwise export framework that the custom, unstructured index map is ready.
Definition: apiGridModel.cxx:258
CaeFaceStreamHandler::streamFace
virtual PWP_UINT32 streamFace(const PWGM_FACESTREAM_DATA &data)=0
Pure virtual face stream handler method.
CaeUnsGridModel::defaultEnumElementOrder
PWP_VOID defaultEnumElementOrder() const
Reset to the default element type order.
Definition: CaeUnsGridModel.cxx:111
CaeGridModel::model_
PWGM_HGRIDMODEL model_
The bound PWGM_HGRIDMODEL.
Definition: CaeGridModel.h:145
CaeUnsGridModel::appendEnumElementOrder
bool appendEnumElementOrder(PWGM_ENUM_ELEMORDER order) const
Append an element type to the current face streaming order.
Definition: CaeUnsGridModel.cxx:104
CaeUnsGridModel::CaeUnsGridModel
CaeUnsGridModel(PWGM_HGRIDMODEL model)
Constructor.
Definition: CaeUnsGridModel.cxx:22