Version: 6.3.1

src/CONVERTOR/VISU_Vtk2MedConvertor.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  File   : VISU_Vtk2MedConvertor.hxx
00021 //  Author : Eugeny NIKOLAEV, Open CASCADE SAS
00022 //
00023 #ifndef VISU_VTK2MEDCONVERTOR_H
00024 #define VISU_VTK2MEDCONVERTOR_H
00025 
00026 #include "VISUConvertor.hxx"
00027 
00028 #include <MED_Common.hxx>
00029 #include <vtkIntArray.h>
00030 #include <vtkDataSet.h>
00031 
00032 #include <vector>
00033 #include <map>
00034 #include <string>
00035 
00036 class vtkUnstructuredGrid;
00037 class vtkIntArray;
00038 
00039 class VISU_CONVERTOR_EXPORT VISU_Vtk2MedConvertor
00040 {
00041 public:
00042 
00043   typedef std::vector<std::string>                  TVectorString;
00044   typedef std::vector<double>                       TVectorDouble;
00045   typedef std::vector<int>                          TCellIds;
00046   typedef std::map<MED::EGeometrieElement,TCellIds> TGeom2CellIds;
00047   
00048   VISU_Vtk2MedConvertor();
00049   
00050   VISU_Vtk2MedConvertor( const std::string theMEDFileName,
00051                          const std::string theFirstVTKFileName );
00052   
00053   VISU_Vtk2MedConvertor( const std::string theMEDFileName,
00054                          const std::string theFirstVTKFileName,
00055                          const TVectorString theDataVTKFileNames );
00056   
00057   
00058   void               setMEDFileName( const std::string theFileName );
00059   std::string        getMEDFileName() const;
00060   
00061   void               setFirstVTKFileName( const std::string theFileName );
00062   std::string        getFirstVTKFileName() const;
00063   
00064   void               setDataVTKFileNames( const TVectorString theFileNames );
00065   void               getDataVTKFileNames( TVectorString& ) const;
00066 
00067   void               setVersion( const MED::EVersion theVersion );
00068   MED::EVersion      getVersion() const;
00069 
00070   void               setMeshName( const std::string theMeshName );
00071   std::string        getMeshName() const;
00072 
00073   void               addToIgnoringFieldList( const std::string& theFieldName );
00074   void               eraseFromIgnoringFieldList( const std::string& theFieldName );
00075   const std::set<std::string>& getIgnoringFieldList() const;
00076 
00077   void               setCellDataFieldNameIDS( const std::string& theFieldName );
00078   const std::string& getCellDataFieldNameIDS() const;
00079     
00080   void               setPointDataFieldNameIDS( const std::string& theFieldName );
00081   const std::string& getPointDataFieldNameIDS() const;
00082 
00083   void               setTimeStamps( const TVectorDouble& theTStamps );
00084   void               getTimeStamps( TVectorDouble& theTStamps ) const;
00085     
00086   int                Execute();
00087     
00088 protected:
00089   
00090   TVectorString         myDataVTKFileNames; // vtk files with data
00091   std::string           myMEDFileName; // output MED file name.
00092   std::string           myFirstVTKFileName;  // vtk file with geometry,data from this file also used.
00093   MED::EVersion         myVersion;
00094   std::string           myMeshName;
00095   std::set<std::string> myIgnoringFieldList;
00096   std::string           myCellDataFieldNameIDS;
00097   std::string           myPointDataFieldNameIDS;
00098   TVectorDouble         myTStamps;
00099   
00100 private:
00101 
00102   // Fill container with indices of cells which match given type.
00103   void
00104   GetIdsOfCellsOfType( vtkDataSet* theInput, // input
00105                        const int type, // input
00106                        vtkIntArray *array ); // output
00107 
00108   
00109   // ret value 0 - OK
00110   // ret value 1 - ERROR
00111   int
00112   Geometry2MED( vtkDataSet* aInput,
00113                 MED::PWrapper myMed,
00114                 MED::PMeshInfo aMeshInfo,
00115                 TGeom2CellIds& outGeom2CellIdMap );
00116 
00117   // ret value 0 - OK
00118   // ret value 1 - ERROR
00119   int
00120   Data2MED( std::vector<vtkDataSet*> theListForAdd,
00121             MED::PWrapper myMed,
00122             MED::PMeshInfo theMeshInfo,
00123             TGeom2CellIds& theGeom2CellIdMap );
00124 
00125   // ret value 0 - OK
00126   // ret value 1 - ERROR
00127   int
00128   CreateElements( vtkDataSet* theInput,
00129                   MED::PMeshInfo theMeshInfo,
00130                   MED::PWrapper  theMed,
00131                   vtkIntArray* theCellsMapper,
00132                   MED::EEntiteMaillage theEntity,
00133                   int theVTKGeom,
00134                   int nbPointsInGeom,
00135                   std::vector<int>& theNumberingConvertor,
00136                   TGeom2CellIds& theGeom2CellIdMap );
00137 
00138   // ret value 0 - OK
00139   // ret value 1 - ERROR
00140   int
00141   CreatePolygons( vtkDataSet* theInput,
00142                   MED::PMeshInfo theMeshInfo,
00143                   MED::PWrapper  theMed,
00144                   vtkIntArray* theCellsMapper,
00145                   MED::EEntiteMaillage theEntity,
00146                   TGeom2CellIds& theGeom2CellIdMap );
00147 
00148   // ret value 0 - OK
00149   // ret value 1 - ERROR
00150   int
00151   CreatePolyedres( vtkDataSet* theInput,
00152                    MED::PMeshInfo theMeshInfo,
00153                    MED::PWrapper  theMed,
00154                    vtkIntArray* theCellsMapper,
00155                    MED::EEntiteMaillage theEntity,
00156                    TGeom2CellIds& theGeom2CellIdMap );
00157   
00158 };
00159 
00160 #endif // VISU_VTK2MEDCONVERTOR_H
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS