VAPOR3 3.9.4
StretchedGrid.h
Go to the documentation of this file.
1#ifndef _StretchedGrid_
2#define _StretchedGrid_
3#include <vapor/common.h>
4#include <vapor/Grid.h>
6
7namespace VAPoR {
25//
27public:
54 //
55 StretchedGrid(const DimsType &dims, const DimsType &bs, const std::vector<float *> &blks, const std::vector<double> &xcoords, const std::vector<double> &ycoords,
56 const std::vector<double> &zcoords);
57 StretchedGrid(const std::vector<size_t> &dims, const std::vector<size_t> &bs, const std::vector<float *> &blks, const std::vector<double> &xcoords, const std::vector<double> &ycoords,
58 const std::vector<double> &zcoords);
59
60 StretchedGrid() = default;
61 virtual ~StretchedGrid() = default;
62
63 virtual size_t GetGeometryDim() const override;
64
65 virtual DimsType GetCoordDimensions(size_t dim) const override;
66
67 static std::string GetClassType() { return ("Stretched"); }
68 std::string GetType() const override { return (GetClassType()); }
69
70 // \copydoc GetGrid::GetBoundingBox()
71 //
72 virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override;
73
74 // \copydoc GetGrid::GetUserCoordinates()
75 //
76 virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override;
77
81 //
82 virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices, double wgts[3]) const;
83
86 virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override
87 {
88 double dummy[3];
89 return (GetIndicesCell(coords, indices, dummy));
90 };
91
92 // \copydoc GetGrid::InsideGrid()
93 //
94 virtual bool InsideGrid(const CoordType &coords) const override;
95
101 const std::vector<double> &GetXCoords() const { return (_xcoords); };
102
108 const std::vector<double> &GetYCoords() const { return (_ycoords); };
109
115 const std::vector<double> &GetZCoords() const { return (_zcoords); };
116
118 public:
119 ConstCoordItrSG(const StretchedGrid *cg, bool begin);
121
123 virtual ~ConstCoordItrSG() {}
124
125 virtual void next();
126 virtual void next(const long &offset);
127 virtual ConstCoordType &deref() const { return (_coords); }
128 virtual const void * address() const { return this; };
129
130 virtual bool equal(const void *rhs) const
131 {
132 const ConstCoordItrSG *itrptr = static_cast<const ConstCoordItrSG *>(rhs);
133
134 return (_index == itrptr->_index);
135 }
136
137 virtual std::unique_ptr<ConstCoordItrAbstract> clone() const { return std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrSG(*this)); };
138
139 private:
140 const StretchedGrid *_sg;
141 DimsType _index;
142 CoordType _coords;
143 };
144
145 virtual ConstCoordItr ConstCoordBegin() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrSG(this, true))); }
146 virtual ConstCoordItr ConstCoordEnd() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrSG(this, false))); }
147
148protected:
149 virtual float GetValueNearestNeighbor(const CoordType &coords) const override;
150
151 virtual float GetValueLinear(const CoordType &coords) const override;
152
153 void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override;
154
155private:
156 std::vector<double> _xcoords;
157 std::vector<double> _ycoords;
158 std::vector<double> _zcoords;
159 CoordType _minu = {{0.0, 0.0, 0.0}};
160 CoordType _maxu = {{0.0, 0.0, 0.0}};
161
162 void _stretchedGrid(const std::vector<double> &xcoords, const std::vector<double> &ycoords, const std::vector<double> &zcoords);
163
164 bool _insideGrid(double x, double y, double z, size_t &i, size_t &j, size_t &k, double &xwgt, double &ywgt, double &zwgt) const;
165};
166}; // namespace VAPoR
167#endif
const CoordType ConstCoordType
Definition: Grid.h:936
virtual const void * address() const
ConstCoordItrSG(const ConstCoordItrSG &rhs)
virtual std::unique_ptr< ConstCoordItrAbstract > clone() const
virtual bool equal(const void *rhs) const
ConstCoordItrSG(const StretchedGrid *cg, bool begin)
virtual void next(const long &offset)
virtual ConstCoordType & deref() const
This class implements a 2D or 3D stretched grid.
Definition: StretchedGrid.h:26
virtual ConstCoordItr ConstCoordEnd() const override
StretchedGrid(const std::vector< size_t > &dims, const std::vector< size_t > &bs, const std::vector< float * > &blks, const std::vector< double > &xcoords, const std::vector< double > &ycoords, const std::vector< double > &zcoords)
void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override
virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override
Definition: StretchedGrid.h:86
virtual float GetValueLinear(const CoordType &coords) const override
virtual DimsType GetCoordDimensions(size_t dim) const override
virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override
const std::vector< double > & GetZCoords() const
static std::string GetClassType()
Definition: StretchedGrid.h:67
virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices, double wgts[3]) const
virtual ~StretchedGrid()=default
virtual size_t GetGeometryDim() const override
std::string GetType() const override
Definition: StretchedGrid.h:68
const std::vector< double > & GetYCoords() const
const std::vector< double > & GetXCoords() const
virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override
virtual ConstCoordItr ConstCoordBegin() const override
Return constant grid coordinate iterator.
virtual bool InsideGrid(const CoordType &coords) const override
virtual float GetValueNearestNeighbor(const CoordType &coords) const override
StretchedGrid(const DimsType &dims, const DimsType &bs, const std::vector< float * > &blks, const std::vector< double > &xcoords, const std::vector< double > &ycoords, const std::vector< double > &zcoords)
Abstract base class for a 2D or 3D structured grid.
#define VDF_API
Definition: common.h:73
std::array< double, 3 > CoordType
Type for specifying floating point coordinates.
Definition: Grid.h:23
std::array< size_t, 3 > DimsType
Type for specifying integer indices.
Definition: Grid.h:26