-
Notifications
You must be signed in to change notification settings - Fork 49
/
UnstructuredGrid3D.cpp
251 lines (190 loc) · 7.11 KB
/
UnstructuredGrid3D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#include <iostream>
#include <vector>
#include "vapor/VAssert.h"
#include <cmath>
#include <time.h>
#ifdef Darwin
#include <mach/mach_time.h>
#endif
#ifdef _WINDOWS
#include "windows.h"
#include "Winbase.h"
#include <limits>
#endif
#include <vapor/utils.h>
#include <vapor/vizutil.h>
#include <vapor/UnstructuredGrid3D.h>
using namespace std;
using namespace VAPoR;
UnstructuredGrid3D::UnstructuredGrid3D(const DimsType &vertexDims, const DimsType &faceDims, const DimsType &edgeDims, const DimsType &bs, const std::vector<float *> &blks, const int *vertexOnFace,
const int *faceOnVertex, const int *faceOnFace,
Location location, // node,face, edge
size_t maxVertexPerFace, size_t maxFacePerVertex, long nodeOffset, long cellOffset, const UnstructuredGridCoordless &xug, const UnstructuredGridCoordless &yug,
const UnstructuredGridCoordless &zug)
: UnstructuredGrid(vertexDims, faceDims, edgeDims, bs, blks, 3, vertexOnFace, faceOnVertex, faceOnFace, location, maxVertexPerFace, maxFacePerVertex, nodeOffset, cellOffset), _xug(xug), _yug(yug),
_zug(zug)
{
// These can be 0 in the case of a single-particle dataset since vapor considers length 1 topological data-dimensions as not contributing to the grids topological dimension
// VAssert(xug.GetNumDimensions() == 1);
// VAssert(yug.GetNumDimensions() == 1);
// VAssert(zug.GetNumDimensions() == 1);
VAssert(location == NODE);
}
UnstructuredGrid3D::UnstructuredGrid3D(const std::vector<size_t> &vertexDims, const std::vector<size_t> &faceDims, const std::vector<size_t> &edgeDims, const std::vector<size_t> &bs,
const std::vector<float *> &blks, const int *vertexOnFace, const int *faceOnVertex, const int *faceOnFace,
Location location, // node,face, edge
size_t maxVertexPerFace, size_t maxFacePerVertex, long nodeOffset, long cellOffset, const UnstructuredGridCoordless &xug, const UnstructuredGridCoordless &yug,
const UnstructuredGridCoordless &zug)
: UnstructuredGrid(vertexDims, faceDims, edgeDims, bs, blks, 3, vertexOnFace, faceOnVertex, faceOnFace, location, maxVertexPerFace, maxFacePerVertex, nodeOffset, cellOffset), _xug(xug), _yug(yug),
_zug(zug)
{
// These can be 0 in the case of a single-particle dataset since vapor considers length 1 topological data-dimensions as not contributing to the grids topological dimension
// VAssert(xug.GetNumDimensions() == 1);
// VAssert(yug.GetNumDimensions() == 1);
// VAssert(zug.GetNumDimensions() == 1);
VAssert(location == NODE);
}
DimsType UnstructuredGrid3D::GetCoordDimensions(size_t dim) const
{
DimsType dims = {1, 1, 1};
if (dim == 0) {
dims = _xug.GetDimensions();
} else if (dim == 1) {
dims = _yug.GetDimensions();
} else if (dim == 2) {
dims = _zug.GetDimensions();
}
return (dims);
}
size_t UnstructuredGrid3D::GetGeometryDim() const { return (3); }
void UnstructuredGrid3D::GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const
{
float range[2];
_xug.GetRange(range);
minu[0] = range[0];
maxu[0] = range[1];
_yug.GetRange(range);
minu[1] = range[0];
maxu[1] = range[1];
_zug.GetRange(range);
minu[2] = range[0];
maxu[2] = range[1];
}
void UnstructuredGrid3D::GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const
{
DimsType cMin;
ClampIndex(min, cMin);
DimsType cMax;
ClampIndex(max, cMax);
float range[2];
_xug.GetRange(min, max, range);
minu[0] = range[0];
maxu[0] = range[1];
_yug.GetRange(min, max, range);
minu[1] = range[0];
maxu[1] = range[1];
_zug.GetRange(min, max, range);
minu[2] = range[0];
maxu[2] = range[1];
}
bool UnstructuredGrid3D::GetEnclosingRegion(const CoordType &minu, const CoordType &maxu, DimsType &min, DimsType &max) const
{
VAssert(0 && "Not implemented");
return (true);
}
void UnstructuredGrid3D::GetUserCoordinates(const DimsType &indices, CoordType &coords) const
{
DimsType cIndices;
ClampIndex(indices, cIndices);
coords[0] = _xug.GetValueAtIndex(cIndices);
coords[1] = _yug.GetValueAtIndex(cIndices);
coords[2] = _zug.GetValueAtIndex(cIndices);
}
bool UnstructuredGrid3D::GetIndicesCell(const CoordType &coords, DimsType &indices) const
{
vector<size_t> nodes2D;
vector<double> lambda;
float zwgt[2];
return (_insideGrid(coords, indices, nodes2D, lambda, zwgt));
}
bool UnstructuredGrid3D::InsideGrid(const CoordType &coords) const
{
DimsType indices;
std::vector<size_t> nodes2D;
vector<double> lambda;
float zwgt[2];
return (_insideGrid(coords, indices, nodes2D, lambda, zwgt));
}
bool UnstructuredGrid3D::_insideGrid(const CoordType &coords, DimsType &cindices, std::vector<size_t> &nodes2D, std::vector<double> &lambda, float zwgt[2]) const
{
VAssert(!"Not implemented");
return false;
}
float UnstructuredGrid3D::GetValueNearestNeighbor(const CoordType &coords) const
{
VAssert(!"Not implemented");
return NAN;
}
float UnstructuredGrid3D::GetValueLinear(const CoordType &coords) const
{
VAssert(!"Not implemented");
return NAN;
}
/////////////////////////////////////////////////////////////////////////////
//
// Iterators
//
/////////////////////////////////////////////////////////////////////////////
UnstructuredGrid3D::ConstCoordItrU3D::ConstCoordItrU3D(const UnstructuredGrid3D *ug, bool begin) : ConstCoordItrAbstract()
{
_ug = ug;
_coords = {0.0, 0.0, 0.0};
if (begin) {
_xCoordItr = ug->_xug.cbegin();
_yCoordItr = ug->_yug.cbegin();
_zCoordItr = ug->_zug.cbegin();
_coords[0] = *_xCoordItr;
_coords[1] = *_yCoordItr;
_coords[2] = *_zCoordItr;
} else {
_xCoordItr = ug->_xug.cend();
_yCoordItr = ug->_yug.cend();
_zCoordItr = ug->_zug.cend();
}
}
UnstructuredGrid3D::ConstCoordItrU3D::ConstCoordItrU3D(const ConstCoordItrU3D &rhs) : ConstCoordItrAbstract()
{
_ug = rhs._ug;
_xCoordItr = rhs._xCoordItr;
_yCoordItr = rhs._yCoordItr;
_zCoordItr = rhs._zCoordItr;
_coords = rhs._coords;
}
UnstructuredGrid3D::ConstCoordItrU3D::ConstCoordItrU3D() : ConstCoordItrAbstract() {}
void UnstructuredGrid3D::ConstCoordItrU3D::next()
{
++_xCoordItr;
++_yCoordItr;
++_zCoordItr;
_coords[0] = *_xCoordItr;
_coords[1] = *_yCoordItr;
_coords[2] = *_zCoordItr;
}
void UnstructuredGrid3D::ConstCoordItrU3D::next(const long &offset)
{
VAssert(offset >= 0);
_xCoordItr += offset;
_yCoordItr += offset;
_zCoordItr += offset;
_coords[0] = *_xCoordItr;
_coords[1] = *_yCoordItr;
_coords[2] = *_zCoordItr;
}
namespace VAPoR {
std::ostream &operator<<(std::ostream &o, const UnstructuredGrid3D &ug)
{
o << "UnstructuredGrid3D " << endl;
o << (const Grid &)ug;
return o;
}
}; // namespace VAPoR