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