source: XIOS/dev/XIOS_DEV_CMIP6/src/filter/spatial_transform_filter.hpp @ 1251

Last change on this file since 1251 was 1158, checked in by oabramkina, 7 years ago

Two server levels: merging with trunk r1137.
There are bugs.

File size: 4.1 KB
Line 
1#ifndef __XIOS_CSpatialTransformFilter__
2#define __XIOS_CSpatialTransformFilter__
3
4#include "filter.hpp"
5
6namespace xios
7{
8  class CGrid;
9  class CGridTransformation;
10  class CSpatialTransformFilterEngine;
11
12  /*!
13   * A generic filter with multiple input slots wrapping any type of spatial transformations.
14   */
15  class CSpatialTransformFilter : public CFilter
16  {
17    public:
18      /*!
19       * Constructs a filter wrapping the specified spatial transformation.
20       *
21       * \param gc the associated garbage collector
22       * \param engine the engine defining the spatial transformation
23       * \param outputValue default value of output pin
24       * \param [in] inputSlotsCount number of input, by default there is only one for field src
25       */
26      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount = 1);
27
28      /*!
29       * Builds the filter graph needed to transform the specified source grid into the specified destination grid.
30       *
31       * \param gc the associated garbage collector
32       * \param srcGrid the source grid
33       * \param destGrid the destination grid
34       * \param hasMissingValue whether field source has missing value
35       * \param defaultValue default value
36       * \return the first and the last filters of the filter graph
37       */
38      static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> >
39      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double defaultValue);
40
41    protected:
42      /*!
43        Overriding this function to process transformations with auxillary inputs
44      */
45      void virtual onInputReady(std::vector<CDataPacketPtr> data);
46
47    protected:
48      //! Default value of output pin
49      double outputDefaultValue;
50  }; // class CSpatialTransformFilter
51
52  /*!
53   * A generic filter engine wrapping a grid transformation.
54   */
55  class CSpatialTransformFilterEngine : public IFilterEngine
56  {
57    public:
58      /*!
59       * Returns the engine wrapping the specified grid transformation.
60       * If the engine already exists it is reused, otherwise it is created.
61       *
62       * \param gridTransformation the grid transformation the engine will use
63       * \return the engine wrapping the specified grid transformation
64       */
65      static CSpatialTransformFilterEngine* get(CGridTransformation* gridTransformation);
66
67      /*!
68       * Applies the grid transformation to the input data and returns the result.
69       *
70       * \param data a vector of packets corresponding to each slot (one in this case)
71       * \param [in] defaultValue default value of output data
72       * \return the result of the grid transformation
73       */
74      CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0);
75
76       /*!
77       * Applies the grid transformation to the input data and returns the result.
78       *
79       * \param data a vector of packets corresponding to each slot (one in this case)
80       * \return the result of the grid transformation
81       */
82      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
83
84
85
86    protected:
87      /*!
88       * Constructs a filter engine wrapping the specified grid transformation.
89       *
90       * \param gridTransformation the grid transformation the engine will use
91       */
92      CSpatialTransformFilterEngine(CGridTransformation* gridTransformation);
93
94      /*!
95       * Applies the grid transformation to the input data and returns the result.
96       * This helper function handles all the communications.
97       *
98       * \param dataSrc the source data
99       * \param dataDest the resulting transformed data
100       */
101      void apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest);
102
103      CGridTransformation* gridTransformation; //!< The grid transformation used by the engine
104
105      //! The allocated engines
106      static std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > engines;
107  }; // class CSpatialTransformFilterEngine
108} // namespace xios
109
110#endif //__XIOS_CSpatialTransformFilter__
Note: See TracBrowser for help on using the repository browser.