Salome HOME
94785d29518553a6331a7a450fd162f934ab0445
[modules/gui.git] / src / VTKViewer / VTKViewer_CellRectPicker.h
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
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 //  File    : VTKViewer_CellRectPicker.h
23 //  Author  : Natalia KOPNOVA
24 //  Module  : SALOME
25
26
27 #ifndef __VTKViewer_CellRectPicker_h
28 #define __VTKViewer_CellRectPicker_h
29
30 #include "VTKViewer_RectPicker.h"
31 #include <map>
32 #include <vector>
33
34 /*! \brief Cell data structure*/
35 typedef struct {
36   vtkIdType cellId;
37   int subId;
38   float depth;
39   float p1[3];
40   float p2[3];
41 } VTKViewer_CellData;
42
43 typedef std::vector<VTKViewer_CellData> VTKViewer_CellDataSet;
44 typedef std::map<vtkActor*, VTKViewer_CellDataSet> VTKViewer_ActorDataMap;
45
46 class vtkCell;
47 class vtkGenericCell;
48 class vtkQuad;
49 /*! \class VTKViewer_CellRectPicker
50  * \brief Rectangular cell picker class.
51  */
52 class VTK_EXPORT VTKViewer_CellRectPicker : public VTKViewer_RectPicker
53 {
54 public:
55   static VTKViewer_CellRectPicker *New();
56   /*! \fn vtkTypeMacro(VTKViewer_CellRectPicker,VTKViewer_RectPicker);
57    * \brief VTK type macros.
58    */
59   vtkTypeMacro(VTKViewer_CellRectPicker,VTKViewer_RectPicker);
60
61   /*! \fn VTKViewer_CellDataSet GetCellData(vtkActor* actor)
62    * \brief Get the id of the picked cells. 
63    * \brief (Notes: use GetActors() to get picked actors list)
64    * \param actor - vtkActor pointer
65    */
66   VTKViewer_CellDataSet GetCellData(vtkActor* actor) 
67     { return this->ActorData[actor]; }
68
69   /*! \fn static int IntersectCells(vtkCell* c1, float d1, vtkCell* c2, float d2, float dir[3]);
70    * \brief The method returns a non-zero value, if the cells intersect each other 
71    * in the direction dir[3].
72    * \param c1 - first vtkCell pointer
73    * \param d1 - 
74    * \param c2 - second vtkCell pointer
75    * \param d2 - 
76    * \param dir[3] - direction
77    * \retval integer - Returned value is 1 if the first cell is top of 
78    * the second one according to direction and 2 if the second cell is top.
79    */
80   static int IntersectCells(vtkCell* c1, float d1, vtkCell* c2, float d2, float dir[3]);
81
82   /*! \fn static char PointInside(float point[3], vtkPoints* list);
83    * \brief Check point position.
84    * \param point[3] - point
85    * \param list - point data set
86    * \retval 0 or 1 - The method returns a non-zero value, if the point is inlide point data set
87    */
88   static char PointInside(float point[3], vtkPoints* list);
89
90 protected:
91   
92   VTKViewer_CellRectPicker();
93   ~VTKViewer_CellRectPicker();
94
95   VTKViewer_ActorDataMap ActorData;
96
97   /*! \fn virtual float IntersectWithHex(float p1[4][4], float p2[4][4], float tol, 
98    *                              vtkAssemblyPath *path, vtkProp3D *p, 
99    *                              vtkAbstractMapper3D *m);
100    */
101   virtual float IntersectWithHex(float p1[4][4], float p2[4][4], float tol, 
102                           vtkAssemblyPath *path, vtkProp3D *p, 
103                           vtkAbstractMapper3D *m);
104   /*! \fn void Initialize();
105    * \brief Clear \a ActorData and call VTKViewer_RectPicker::Initialize() method
106    */
107   void Initialize();
108
109   
110   void IncludeCell(vtkDataSet* input, VTKViewer_CellData cellData, VTKViewer_CellDataSet& dalaList);
111   void IncludeActor(vtkProp3D* prop, vtkDataSet* input, VTKViewer_CellDataSet& dataList);
112
113 private:
114   vtkGenericCell *Cell;
115   vtkQuad* Quad1;
116   vtkQuad* Quad2;
117 };
118
119 #endif
120
121