Salome HOME
70f620fb19280a1e9e5931a99d3bae631201de04
[modules/visu.git] / src / CONVERTOR / VISU_Structures.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 //  File   : 
23 //  Author : Alexey PETROV
24 //  Module : VISU
25 //
26 #ifndef VISU_Structures_HeaderFile
27 #define VISU_Structures_HeaderFile
28
29 /*! 
30   \file VISU_Structures.hxx
31   \brief The file contains definitions for basic classes of the VISU CONVERTER package
32 */
33
34 #include "VISUConvertor.hxx"
35 #include "VISU_IDMapper.hxx"
36 #include "VISU_ConvertorDef.hxx"
37
38 #include "MED_Vector.hxx"
39
40 #include <map>
41 #include <set>
42 #include <string>
43 #include <stdexcept>
44
45 namespace VISU
46 {
47   using MED::TVector;
48
49   //---------------------------------------------------------------
50   typedef std::string TName;
51   typedef TVector<TName> TNames;
52
53   //---------------------------------------------------------------
54   //! Define a basic class for all MED entites which can be identified by its number
55   struct VISU_CONVERTOR_EXPORT TIntId: virtual TBaseStructure
56   {
57     vtkIdType myId;
58
59     TIntId();
60   };
61
62
63   //---------------------------------------------------------------
64   //! Define an utility base class which is repsonsible for preventing repetion
65   struct VISU_CONVERTOR_EXPORT TIsVTKDone: virtual TBaseStructure
66   {
67     mutable bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure 
68     mutable bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation  
69
70     TIsVTKDone();
71   };
72
73   
74   //---------------------------------------------------------------
75   typedef std::map<TEntity, PMeshOnEntity> TMeshOnEntityMap;
76   typedef std::map<TName, PGroup> TGroupMap;
77
78   //! Define a basic class which corresponds to MED MESH entity
79   /*!
80     This class in its turn contains map of TMeshOnEntity and TGroup substructures,
81     also it keeps name and dimention of corresponding MED MESH entity.
82   */
83   struct VISU_CONVERTOR_EXPORT TMesh: virtual TBaseStructure
84   {
85     TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES
86     TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS
87     TName myName; //! Name of the corresponding MED MESH
88     vtkIdType myDim; //! Dimension of the corresponding MED MESH
89
90     std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree
91     std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree
92     std::string myPartsEntry; //!< To simplify publication of the parts in a data tree
93
94     TMesh();
95   };
96   typedef std::map<std::string, PMesh> TMeshMap;
97
98
99   //---------------------------------------------------------------
100   //! Define a basic class which corresponds to MED PROFILE entity
101   struct VISU_CONVERTOR_EXPORT TSubProfile: virtual TBaseStructure
102   {
103     //! Get object number of mesh cell by its VTK one
104     virtual 
105     vtkIdType 
106     GetElemObjID(vtkIdType theID) const = 0;
107
108     //! Get cell VTK ID for corresponding object ID
109     virtual 
110     vtkIdType 
111     GetElemVTKID(vtkIdType theID) const = 0;
112   };
113
114
115   //---------------------------------------------------------------
116   //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY
117   struct VISU_CONVERTOR_EXPORT TProfile: virtual TNamedIDMapper
118   {};
119
120
121   //---------------------------------------------------------------
122   bool VISU_CONVERTOR_EXPORT
123   operator<(const PSubProfile& theLeft, const PSubProfile& theRight);
124
125   typedef std::set<PSubProfile> TProfileKey;
126   typedef std::map<TProfileKey, PProfile> TProfileMap;
127
128
129   //---------------------------------------------------------------
130   //! Define a basic class for MED GAUSS entity
131   struct VISU_CONVERTOR_EXPORT TGauss: virtual TBaseStructure
132   {};
133
134
135   //---------------------------------------------------------------
136   //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE
137   struct VISU_CONVERTOR_EXPORT TGaussSubMesh: virtual TBaseStructure
138   {
139     PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located
140   };
141
142   
143   //---------------------------------------------------------------
144   //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY
145   struct VISU_CONVERTOR_EXPORT TGaussMesh: virtual TGaussPtsIDMapper
146   {};
147
148
149   //---------------------------------------------------------------
150   bool VISU_CONVERTOR_EXPORT
151   operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight);
152
153   typedef std::set<PGaussSubMesh> TGaussKey;
154   typedef std::map<TGaussKey, PGaussMesh> TGaussMeshMap;
155
156
157   //---------------------------------------------------------------
158
159   typedef std::map<TName, PFamily> TFamilyMap;
160   typedef std::map<TName, PField> TFieldMap;
161
162   typedef std::map<vtkIdType, PFamily> TFamilyIDMap;
163
164   //! Define a basic class which corresponds to MED ENTITY
165   /*!
166     This class in its turn contains map of TGaussMesh and TProfile substructures,
167     also it keeps corresponding map of MED FAMILIES and FIELDS.
168   */
169   struct VISU_CONVERTOR_EXPORT TMeshOnEntity: virtual TNamedIDMapper
170   {
171     TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it
172     TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it
173
174     TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it
175     TFamilyIDMap myFamilyIDMap; //!< Contains map of MED FAMILIES which belongs to it
176
177     TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it
178
179     TName myMeshName; //!< Contains name of the MED MESH where the it belongs to.
180     TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to.
181
182     TMeshOnEntity();
183   };
184
185
186   //---------------------------------------------------------------
187   //! Define a basic class for MED FAMILY entity
188   struct VISU_CONVERTOR_EXPORT TFamily: virtual TIntId,
189                   virtual TUnstructuredGridIDMapper
190   {
191     TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to.
192     TName myName; //!< Contains name of the corresponding MED FAMILY
193
194     TFamily();
195   };
196
197
198   //---------------------------------------------------------------
199   bool VISU_CONVERTOR_EXPORT
200   operator<(const PFamily& theLeft, const PFamily& theRight);
201
202   typedef std::set<PFamily> TFamilySet;
203
204   //! Define a basic class for MED GROUP entity
205   struct VISU_CONVERTOR_EXPORT TGroup: virtual TUnstructuredGridIDMapper
206   {
207     TFamilySet myFamilySet;
208   };
209
210
211   //---------------------------------------------------------------
212   typedef std::map<vtkIdType, PValForTime> TValField;
213   typedef std::pair<vtkFloatingPointType, vtkFloatingPointType> TMinMax;
214
215   //! Define a basic class for MED FIELD entity
216   struct VISU_CONVERTOR_EXPORT TField: virtual TIntId
217   {
218     TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
219     TName myName; //!< Contains name of the corresponding MED FIELD
220     TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
221     TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS
222     TNames myCompNames; //!< Contains names of components of the MED FIELD
223     TNames myUnitNames; //!< Contains names of units of the MED FIELD
224     vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD
225     bool myIsELNO;      //!< Defines whether this field contains specific "ELNO" data or not
226
227     //! Calculate min/max values for each of the MED FIELD components among all its timestamps
228     /*!
229       Numeration of the components starts from 1.
230       Zero component contains min/max value for modulus of corresponding vector
231     */
232     virtual
233     TMinMax 
234     GetMinMax(vtkIdType theCompID,
235               const TNames& theGroupNames,
236               TGaussMetric theGaussMetric = VISU::AVERAGE_METRIC) = 0;
237     
238     //! Calculate average min/max values for each of the MED FIELD components among all its timestamps
239     virtual
240     TMinMax 
241     GetAverageMinMax(vtkIdType theCompID,
242                      const TNames& theGroupNames,
243                      TGaussMetric theGaussMetric = VISU::AVERAGE_METRIC) = 0;
244
245     bool myIsMinMaxInitilized; //!< Is the min / max values are calculated
246
247     TField();
248   };
249
250   // MULTIPR
251   struct VISU_CONVERTOR_EXPORT TPart: virtual TIntId
252   {
253     vtkIdType myCurrentRes; //!< Keeps current resolution fot this part
254
255     TPart();
256   };
257
258
259   //---------------------------------------------------------------
260   typedef std::pair<double, std::string> TTime;
261
262   //! Define a basic class for MED TIMESTAMP entity
263   struct VISU_CONVERTOR_EXPORT TValForTime: virtual TIntId
264   {
265     TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
266     TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
267     TName myFieldName; //!< Contains name of the MED FIELD where it belongs to.
268     TTime myTime;
269
270     PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to
271     PGaussMesh myGaussMesh;
272
273     //! Get maximum number of Gauss Points among all geometrical types (provided for convenience)
274     virtual
275     int
276     GetMaxNbGauss() const = 0;
277   };
278  
279
280   //---------------------------------------------------------------
281 }
282
283
284 #endif