Salome HOME
updated copyright message
[modules/paravis.git] / src / Plugins / DifferenceTimesteps / plugin / DifferenceTimestepsModule / vtkDifferenceTimestepsFilter.h
1 // Copyright (C) 2014-2023  CEA, EDF
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   void PrintSelf(ostream&, vtkIndent) override;
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   ~vtkDifferenceTimestepsFilter() override;
69
70   /// The methods which is called on filtering data
71   int FillInputPortInformation(int, vtkInformation*) override;
72
73   int FillOutputPortInformation(int, vtkInformation*) override;
74
75   int RequestDataObject(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
76
77   int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
78
79   int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
80
81   //int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
82
83   // Description:
84   // General computation differences routine for any type on input data. This
85   // is called recursively when heirarchical/multiblock data is encountered.
86   vtkDataObject* DifferenceDataObject(vtkDataObject* theInput1, vtkDataObject* theInput2);
87
88   // Description:
89   // Root level interpolation for a concrete dataset object.
90   // Point/Cell data and points are different.
91   // Needs improving if connectivity is to be handled.
92   virtual vtkDataSet* DifferenceDataSet(vtkDataSet* theInput1, vtkDataSet* theInput2);
93
94   // Description:
95   // Compute difference a single vtkDataArray. Called from computation
96   // of the difference routine on pointdata or celldata.
97   virtual vtkDataArray* DifferenceDataArray(vtkDataArray** theArrays, vtkIdType theN);
98
99   // Description:
100   // Range of indices of the time steps.
101   int RangeIndicesTimeSteps[2];
102
103   // Description:
104   // First time step index.
105   int FirstTimeStepIndex;
106
107   // Description:
108   // Second time step index.
109   int SecondTimeStepIndex;
110
111   // Description:
112   // Length of time steps array
113   int NumberTimeSteps;
114
115   // Description:
116   // Array of time step values.
117   std::vector<double> TimeStepValues;
118
119   // Description:
120   // Prefix of array name.
121   char* ArrayNamePrefix;
122
123 private:
124   vtkDifferenceTimestepsFilter(const vtkDifferenceTimestepsFilter&) = delete;
125   void operator=(const vtkDifferenceTimestepsFilter&) = delete;
126
127   // Description:
128   // Get field association type.
129   int GetInputFieldAssociation();
130
131   // Description:
132   // Called just before computation of the difference of the dataset to ensure that
133   // each data array has the same array name, number of tuples or components and etc.
134   bool VerifyArrays(vtkDataArray** theArrays, int theNumArrays);
135 };
136
137 #endif // __DifferenceTimestepsFilter_h_