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