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