Salome HOME
5ee14a487ec7050e8b1cc70418b5ee694ca4895a
[modules/visu.git] / src / CONVERTOR / VISU_Convertor.hxx
1 // Copyright (C) 2007-2011  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 //  VISU CONVERTOR :
24 //  File   : VISU_Convertor.hxx
25 //  Author : Alexey PETROV
26 //  Module : VISU
27 //
28 #ifndef VISU_Convertor_HeaderFile
29 #define VISU_Convertor_HeaderFile
30
31 /*! 
32   \file VISU_Convertor.hxx
33   \brief The file represents definition of basic interface of the VISU CONVERTER package
34 */
35
36 #include "VISU_Structures.hxx"
37
38
39 //---------------------------------------------------------------
40 //! This class defines interface to read VTK interpretation of MED entities
41 /*!
42   It is the main class of the VISU CONVERTER package.
43   Following MED entities can be retrived from any MED file:
44   - mesh from corresponding MED ENTITIES;
45   - MED TIMESTAMPS;
46   - MED FAMILIES;
47   - MED GROUPS.
48   The class produce its work in two main steps:
49   1. Perfrom parsing of MED file to get known what MED entities are pressent in it
50   2. Get VTK representation for any existing MED entity
51   Also, it can perform some additional work to calculate expected amount of memory to build defined VTK representation
52 */
53 class VISU_CONVERTOR_EXPORT VISU_Convertor
54 {
55 public:
56   //! Get brief name of the corresponding source MED file
57   virtual
58   const std::string& 
59   GetName();
60
61   //! Let known whether the source MED file parsed or not
62   virtual
63   int
64   IsDone() const;
65
66   //! This method perform first parsing of MED file to get known what MED entities are pressent in it
67   virtual
68   VISU_Convertor* 
69   Build() = 0;
70
71   //! This method perform first parsing of MED file to get known what MED mesh entities are pressent in it
72   virtual
73   VISU_Convertor* 
74   BuildEntities() = 0;
75
76   //! This method perform first parsing of MED file to get known what MED fields are pressent in it
77   virtual
78   VISU_Convertor* 
79   BuildFields() = 0;
80
81   //! This min /max calculation over existing MED fields
82   virtual
83   VISU_Convertor* 
84   BuildMinMax() = 0;
85
86   //! This method perform first parsing of MED file to get known what MED groups are pressent in it
87   virtual
88   VISU_Convertor* 
89   BuildGroups() = 0;
90
91   //! This method allow to get known what MED entities are present is the MED file
92   virtual
93   const VISU::TMeshMap& 
94   GetMeshMap();
95
96   //! Get amount of memory to build VTK representations for all existing MED entities
97   virtual
98   size_t
99   GetSize() = 0;
100
101   //! Get mesh for corresponding MED ENTITY
102   virtual
103   VISU::PNamedIDMapper 
104   GetMeshOnEntity(const std::string& theMeshName, 
105                   const VISU::TEntity& theEntity) = 0;
106   
107   //! Get amount of memory to build mesh for corresponding MED ENTITY
108   virtual
109   size_t
110   GetMeshOnEntitySize(const std::string& theMeshName, 
111                       const VISU::TEntity& theEntity) = 0;
112   
113   //! Get mesh for corresponding MED FAMILY
114   virtual 
115   VISU::PUnstructuredGridIDMapper 
116   GetFamilyOnEntity(const std::string& theMeshName, 
117                     const VISU::TEntity& theEntity,
118                     const std::string& theFamilyName) = 0;
119
120   //! Get amount of memory to build mesh for corresponding MED FAMILY
121   virtual 
122   size_t 
123   GetFamilyOnEntitySize(const std::string& theMeshName, 
124                         const VISU::TEntity& theEntity,
125                         const std::string& theFamilyName) = 0;
126
127   //! Get mesh for corresponding MED GROUP
128   virtual
129   VISU::PUnstructuredGridIDMapper
130   GetMeshOnGroup(const std::string& theMeshName, 
131                  const std::string& theGroupName) = 0;
132   
133   //! Get amount of memory to build mesh for corresponding MED GROUP
134   virtual
135   size_t
136   GetMeshOnGroupSize(const std::string& theMeshName, 
137                      const std::string& theGroupName) = 0;
138   
139   //! Get mesh with attached values for corresponding MED TIMESTAMP
140   virtual
141   VISU::PUnstructuredGridIDMapper 
142   GetTimeStampOnMesh(const std::string& theMeshName, 
143                      const VISU::TEntity& theEntity,
144                      const std::string& theFieldName,
145                      int theTimeStampNumber) = 0;
146
147   //! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP
148   virtual
149   VISU::PGaussPtsIDMapper 
150   GetTimeStampOnGaussPts(const std::string& theMeshName, 
151                          const VISU::TEntity& theEntity,
152                          const std::string& theFieldName,
153                          int theTimeStampNumber) = 0;
154    
155   //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh
156   virtual 
157   size_t
158   GetTimeStampOnMeshSize(const std::string& theMeshName, 
159                          const VISU::TEntity& theEntity,
160                          const std::string& theFieldName,
161                          int theTimeStampNumber,
162                          bool& theIsEstimated) = 0;
163     
164   //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on Gauss Points
165   virtual 
166   size_t
167   GetTimeStampOnGaussPtsSize(const std::string& theMeshName, 
168                              const VISU::TEntity& theEntity,
169                              const std::string& theFieldName,
170                              int theTimeStampNumber,
171                              bool& theIsEstimated) = 0;
172     
173   //! Get amount of memory to build all MED TIMESTAMPS for corresponding MED FIELD
174   virtual 
175   size_t
176   GetFieldOnMeshSize(const std::string& theMeshName, 
177                      const VISU::TEntity& theEntity,
178                      const std::string& theFieldName) = 0;
179   
180   //! Find MED FIELD container
181   virtual
182   const VISU::PField 
183   GetField(const std::string& theMeshName, 
184            VISU::TEntity theEntity, 
185            const std::string& theFieldName) = 0;
186   
187   //! Find MED TIMESTAMP container
188   virtual
189   const VISU::PValForTime 
190   GetTimeStamp(const std::string& theMeshName, 
191                const VISU::TEntity& theEntity,
192                const std::string& theFieldName,
193                int theTimeStampNumber) = 0;
194     
195   //! Allow to generate pretty name for MED TIMESTAMP
196   static 
197   std::string 
198   GenerateName(const VISU::TTime& aTime);
199
200   static 
201   std::string 
202   GenerateName(const std::string& theName, unsigned int theTimeId);
203
204 protected:
205   VISU_Convertor();
206   
207   std::string myName;
208   VISU::TMeshMap myMeshMap;
209   int myIsDone;
210 };
211
212 extern "C"
213 {
214   //! Instatiate proper VISU_Convertor subclass
215   VISU_CONVERTOR_EXPORT
216   VISU_Convertor*
217   CreateConvertor(const std::string& theFileName);
218 };
219
220
221 #endif