Salome HOME
Compatibility CMake
[modules/visu.git] / src / CONVERTOR / VISU_ConvertorUtils.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_ConvertorUtils.hxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26 //
27 #ifndef VISU_ConvertorUtils_HeaderFile
28 #define VISU_ConvertorUtils_HeaderFile
29
30 #include "VISUConvertor.hxx"
31
32 #include "VISU_ConvertorDef.hxx"
33 #include "VISU_IDMapper.hxx"
34 #include "MED_Utilities.hxx"
35
36 #include "VTKViewer.h"
37 #include <vtkSystemIncludes.h>
38
39 #include <string>
40
41 class vtkInformationVector;
42 class vtkUnstructuredGrid;
43 class vtkPolyData;
44 class vtkTimerLog;
45 class vtkDataSet;
46 class vtkCell;
47
48 #ifndef VISU_ENABLE_QUADRATIC
49   #define VISU_ENABLE_QUADRATIC
50   #define VISU_USE_VTK_QUADRATIC
51 #endif
52
53 namespace MED
54 {
55   class PrefixPrinter;
56 }
57
58 namespace VISU
59 {
60   //---------------------------------------------------------------
61   //! Get number of nodes for defined geometrical type
62   vtkIdType VISU_CONVERTOR_EXPORT
63   VISUGeom2NbNodes(EGeometry theGeom);
64
65
66   //---------------------------------------------------------------
67   //! Maps VISU geometrical type to VTK one
68   vtkIdType
69   VISUGeom2VTK(EGeometry theGeom);
70
71
72   //---------------------------------------------------------------
73   //! The utility function allows to write vtkUnstructuredGrid to a file with defined name
74   VISU_CONVERTOR_EXPORT
75   void 
76   WriteToFile(vtkUnstructuredGrid* theDataSet, 
77               const std::string& theFileName);
78
79
80   //---------------------------------------------------------------
81   //! The utility function allows to write vtkPolyData to a file with defined name
82   VISU_CONVERTOR_EXPORT
83   void 
84   WriteToFile(vtkPolyData* theDataSet, 
85               const std::string& theFileName);
86
87
88   //---------------------------------------------------------------
89   VISU_CONVERTOR_EXPORT
90   bool 
91   IsDataOnCells(vtkDataSet* theDataSet);
92
93   //---------------------------------------------------------------
94   VISU_CONVERTOR_EXPORT
95   bool 
96   IsElnoData(vtkDataSet* theDataSet);
97
98
99   //---------------------------------------------------------------
100   VISU_CONVERTOR_EXPORT
101   bool 
102   IsDataOnPoints(vtkDataSet* theDataSet);
103
104
105   //---------------------------------------------------------------
106   VISU_CONVERTOR_EXPORT
107   vtkIdType
108   GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity = -1);
109
110
111   //---------------------------------------------------------------
112   VISU_CONVERTOR_EXPORT
113   vtkIdType
114   GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID);
115
116
117   //---------------------------------------------------------------
118   VISU_CONVERTOR_EXPORT
119   vtkCell* 
120   GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID);
121
122
123   //---------------------------------------------------------------
124   VISU_CONVERTOR_EXPORT
125   vtkIdType
126   GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID);
127
128
129   //---------------------------------------------------------------
130   VISU_CONVERTOR_EXPORT
131   vtkIdType
132   GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID);
133
134
135   //---------------------------------------------------------------
136   VISU_CONVERTOR_EXPORT
137   vtkFloatingPointType* 
138   GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID);
139
140   //---------------------------------------------------------------
141   VISU_CONVERTOR_EXPORT
142   TGaussPointID
143   GetObjID(vtkDataSet *theDataSet, vtkIdType theID);
144
145
146   //---------------------------------------------------------------
147   typedef vtkIdType TInputID;
148   typedef vtkIdType TCellID; 
149   typedef std::pair<TInputID,TCellID> TInputCellID;
150
151   VISU_CONVERTOR_EXPORT
152   TInputCellID
153   GetInputCellID(vtkDataSet *theDataSet, vtkIdType theObjID);
154
155
156   VISU_CONVERTOR_EXPORT
157   vtkDataSet*
158   GetInput(vtkInformationVector **theInputVector, 
159            vtkIdType theInputId = 0);
160
161   VISU_CONVERTOR_EXPORT
162   vtkDataSet*
163   GetOutput(vtkInformationVector *theOutputVector);
164
165   //! Utility for ELNO Data Selection
166   //---------------------------------------------------------------
167   typedef vtkIdType TVTKPointID;
168   typedef vtkIdType TVTKCellID;
169   typedef std::pair<TVTKPointID,TVTKCellID> TElnoPointID;
170   typedef std::vector<TElnoPointID> TElnoPoints;
171
172   VISU_CONVERTOR_EXPORT 
173   TElnoPoints
174   GetElnoPoints(vtkDataSet *theDataSet, vtkIdType theNodeObjID);
175
176   //---------------------------------------------------------------
177   //! The utility class that allows to perform perfomance mesurement
178   class VISU_CONVERTOR_EXPORT TTimerLog
179   {
180     int myIsDebug;
181     double myCPUTime;
182     std::string myName;
183     vtkTimerLog* myTimerLog;
184     MED::PrefixPrinter myPrefixPrinter;
185   public:
186
187     TTimerLog(int theIsDebug,
188               const std::string& theName);
189     ~TTimerLog();
190   };
191   
192
193   //---------------------------------------------------------------
194 }
195
196 #endif