]> SALOME platform Git repositories - modules/visu.git/blob - src/CONVERTOR/VISU_Vtk2MedConvertor.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/visu.git] / src / CONVERTOR / VISU_Vtk2MedConvertor.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 //  File   : VISU_Vtk2MedConvertor.hxx
23 //  Author : Eugeny NIKOLAEV, Open CASCADE SAS
24 //
25
26 #ifndef VISU_VTK2MEDCONVERTOR_H
27 #define VISU_VTK2MEDCONVERTOR_H
28
29 #include <MED_Common.hxx>
30 #include <vtkIntArray.h>
31 #include <vtkDataSet.h>
32
33 #include <vector>
34 #include <map>
35 #include <string>
36
37 class vtkUnstructuredGrid;
38 class vtkIntArray;
39
40 class VISU_Vtk2MedConvertor
41 {
42 public:
43
44   typedef std::vector<std::string>                  TVectorString;
45   typedef std::vector<double>                       TVectorDouble;
46   typedef std::vector<int>                          TCellIds;
47   typedef std::map<MED::EGeometrieElement,TCellIds> TGeom2CellIds;
48   
49   VISU_Vtk2MedConvertor();
50   
51   VISU_Vtk2MedConvertor( const std::string theMEDFileName,
52                          const std::string theFirstVTKFileName );
53   
54   VISU_Vtk2MedConvertor( const std::string theMEDFileName,
55                          const std::string theFirstVTKFileName,
56                          const TVectorString theDataVTKFileNames );
57   
58   
59   void               setMEDFileName( const std::string theFileName );
60   std::string        getMEDFileName() const;
61   
62   void               setFirstVTKFileName( const std::string theFileName );
63   std::string        getFirstVTKFileName() const;
64   
65   void               setDataVTKFileNames( const TVectorString theFileNames );
66   void               getDataVTKFileNames( TVectorString& ) const;
67
68   void               setVersion( const MED::EVersion theVersion );
69   MED::EVersion      getVersion() const;
70
71   void               setMeshName( const std::string theMeshName );
72   std::string        getMeshName() const;
73
74   void               addToIgnoringFieldList( const std::string& theFieldName );
75   void               eraseFromIgnoringFieldList( const std::string& theFieldName );
76   const std::set<std::string>& getIgnoringFieldList() const;
77
78   void               setCellDataFieldNameIDS( const std::string& theFieldName );
79   const std::string& getCellDataFieldNameIDS() const;
80     
81   void               setPointDataFieldNameIDS( const std::string& theFieldName );
82   const std::string& getPointDataFieldNameIDS() const;
83
84   void               setTimeStamps( const TVectorDouble& theTStamps );
85   void               getTimeStamps( TVectorDouble& theTStamps ) const;
86     
87   int                Execute();
88     
89 protected:
90   
91   TVectorString         myDataVTKFileNames; // vtk files with data
92   std::string           myMEDFileName; // output MED file name.
93   std::string           myFirstVTKFileName;  // vtk file with geometry,data from this file also used.
94   MED::EVersion         myVersion;
95   std::string           myMeshName;
96   std::set<std::string> myIgnoringFieldList;
97   std::string           myCellDataFieldNameIDS;
98   std::string           myPointDataFieldNameIDS;
99   TVectorDouble         myTStamps;
100   
101 private:
102
103   // Fill container with indices of cells which match given type.
104   void
105   GetIdsOfCellsOfType( vtkDataSet* theInput, // input
106                        const int type, // input
107                        vtkIntArray *array ); // output
108
109   
110   // ret value 0 - OK
111   // ret value 1 - ERROR
112   int
113   Geometry2MED( vtkDataSet* aInput,
114                 MED::PWrapper myMed,
115                 MED::PMeshInfo aMeshInfo,
116                 TGeom2CellIds& outGeom2CellIdMap );
117
118   // ret value 0 - OK
119   // ret value 1 - ERROR
120   int
121   Data2MED( std::vector<vtkDataSet*> theListForAdd,
122             MED::PWrapper myMed,
123             MED::PMeshInfo theMeshInfo,
124             TGeom2CellIds& theGeom2CellIdMap );
125
126   // ret value 0 - OK
127   // ret value 1 - ERROR
128   int
129   CreateElements( vtkDataSet* theInput,
130                   MED::PMeshInfo theMeshInfo,
131                   MED::PWrapper  theMed,
132                   vtkIntArray* theCellsMapper,
133                   MED::EEntiteMaillage theEntity,
134                   int theVTKGeom,
135                   int nbPointsInGeom,
136                   std::vector<int>& theNumberingConvertor,
137                   TGeom2CellIds& theGeom2CellIdMap );
138
139   // ret value 0 - OK
140   // ret value 1 - ERROR
141   int
142   CreatePolygons( vtkDataSet* theInput,
143                   MED::PMeshInfo theMeshInfo,
144                   MED::PWrapper  theMed,
145                   vtkIntArray* theCellsMapper,
146                   MED::EEntiteMaillage theEntity,
147                   TGeom2CellIds& theGeom2CellIdMap );
148
149   // ret value 0 - OK
150   // ret value 1 - ERROR
151   int
152   CreatePolyedres( vtkDataSet* theInput,
153                    MED::PMeshInfo theMeshInfo,
154                    MED::PWrapper  theMed,
155                    vtkIntArray* theCellsMapper,
156                    MED::EEntiteMaillage theEntity,
157                    TGeom2CellIds& theGeom2CellIdMap );
158   
159 };
160
161 #endif // VISU_VTK2MEDCONVERTOR_H