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