Pointwise Plugin SDK
CaeStrGridModel.cxx
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * CaeStrGridModel class
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 #if !defined(PWGM_HIDE_STRUCTURED_API)
10 
11 #include "apiGridModel.h"
12 #include "apiPWP.h"
13 
14 #include "CaeGridModel.h"
15 #include "CaeStrGridModel.h"
16 
17 
18 //***************************************************************************
19 //***************************************************************************
20 //***************************************************************************
21 
23  CaeGridModel(model)
24 {
25 }
26 
28  CaeGridModel(src.model_)
29 {
30 }
31 
33 {
34 }
35 
36 
37 
38 static PWGM_INDEX3
39 ndxMapperCB(const PWGM_INDEX3 pwgmNdx, void *data)
40 {
42  return handler->mapIndex(pwgmNdx);
43 }
44 
45 bool
47 {
48  return 0 != PwModCustomIndex3SchemeReady(model_, ndxMapperCB, &handler);
49 }
50 
51 
52 bool
54 {
55  return 0 != PwXform2to3(&x2, &x3);
56 }
57 
58 bool
60 {
61  return 0 != PwXform3to2(&x3, &x2);
62 }
63 
66 {
67  return PwXformApply(&x3, ijk);
68 }
69 
72  localAxis, bool *pFlipped)
73 {
74  PWP_BOOL locFlipped;
75  PWGM_ENUM_IJK ret = PwXformFollows(&x3, localAxis, &locFlipped);
76  if (0 != pFlipped) {
77  *pFlipped = (0 != locFlipped);
78  }
79  return ret;
80 }
81 
84  ijk)
85 {
86  return PwXform2Apply(&x2, ijk);
87 }
88 
91  localAxis, bool *pFlipped)
92 {
93  PWP_BOOL locFlipped;
94  PWGM_ENUM_IJK ret = PwXform2Follows(&x2, localAxis, &locFlipped);
95  if (0 != pFlipped) {
96  *pFlipped = (0 != locFlipped);
97  }
98  return ret;
99 }
100 
101 bool
103 {
104  return 0 != PwInRange(ijk, &range);
105 }
106 
107 
108 // data layout for PWGM_HBNDRY:
109 // struct PWGM_HBNDRY {
110 // PWGM_HGRIDMODEL hP;
111 // PWP_UINT32 id;
112 // }
113 
114 bool
115 operator==(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
116 {
117  // for speed, compare ids first. This assumes that most compares will
118  // differ in ids. Only if ids are the same will the remaining, more
119  // expensive compares be performed.
120  return (PWGM_HBNDRY_ID(h1) == PWGM_HBNDRY_ID(h2)) && // .id
121  (PWGM_HBNDRY_OUT_GMIMPL(h1) == PWGM_HBNDRY_OUT_GMIMPL(h2)); // .hP
122 }
123 
124 bool
125 operator!=(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
126 {
127  return !(h1 == h2);
128 }
129 
130 bool
131 operator<(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
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  if (PWGM_HBNDRY_ID(h1) < PWGM_HBNDRY_ID(h2)) { // .id
137  return true;
138  }
139  else if (PWGM_HBNDRY_ID(h1) > PWGM_HBNDRY_ID(h2)) { // .id
140  return false;
141  }
142  else if (PWGM_HBNDRY_OUT_GMIMPL(h1) < PWGM_HBNDRY_OUT_GMIMPL(h2)) { // parent.hP
143  return true;
144  }
145  return false; // PWGM_HBNDRY_OUT_GMIMPL(h1) >= PWGM_HBNDRY_OUT_GMIMPL(h2)
146 }
147 
148 bool
149 operator>(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
150 {
151  return (h1 != h2) && !(h1 < h2);
152 }
153 
154 
155 // data layout for PWGM_HCNXN:
156 // struct PWGM_HCNXN {
157 // PWGM_HGRIDMODEL hP;
158 // PWP_UINT32 id;
159 // }
160 
161 bool
162 operator==(const PWGM_HCNXN &h1, const PWGM_HCNXN &h2)
163 {
164  // for speed, compare ids first. This assumes that most compares will
165  // differ in ids. Only if ids are the same will the remaining, more
166  // expensive compares be performed.
167  return (PWGM_HCNXN_ID(h1) == PWGM_HCNXN_ID(h2)) && // .id
168  (PWGM_HCNXN_OUT_GMIMPL(h1) == PWGM_HCNXN_OUT_GMIMPL(h2)); // .hP
169 }
170 
171 bool
172 operator!=(const PWGM_HCNXN &h1, const PWGM_HCNXN &h2)
173 {
174  return !(h1 == h2);
175 }
176 
177 bool
178 operator<(const PWGM_HCNXN &h1, const PWGM_HCNXN &h2)
179 {
180  // for speed, compare ids first. This assumes that most compares will
181  // differ in ids. Only if ids are the same will the remaining, more
182  // expensive compares be performed.
183  if (PWGM_HCNXN_ID(h1) < PWGM_HCNXN_ID(h2)) { // .id
184  return true;
185  }
186  else if (PWGM_HCNXN_ID(h1) > PWGM_HCNXN_ID(h2)) { // .id
187  return false;
188  }
189  else if (PWGM_HCNXN_OUT_GMIMPL(h1) < PWGM_HCNXN_OUT_GMIMPL(h2)) { // parent.hP
190  return true;
191  }
192  return false; // PWGM_HCNXN_OUT_GMIMPL(h1) >= PWGM_HCNXN_OUT_GMIMPL(h2)
193 }
194 
195 bool
196 operator>(const PWGM_HCNXN &h1, const PWGM_HCNXN &h2)
197 {
198  return (h1 != h2) && !(h1 < h2);
199 }
200 
201 #endif // PWGM_HIDE_STRUCTURED_API
CaeGridModel.h
CaeStrGridModel::xform2Apply
static PWGM_INDEX3 xform2Apply(const PWGM_INDEX_XFORM2 &x2, const PWGM_INDEX3 &ijk)
Apply a transform to an ij connection index.
Definition: CaeStrGridModel.cxx:83
CaeStrGridModel::xformFollows
static PWGM_ENUM_IJK xformFollows(const PWGM_INDEX_XFORM &x3, PWGM_ENUM_IJK localAxis, bool *pFlipped=0)
Determines which axes are parallel in a transformed ijk system.
Definition: CaeStrGridModel.cxx:71
CaeStrGridModel::xform2to3
static bool xform2to3(const PWGM_INDEX_XFORM2 &x2, PWGM_INDEX_XFORM &x3)
Up converts an ij transform to an equivalent ijk transform.
Definition: CaeStrGridModel.cxx:53
PwXform2Follows
PWGM_ENUM_IJK PwXform2Follows(const PWGM_INDEX_XFORM2 *pX2, PWGM_ENUM_IJK localAxis, PWP_BOOL *pFlipped)
For a given localAxis, determine the corresponding axis in the transformed system.
Definition: apiGridModel.cxx:768
CaeStrGridModel::~CaeStrGridModel
virtual ~CaeStrGridModel()
Destructor.
Definition: CaeStrGridModel.cxx:32
operator==
bool operator==(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
Definition: CaeStrGridModel.cxx:115
CaeStrGridModel::xform2Follows
static PWGM_ENUM_IJK xform2Follows(const PWGM_INDEX_XFORM2 &x2, PWGM_ENUM_IJK localAxis, bool *pFlipped=0)
Determines which axes are parallel in a transformed ij system.
Definition: CaeStrGridModel.cxx:90
PWGM_HBNDRY_ID
#define PWGM_HBNDRY_ID(h)
gets the boundary's guid from the handle
Definition: apiGridModel.h:475
CaeStrCustomIndexHandler
The structured grid model index mapper handler class.
Definition: CaeStrGridModel.h:36
PWGM_HGRIDMODEL
An opaque handle to a grid model.
Definition: apiGridModel.h:326
CaeGridModel
The grid model base class.
Definition: CaeGridModel.h:46
CaeStrGridModel::inRange
static bool inRange(const PWGM_INDEX3 &ijk, const PWGM_STR_RANGE &range)
Determines if an ijk index is within a given min/max range.
Definition: CaeStrGridModel.cxx:102
PWGM_HCNXN
An opaque handle to a structured, inter-block connection.
Definition: apiGridModel.h:482
PwXform3to2
PWP_BOOL PwXform3to2(const PWGM_INDEX_XFORM *pX3, PWGM_INDEX_XFORM2 *pX2)
Convert a 3D transform matrix to it's 2D equivalent.
Definition: apiGridModel.cxx:676
apiGridModel.h
Pointwise Grid Model API Specification (PWGM-API)
PWGM_INDEX_XFORM2
The 2D transform matrix data type.
Definition: apiGridModel.h:932
PWGM_INDEX3
Structured grid ijk index data type.
Definition: apiGridModel.h:888
PWGM_HCNXN_ID
#define PWGM_HCNXN_ID(h)
gets the connection's guid from the handle
Definition: apiGridModel.h:500
CaeStrGridModel::xformApply
static PWGM_INDEX3 xformApply(const PWGM_INDEX_XFORM &x3, const PWGM_INDEX3 &ijk)
Apply an ijk transform to an ijk connection index.
Definition: CaeStrGridModel.cxx:65
PwModCustomIndex3SchemeReady
PWP_BOOL PwModCustomIndex3SchemeReady(PWGM_HGRIDMODEL model, PWGM_INDEX3MAPPERCB cb, void *data)
Notifys the Pointwise export framework that the custom, structured index3 map is ready.
Definition: apiGridModel.cxx:554
CaeStrCustomIndexHandler::mapIndex
virtual PWGM_INDEX3 mapIndex(const PWGM_INDEX3 pwgmNdx)=0
Pure virtual index mapping method.
PwInRange
PWP_BOOL PwInRange(PWGM_INDEX3 ijk, const PWGM_STR_RANGE *pRange)
Determines if an PWGM_INDEX3 is within a PWGM_STR_RANGE.
Definition: apiGridModel.cxx:781
PwXformApply
PWGM_INDEX3 PwXformApply(const PWGM_INDEX_XFORM *pX3, PWGM_INDEX3 ijk)
Apply a PWGM_INDEX_XFORM transform to a PWGM_INDEX3 value.
Definition: apiGridModel.cxx:699
ndxMapperCB
static PWGM_INDEX3 ndxMapperCB(const PWGM_INDEX3 pwgmNdx, void *data)
Definition: CaeStrGridModel.cxx:39
CaeStrGridModel
The structured grid model class.
Definition: CaeStrGridModel.h:66
PWGM_INDEX_XFORM
The 3D transform matrix data type.
Definition: apiGridModel.h:921
PWP_BOOL
int PWP_BOOL
logical value
Definition: apiPWP.h:303
operator>
bool operator>(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
Definition: CaeStrGridModel.cxx:149
PwXform2to3
PWP_BOOL PwXform2to3(const PWGM_INDEX_XFORM2 *pX2, PWGM_INDEX_XFORM *pX3)
Convert a 2D transform matrix to it's 3D equivalent.
Definition: apiGridModel.cxx:646
CaeStrGridModel::CaeStrGridModel
CaeStrGridModel(PWGM_HGRIDMODEL model)
Constructor.
Definition: CaeStrGridModel.cxx:22
PWGM_HBNDRY
An opaque handle to a structured block boundary.
Definition: apiGridModel.h:457
PwXformFollows
PWGM_ENUM_IJK PwXformFollows(const PWGM_INDEX_XFORM *pX3, PWGM_ENUM_IJK localAxis, PWP_BOOL *pFlipped)
For a given localAxis, determine the corresponding axis in the transformed system.
Definition: apiGridModel.cxx:713
operator!=
bool operator!=(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
Definition: CaeStrGridModel.cxx:125
apiPWP.h
Pointwise Plugin API (PWP-API)
CaeStrGridModel.h
CaeStrGridModel::customIndexSchemeReady
bool customIndexSchemeReady(CaeStrCustomIndexHandler &handler) const
Notify export framework that custom index mapper is ready for use.
Definition: CaeStrGridModel.cxx:46
operator<
bool operator<(const PWGM_HBNDRY &h1, const PWGM_HBNDRY &h2)
Definition: CaeStrGridModel.cxx:131
PWGM_ENUM_IJK
PWGM_ENUM_IJK
IJK component type ids.
Definition: apiGridModel.h:1015
PwXform2Apply
PWGM_INDEX3 PwXform2Apply(const PWGM_INDEX_XFORM2 *pX2, PWGM_INDEX3 ijk)
Apply a PWGM_INDEX_XFORM2 transform to a PWGM_INDEX3 value.
Definition: apiGridModel.cxx:757
PWGM_STR_RANGE
Structured grid ijk range data type.
Definition: apiGridModel.h:909
CaeStrGridModel::xform3to2
static bool xform3to2(const PWGM_INDEX_XFORM &x3, PWGM_INDEX_XFORM2 &x2)
Down converts a ijk transform to an equivalent ij transform.
Definition: CaeStrGridModel.cxx:59
CaeGridModel::model_
PWGM_HGRIDMODEL model_
The bound PWGM_HGRIDMODEL.
Definition: CaeGridModel.h:145