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