1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // File : VISU_MedConvertor.hxx
23 // Author : Alexey PETROV
26 #ifndef VISU_MedConvertor_HeaderFile
27 #define VISU_MedConvertor_HeaderFile
29 #include "VISUConvertor.hxx"
30 #include "VISU_Convertor_impl.hxx"
31 #include "VISU_Structures_impl.hxx"
32 #include "VISU_PointCoords.hxx"
33 #include "VISU_MeshValue.hxx"
35 #include "MED_Wrapper.hxx"
36 #include "MED_Common.hxx"
37 #include "MED_Structures.hxx"
38 #include "MED_GaussUtils.hxx"
40 #include <boost/thread/mutex.hpp>
44 //---------------------------------------------------------------
45 struct VISU_CONVERTOR_EXPORT TMEDCoordHolder: TCoordHolder<MED::PNodeCoord>
51 return &(*myCoord)[0];
58 return &(*myCoord)[0];
63 //---------------------------------------------------------------
64 struct VISU_CONVERTOR_EXPORT TMEDGaussCoordHolder: TCoordHolderBase
66 MED::PGaussCoord myGaussCoord;
68 //! To initilize the instance
70 Init(const MED::PGaussCoord& theGaussCoord)
72 MED::TInt aNbGauss = theGaussCoord->GetNbGauss();
73 MED::TInt aNbElem = theGaussCoord->GetNbElem();
74 MED::TInt aDim = theGaussCoord->GetDim();
75 MED::TInt aNbCells = aNbElem * aNbGauss;
76 TCoordHolderBase::Init(aNbCells, aDim);
77 myGaussCoord = theGaussCoord;
80 //! Get slice of coordinates for defined node (const version)
83 GetCoordSlice(vtkIdType theNodeId) const
85 MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
86 MED::TCCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
87 MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
88 return aCoordSliceArr[aGaussId];
91 //! Get slice of coordinates for defined node
94 GetCoordSlice(vtkIdType theNodeId)
96 MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
97 MED::TCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
98 MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
99 return aCoordSliceArr[aGaussId];
106 return myGaussCoord->GetValuePtr();
111 //---------------------------------------------------------------
112 template<class TValueType>
113 struct VISU_CONVERTOR_EXPORT TTMEDMeshValue: TTMeshValueHolder<TValueType,
114 MED::SharedPtr<MED::TTMeshValue<MED::TVector<TValueType> > > >
120 return this->myContainer->GetPointer();
127 return this->myContainer->GetPointer();
132 //---------------------------------------------------------------
133 typedef std::map<vtkIdType, vtkIdType> TObj2VTKID;
135 class TMEDNamedPointCoords: public virtual TNamedPointCoords
137 MED::EBooleen myIsElemNum; //!< Keeps whether the numeration exists or not
138 MED::PElemNum myElemNum; //!< Keeps objects numeration
139 mutable TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
141 MED::EVersion myVersion;
142 MED::PString myElemNames; //!< Keeps whether the names exists or not
143 MED::EBooleen myIsElemNames; //!< Keeps objects names
146 TMEDNamedPointCoords():
147 myIsElemNum(MED::eFAUX),
148 myIsElemNames(MED::eFAUX)
152 Init(const MED::PNodeInfo& theNodeInfo,
153 MED::EVersion theVersion);
156 Init(const MED::PGrilleInfo& theGrilleInfo);
158 //! Get object number for node by its VTK one
161 GetObjID(vtkIdType theID) const;
163 //! Get VTK number for node by its object one
166 GetVTKID(vtkIdType theID) const;
168 //! Get name of node by its object number
171 GetNodeName(vtkIdType theObjID) const;
173 //! Gets memory size used by the instance (bytes).
178 typedef MED::SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
181 //---------------------------------------------------------------
182 struct VISU_CONVERTOR_EXPORT TMEDMesh: virtual TMeshImpl
184 MED::PMeshInfo myMeshInfo;
185 MED::TEntityInfo myEntityInfo;
187 typedef MED::SharedPtr<TMEDMesh> PMEDMesh;
190 //---------------------------------------------------------------
191 struct VISU_CONVERTOR_EXPORT TMEDSubProfile: virtual TSubProfileImpl
193 MED::EGeometrieElement myMGeom;
196 myIsElemNum(MED::eFAUX)
199 MED::EBooleen myIsElemNum;
200 MED::PElemNum myElemNum;
204 GetElemObjID(vtkIdType theID) const;
206 //! Reimplement the TSubProfileImpl::GetElemVTKID
209 GetElemVTKID(vtkIdType theID) const;
211 //! Gets memory size used by the instance (bytes).
216 typedef MED::SharedPtr<TMEDSubProfile> PMEDSubProfile;
219 //---------------------------------------------------------------
220 struct VISU_CONVERTOR_EXPORT TMEDProfile: virtual TProfileImpl
222 typedef MED::SharedPtr<TMEDProfile> PMEDProfile;
225 //---------------------------------------------------------------
226 struct VISU_CONVERTOR_EXPORT TMEDGauss: virtual TGaussImpl
228 MED::PGaussInfo myGaussInfo;
230 //! To define a way to implement more detail comparision of the TGaussSubMesh instances
233 LessThan(const PGaussImpl& theGauss,
234 bool& theResult) const;
236 typedef MED::SharedPtr<TMEDGauss> PMEDGauss;
239 //---------------------------------------------------------------
240 struct VISU_CONVERTOR_EXPORT TMEDGaussSubMesh: virtual TGaussSubMeshImpl
243 myIsElemNum(MED::eFAUX)
246 MED::EBooleen myIsElemNum;
247 MED::PElemNum myElemNum;
251 GetObjID(vtkIdType theID) const;
255 GetVTKID( const TGaussPointID& theID ) const;
257 //! Gets memory size used by the instance (bytes).
262 typedef MED::SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
265 //---------------------------------------------------------------
266 struct VISU_CONVERTOR_EXPORT TMEDGaussMesh: virtual TGaussMeshImpl
268 typedef MED::SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
271 //---------------------------------------------------------------
272 struct VISU_CONVERTOR_EXPORT TMEDSubMesh: virtual TSubMeshImpl
275 myIsElemNum(MED::eFAUX),
276 myIsElemNames(MED::eFAUX)
279 MED::EBooleen myIsElemNum;
280 MED::PElemNum myElemNum;
282 MED::EVersion myVersion;
283 MED::PString myElemNames;
284 MED::EBooleen myIsElemNames;
287 Init(const MED::PElemInfo& theElemInfo,
288 MED::EVersion theVersion);
291 Init(const MED::PGrilleInfo& theGrilleInfo);
295 GetElemObjID(vtkIdType theID) const;
299 GetElemName(vtkIdType theObjID) const;
301 //! Gets memory size used by the instance (bytes).
306 typedef MED::SharedPtr<TMEDSubMesh> PMEDSubMesh;
309 //---------------------------------------------------------------
310 typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
312 typedef std::map<vtkIdType,vtkIdType> TElemID2FamilyID;
313 typedef std::map<MED::EGeometrieElement,TElemID2FamilyID> TGeom2ElemID2FamilyID;
315 struct VISU_CONVERTOR_EXPORT TMEDMeshOnEntity: virtual TMeshOnEntityImpl
317 TFamilyID2CellsSize myFamilyID2CellsSize;
318 TGeom2ElemID2FamilyID myGeom2ElemID2FamilyID;
319 MED::TGeom2Size myGeom2Size;
321 typedef MED::SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
324 //---------------------------------------------------------------
325 struct VISU_CONVERTOR_EXPORT TMEDFamily: virtual TFamilyImpl
327 typedef MED::SharedPtr<TMEDFamily> PMEDFamily;
330 //---------------------------------------------------------------
331 struct VISU_CONVERTOR_EXPORT TMEDGroup: virtual TGroupImpl
333 typedef MED::SharedPtr<TMEDGroup> PMEDGroup;
336 //---------------------------------------------------------------
337 struct VISU_CONVERTOR_EXPORT TMEDField: virtual TFieldImpl
339 typedef MED::SharedPtr<TMEDField> PMEDField;
342 //---------------------------------------------------------------
343 struct VISU_CONVERTOR_EXPORT TMEDValForTime: virtual TValForTimeImpl
345 typedef MED::SharedPtr<TMEDValForTime> PMEDValForTime;
349 class VISU_MedConvertor: public VISU_Convertor_impl
352 VISU_MedConvertor(const VISU_MedConvertor&);
354 bool myIsEntitiesDone;
360 VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed);
379 MED::PWrapper myMed; // mpv : bug 13568: one med per converter
383 LoadMeshOnEntity(VISU::PMeshImpl theMesh,
384 VISU::PMeshOnEntityImpl theMeshOnEntity);
388 LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
389 VISU::PMeshOnEntityImpl theMeshOnEntity,
390 VISU::PFamilyImpl theFamily);
394 LoadMeshOnGroup(VISU::PMeshImpl theMesh,
395 const VISU::TFamilySet& theFamilySet);
399 LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
400 VISU::PMeshOnEntityImpl theMeshOnEntity,
401 VISU::PFieldImpl theField,
402 VISU::PValForTimeImpl theValForTime);
406 LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
407 VISU::PMeshOnEntityImpl theMeshOnEntity,
408 VISU::PFieldImpl theField,
409 VISU::PValForTimeImpl theValForTime);
412 LoadPoints(const MED::PWrapper& theMed,
413 const VISU::PMEDMesh theMesh);
416 LoadPointsOnFamily(const MED::PWrapper& theMed,
417 const VISU::PMEDMesh theMesh,
418 const VISU::PMEDFamily theFamily);
421 LoadCellsOnEntity(const MED::PWrapper& theMed,
422 const VISU::PMEDMesh theMesh,
423 const VISU::PMEDMeshOnEntity theMeshOnEntity);
426 LoadCellsOnFamily(const MED::PWrapper& theMed,
427 const VISU::PMEDMesh theMesh,
428 const VISU::PMEDMeshOnEntity theMeshOnEntity,
429 const VISU::PMEDFamily theFamily);
432 LoadValForTimeOnMesh(const MED::PWrapper& theMed,
433 VISU::PMEDMesh theMesh,
434 VISU::PMEDMeshOnEntity theMeshOnEntity,
435 VISU::PMEDField theField,
436 VISU::PMEDValForTime theValForTime);
439 LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
440 VISU::PMEDMesh theMesh,
441 VISU::PMEDMeshOnEntity theMeshOnEntity,
442 VISU::PMEDField theField,
443 VISU::PMEDValForTime theValForTime);