3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_Convertor.hxx
24 // Author : Alexey PETROV
27 #ifndef VISU_Convertor_HeaderFile
28 #define VISU_Convertor_HeaderFile
31 \file VISU_Convertor.hxx
32 \brief The file contains definitions for basic classes of the VISU CONVERTER package
35 #include "VISU_IDMapper.hxx"
36 #include "VISU_ConvertorDef.hxx"
38 #include "MED_Vector.hxx"
50 //---------------------------------------------------------------
51 typedef std::string TName;
53 typedef TVector<TName> TNames;
55 //---------------------------------------------------------------
56 //! Define a basic class for all MED entites which can be identified by its number
57 struct TIntId: virtual TBaseStructure
66 //---------------------------------------------------------------
67 typedef std::map<TEntity,PMeshOnEntity> TMeshOnEntityMap;
68 typedef std::map<TName,PGroup> TGroupMap;
70 //! Define a basic class which corresponds to MED MESH entity
72 This class in its turn contains map of TMeshOnEntity and TGroup substructures,
73 also it keeps name and dimention of corresponding MED MESH entity.
75 struct TMesh: virtual TBaseStructure
77 TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES
78 TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS
79 TName myName; //! Name of the corresponding MED MESH
80 int myDim; //! Dimension of the corresponding MED MESH
85 typedef std::map<std::string,PMesh> TMeshMap;
88 //---------------------------------------------------------------
89 //! Define a basic class which corresponds to MED PROFILE entity
90 struct TSubProfile: virtual TBaseStructure
94 //---------------------------------------------------------------
95 //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY
96 struct TProfile: virtual TNamedIDMapper
100 //---------------------------------------------------------------
102 operator<(const PSubProfile& theLeft, const PSubProfile& theRight);
104 typedef std::set<PSubProfile> TProfileKey;
105 typedef std::map<TProfileKey,PProfile> TProfileMap;
108 //---------------------------------------------------------------
109 //! Define a basic class for MED GAUSS entity
110 struct TGauss: virtual TBaseStructure
114 //---------------------------------------------------------------
115 //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE
116 struct TGaussSubMesh: virtual TBaseStructure
118 PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located
122 //---------------------------------------------------------------
123 //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY
124 struct TGaussMesh: virtual TGaussPtsIDMapper
128 //---------------------------------------------------------------
130 operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight);
132 typedef std::set<PGaussSubMesh> TGaussKey;
133 typedef std::map<TGaussKey,PGaussMesh> TGaussMeshMap;
136 //---------------------------------------------------------------
138 typedef std::map<TName,PFamily> TFamilyMap;
139 typedef std::map<TName,PField> TFieldMap;
141 //! Define a basic class which corresponds to MED ENTITY
143 This class in its turn contains map of TGaussMesh and TProfile substructures,
144 also it keeps corresponding map of MED FAMILIES and FIELDS.
146 struct TMeshOnEntity: virtual TNamedIDMapper
148 TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it
149 TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it
151 TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it
152 TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it
154 TName myMeshName; //!< Contains name of the MED MESH where the it belongs to.
155 TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to.
159 //---------------------------------------------------------------
160 //! Define a basic class for MED FAMILY entity
161 struct TFamily: virtual TIntId,
164 TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to.
165 TName myName; //!< Contains name of the corresponding MED FAMILY
169 //---------------------------------------------------------------
170 typedef std::set<PFamily> TFamilySet;
172 //! Define a basic class for MED GROUP entity
173 struct TGroup: virtual TIDMapper
175 TFamilySet myFamilySet;
179 //---------------------------------------------------------------
180 typedef std::map<vtkIdType,PValForTime> TValField;
181 typedef std::pair<float,float> TMinMax;
183 //! Define a basic class for MED FIELD entity
184 struct TField: virtual TIntId
186 TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
187 TName myName; //!< Contains name of the corresponding MED FIELD
188 TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
189 TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS
190 TNames myCompNames; //!< Contains names of components of the MED FIELD
191 TNames myUnitNames; //!< Contains names of units of the MED FIELD
192 vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD
194 //! Calculate min/max values for each of the MED FIELD components among all its timestamps
196 Numeration of the components starts from 1.
197 Zero component contains min/max value for modulus of corresponding vector
201 GetMinMax(vtkIdType theCompID) = 0;
203 bool myIsMinMaxInitilized; //!< Is the min / max values are calculated
207 myIsMinMaxInitilized(false)
212 //---------------------------------------------------------------
213 typedef std::pair<double,std::string> TTime;
215 //! Define a basic class for MED TIMESTAMP entity
216 struct TValForTime: virtual TIntId
218 TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
219 TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
220 TName myFieldName; //!< Contains name of the MED FIELD where it belongs to.
223 PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to
224 PGaussMesh myGaussMesh;
228 //---------------------------------------------------------------
229 //! The utility function allows to write vtkUnstructuredGrid to a file with defined name
231 WriteToFile(vtkUnstructuredGrid* theDataSet,
232 const std::string& theFileName);
236 //---------------------------------------------------------------
237 //! This class defines interface to read VTK interpretation of MED entities
239 It is the main class of the VISU CONVERTER package.
240 Following MED entities can be retrived from any MED file:
241 - mesh from corresponding MED ENTITIES;
245 The class produce its work in two main steps:
246 1. Perfrom parsing of MED file to get known what MED entities are pressent in it
247 2. Get VTK representation for any existing MED entity
248 Also, it can perform some additional work to calculate expected amount of memory to build defined VTK representation
255 VISU::TMeshMap myMeshMap;
263 //! Get brief name of the corresponding source MED file
266 GetName(){ return myName;}
268 //! Let known whether the source MED file parsed or not
271 IsDone() const { return myIsDone; }
273 //! Defines what subtype of vtkDataSet is used for MED to VTK mapping
274 typedef VISU::TVTKOutput TOutput;
276 //! This method perform first parsing of MED file to get known what MED entities are pressent in it
281 //! This method perform first parsing of MED file to get known what MED mesh entities are pressent in it
286 //! This method perform first parsing of MED file to get known what MED fields are pressent in it
291 //! This min /max calculation over existing MED fields
296 //! This method perform first parsing of MED file to get known what MED groups are pressent in it
301 //! This method allow to get known what MED entities are present is the MED file
303 const VISU::TMeshMap&
306 //! Get amount of memory to build VTK representations for all existing MED entities
311 //! Get mesh for corresponding MED ENTITY
314 GetMeshOnEntity(const std::string& theMeshName,
315 const VISU::TEntity& theEntity) = 0;
317 //! Get amount of memory to build mesh for corresponding MED ENTITY
320 GetMeshOnEntitySize(const std::string& theMeshName,
321 const VISU::TEntity& theEntity) = 0;
323 //! Get mesh for corresponding MED FAMILY
326 GetFamilyOnEntity(const std::string& theMeshName,
327 const VISU::TEntity& theEntity,
328 const std::string& theFamilyName) = 0;
330 //! Get amount of memory to build mesh for corresponding MED FAMILY
333 GetFamilyOnEntitySize(const std::string& theMeshName,
334 const VISU::TEntity& theEntity,
335 const std::string& theFamilyName) = 0;
337 //! Get mesh for corresponding MED GROUP
340 GetMeshOnGroup(const std::string& theMeshName,
341 const std::string& theGroupName) = 0;
343 //! Get amount of memory to build mesh for corresponding MED GROUP
346 GetMeshOnGroupSize(const std::string& theMeshName,
347 const std::string& theGroupName) = 0;
349 //! Get mesh with attached values for corresponding MED TIMESTAMP
352 GetTimeStampOnMesh(const std::string& theMeshName,
353 const VISU::TEntity& theEntity,
354 const std::string& theFieldName,
355 int theStampsNum) = 0;
357 //! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP
359 VISU::PGaussPtsIDMapper
360 GetTimeStampOnGaussPts(const std::string& theMeshName,
361 const VISU::TEntity& theEntity,
362 const std::string& theFieldName,
363 int theStampsNum) = 0;
365 //! Get amount of memory to build mesh for corresponding MED TIMESTAMP
368 GetTimeStampSize(const std::string& theMeshName,
369 const VISU::TEntity& theEntity,
370 const std::string& theFieldName,
371 int theStampsNum) = 0;
373 //! Get amount of memory to build all MED TIMESTAMPS for corresponding MED FIELD
376 GetFieldOnMeshSize(const std::string& theMeshName,
377 const VISU::TEntity& theEntity,
378 const std::string& theFieldName) = 0;
380 //! Find MED FIELD container
383 GetField(const std::string& theMeshName,
384 VISU::TEntity theEntity,
385 const std::string& theFieldName) = 0;
387 //! Find MED TIMESTAMP container
389 const VISU::PValForTime
390 GetTimeStamp(const std::string& theMeshName,
391 const VISU::TEntity& theEntity,
392 const std::string& theFieldName,
393 int theStampsNum) = 0;
395 //! Allow to generate pretty name for MED TIMESTAMP
398 GenerateName(const VISU::TTime& aTime);
402 GenerateName(const std::string& theName, unsigned int theTimeId);
407 //! Instatiate proper VISU_Convertor subclass
409 CreateConvertor(const std::string& theFileName);