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 
28  CaeGridModel(src.model_)
29 {
30 }
31 
33 {
34 }
35 
38 {
39  return PwModDomainCount(model_);
40 }
41 
44 {
45  return PwModVertexCount(model_);
46 }
47 
48 
49 
50 static PWP_UINT32
52 {
54  return handler->streamBegin(*data);
55 }
56 
57 static PWP_UINT32
59 {
61  return handler->streamFace(*data);
62 }
63 
64 static PWP_UINT32
66 {
68  return handler->streamEnd(*data);
69 }
70 
71 bool
73  CaeFaceStreamHandler &handler) const
74 {
75  return 0 != PwModStreamFaces(model_, order, beginCB, faceCB, endCB,
76  &handler);
77 }
78 
79 
80 
81 static PWP_UINT64
82 ndxMapperCB(const PWP_UINT64 pwgmNdx, void *data)
83 {
85  return handler->mapIndex(pwgmNdx);
86 }
87 
88 bool
90 {
91  return 0 != PwModCustomIndexSchemeReady(model_, ndxMapperCB, &handler);
92 }
93 
94 
95 
96 bool
98 {
99  return 0 != PwModAppendEnumElementOrder(model_, order);
100 }
101 
102 PWP_VOID
104 {
106 }
107 
110 {
111  model_ = rhs.model_;
112  return *this;
113 }
114 
115 
116 //***************************************************************************
117 //***************************************************************************
118 //***************************************************************************
119 
120 // data layout for PWGM_HELEMENT:
121 // struct PWGM_HELEMENT {
122 // struct PWGM_HELEMENT_BASE parent {
123 // PWGM_HGRIDMODEL hP;
124 // PWP_UINT32 id;
125 // }
126 // unsigned char ptype;
127 // PWP_UINT32 id;
128 // }
129 
130 bool
132 {
133  // for speed, compare ids first. This assumes that most compares will
134  // differ in ids. Only if ids are the same will the remaining, more
135  // expensive compares be performed.
136  return (PWGM_HELEMENT_ID(h1) == PWGM_HELEMENT_ID(h2)) && // .id
137  (PWGM_HELEMENT_PID(h1) == PWGM_HELEMENT_PID(h2)) && // parent.id
138  (PWGM_HELEMENT_PTYPE(h1) == PWGM_HELEMENT_PTYPE(h2)) && // .type
139  (PWGM_HELEMENT_OUT_GMIMPL(h1) == PWGM_HELEMENT_OUT_GMIMPL(h2)); // parent.hP
140 }
141 
142 bool
144 {
145  return !(h1 == h2);
146 }
147 
148 bool
149 operator<(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
150 {
151  // for speed, compare ids first. This assumes that most compares will
152  // differ in ids. Only if ids are the same will the remaining, more
153  // expensive compares be performed.
154  if (PWGM_HELEMENT_ID(h1) < PWGM_HELEMENT_ID(h2)) { // .id
155  return true;
156  }
157  else if (PWGM_HELEMENT_ID(h1) > PWGM_HELEMENT_ID(h2)) { // .id
158  return false;
159  }
160  else if (PWGM_HELEMENT_PID(h1) < PWGM_HELEMENT_PID(h2)) { // parent.id
161  return true;
162  }
163  else if (PWGM_HELEMENT_PID(h1) > PWGM_HELEMENT_PID(h2)) { // parent.id
164  return false;
165  }
166  else if (PWGM_HELEMENT_PTYPE(h1) < PWGM_HELEMENT_PTYPE(h2)) { // .type
167  return true;
168  }
169  else if (PWGM_HELEMENT_PTYPE(h1) > PWGM_HELEMENT_PTYPE(h2)) { // .type
170  return false;
171  }
172  else if (PWGM_HELEMENT_OUT_GMIMPL(h1) < PWGM_HELEMENT_OUT_GMIMPL(h2)) { //parent.hP
173  return true;
174  }
175  return false; // PWGM_HELEMENT_OUT_GMIMPL(h1) >= PWGM_HELEMENT_OUT_GMIMPL(h2)
176 }
177 
178 bool
179 operator>(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
180 {
181  return (h1 != h2) && !(h1 < h2);
182 }
183 
184 
185 //***************************************************************************
186 //***************************************************************************
187 //***************************************************************************
188 
189 // data layout for PWGM_HVERTEX:
190 // struct PWGM_HVERTEX {
191 // PWGM_HGRIDMODEL hP;
192 // PWP_UINT32 id;
193 // }
194 
195 bool
196 operator==(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
197 {
198  // for speed, compare ids first. This assumes that most compares will
199  // differ in ids. Only if ids are the same will the remaining, more
200  // expensive compares be performed.
201  return (PWGM_HVERTEX_ID(h1) == PWGM_HVERTEX_ID(h2)) && // .id
202  (PWGM_HVERTEX_OUT_GMIMPL(h1) == PWGM_HVERTEX_OUT_GMIMPL(h2)); // .hP
203 }
204 
205 bool
206 operator!=(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
207 {
208  return !(h1 == h2);
209 }
210 
211 bool
212 operator<(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
213 {
214  // for speed, compare ids first. This assumes that most compares will
215  // differ in ids. Only if ids are the same will the remaining, more
216  // expensive compares be performed.
217  if (PWGM_HVERTEX_ID(h1) < PWGM_HVERTEX_ID(h2)) { // .id
218  return true;
219  }
220  else if (PWGM_HVERTEX_ID(h1) > PWGM_HVERTEX_ID(h2)) { // .id
221  return false;
222  }
223  else if (PWGM_HVERTEX_OUT_GMIMPL(h1) < PWGM_HVERTEX_OUT_GMIMPL(h2)) { // parent.hP
224  return true;
225  }
226  return false; // PWGM_HVERTEX_OUT_GMIMPL(h1) >= PWGM_HVERTEX_OUT_GMIMPL(h2)
227 }
228 
229 bool
230 operator>(const PWGM_HVERTEX &h1, const PWGM_HVERTEX &h2)
231 {
232  return (h1 != h2) && !(h1 < h2);
233 }
234 
235 #endif // PWGM_HIDE_UNSTRUCTURED_API
faceCB
static PWP_UINT32 faceCB(PWGM_FACESTREAM_DATA *data)
Definition: CaeUnsGridModel.cxx:58
CaeGridModel.h
PWGM_ENDSTREAM_DATA::userData
void * userData
The PwModStreamFaces user data ptr.
Definition: apiGridModel.h:1144
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:1062
ndxMapperCB
static PWP_UINT64 ndxMapperCB(const PWP_UINT64 pwgmNdx, void *data)
Definition: CaeUnsGridModel.cxx:82
operator==
bool operator==(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:131
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
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
endCB
static PWP_UINT32 endCB(PWGM_ENDSTREAM_DATA *data)
Definition: CaeUnsGridModel.cxx:65
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:697
operator>
bool operator>(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:179
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:32
operator<
bool operator<(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:149
PWGM_BEGINSTREAM_DATA
Data passed to a PWGM_BEGINSTREAMCB callback function.
Definition: apiGridModel.h:1055
PWGM_FACESTREAM_DATA::userData
void * userData
The PwModStreamFaces user data ptr.
Definition: apiGridModel.h:1128
CaeUnsGridModel::customIndexSchemeReady
bool customIndexSchemeReady(CaeUnsCustomIndexHandler &handler) const
Notify export framework that custom index mapper is ready for use.
Definition: CaeUnsGridModel.cxx:89
CaeUnsGridModel::streamFaces
bool streamFaces(PWGM_ENUM_FACEORDER order, CaeFaceStreamHandler &handler) const
Initiate ordered face streaming to the given handler.
Definition: CaeUnsGridModel.cxx:72
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:109
PWGM_ENDSTREAM_DATA
Data passed to a PWGM_ENDSTREAMCB callback function.
Definition: apiGridModel.h:1141
PWGM_FACESTREAM_DATA
Data passed to a PWGM_FACESTREAMCB callback function.
Definition: apiGridModel.h:1104
operator!=
bool operator!=(const PWGM_HELEMENT &h1, const PWGM_HELEMENT &h2)
Definition: CaeUnsGridModel.cxx:143
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
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:37
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:43
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:51
PWGM_ENUM_FACEORDER
PWGM_ENUM_FACEORDER
The orderings supported by face streaming.
Definition: apiGridModel.h:1030
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:103
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:97
CaeUnsGridModel::CaeUnsGridModel
CaeUnsGridModel(PWGM_HGRIDMODEL model)
Constructor.
Definition: CaeUnsGridModel.cxx:22