]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_MedFileBrowser.hxx
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDMEM / MEDMEM_MedFileBrowser.hxx
1 // Copyright (C) 2007-2012  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 # ifndef MEDFILEBROWSER_HXX
24 # define MEDFILEBROWSER_HXX
25
26 #include "MEDMEM.hxx"
27 #include "MEDMEM_define.hxx"
28 #include "MEDMEM_Exception.hxx"
29
30 #include <string>
31 #include <map>
32 #include <vector>
33
34 namespace MEDMEM {
35
36 typedef struct { int dt; int it; } DT_IT_; //!< { numero du pas de temps, numero d'ordre }
37 struct MEDMEM_EXPORT LT_DT_IT_
38 {
39   bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
40   {
41     if ( p1.dt == p2.dt)
42       return p1.it < p2.it ;
43     else
44       return  p1.dt < p2.dt ;
45   }
46 };
47 typedef std::vector<DT_IT_> VEC_DT_IT_;
48
49 /*!
50  * \brief Class giving access to names of meshes and fields contained in the med file
51  */
52 class MEDMEM_EXPORT MEDFILEBROWSER
53 {
54   std::string                          _fileName;
55
56   std::map< std::string, bool >        _meshes; //!< mesh name and isStructured flag
57
58   typedef struct
59   {
60     MED_EN::med_type_champ _type;
61     std::string            _meshName;
62     VEC_DT_IT_             _vec_dtit;
63   } FIELD_DATA_;
64
65   std::map< std::string, FIELD_DATA_ > _fields; //!< field name and its type and "dtit"
66
67 public:
68
69   MEDFILEBROWSER();
70   MEDFILEBROWSER (const std::string & fileName) throw (MEDEXCEPTION);
71   void readFileStruct(const std::string & fileName) throw (MEDEXCEPTION);
72
73   std::string  getFileName() const;
74
75   int        getNumberOfMeshes ( void ) const;
76   int        getNumberOfFields ( void ) const;
77
78   void       getMeshNames      ( std::string * meshNames ) const;
79   void       getFieldNames     ( std::string * fieldNames ) const;
80
81   std::vector< std::string > getMeshNames () const;
82   std::vector< std::string > getFieldNames() const;
83
84   bool isStructuredMesh(const std::string & meshName) const throw (MEDEXCEPTION);
85
86   MED_EN::med_type_champ getFieldType (const std::string & fieldName) const throw (MEDEXCEPTION) ;
87   std::string             getMeshName (const std::string & fieldName) const throw (MEDEXCEPTION) ;
88   VEC_DT_IT_        getFieldIteration (const std::string & fieldName) const throw (MEDEXCEPTION) ;
89 };
90
91 }
92
93 #endif