Salome HOME
initial commit from paravisaddons
[tools/paravisaddons_common.git] / src / RateOfFlowThroughSection / plugin / RateOfFlowThroughSectionModule / vtkRateOfFlowThroughSection.h
1 // Copyright (C) 2021  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 : Anthony Geay (EDF R&D)
20
21 #ifndef vtkRateOfFlowThroughSection_h__
22 #define vtkRateOfFlowThroughSection_h__
23
24 #include <vtkDataObjectAlgorithm.h>
25 #include "vtkExplodePolyLine.h"
26 #include <vtkAdjacentVertexIterator.h>
27 #include <vtkAlgorithmOutput.h>
28 #include <vtkCell.h>
29 #include <vtkCellData.h>
30 #include <vtkCellType.h>
31 #include <vtkCharArray.h>
32 #include <vtkDataArraySelection.h>
33 #include <vtkDataObjectTreeIterator.h>
34
35 #include <vtkDataSet.h>
36 #include <vtkDataSetAttributes.h>
37 #include <vtkDemandDrivenPipeline.h>
38 #include <vtkDoubleArray.h>
39 #include <vtkExecutive.h>
40 #include <vtkDoubleArray.h>
41 #include <vtkInEdgeIterator.h>
42 #include <vtkInformation.h>
43 #include <vtkInformationDataObjectKey.h>
44 #include <vtkInformationStringKey.h>
45 #include <vtkInformationVector.h>
46 #include <vtkIntArray.h>
47 #include <vtkMultiBlockDataSet.h>
48 #include <vtkMutableDirectedGraph.h>
49 #include <vtkNew.h>
50 #include <vtkObjectFactory.h>
51 #include <vtkPointData.h>
52 #include <vtkPolyData.h>
53 #include <vtkResampleWithDataSet.h>
54 #include <vtkStreamingDemandDrivenPipeline.h>
55 #include <vtkStringArray.h>
56 #include <vtkTable.h>
57 #include <vtkTimeStamp.h>
58 #include <vtkUnsignedCharArray.h>
59 #include <vtkUnstructuredGrid.h>
60 #include <vtkVariantArray.h>
61 #include <vtkWarpScalar.h>
62 #include <vtkSetGet.h>
63
64 #include "VTKToMEDMem.h"
65
66 #include <map>
67 #include <deque>
68 #include <sstream>
69
70 class vtkMutableDirectedGraph;
71
72 class VTK_EXPORT vtkRateOfFlowThroughSection : public vtkDataObjectAlgorithm
73 {
74 public:
75   static vtkRateOfFlowThroughSection *New();
76   vtkTypeMacro(vtkRateOfFlowThroughSection, vtkDataObjectAlgorithm);
77   void PrintSelf(ostream &os, vtkIndent indent) override;
78
79   void SetSourceData(vtkDataObject *input);
80
81   void SetSourceConnection(vtkAlgorithmOutput *algOutput);
82
83   int FillOutputPortInformation(int, vtkInformation *) override;
84
85 protected:
86   vtkRateOfFlowThroughSection();
87   ~vtkRateOfFlowThroughSection() override;
88
89   int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
90   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
91   int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
92
93   int NumberOfTimeSteps;
94   int CurrentTimeIndex;
95   bool IsExecuting;
96   class  VTK_EXPORT vtkInternal {
97   public:
98     vtkInternal() {};
99     void pushData(double timeStep, double value) { _data.emplace_back(timeStep, value); }
100     void fillTable(vtkTable *table) const;
101     void analyzeInputDataSets(vtkUnstructuredGrid *ds1, vtkDataSet *ds2);
102     bool computationNeeded() const
103     {
104       if (_recomputationOfMatrixNeeded)
105       {
106         _matrix.clear();
107       }
108       return _recomputationOfMatrixNeeded;
109     };
110     std::vector<std::map<int, double>> &getMatrix() { return _matrix; }
111     void setOrtho(const MEDCoupling::DataArrayDouble *ortho) { _ortho.takeRef(ortho); }
112     const MEDCoupling::DataArrayDouble *getOrtho() const { return (const MEDCoupling::DataArrayDouble *)_ortho; }
113     void setMeasure(const MEDCoupling::DataArrayDouble *measure) { _measure.takeRef(measure); }
114     const MEDCoupling::DataArrayDouble *getMeasure() { return (const MEDCoupling::DataArrayDouble *)_measure; }
115
116   private:
117     std::vector<std::pair<double, double>> _data;
118     vtkMTimeType _mt1 = 0;
119     vtkMTimeType _mt2 = 0;
120     mutable std::vector<std::map<int, double>> _matrix;
121     bool _recomputationOfMatrixNeeded = true;
122     MEDCoupling::MCConstAuto<MEDCoupling::DataArrayDouble> _ortho;
123     MEDCoupling::MCConstAuto<MEDCoupling::DataArrayDouble> _measure;
124   };
125
126   vtkInternal *Internal;
127
128 private:
129   vtkRateOfFlowThroughSection(const vtkRateOfFlowThroughSection &) = delete;
130   void operator=(const vtkRateOfFlowThroughSection &) = delete;
131 };
132
133 #endif