]> SALOME platform Git repositories - modules/visu.git/blob - src/PIPELINE/VISU_PipeLine.hxx
Salome HOME
Merge with branch V2_2_0_VISU_improvement
[modules/visu.git] / src / PIPELINE / VISU_PipeLine.hxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 // File:    VISU_PipeLine.hxx
24 // Author:  Alexey PETROV
25 // Module : VISU
26
27 #ifndef VISU_PipeLine_HeaderFile
28 #define VISU_PipeLine_HeaderFile
29
30 #include <vtkObject.h>
31 #include <vtkSmartPointer.h>
32
33 #include <vector>
34
35 template <class T>
36 class TVTKSmartPtr: public vtkSmartPointer<T>
37 {
38 public:
39   TVTKSmartPtr() {}
40   TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
41     if(r && theIsOwner)
42       r->Delete();
43   }
44   TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){
45     vtkSmartPointer<T>::operator=(r);
46     if(r && theIsOwner)
47       r->Delete();
48     return *this;
49   }
50   TVTKSmartPtr& operator=(T* r){
51     vtkSmartPointer<T>::operator=(r);
52     return *this;
53   }
54   operator T* () const {
55     return vtkSmartPointer<T>::GetPointer();
56   }
57 };
58
59 class vtkDataSetMapper;
60 class vtkUnstructuredGrid;
61 class vtkExtractGeometry;
62 class vtkImplicitBoolean;
63 class vtkPlane;
64
65 class SALOME_ExtractGeometry;
66
67 typedef vtkUnstructuredGrid TInput;
68
69 class VISU_PipeLine : public vtkObject{
70 public:
71   vtkTypeMacro(VISU_PipeLine,vtkObject);
72   virtual ~VISU_PipeLine();
73
74   virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
75   virtual void SameAs(VISU_PipeLine *thePipeLine);
76
77 public:
78   virtual void SetInput(TInput* theInput);
79   virtual TInput* GetInput() const;
80
81   bool IsPlanarInput() const;
82
83   typedef vtkDataSetMapper TMapper;
84   virtual TMapper* GetMapper();
85
86   virtual void Init() = 0;
87   virtual void Update();
88
89   static int CheckAvailableMemory(const float& theSize);
90   static float GetAvailableMemory(float theSize = 16*1024*1024.0,
91                                   float theMinSize = 1024*1024.0);
92
93   // Clipping planes
94   void RemoveAllClippingPlanes();
95   vtkIdType GetNumberOfClippingPlanes() const;
96   void AddClippingPlane(vtkPlane* thePlane);
97   vtkPlane* GetClippingPlane(vtkIdType theID) const;
98
99   void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
100   void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
101
102   bool IsShrinkable() { return myIsShrinkable; }
103
104 protected:
105   VISU_PipeLine();
106   VISU_PipeLine(const VISU_PipeLine&);
107
108   virtual TInput* GetInput2() const;
109   virtual void Build() = 0;
110
111   bool myIsShrinkable;
112
113   TInput  *myInput;
114   TMapper *myMapper;
115
116   // Clipping planes
117   TVTKSmartPtr<SALOME_ExtractGeometry> myExtractGeometry;
118 };
119
120 #endif