Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / PIPELINE / VISU_CutPlanesPL.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 // File:    VISU_CutPlanesPL.hxx
25 // Author:  Alexey PETROV
26 // Module : VISU
27 //
28 #ifndef VISU_CutPlanesPL_HeaderFile
29 #define VISU_CutPlanesPL_HeaderFile
30
31 #include "VISUPipeline.hxx"
32 #include "VISU_ScalarMapPL.hxx"
33 #include "VISU_OptionalDeformationPL.hxx"
34 #include "VISU_MapperHolder.hxx"
35
36 #include <vector>
37
38 class vtkAppendPolyData;
39
40
41 //----------------------------------------------------------------------------
42 class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL,
43                                               public VISU_OptionalDeformationPL
44 {
45 public:
46   vtkTypeMacro(VISU_CutPlanesPL, VISU_ScalarMapPL);
47
48   static 
49   VISU_CutPlanesPL* 
50   New();
51
52   virtual
53   unsigned long int 
54   GetMTime();
55
56   //----------------------------------------------------------------------------
57   enum PlaneOrientation {XY, YZ, ZX};
58
59   virtual 
60   void
61   SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient,
62                  vtkFloatingPointType theXAng, 
63                  vtkFloatingPointType theYAng, 
64                  int theNum = 0);
65   
66   virtual 
67   const PlaneOrientation& 
68   GetPlaneOrientation(int theNum = 0);
69
70   virtual
71   vtkFloatingPointType 
72   GetRotateX(int theNum = 0);
73
74   virtual
75   vtkFloatingPointType
76   GetRotateY(int theNum = 0);
77
78   virtual
79   vtkFloatingPointType 
80   GetDisplacement(int theNum = 0);
81
82   virtual
83   void
84   SetDisplacement(vtkFloatingPointType theDisp, 
85                   int theNum = 0);
86
87   virtual
88   void
89   SetPartPosition(int thePartNumber, 
90                   vtkFloatingPointType thePartPosition);
91
92   virtual
93   vtkFloatingPointType 
94   GetPartPosition(int thePartNumber, 
95                   int theNum = 0);
96
97   virtual 
98   void
99   SetPartDefault(int thePartNumber);
100
101   virtual
102   int
103   IsPartDefault(int thePartNumber);
104
105   virtual
106   void
107   SetNbParts(int theNb);
108
109   virtual
110   int
111   GetNbParts();
112
113 public:
114   virtual
115   void
116   Init();
117
118   virtual
119   void
120   Update();
121
122   //! Gets memory size used by the instance (bytes).
123   virtual
124   unsigned long int
125   GetMemorySize();
126
127   virtual
128   vtkAppendPolyData* 
129   GetAppendPolyData() 
130   { 
131     return myAppendPolyData; 
132   }
133
134 public:
135   static
136   vtkFloatingPointType* 
137   GetRx(vtkFloatingPointType theRx[3][3], 
138         vtkFloatingPointType thaAng);
139
140   static
141   vtkFloatingPointType* 
142   GetRy(vtkFloatingPointType theRy[3][3], 
143         vtkFloatingPointType thaAng);
144
145   static
146   vtkFloatingPointType* 
147   GetRz(vtkFloatingPointType theRz[3][3], 
148         vtkFloatingPointType thaAng);
149
150   static
151   void
152   CorrectPnt(vtkFloatingPointType thePnt[3], 
153              const vtkFloatingPointType BoundPrj[6]);
154
155   static
156   void
157   GetBoundProject(vtkFloatingPointType BoundPrj[3], 
158                   const vtkFloatingPointType BoundBox[6], 
159                   const vtkFloatingPointType Dir[3]);
160
161   static
162   void
163   GetDir(vtkFloatingPointType theDir[3],
164          const vtkFloatingPointType theAng[3],
165          const PlaneOrientation& theBasePlane);
166
167   static 
168   void
169   ClearAppendPolyData(vtkAppendPolyData *theAppendPolyData);
170
171   static 
172   void
173   CutWithPlane(vtkAppendPolyData* theAppendPolyData, 
174                vtkDataSet* theDataSet,
175                vtkFloatingPointType theDir[3], 
176                vtkFloatingPointType theOrig[3]);
177
178   static
179   void
180   CutWithPlanes(vtkAppendPolyData* theAppendPolyData, 
181                 vtkDataSet* theDataSet,
182                 int theNbPlanes, 
183                 vtkFloatingPointType theDir[3], 
184                 vtkFloatingPointType theBounds[6],
185                 const std::vector<vtkFloatingPointType>& thePlanePosition,
186                 const std::vector<int>& thePlaneCondition,
187                 vtkFloatingPointType theDisplacement);
188
189   virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper);
190   VISU::PUnstructuredGridIDMapper getVectorialField();
191
192   virtual
193   void
194   SetMapScale(vtkFloatingPointType theMapScale = 1.0);
195
196
197 protected:
198   VISU_CutPlanesPL();
199
200   virtual
201   ~VISU_CutPlanesPL();
202
203   virtual 
204   vtkDataSet* 
205   InsertCustomPL();
206
207   virtual
208   void
209   DoShallowCopy(VISU_PipeLine *thePipeLine,
210                 bool theIsCopyInput);
211
212   void
213   SetPartPosition(int theNum = 0);
214
215   int myNbParts;
216   PlaneOrientation myBasePlane[2];
217   vtkFloatingPointType myAng[2][3], myDisplacement[2];
218   vtkAppendPolyData *myAppendPolyData;
219   std::vector<vtkFloatingPointType> myPartPosition;
220   std::vector<int> myPartCondition;
221
222 private:
223   VISU_CutPlanesPL(const VISU_CutPlanesPL&);  // Not implemented.
224   void operator=(const VISU_CutPlanesPL&);  // Not implemented.
225 };
226
227 #endif