VAPoR  0.1
SphericalGrid.h
Go to the documentation of this file.
1 #ifndef _SphericalGrid_
2 #define _SphericalGrid_
3 #include <vector>
4 #include <vapor/common.h>
5 #include "RegularGrid.h"
6 #ifdef _WINDOWS
7 #pragma warning(disable : 4251 4100)
8 #endif
9 
10 //
25 //
26 
27 namespace VAPoR {
29 public:
30 
69  const size_t bs[3],
70  const size_t min[3],
71  const size_t max[3],
72  const double extents[6],
73  const size_t permutation[3],
74  const bool periodic[3],
75  float ** blks
76 );
77 
91  const size_t bs[3],
92  const size_t min[3],
93  const size_t max[3],
94  const double extents[6],
95  const size_t permutation[3],
96  const bool periodic[3],
97  float ** blks,
98  float missing_value
99  );
100 
101 
104  float GetValue(double x, double y, double z) const;
105 
109  //
110  virtual void GetUserExtents(double extents[6]) const {
111  for (int i=0; i<6; i++) extents[i] = _extentsC[i];
112  };
113 
114 
117  virtual void GetBoundingBox(
118  const size_t min[3],
119  const size_t max[3],
120  double extents[6]
121  ) const;
122 
125  virtual void GetEnclosingRegion(
126  const double minu[3], const double maxu[3],
127  size_t min[3], size_t max[3]
128  ) const;
129 
132  int GetUserCoordinates(
133  size_t i, size_t j, size_t k,
134  double *x, double *y, double *z
135  ) const;
136 
139  void GetIJKIndex(
140  double x, double y, double z,
141  size_t *i, size_t *j, size_t *k
142  ) const;
143 
146  void GetIJKIndexFloor(
147  double x, double y, double z,
148  size_t *i, size_t *j, size_t *k
149  ) const;
150 
151  int Reshape(
152  const size_t min[3],
153  const size_t max[3],
154  const bool periodic[3]
155  );
156 
168  bool InsideGrid(double x, double y, double z) const;
169 
170 
171 
172  // phi is in range -180 to 180, theta is in range -180/2 to 180/2
173  //
174  static inline void CartToSph(
175  double x, double y, double z, double *phi, double *theta, double *r
176  );
177 
178  static inline void SphToCart(
179  double phi, double theta, double r,
180  double *x, double *y, double *z
181  );
182 
183 private:
184  double _extentsC[6]; // extents in Cartesian coordinates, ordered x,y,z
185  std::vector <long> _permutation; // permutation vector for coordinate ordering
186 
187  void _GetUserExtents(double extents[6]) const;
188 
189  void _permute(
190  const std::vector<long>& permutation,
191  double result[3], double x, double y, double z
192  ) const;
193 
194 
195 };
196 };
197 #endif
virtual void GetUserExtents(double extents[6]) const
#define VDF_API
Definition: common.h:61