Salome HOME
73b42cdffdfaff8ddfc253d685654de55f01b4d8
[modules/visu.git] / src / PIPELINE / VISU_CutPlanesPL.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_CutPlanesPL.hxx
24 // Author:  Alexey PETROV
25 // Module : VISU
26
27 #ifndef VISU_CutPlanesPL_HeaderFile
28 #define VISU_CutPlanesPL_HeaderFile
29
30 #include "VISU_ScalarMapPL.hxx"
31
32 #include <vector>
33
34 class vtkAppendPolyData;
35
36 class VISU_CutPlanesPL : public VISU_ScalarMapPL{
37 protected:
38   VISU_CutPlanesPL();
39   VISU_CutPlanesPL(const VISU_CutPlanesPL&);
40 public:
41   vtkTypeMacro(VISU_CutPlanesPL,VISU_ScalarMapPL);
42   static VISU_CutPlanesPL* New();
43   virtual ~VISU_CutPlanesPL();
44   virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
45
46   enum PlaneOrientation {XY, YZ, ZX};
47   virtual const PlaneOrientation& GetPlaneOrientation(int theNum = 0) { return myBasePlane[theNum];}
48   virtual void SetPlaneOrientation(const PlaneOrientation& theOrient, int theNum = 0) { 
49     myBasePlane[theNum] = theOrient;
50   }
51
52   virtual float GetDisplacement(int theNum = 0) { return myDisplacement[theNum];}
53   virtual void SetDisplacement(float theDisp, int theNum = 0) { myDisplacement[theNum] = theDisp;}
54
55   virtual void SetPartPosition(int thePartNumber, float thePartPosition);
56   virtual float GetPartPosition(int thePartNumber, int theNum = 0);
57
58   virtual void SetPartDefault(int thePartNumber);
59   virtual int IsPartDefault(int thePartNumber);
60
61   virtual void SetRotateX(float theAngle, int theNum = 0);
62   virtual float GetRotateX(int theNum = 0);
63   virtual void SetRotateY(float theAngle, int theNum = 0);
64   virtual float GetRotateY(int theNum = 0);
65       
66   virtual void SetNbParts(int theNb);
67   virtual int GetNbParts(){ return myNbParts;}
68     
69 public:
70   virtual void Init();
71   virtual void Update();
72   virtual vtkAppendPolyData* GetAppendPolyData() { return myAppendPolyData; }
73   
74 public:
75   static float* GetRx(float theRx[3][3], float thaAng);
76   static float* GetRy(float theRy[3][3], float thaAng);
77   static float* GetRz(float theRz[3][3], float thaAng);
78
79   static void CorrectPnt(float thePnt[3], const float BoundPrj[6]);
80   static void GetBoundProject(float BoundPrj[3], const float BoundBox[6], const float Dir[3]);
81
82   static void GetDir(float theDir[3], float theAng[3], const PlaneOrientation& theBasePlane);
83
84   static void ClearAppendPolyData(vtkAppendPolyData *theAppendPolyData);
85
86   static void CutWithPlane(vtkAppendPolyData* theAppendPolyData, vtkDataSet* theDataSet,
87                            float theDir[3], float theOrig[3]);
88   static void CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDataSet* theDataSet,
89                             int theNbPlanes, float theDir[3], float theBounds[6], 
90                             const std::vector<float>& thePlanePosition, 
91                             const std::vector<int>& thePlaneCondition,
92                             float theDisplacement);
93 protected:
94   virtual THook* DoHook();
95   void SetPartPosition(int theNum = 0);
96
97   int myNbParts;
98   PlaneOrientation myBasePlane[2];
99   float myAng[2][3], myDisplacement[2];
100   vtkAppendPolyData *myAppendPolyData;
101   std::vector<float> myPartPosition;
102   std::vector<int> myPartCondition;
103 };
104
105 #endif