Salome HOME
ab473e7c8b89eabea851df4f8b72e959999752ee
[modules/paravis.git] / src / Plugins / StaticMesh / vtkStaticPlaneCutter.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    vtkStaticPlaneCutter.h
5
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13
14 =========================================================================*/
15 /**
16  * @class   vtkStaticPlaneCutter
17  * @brief   StaticMesh aware implementation of vtkPlaneCutter vtk vtkUnstructuredGrid
18  *
19  * This class specialize vtkPlaneCutter for vtkUnstructuredGrid input.
20  * It uses a cache when the associated data chage over time but not the geometry.
21  * In order to be able to update the cache, we keep track of cells ids
22  * when the cache is computed.
23  * Contrary to its parent, this class does not interpolate point data,
24  * only transmit cell data.
25  *
26  *
27  * @sa
28  * vtkPlaneCutter
29 */
30
31 #ifndef vtkStaticPlaneCutter_h
32 #define vtkStaticPlaneCutter_h
33
34 #include <vtkIdList.h>
35 #include <vtkNew.h>
36 #include <vtkPlaneCutter.h>
37 #include <vtkSmartPointer.h>
38
39 #include <vector>
40
41 class vtkMultiPieceDataSet;
42
43 class vtkStaticPlaneCutter : public vtkPlaneCutter
44 {
45 public:
46   static vtkStaticPlaneCutter* New();
47   typedef vtkPlaneCutter Superclass; // vtkTypeMacro can't be used with a factory built object
48   void PrintSelf(ostream &os, vtkIndent indent) override;
49
50   int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
51
52 protected:
53   vtkStaticPlaneCutter();
54   ~vtkStaticPlaneCutter() override;
55
56   /**
57    * Check input for Ids cell array, if absent, compute and add them.
58    */
59   static void AddIdsArray(vtkDataSet* input, vtkDataSet* output);
60
61   /**
62    * Remove an Ids cell array in all polydata pieces of output
63    */
64   static void RemoveIdsArray(vtkMultiPieceDataSet* output);
65
66   /**
67    * Update cache point, cell and field data using input
68    */
69   void UpdateCacheData(vtkDataSet* input);
70
71   /**
72    * Compute the ids and weights to be used when updating the cache later
73    */
74   void ComputeIds(vtkUnstructuredGrid* input);
75
76   void ClearWeightsVector();
77
78   vtkNew<vtkMultiPieceDataSet> Cache;
79   std::vector<vtkSmartPointer<vtkIdList> > CellToCopyFrom;
80   std::vector<vtkSmartPointer<vtkIdList> > CellToCopyTo;
81   std::vector<std::vector<std::pair<vtkSmartPointer<vtkIdList>, double*>>> WeightsVectorCompo;
82   vtkMTimeType InputMeshTime;
83   vtkMTimeType FilterMTime;
84
85 private:
86   // Hide these from the user and the compiler.
87   vtkStaticPlaneCutter(const vtkStaticPlaneCutter&) = delete;
88   void operator=(const vtkStaticPlaneCutter&) = delete;
89 };
90
91 #endif