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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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
82 std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree
83 std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree
88 typedef std::map<std::string,PMesh> TMeshMap;
91 //---------------------------------------------------------------
92 //! Define a basic class which corresponds to MED PROFILE entity
93 struct TSubProfile: virtual TBaseStructure
97 //---------------------------------------------------------------
98 //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY
99 struct TProfile: virtual TNamedIDMapper
103 //---------------------------------------------------------------
105 operator<(const PSubProfile& theLeft, const PSubProfile& theRight);
107 typedef std::set<PSubProfile> TProfileKey;
108 typedef std::map<TProfileKey,PProfile> TProfileMap;
111 //---------------------------------------------------------------
112 //! Define a basic class for MED GAUSS entity
113 struct TGauss: virtual TBaseStructure
117 //---------------------------------------------------------------
118 //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE
119 struct TGaussSubMesh: virtual TBaseStructure
121 PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located
125 //---------------------------------------------------------------
126 //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY
127 struct TGaussMesh: virtual TGaussPtsIDMapper
131 //---------------------------------------------------------------
133 operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight);
135 typedef std::set<PGaussSubMesh> TGaussKey;
136 typedef std::map<TGaussKey,PGaussMesh> TGaussMeshMap;
139 //---------------------------------------------------------------
141 typedef std::map<TName,PFamily> TFamilyMap;
142 typedef std::map<TName,PField> TFieldMap;
144 //! Define a basic class which corresponds to MED ENTITY
146 This class in its turn contains map of TGaussMesh and TProfile substructures,
147 also it keeps corresponding map of MED FAMILIES and FIELDS.
149 struct TMeshOnEntity: virtual TNamedIDMapper
151 TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it
152 TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it
154 TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it
155 TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it
157 TName myMeshName; //!< Contains name of the MED MESH where the it belongs to.
158 TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to.
162 //---------------------------------------------------------------
163 //! Define a basic class for MED FAMILY entity
164 struct TFamily: virtual TIntId,
167 TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to.
168 TName myName; //!< Contains name of the corresponding MED FAMILY
172 //---------------------------------------------------------------
173 typedef std::set<PFamily> TFamilySet;
175 //! Define a basic class for MED GROUP entity
176 struct TGroup: virtual TIDMapper
178 TFamilySet myFamilySet;
182 //---------------------------------------------------------------
183 typedef std::map<vtkIdType,PValForTime> TValField;
184 typedef std::pair<vtkFloatingPointType,vtkFloatingPointType> TMinMax;
186 //! Define a basic class for MED FIELD entity
187 struct TField: virtual TIntId
189 TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
190 TName myName; //!< Contains name of the corresponding MED FIELD
191 TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
192 TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS
193 TNames myCompNames; //!< Contains names of components of the MED FIELD
194 TNames myUnitNames; //!< Contains names of units of the MED FIELD
195 vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD
197 //! Calculate min/max values for each of the MED FIELD components among all its timestamps
199 Numeration of the components starts from 1.
200 Zero component contains min/max value for modulus of corresponding vector
204 GetMinMax(vtkIdType theCompID) = 0;
206 bool myIsMinMaxInitilized; //!< Is the min / max values are calculated
210 myIsMinMaxInitilized(false)
215 //---------------------------------------------------------------
216 typedef std::pair<double,std::string> TTime;
218 //! Define a basic class for MED TIMESTAMP entity
219 struct TValForTime: virtual TIntId
221 TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
222 TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
223 TName myFieldName; //!< Contains name of the MED FIELD where it belongs to.
226 PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to
227 PGaussMesh myGaussMesh;
231 //---------------------------------------------------------------
232 //! The utility function allows to write vtkUnstructuredGrid to a file with defined name
234 WriteToFile(vtkUnstructuredGrid* theDataSet,
235 const std::string& theFileName);
239 //---------------------------------------------------------------
240 //! This class defines interface to read VTK interpretation of MED entities
242 It is the main class of the VISU CONVERTER package.
243 Following MED entities can be retrived from any MED file:
244 - mesh from corresponding MED ENTITIES;
248 The class produce its work in two main steps:
249 1. Perfrom parsing of MED file to get known what MED entities are pressent in it
250 2. Get VTK representation for any existing MED entity
251 Also, it can perform some additional work to calculate expected amount of memory to build defined VTK representation
258 VISU::TMeshMap myMeshMap;
266 //! Get brief name of the corresponding source MED file
269 GetName(){ return myName;}
271 //! Let known whether the source MED file parsed or not
274 IsDone() const { return myIsDone; }
276 //! Defines what subtype of vtkDataSet is used for MED to VTK mapping
277 typedef VISU::TVTKOutput TOutput;
279 //! This method perform first parsing of MED file to get known what MED entities are pressent in it
284 //! This method perform first parsing of MED file to get known what MED mesh entities are pressent in it
289 //! This method perform first parsing of MED file to get known what MED fields are pressent in it
294 //! This min /max calculation over existing MED fields
299 //! This method perform first parsing of MED file to get known what MED groups are pressent in it
304 //! This method allow to get known what MED entities are present is the MED file
306 const VISU::TMeshMap&
309 //! Get amount of memory to build VTK representations for all existing MED entities
314 //! Get mesh for corresponding MED ENTITY
317 GetMeshOnEntity(const std::string& theMeshName,
318 const VISU::TEntity& theEntity) = 0;
320 //! Get amount of memory to build mesh for corresponding MED ENTITY
323 GetMeshOnEntitySize(const std::string& theMeshName,
324 const VISU::TEntity& theEntity) = 0;
326 //! Get mesh for corresponding MED FAMILY
329 GetFamilyOnEntity(const std::string& theMeshName,
330 const VISU::TEntity& theEntity,
331 const std::string& theFamilyName) = 0;
333 //! Get amount of memory to build mesh for corresponding MED FAMILY
336 GetFamilyOnEntitySize(const std::string& theMeshName,
337 const VISU::TEntity& theEntity,
338 const std::string& theFamilyName) = 0;
340 //! Get mesh for corresponding MED GROUP
343 GetMeshOnGroup(const std::string& theMeshName,
344 const std::string& theGroupName) = 0;
346 //! Get amount of memory to build mesh for corresponding MED GROUP
349 GetMeshOnGroupSize(const std::string& theMeshName,
350 const std::string& theGroupName) = 0;
352 //! Get mesh with attached values for corresponding MED TIMESTAMP
355 GetTimeStampOnMesh(const std::string& theMeshName,
356 const VISU::TEntity& theEntity,
357 const std::string& theFieldName,
358 int theStampsNum) = 0;
360 //! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP
362 VISU::PGaussPtsIDMapper
363 GetTimeStampOnGaussPts(const std::string& theMeshName,
364 const VISU::TEntity& theEntity,
365 const std::string& theFieldName,
366 int theStampsNum) = 0;
368 //! Get amount of memory to build mesh for corresponding MED TIMESTAMP
371 GetTimeStampSize(const std::string& theMeshName,
372 const VISU::TEntity& theEntity,
373 const std::string& theFieldName,
374 int theStampsNum) = 0;
376 //! Get amount of memory to build all MED TIMESTAMPS for corresponding MED FIELD
379 GetFieldOnMeshSize(const std::string& theMeshName,
380 const VISU::TEntity& theEntity,
381 const std::string& theFieldName) = 0;
383 //! Find MED FIELD container
386 GetField(const std::string& theMeshName,
387 VISU::TEntity theEntity,
388 const std::string& theFieldName) = 0;
390 //! Find MED TIMESTAMP container
392 const VISU::PValForTime
393 GetTimeStamp(const std::string& theMeshName,
394 const VISU::TEntity& theEntity,
395 const std::string& theFieldName,
396 int theStampsNum) = 0;
398 //! Allow to generate pretty name for MED TIMESTAMP
401 GenerateName(const VISU::TTime& aTime);
405 GenerateName(const std::string& theName, unsigned int theTimeId);
410 //! Instatiate proper VISU_Convertor subclass
412 CreateConvertor(const std::string& theFileName);