Pointwise Plugin SDK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
virtual PWP_UINT32 streamFace(const PWGM_FACESTREAM_DATA &data)=0
Pure virtual face stream handler method.
Data passed to a PWGM_ENDSTREAMCB callback function.
Grid element handle declaration.
Definition: apiGridModel.h:427
void * userData
The PwModStreamFaces user data ptr.
Data passed to a PWGM_FACESTREAMCB callback function.
unsigned long long PWP_UINT64
64-bit unsigned integer
Definition: apiPWP.h:243
PWP_UINT32 vertexCount() const
Get the number of unstructured vertices in the model.
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
CaeUnsGridModel(PWGM_HGRIDMODEL model)
Constructor.
Pointwise Plugin API (PWP-API)
bool operator==(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
void PWP_VOID
no value
Definition: apiPWP.h:317
PWP_VOID PwModDefaultEnumElementOrder(PWGM_HGRIDMODEL model)
Reset the enumElements() ordering sequence to the default (none).
PWGM_HGRIDMODEL model_
The bound PWGM_HGRIDMODEL.
Definition: CaeGridModel.h:145
Pointwise Grid Model API Specification (PWGM-API)
Data passed to a PWGM_BEGINSTREAMCB callback function.
virtual PWP_UINT32 streamEnd(const PWGM_ENDSTREAM_DATA &data)
Virtual end stream implementation.
An opaque handle to a grid vertex element.
Definition: apiGridModel.h:398
PWP_UINT32 PwModVertexCount(PWGM_HGRIDMODEL model)
Get the number of model vertex elements.
#define PWGM_HELEMENT_ID(h)
gets the element&#39;s guid from the handle
Definition: apiGridModel.h:450
The unstructured grid model class.
virtual ~CaeUnsGridModel()
Destructor.
The unstructured grid model face stream handler class.
PWGM_ENUM_FACEORDER
The orderings supported by face streaming.
#define PWGM_HVERTEX_ID(h)
gets the vertex&#39;s guid from the handle
Definition: apiGridModel.h:416
PWP_BOOL PwModCustomIndexSchemeReady(PWGM_HGRIDMODEL model, PWGM_INDEXMAPPERCB cb, void *data)
Notifys the Pointwise export framework that the custom, unstructured index map is ready...
The unstructured grid model index mapper handler class.
static PWP_UINT32 beginCB(PWGM_BEGINSTREAM_DATA *data)
bool operator!=(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
CaeUnsGridModel & operator=(const CaeUnsGridModel &rhs)
Assignment operator.
#define PWGM_HELEMENT_PID(h)
gets the element&#39;s parent id
Definition: apiGridModel.h:446
static PWP_UINT32 faceCB(PWGM_FACESTREAM_DATA *data)
bool appendEnumElementOrder(PWGM_ENUM_ELEMORDER order) const
Append an element type to the current face streaming order.
PWP_VOID defaultEnumElementOrder() const
Reset to the default element type order.
bool streamFaces(PWGM_ENUM_FACEORDER order, CaeFaceStreamHandler &handler) const
Initiate ordered face streaming to the given handler.
virtual PWP_UINT64 mapIndex(const PWP_UINT64 pwgmNdx)=0
Pure virtual index mapping method.
The grid model base class.
Definition: CaeGridModel.h:46
static PWP_UINT32 endCB(PWGM_ENDSTREAM_DATA *data)
PWP_UINT32 PwModDomainCount(PWGM_HGRIDMODEL model)
Get the number of domain elements in the model.
void * userData
The PwModStreamFaces user data ptr.
virtual PWP_UINT32 streamBegin(const PWGM_BEGINSTREAM_DATA &data)
Virtual begin stream implementation.
void * userData
The PwModStreamFaces user data ptr.
bool customIndexSchemeReady(CaeUnsCustomIndexHandler &handler) const
Notify export framework that custom index mapper is ready for use.
An opaque handle to a grid model.
Definition: apiGridModel.h:326
static PWP_UINT64 ndxMapperCB(const PWP_UINT64 pwgmNdx, void *data)
PWGM_ENUM_ELEMORDER
Types of element orderings.
Definition: apiGridModel.h:697
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&#39;s faces to a callback function in the specified order.
bool operator>(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
PWP_UINT32 patchCount() const
Get the number of boundary patches in the model.
bool operator<(const PWGM_HBLOCK &h1, const PWGM_HBLOCK &h2)
#define PWGM_HELEMENT_PTYPE(h)
gets the element&#39;s parent handle type
Definition: apiGridModel.h:448
PWP_BOOL PwModAppendEnumElementOrder(PWGM_HGRIDMODEL model, PWGM_ENUM_ELEMORDER order)
Append an element order to the enumElements() ordering sequence.