VAPOR3 3.9.4
RegularGrid.h
Go to the documentation of this file.
1#ifndef _RegularGrid_
2#define _RegularGrid_
3
4#include <ostream>
5#include <vector>
6#include <vapor/common.h>
8
9namespace VAPoR {
10
23//
24
26public:
42 //
43 RegularGrid(const DimsType &dims, const DimsType &bs, const std::vector<float *> &blks, const CoordType &minu, const CoordType &maxu);
44 RegularGrid(const std::vector<size_t> &dims, const std::vector<size_t> &bs, const std::vector<float *> &blks, const std::vector<double> &minu, const std::vector<double> &maxu);
45
46 RegularGrid() = default;
47 virtual ~RegularGrid() = default;
48
49 virtual size_t GetGeometryDim() const override { return (_geometryDim); }
50
51 virtual DimsType GetCoordDimensions(size_t dim) const override;
52
53 static std::string GetClassType() { return ("Regular"); }
54 std::string GetType() const override { return (GetClassType()); }
55
57 //
58 virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override;
59
61 //
62 virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override;
63
64 // For grandparent inheritance of
65 // Grid::GetUserCoordinates(const size_t indices[], double coords[])
66 //
67 using Grid::GetUserCoordinates;
68
71 virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override;
72
74 //
75 virtual bool InsideGrid(const CoordType &coords) const override;
76
78 public:
79 ConstCoordItrRG(const RegularGrid *rg, bool begin);
81
83 virtual ~ConstCoordItrRG() {}
84
85 virtual void next();
86 virtual void next(const long &offset);
87 virtual ConstCoordType &deref() const { return (_coords); }
88 virtual const void * address() const { return this; };
89
90 virtual bool equal(const void *rhs) const
91 {
92 const ConstCoordItrRG *itrptr = static_cast<const ConstCoordItrRG *>(rhs);
93
94 return (_index == itrptr->_index);
95 }
96
97 virtual std::unique_ptr<ConstCoordItrAbstract> clone() const { return std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrRG(*this)); };
98
99 private:
100 DimsType _index;
101 DimsType _dims;
102 CoordType _minu;
103 CoordType _delta;
104 CoordType _coords;
105 };
106
107 virtual ConstCoordItr ConstCoordBegin() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrRG(this, true))); }
108 virtual ConstCoordItr ConstCoordEnd() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrRG(this, false))); }
109
110 VDF_API friend std::ostream &operator<<(std::ostream &o, const RegularGrid &rg);
111
112protected:
113 virtual float GetValueNearestNeighbor(const CoordType &coords) const override;
114
115 virtual float GetValueLinear(const CoordType &coords) const override;
116
118 //
119 virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override;
120
121private:
122 void _regularGrid(const CoordType &minu, const CoordType &maxu);
123
124 CoordType _minu = {{0.0, 0.0, 0.0}};
125 CoordType _maxu = {{0.0, 0.0, 0.0}};
126 size_t _geometryDim;
127 CoordType _delta; // increment between grid points in user coords
128};
129}; // namespace VAPoR
130#endif
const CoordType ConstCoordType
Definition: Grid.h:936
virtual const void * address() const
Definition: RegularGrid.h:88
virtual bool equal(const void *rhs) const
Definition: RegularGrid.h:90
ConstCoordItrRG(const ConstCoordItrRG &rhs)
virtual std::unique_ptr< ConstCoordItrAbstract > clone() const
Definition: RegularGrid.h:97
virtual void next(const long &offset)
virtual ConstCoordType & deref() const
Definition: RegularGrid.h:87
ConstCoordItrRG(const RegularGrid *rg, bool begin)
This class implements a 2D or 3D regular grid.
Definition: RegularGrid.h:25
static std::string GetClassType()
Definition: RegularGrid.h:53
virtual ConstCoordItr ConstCoordBegin() const override
Return constant grid coordinate iterator.
Definition: RegularGrid.h:107
RegularGrid()=default
virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override
virtual ~RegularGrid()=default
virtual float GetValueLinear(const CoordType &coords) const override
virtual size_t GetGeometryDim() const override
Definition: RegularGrid.h:49
virtual bool InsideGrid(const CoordType &coords) const override
VDF_API friend std::ostream & operator<<(std::ostream &o, const RegularGrid &rg)
virtual ConstCoordItr ConstCoordEnd() const override
Definition: RegularGrid.h:108
virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override
RegularGrid(const std::vector< size_t > &dims, const std::vector< size_t > &bs, const std::vector< float * > &blks, const std::vector< double > &minu, const std::vector< double > &maxu)
std::string GetType() const override
Definition: RegularGrid.h:54
virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override
RegularGrid(const DimsType &dims, const DimsType &bs, const std::vector< float * > &blks, const CoordType &minu, const CoordType &maxu)
virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override
virtual DimsType GetCoordDimensions(size_t dim) const override
virtual float GetValueNearestNeighbor(const CoordType &coords) const override
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