MI - Fimex
CachedInterpolation.h
Go to the documentation of this file.
1 /*
2  * Fimex
3  *
4  * (C) Copyright 2008, met.no
5  *
6  * Project Info: https://wiki.met.no/fimex/start
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21  * USA.
22  */
23 
24 #ifndef CACHEDINTERPOLATION_H_
25 #define CACHEDINTERPOLATION_H_
26 
27 #include <boost/shared_array.hpp>
28 #include "fimex/interpolation.h"
29 #include "fimex/Data.h"
30 #include "fimex/SliceBuilder.h"
31 
32 namespace MetNoFimex
33 {
34 
35 //forward decl.
36 class CDMReader;
37 
45  // name of x-dimension
47  // name of y-dimension
49  // offset on x-axis
50  size_t xMin;
51  // original complete size of x-axis
52  size_t xOrg;
53  // offset on y-axis
54  size_t yMin;
55  // original complete size of y-axis
56  size_t yOrg;
57 };
58 
63 private:
64  std::string _xDimName, _yDimName;
65 public:
66  CachedInterpolationInterface(std::string xDimName, std::string yDimName) : _xDimName(xDimName), _yDimName(yDimName) {}
68  virtual boost::shared_array<float> interpolateValues(boost::shared_array<float> inData, size_t size, size_t& newSize) const = 0;
70  virtual size_t getInX() const = 0;
72  virtual size_t getInY() const = 0;
74  virtual size_t getOutX() const = 0;
76  virtual size_t getOutY() const = 0;
85  virtual boost::shared_ptr<Data> getInputDataSlice(boost::shared_ptr<CDMReader> reader, const std::string& varName, size_t unLimDim) const;
94  virtual boost::shared_ptr<Data> getInputDataSlice(boost::shared_ptr<CDMReader> reader, const std::string& varName, const SliceBuilder& sb) const;
95 private:
100  virtual boost::shared_ptr<ReducedInterpolationDomain> reducedDomain() const {return boost::shared_ptr<ReducedInterpolationDomain>();}
101 };
102 
108 {
109 private:
110  std::vector<double> pointsOnXAxis;
111  std::vector<double> pointsOnYAxis;
112  size_t inX;
113  size_t inY;
114  size_t outX;
115  size_t outY;
116  boost::shared_ptr<ReducedInterpolationDomain> reducedDomain_;
117  int (*func)(const float* infield, float* outvalues, const double x, const double y, const int ix, const int iy, const int iz);
118 public:
128  CachedInterpolation(std::string xDimName, std::string yDimName, int funcType, std::vector<double> pointsOnXAxis, std::vector<double> pointsOnYAxis, size_t inX, size_t inY, size_t outX, size_t outY);
129  virtual ~CachedInterpolation() {}
137  virtual boost::shared_array<float> interpolateValues(boost::shared_array<float> inData, size_t size, size_t& newSize) const;
141  virtual size_t getInX() const {return inX;}
145  virtual size_t getInY() const {return inY;}
149  virtual size_t getOutX() const {return outX;}
153  virtual size_t getOutY() const {return outY;}
154  virtual boost::shared_ptr<ReducedInterpolationDomain> reducedDomain() const {return reducedDomain_;}
159  void createReducedDomain(std::string xDimName, std::string yDimName);
160 
161 };
162 
163 
164 
165 }
166 
167 #endif /*CACHEDINTERPOLATION_H_*/
CachedInterpolationInterface(std::string xDimName, std::string yDimName)
Definition: CachedInterpolation.h:66
virtual ~CachedInterpolationInterface()
Definition: CachedInterpolation.h:67
size_t yOrg
Definition: CachedInterpolation.h:56
basic_string< char > string
Definition: CachedInterpolation.h:44
size_t xMin
Definition: CachedInterpolation.h:50
Definition: SliceBuilder.h:46
size_t xOrg
Definition: CachedInterpolation.h:52
virtual size_t getInY() const
Definition: CachedInterpolation.h:145
std::string xDim
Definition: CachedInterpolation.h:46
std::string yDim
Definition: CachedInterpolation.h:48
Definition: C_CDMReader.h:35
size_t yMin
Definition: CachedInterpolation.h:54
virtual size_t getOutY() const
Definition: CachedInterpolation.h:153
virtual boost::shared_ptr< ReducedInterpolationDomain > reducedDomain() const
Definition: CachedInterpolation.h:154
virtual ~CachedInterpolation()
Definition: CachedInterpolation.h:129
Definition: CachedInterpolation.h:107
Definition: CachedInterpolation.h:62
virtual size_t getInX() const
Definition: CachedInterpolation.h:141
virtual size_t getOutX() const
Definition: CachedInterpolation.h:149