source: XIOS/trunk/src/filter/spatial_transform_filter.hpp @ 644

Last change on this file since 644 was 644, checked in by rlacroix, 6 years ago

Use the filter infrastructure to handle the spatial transformations.

Add a spatial transform filter to do so.

File size: 3.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 one input slot 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       */
24      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine);
25
26      /*!
27       * Builds the filter graph needed to transform the specified source grid into the specified destination grid.
28       *
29       * \param gc the associated garbage collector
30       * \param srcGrid the source grid
31       * \param destGrid the destination grid
32       * \return the first and the last filters of the filter graph
33       */
34      static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> >
35      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid);
36  }; // class CSpatialTransformFilter
37
38  /*!
39   * A generic filter engine wrapping a grid transformation.
40   */
41  class CSpatialTransformFilterEngine : public IFilterEngine
42  {
43    public:
44      /*!
45       * Returns the engine wrapping the specified grid transformation.
46       * If the engine already exists it is reused, otherwise it is created.
47       *
48       * \param gridTransformation the grid transformation the engine will use
49       * \return the engine wrapping the specified grid transformation
50       */
51      static CSpatialTransformFilterEngine* get(CGridTransformation* gridTransformation);
52
53      /*!
54       * Applies the grid transformation to the input data and returns the result.
55       *
56       * \param data a vector of packets corresponding to each slot (one in this case)
57       * \return the result of the grid transformation
58       */
59      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
60
61    protected:
62      /*!
63       * Constructs a filter engine wrapping the specified grid transformation.
64       *
65       * \param gridTransformation the grid transformation the engine will use
66       */
67      CSpatialTransformFilterEngine(CGridTransformation* gridTransformation);
68
69      /*!
70       * Applies the grid transformation to the input data and returns the result.
71       * This helper function handles all the communications.
72       *
73       * \param dataSrc the source data
74       * \param dataDest the resulting transformed data
75       */
76      void apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest);
77
78      CGridTransformation* gridTransformation; //!< The grid transformation used by the engine
79
80      //! The allocated engines
81      static std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > engines;
82  }; // class CSpatialTransformFilterEngine
83} // namespace xios
84
85#endif //__XIOS_CSpatialTransformFilter__
Note: See TracBrowser for help on using the repository browser.