Salome HOME
Fix for Bug IPAL8945
[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 <vector>
31 #include <vtkObject.h>
32 #include <vtkSmartPointer.h>
33
34 #include "VISU_IDMapper.hxx"
35
36 class vtkCell;
37 class vtkDataSet;
38 class vtkImplicitFunction;
39
40 template <class T>
41 class TVTKSmartPtr: public vtkSmartPointer<T>
42 {
43 public:
44   TVTKSmartPtr()
45   {}
46
47   TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) 
48   {
49     if(r && theIsOwner)
50       r->Delete();
51   }
52
53   TVTKSmartPtr& operator()(T* r, bool theIsOwner = false)
54   {
55     vtkSmartPointer<T>::operator=(r);
56     if(r && theIsOwner)
57       r->Delete();
58     return *this;
59   }
60
61   TVTKSmartPtr& operator=(T* r)
62   {
63     vtkSmartPointer<T>::operator=(r);
64     return *this;
65   }
66
67   operator T* () const 
68   {
69     return vtkSmartPointer<T>::GetPointer();
70   }
71 };
72
73 class vtkMapper;
74 class vtkDataSetMapper;
75 class vtkUnstructuredGrid;
76 class vtkExtractGeometry;
77 class vtkImplicitBoolean;
78 class vtkPlane;
79
80 class SALOME_ExtractGeometry;
81
82 typedef VISU::TVTKOutput TInput;
83
84 class VISU_PipeLine : public vtkObject{
85 public:
86   vtkTypeMacro(VISU_PipeLine,vtkObject);
87   virtual
88   ~VISU_PipeLine();
89
90   virtual
91   void
92   DebugOn();
93
94   virtual
95   void
96   DebugOff();
97
98   virtual
99   void
100   ShallowCopy(VISU_PipeLine *thePipeLine);
101
102   virtual
103   void
104   SameAs(VISU_PipeLine *thePipeLine);
105
106 public:
107   virtual
108   void
109   SetInput(TInput* theInput);
110
111   virtual
112   TInput* 
113   GetInput() const;
114
115   virtual
116   vtkDataSet* 
117   GetOutput();
118
119   bool
120   IsPlanarInput() const;
121
122   typedef vtkMapper TMapper;
123
124   virtual 
125   TMapper* 
126   GetMapper();
127
128   virtual
129   void
130   Init() = 0;
131
132   virtual
133   void
134   Update();
135
136   static
137   int
138   CheckAvailableMemory(const float& theSize);
139   
140   static
141   float
142   GetAvailableMemory(float theSize = 16*1024*1024.0,
143                      float theMinSize = 1024*1024.0);
144
145   // Clipping planes
146   void 
147   RemoveAllClippingPlanes();
148
149   vtkIdType
150   GetNumberOfClippingPlanes() const;
151
152   bool
153   AddClippingPlane(vtkPlane* thePlane);
154
155   vtkPlane* 
156   GetClippingPlane(vtkIdType theID) const;
157
158   void
159   SetPlaneParam(float theDir[3], 
160                 float theDist, 
161                 vtkPlane* thePlane);
162
163   void
164   GetPlaneParam(float theDir[3], 
165                 float& theDist, 
166                 vtkPlane* thePlane);
167
168   bool 
169   IsShrinkable() { return myIsShrinkable; }
170
171   virtual
172   vtkIdType
173   GetNodeObjID(vtkIdType theID);
174
175   virtual
176   vtkIdType
177   GetNodeVTKID(vtkIdType theID);
178
179   virtual
180   float* 
181   GetNodeCoord(vtkIdType theObjID);
182
183   virtual
184   vtkIdType
185   GetElemObjID(vtkIdType theID);
186
187   virtual
188   vtkIdType
189   GetElemVTKID(vtkIdType theID);
190
191   virtual
192   vtkCell*
193   GetElemCell(vtkIdType theObjID);
194
195   void 
196   SetIDMapper(const VISU::PIDMapper& theIDMapper);
197
198   const VISU::PIDMapper&  
199   GetIDMapper()const;
200
201   void
202   SetImplicitFunction(vtkImplicitFunction *theFunction);
203
204   vtkImplicitFunction* 
205   GetImplicitFunction();
206
207   SALOME_ExtractGeometry*
208   GetExtractGeometryFilter();
209
210 protected:
211   VISU_PipeLine();
212   VISU_PipeLine(const VISU_PipeLine&);
213
214   virtual 
215   TInput* 
216   GetInput2() const;
217
218   virtual
219   void
220   Build() = 0;
221
222   bool myIsShrinkable;
223
224   TVTKSmartPtr<TInput> myInput;
225   VISU::PIDMapper myIDMapper;
226   TVTKSmartPtr<vtkDataSetMapper> myMapper;
227
228   // Clipping planes
229   TVTKSmartPtr<SALOME_ExtractGeometry> myExtractGeometry;
230 };
231
232 #endif