VAPOR3 3.9.4
ConstantGrid.h
Go to the documentation of this file.
1#ifndef CONSTANTGRID_H
2#define CONSTANTGRID_H
3
4/*
5 * This class represents a constant field. That means,
6 * querying values from any location of this field will return that constant value.
7 *
8 * It also implements pure virtual functions of the Grid class in the simplest possible fashion,
9 * but those functions do not perform any calculation, and should not be used.
10 *
11 * Finally, a DataMgr would not return a ConstantGrid at any occasion; rather, this
12 * class is supposed to be created and used locally by its user.
13 */
14
15#include "vapor/Grid.h"
16
17namespace VAPoR {
18
19class VDF_API ConstantGrid : public Grid {
20public:
21 // The constant value is specified via the constructor
22 // It also requires specification of the dimentionality.
23 ConstantGrid(float v, size_t d);
24
25 //
26 // Useful functions of ConstantGrid.
27 // Additional ones could be added when needed.
28 //
29 // The following four GetValue methods all return the constant value of this grid.
30 float GetConstantValue() const;
31 float GetValue(const CoordType &coords) const override;
32 float GetValueNearestNeighbor(const CoordType &coords) const override;
33 float GetValueLinear(const CoordType &coords) const override;
34
35 // This version of ConstantGrid is considered to have infinity extents,
36 // so the following method will return numerical mins and maxes.
37 // Note: other flavors of ConstantGrids may have specific user extents.
38 virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override;
39 // Similarly, this will always return true.
40 virtual bool InsideGrid(const CoordType &coords) const override;
41
42 std::string GetType() const override;
43
44 // Overwrites the same function from Grid, which will always give you a zero.
45 virtual size_t GetTopologyDim() const override;
46
47private:
48 //
49 // Pure virtual functions from Grid class.
50 // They do nothing and return meaningless values.
51 // Do not use!
52 //
53 DimsType GetCoordDimensions(size_t) const override;
54 size_t GetGeometryDim() const override;
55 const DimsType & GetNodeDimensions() const override;
56 const size_t GetNumNodeDimensions() const override;
57 const DimsType & GetCellDimensions() const override;
58 const size_t GetNumCellDimensions() const override;
59 void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override {}
60 bool GetEnclosingRegion(const CoordType &minu, const CoordType &maxu, DimsType &min, DimsType &max) const override { return (false); }
61 virtual void GetUserCoordinates(const DimsType &, CoordType &) const override {}
62 bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override;
63 bool GetCellNodes(const DimsType &, std::vector<DimsType> &) const override;
64 bool GetCellNeighbors(const DimsType &, std::vector<DimsType> &) const override;
65 bool GetNodeCells(const DimsType &, std::vector<DimsType> &) const override;
66 size_t GetMaxVertexPerFace() const override;
67 size_t GetMaxVertexPerCell() const override;
68 void ClampCoord(const CoordType &coords, CoordType &cCoords) const override { cCoords = coords; }
69 ConstCoordItr ConstCoordBegin() const override;
70 ConstCoordItr ConstCoordEnd() const override;
71
72 // Private data member that holds this constant value.
73 const float _value;
74 const size_t _topologyDim; // Not to be confused with _topologyDimension in
75 // the base Grid class, which is private to Grid.
76
77 mutable VAPoR::DimsType _duplicate;
78
79}; // end ConstantGrid class
80}; // namespace VAPoR
81#endif
float GetValue(const CoordType &coords) const override
float GetValueLinear(const CoordType &coords) const override
float GetConstantValue() const
ConstantGrid(float v, size_t d)
virtual size_t GetTopologyDim() const override
float GetValueNearestNeighbor(const CoordType &coords) const override
virtual bool InsideGrid(const CoordType &coords) const override
std::string GetType() const override
virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override
Abstract base class for a 2D or 3D structured or unstructured grid.
Definition: Grid.h:56
#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