Salome HOME
Merge from BR_PORTING_VTK6 01/03/2013
[modules/gui.git] / src / VTKViewer / VTKViewer_GeometryFilter.h
1 // Copyright (C) 2007-2012  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 #ifndef VTKVIEWER_GEOMETRYFILTER_H
24 #define VTKVIEWER_GEOMETRYFILTER_H
25
26 #include "VTKViewer.h"
27
28 #include <vtkGeometryFilter.h>
29
30 #include <map>
31 #include <vector>
32
33 #ifdef WIN32
34 #pragma warning ( disable:4251 )
35 #endif
36
37 class vtkUnstructuredGrid;
38
39 /*! \brief This class used same as vtkGeometryFilter. See documentation on VTK for more information.
40  */
41 class VTKVIEWER_EXPORT VTKViewer_GeometryFilter : public vtkGeometryFilter 
42 {
43 public:
44   /*! \fn static VTKViewer_GeometryFilter *New()
45    */
46   static VTKViewer_GeometryFilter *New();
47   
48   /*! \fn vtkTypeMacro(VTKViewer_GeometryFilter, vtkGeometryFilter)
49    *  \brief VTK type revision macros.
50    */
51   vtkTypeMacro(VTKViewer_GeometryFilter, vtkGeometryFilter);
52   /*! \fn void SetInside(int theShowInside)
53    * \brief Sets \a myShowInside flag. \a myShowInside is changed, call this->Modified().
54    * \param theShowInside - used for changing value of \a myShowInside variable.
55    */
56   void SetInside(int theShowInside);
57   /*! \fn int GetInside()
58    * \brief Return value of \a myShowInside
59    * \retval myShowInside
60    */
61   int GetInside();
62   /*! \fn void SetWireframeMode(int theIsWireframeMode)
63    * \brief Sets \a myIsWireframeMode flag. \a myIsWireframeMode is changed, call this->Modified().
64    * \param theIsWireframeMode - used for changing value of \a myIsWireframeMode variable.
65    */
66
67   int GetAppendCoincident3D() const;
68   /*! \fn void SetAppendCoincident3D()
69    *  \brief Sets \a myAppendCoincident3D flag. If this flag is true, filter append to the 
70       result data set coincident 3D elements.
71    */
72
73   void SetAppendCoincident3D(int theFlag);
74   /*! \fn int SetAppendCoincident3D()
75    * \brief Return value of \a myAppendCoincident3D
76    * \retval myAppendCoincident3D
77    */
78
79   void SetWireframeMode(int theIsWireframeMode);
80   /*! \fn int GetWireframeMode()
81    * \brief Return value of \a myIsWireframeMode
82    * \retval myIsWireframeMode
83    */
84   int GetWireframeMode();
85   /*! \fn void SetStoreMapping(int theStoreMapping);
86    * \brief Sets \a myStoreMapping flag and call this->Modified()
87    * \param theStoreMapping - used for changing value of \a myStoreMapping variable.
88    */
89   void SetStoreMapping(int theStoreMapping);
90   /*! \fn int GetStoreMapping()
91    * \brief Return value of \a myStoreMapping
92    * \retval myStoreMapping
93    */
94   int GetStoreMapping();
95   /*! \fn virtual vtkIdType GetNodeObjId(int theVtkID)
96    * \brief Return input value theVtkID
97    * \retval theVtkID
98    */
99   virtual vtkIdType GetNodeObjId(int theVtkID) { return theVtkID;}
100   /*! \fn virtual vtkIdType GetElemObjId(int theVtkID);
101    * \brief Return object ID by VTK ID cell 
102    * \retval myVTK2ObjIds[theVtkID]
103    */
104   virtual vtkIdType GetElemObjId(int theVtkID);
105
106   virtual void SetQuadraticArcMode(bool theFlag);
107   virtual bool GetQuadraticArcMode() const;
108
109   virtual void   SetQuadraticArcAngle(double theMaxAngle);
110   virtual double GetQuadraticArcAngle() const;
111
112   typedef std::vector<vtkIdType> TVectorId;
113   typedef std::map<vtkIdType, TVectorId> TMapOfVectorId;
114
115   static void InsertId( const vtkIdType theCellId,
116                         const vtkIdType theCellType,
117                         TVectorId& theVTK2ObjIds,
118                         TMapOfVectorId& theDimension2VTK2ObjIds );
119
120 protected:
121   /*! \fn VTKViewer_GeometryFilter();
122    * \brief Constructor which sets \a myShowInside = 0 and \a myStoreMapping = 0
123    */
124   VTKViewer_GeometryFilter();
125   /*! \fn ~VTKViewer_GeometryFilter();
126    * \brief Destructor.
127    */
128   ~VTKViewer_GeometryFilter();
129
130   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
131
132   //special cases for performance
133   
134   /*! \fn void UnstructuredGridExecute();
135    * \brief Filter culculation method for data object type is VTK_UNSTRUCTURED_GRID.
136    */
137   int UnstructuredGridExecute (vtkDataSet *, vtkPolyData *, vtkInformation *);
138
139
140   void BuildArcedPolygon(vtkIdType cellId,
141                          vtkUnstructuredGrid* input,
142                          vtkPolyData *output,
143                          TMapOfVectorId& theDimension2VTK2ObjIds,
144                          bool triangulate = false);
145     
146 private:
147   TVectorId myVTK2ObjIds;
148   int       myShowInside;
149   int       myStoreMapping;
150   int       myIsWireframeMode;
151   int       myAppendCoincident3D;
152
153   double    myMaxArcAngle;   // define max angle for mesh 2D quadratic element in the degrees
154   bool      myIsBuildArc;     // flag for representation 2D quadratic element as arked polygon
155 };
156
157 #ifdef WIN32
158 #pragma warning ( default:4251 )
159 #endif
160
161 #endif