Salome HOME
Merge branch 'oscar/imps_2017'
[modules/gui.git] / src / VTKViewer / VTKViewer_GeometryFilter.h
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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 int GetAppendCoincident3D()
63    * \brief Return value of \a myAppendCoincident3D
64    * \retval myAppendCoincident3D
65    */
66   int GetAppendCoincident3D() const;
67   /*! \fn void SetAppendCoincident3D()
68    *  \brief Sets \a myAppendCoincident3D flag. If this flag is true, filter append to the 
69       result data set coincident 3D elements.
70    */
71   void SetAppendCoincident3D(int theFlag);
72   /*! \fn void SetWireframeMode(int theIsWireframeMode)
73    * \brief Sets \a myIsWireframeMode flag. \a myIsWireframeMode is changed, call this->Modified().
74    * \param theIsWireframeMode - used for changing value of \a myIsWireframeMode variable.
75    */
76   void SetWireframeMode(int theIsWireframeMode);
77   /*! \fn int GetWireframeMode()
78    * \brief Return value of \a myIsWireframeMode
79    * \retval myIsWireframeMode
80    */
81   int GetWireframeMode();
82   /*! \fn void SetStoreMapping(int theStoreMapping);
83    * \brief Sets \a myStoreMapping flag and call this->Modified()
84    * \param theStoreMapping - used for changing value of \a myStoreMapping variable.
85    */
86   void SetStoreMapping(int theStoreMapping);
87   /*! \fn int GetStoreMapping()
88    * \brief Return value of \a myStoreMapping
89    * \retval myStoreMapping
90    */
91   int GetStoreMapping();
92   /*! \fn virtual vtkIdType GetNodeObjId(int theVtkID)
93    * \brief Return input value theVtkID
94    * \retval theVtkID
95    */
96   virtual vtkIdType GetNodeObjId(int theVtkID) { return theVtkID;}
97   /*! \fn virtual vtkIdType GetElemObjId(int theVtkID);
98    * \brief Return object ID by VTK ID cell 
99    * \retval myVTK2ObjIds[theVtkID]
100    */
101   virtual vtkIdType GetElemObjId(int theVtkID);
102
103   virtual void SetQuadraticArcMode(bool theFlag);
104   virtual bool GetQuadraticArcMode() const;
105
106   virtual void   SetQuadraticArcAngle(double theMaxAngle);
107   virtual double GetQuadraticArcAngle() const;
108
109   typedef std::vector<vtkIdType> TVectorId;
110   //typedef std::map<vtkIdType, TVectorId> TMapOfVectorId;
111   typedef std::vector<TVectorId> TMapOfVectorId;
112
113   static void InsertId( const vtkIdType theCellId,
114                         const vtkIdType theCellType,
115                         TVectorId& theVTK2ObjIds,
116                         TMapOfVectorId& theDimension2VTK2ObjIds );
117
118 protected:
119   /*! \fn VTKViewer_GeometryFilter();
120    * \brief Constructor which sets \a myShowInside = 0 and \a myStoreMapping = 0
121    */
122   VTKViewer_GeometryFilter();
123   /*! \fn ~VTKViewer_GeometryFilter();
124    * \brief Destructor.
125    */
126   ~VTKViewer_GeometryFilter();
127
128   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
129
130   //special cases for performance
131   
132   /*! \fn void UnstructuredGridExecute();
133    * \brief Filter culculation method for data object type is VTK_UNSTRUCTURED_GRID.
134    */
135   int UnstructuredGridExecute (vtkDataSet *, vtkPolyData *, vtkInformation *);
136
137
138   void BuildArcedPolygon(vtkIdType cellId,
139                          vtkUnstructuredGrid* input,
140                          vtkPolyData *output,
141                          TMapOfVectorId& theDimension2VTK2ObjIds,
142                          bool triangulate = false);
143     
144 private:
145   TVectorId myVTK2ObjIds;
146   int       myShowInside;
147   int       myStoreMapping;
148   int       myIsWireframeMode;
149   int       myAppendCoincident3D;
150
151   double    myMaxArcAngle;   // define max angle for mesh 2D quadratic element in the degrees
152   bool      myIsBuildArc;     // flag for representation 2D quadratic element as arked polygon
153 };
154
155 #ifdef WIN32
156 #pragma warning ( default:4251 )
157 #endif
158
159 #endif