Salome HOME
f232cc1d48e7d95ebc44881093db22da1c5b5e89
[modules/paravis.git] / src / Plugins / DifferenceTimesteps / vtkDifferenceTimestepsFilter.h
1 // Copyright (C) 2014-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Maxim Glibin
20
21 #ifndef __DifferenceTimestepsFilter_h_
22 #define __DifferenceTimestepsFilter_h_
23
24 #include <vtkMultiTimeStepAlgorithm.h>
25
26 #include <vector>
27
28 class vtkDataSet;
29 class vtkStringArray;
30
31 /**
32  * Description of class:
33  * Class allows to compute difference between two time steps of one data array (field).
34 */
35 class VTK_EXPORT vtkDifferenceTimestepsFilter : public vtkMultiTimeStepAlgorithm
36 {
37 public:
38   /// Returns pointer on a new instance of the class
39   static vtkDifferenceTimestepsFilter* New();
40
41   vtkTypeMacro(vtkDifferenceTimestepsFilter, vtkMultiTimeStepAlgorithm);
42
43   /// Prints current state of the objects
44   virtual void PrintSelf(ostream &, vtkIndent);
45
46   // Description:
47   // Set/Get methods for first time step.
48   vtkSetMacro(FirstTimeStepIndex, int);
49   vtkGetMacro(FirstTimeStepIndex, int);
50
51   // Description:
52   // Set/Get methods for first time step.
53   vtkSetMacro(SecondTimeStepIndex, int);
54   vtkGetMacro(SecondTimeStepIndex, int);
55
56   // Description:
57   // Get methods for range of indices of time steps.
58   vtkGetVector2Macro(RangeIndicesTimeSteps, int);
59
60   // Description:
61   // Set/Get methods for prefix of array name.
62   vtkSetStringMacro(ArrayNamePrefix);
63   vtkGetStringMacro(ArrayNamePrefix);
64
65 protected:
66   /// Constructor & destructor
67   vtkDifferenceTimestepsFilter();
68   virtual ~vtkDifferenceTimestepsFilter();
69
70   /// The methods which is called on filtering data
71   virtual int FillInputPortInformation(int, vtkInformation *);
72
73   virtual int FillOutputPortInformation(int, vtkInformation *);
74
75   virtual int RequestDataObject(vtkInformation *,
76                                 vtkInformationVector **,
77                                 vtkInformationVector *);
78
79   virtual int RequestInformation(vtkInformation *,
80                                  vtkInformationVector **,
81                                  vtkInformationVector *);
82
83   virtual int RequestUpdateExtent(vtkInformation *,
84                                   vtkInformationVector **,
85                                   vtkInformationVector *);
86
87   virtual int RequestData(vtkInformation *,
88                           vtkInformationVector **,
89                           vtkInformationVector *);
90
91   // Description:
92   // General computation differences routine for any type on input data. This
93   // is called recursively when heirarchical/multiblock data is encountered.
94   vtkDataObject *DifferenceDataObject(vtkDataObject* theInput1,
95                                       vtkDataObject* theInput2);
96
97   // Description:
98   // Root level interpolation for a concrete dataset object.
99   // Point/Cell data and points are different.
100   // Needs improving if connectivity is to be handled.
101   virtual vtkDataSet *DifferenceDataSet(vtkDataSet* theInput1,
102                                         vtkDataSet* theInput2);
103
104   // Description:
105   // Compute difference a single vtkDataArray. Called from computation
106   // of the difference routine on pointdata or celldata.
107   virtual vtkDataArray *DifferenceDataArray(vtkDataArray** theArrays,
108                                             vtkIdType      theN);
109
110   // Description:
111   // Range of indices of the time steps.
112   int RangeIndicesTimeSteps[2];
113   
114   // Description:
115   // First time step index.
116   int FirstTimeStepIndex;
117
118   // Description:
119   // Second time step index.
120   int SecondTimeStepIndex;
121
122   // Description:
123   // Length of time steps array
124   int NumberTimeSteps;
125
126   // Description:
127   // Array of time step values.
128   std::vector<double> TimeStepValues;
129
130   // Description:
131   // Prefix of array name.
132   char *ArrayNamePrefix;
133
134 private:
135   vtkDifferenceTimestepsFilter(const vtkDifferenceTimestepsFilter &); // Not implemented yet
136   void operator=(const vtkDifferenceTimestepsFilter &); // Not implemented yet
137
138   // Description:
139   // Get field association type.
140   int GetInputFieldAssociation();
141
142   // Description:
143   // Called just before computation of the difference of the dataset to ensure that
144   // each data array has the same array name, number of tuples or components and etc.
145   bool VerifyArrays(vtkDataArray **theArrays, int theNumArrays);
146 };
147
148 #endif // __DifferenceTimestepsFilter_h_