Salome HOME
Update copyright information
[modules/visu.git] / src / CONVERTOR / VISU_Vtk2MedConvertor.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  File   : VISU_Vtk2MedConvertor.hxx
21 //  Author : Eugeny NIKOLAEV, Open CASCADE SAS
22 //
23 #ifndef VISU_VTK2MEDCONVERTOR_H
24 #define VISU_VTK2MEDCONVERTOR_H
25
26 #include "VISUConvertor.hxx"
27
28 #include <MED_Common.hxx>
29 #include <vtkIntArray.h>
30 #include <vtkDataSet.h>
31
32 #include <vector>
33 #include <map>
34 #include <string>
35
36 class vtkUnstructuredGrid;
37 class vtkIntArray;
38
39 class VISU_CONVERTOR_EXPORT VISU_Vtk2MedConvertor
40 {
41 public:
42
43   typedef std::vector<std::string>                  TVectorString;
44   typedef std::vector<double>                       TVectorDouble;
45   typedef std::vector<int>                          TCellIds;
46   typedef std::map<MED::EGeometrieElement,TCellIds> TGeom2CellIds;
47   
48   VISU_Vtk2MedConvertor();
49   
50   VISU_Vtk2MedConvertor( const std::string theMEDFileName,
51                          const std::string theFirstVTKFileName );
52   
53   VISU_Vtk2MedConvertor( const std::string theMEDFileName,
54                          const std::string theFirstVTKFileName,
55                          const TVectorString theDataVTKFileNames );
56   
57   
58   void               setMEDFileName( const std::string theFileName );
59   std::string        getMEDFileName() const;
60   
61   void               setFirstVTKFileName( const std::string theFileName );
62   std::string        getFirstVTKFileName() const;
63   
64   void               setDataVTKFileNames( const TVectorString theFileNames );
65   void               getDataVTKFileNames( TVectorString& ) const;
66
67   void               setVersion( const MED::EVersion theVersion );
68   MED::EVersion      getVersion() const;
69
70   void               setMeshName( const std::string theMeshName );
71   std::string        getMeshName() const;
72
73   void               addToIgnoringFieldList( const std::string& theFieldName );
74   void               eraseFromIgnoringFieldList( const std::string& theFieldName );
75   const std::set<std::string>& getIgnoringFieldList() const;
76
77   void               setCellDataFieldNameIDS( const std::string& theFieldName );
78   const std::string& getCellDataFieldNameIDS() const;
79     
80   void               setPointDataFieldNameIDS( const std::string& theFieldName );
81   const std::string& getPointDataFieldNameIDS() const;
82
83   void               setTimeStamps( const TVectorDouble& theTStamps );
84   void               getTimeStamps( TVectorDouble& theTStamps ) const;
85     
86   int                Execute();
87     
88 protected:
89   
90   TVectorString         myDataVTKFileNames; // vtk files with data
91   std::string           myMEDFileName; // output MED file name.
92   std::string           myFirstVTKFileName;  // vtk file with geometry,data from this file also used.
93   MED::EVersion         myVersion;
94   std::string           myMeshName;
95   std::set<std::string> myIgnoringFieldList;
96   std::string           myCellDataFieldNameIDS;
97   std::string           myPointDataFieldNameIDS;
98   TVectorDouble         myTStamps;
99   
100 private:
101
102   // Fill container with indices of cells which match given type.
103   void
104   GetIdsOfCellsOfType( vtkDataSet* theInput, // input
105                        const int type, // input
106                        vtkIntArray *array ); // output
107
108   
109   // ret value 0 - OK
110   // ret value 1 - ERROR
111   int
112   Geometry2MED( vtkDataSet* aInput,
113                 MED::PWrapper myMed,
114                 MED::PMeshInfo aMeshInfo,
115                 TGeom2CellIds& outGeom2CellIdMap );
116
117   // ret value 0 - OK
118   // ret value 1 - ERROR
119   int
120   Data2MED( std::vector<vtkDataSet*> theListForAdd,
121             MED::PWrapper myMed,
122             MED::PMeshInfo theMeshInfo,
123             TGeom2CellIds& theGeom2CellIdMap );
124
125   // ret value 0 - OK
126   // ret value 1 - ERROR
127   int
128   CreateElements( vtkDataSet* theInput,
129                   MED::PMeshInfo theMeshInfo,
130                   MED::PWrapper  theMed,
131                   vtkIntArray* theCellsMapper,
132                   MED::EEntiteMaillage theEntity,
133                   int theVTKGeom,
134                   int nbPointsInGeom,
135                   std::vector<int>& theNumberingConvertor,
136                   TGeom2CellIds& theGeom2CellIdMap );
137
138   // ret value 0 - OK
139   // ret value 1 - ERROR
140   int
141   CreatePolygons( vtkDataSet* theInput,
142                   MED::PMeshInfo theMeshInfo,
143                   MED::PWrapper  theMed,
144                   vtkIntArray* theCellsMapper,
145                   MED::EEntiteMaillage theEntity,
146                   TGeom2CellIds& theGeom2CellIdMap );
147
148   // ret value 0 - OK
149   // ret value 1 - ERROR
150   int
151   CreatePolyedres( vtkDataSet* theInput,
152                    MED::PMeshInfo theMeshInfo,
153                    MED::PWrapper  theMed,
154                    vtkIntArray* theCellsMapper,
155                    MED::EEntiteMaillage theEntity,
156                    TGeom2CellIds& theGeom2CellIdMap );
157   
158 };
159
160 #endif // VISU_VTK2MEDCONVERTOR_H