1 // Copyright (C) 2007-2012 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
23 // File : VISU_MedConvertor.hxx
24 // Author : Alexey PETROV
27 #ifndef VISU_MedConvertor_HeaderFile
28 #define VISU_MedConvertor_HeaderFile
30 #include "VISUConvertor.hxx"
31 #include "VISU_Convertor_impl.hxx"
32 #include "VISU_Structures_impl.hxx"
33 #include "VISU_PointCoords.hxx"
34 #include "VISU_MeshValue.hxx"
36 #include "MED_Wrapper.hxx"
37 #include "MED_Common.hxx"
38 #include "MED_Structures.hxx"
39 #include "MED_GaussUtils.hxx"
41 #include <boost/thread/mutex.hpp>
45 //---------------------------------------------------------------
46 struct VISU_CONVERTOR_EXPORT TMEDCoordHolder: TCoordHolder<MED::PNodeCoord>
52 return &(*myCoord)[0];
59 return &(*myCoord)[0];
64 //---------------------------------------------------------------
65 struct VISU_CONVERTOR_EXPORT TMEDGaussCoordHolder: TCoordHolderBase
67 MED::PGaussCoord myGaussCoord;
69 //! To initilize the instance
71 Init(const MED::PGaussCoord& theGaussCoord)
73 MED::TInt aNbGauss = theGaussCoord->GetNbGauss();
74 MED::TInt aNbElem = theGaussCoord->GetNbElem();
75 MED::TInt aDim = theGaussCoord->GetDim();
76 MED::TInt aNbCells = aNbElem * aNbGauss;
77 TCoordHolderBase::Init(aNbCells, aDim);
78 myGaussCoord = theGaussCoord;
81 //! Get slice of coordinates for defined node (const version)
84 GetCoordSlice(vtkIdType theNodeId) const
86 MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
87 MED::TCCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
88 MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
89 return aCoordSliceArr[aGaussId];
92 //! Get slice of coordinates for defined node
95 GetCoordSlice(vtkIdType theNodeId)
97 MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
98 MED::TCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
99 MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
100 return aCoordSliceArr[aGaussId];
107 return myGaussCoord->GetValuePtr();
112 //---------------------------------------------------------------
113 template<class TValueType>
114 struct VISU_CONVERTOR_EXPORT TTMEDMeshValue: TTMeshValueHolder<TValueType,
115 MED::SharedPtr<MED::TTMeshValue<MED::TVector<TValueType> > > >
121 return this->myContainer->GetPointer();
128 return this->myContainer->GetPointer();
133 //---------------------------------------------------------------
134 typedef std::map<vtkIdType, vtkIdType> TObj2VTKID;
136 class TMEDNamedPointCoords: public virtual TNamedPointCoords
138 MED::EBooleen myIsElemNum; //!< Keeps whether the numeration exists or not
139 MED::PElemNum myElemNum; //!< Keeps objects numeration
140 mutable TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
142 MED::EVersion myVersion;
143 MED::PString myElemNames; //!< Keeps whether the names exists or not
144 MED::EBooleen myIsElemNames; //!< Keeps objects names
147 TMEDNamedPointCoords():
148 myIsElemNum(MED::eFAUX),
149 myIsElemNames(MED::eFAUX)
153 Init(const MED::PNodeInfo& theNodeInfo,
154 MED::EVersion theVersion);
157 Init(const MED::PGrilleInfo& theGrilleInfo);
159 //! Get object number for node by its VTK one
162 GetObjID(vtkIdType theID) const;
164 //! Get VTK number for node by its object one
167 GetVTKID(vtkIdType theID) const;
169 //! Get name of node by its object number
172 GetNodeName(vtkIdType theObjID) const;
174 //! Gets memory size used by the instance (bytes).
179 typedef MED::SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
182 //---------------------------------------------------------------
183 struct VISU_CONVERTOR_EXPORT TMEDMesh: virtual TMeshImpl
185 MED::PMeshInfo myMeshInfo;
186 MED::TEntityInfo myEntityInfo;
188 typedef MED::SharedPtr<TMEDMesh> PMEDMesh;
191 //---------------------------------------------------------------
192 struct VISU_CONVERTOR_EXPORT TMEDSubProfile: virtual TSubProfileImpl
194 MED::EGeometrieElement myMGeom;
197 myIsElemNum(MED::eFAUX)
200 MED::EBooleen myIsElemNum;
201 MED::PElemNum myElemNum;
205 GetElemObjID(vtkIdType theID) const;
207 //! Reimplement the TSubProfileImpl::GetElemVTKID
210 GetElemVTKID(vtkIdType theID) const;
212 //! Gets memory size used by the instance (bytes).
217 typedef MED::SharedPtr<TMEDSubProfile> PMEDSubProfile;
220 //---------------------------------------------------------------
221 struct VISU_CONVERTOR_EXPORT TMEDProfile: virtual TProfileImpl
223 typedef MED::SharedPtr<TMEDProfile> PMEDProfile;
226 //---------------------------------------------------------------
227 struct VISU_CONVERTOR_EXPORT TMEDGauss: virtual TGaussImpl
229 MED::PGaussInfo myGaussInfo;
231 //! To define a way to implement more detail comparision of the TGaussSubMesh instances
234 LessThan(const PGaussImpl& theGauss,
235 bool& theResult) const;
237 typedef MED::SharedPtr<TMEDGauss> PMEDGauss;
240 //---------------------------------------------------------------
241 struct VISU_CONVERTOR_EXPORT TMEDGaussSubMesh: virtual TGaussSubMeshImpl
244 myIsElemNum(MED::eFAUX)
247 MED::EBooleen myIsElemNum;
248 MED::PElemNum myElemNum;
252 GetObjID(vtkIdType theID) const;
256 GetVTKID( const TGaussPointID& theID ) const;
258 //! Gets memory size used by the instance (bytes).
263 typedef MED::SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
266 //---------------------------------------------------------------
267 struct VISU_CONVERTOR_EXPORT TMEDGaussMesh: virtual TGaussMeshImpl
269 typedef MED::SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
272 //---------------------------------------------------------------
273 struct VISU_CONVERTOR_EXPORT TMEDSubMesh: virtual TSubMeshImpl
276 myIsElemNum(MED::eFAUX),
277 myIsElemNames(MED::eFAUX)
280 MED::EBooleen myIsElemNum;
281 MED::PElemNum myElemNum;
283 MED::EVersion myVersion;
284 MED::PString myElemNames;
285 MED::EBooleen myIsElemNames;
288 Init(const MED::PElemInfo& theElemInfo,
289 MED::EVersion theVersion);
292 Init(const MED::PGrilleInfo& theGrilleInfo);
296 GetElemObjID(vtkIdType theID) const;
300 GetElemName(vtkIdType theObjID) const;
302 //! Gets memory size used by the instance (bytes).
307 typedef MED::SharedPtr<TMEDSubMesh> PMEDSubMesh;
310 //---------------------------------------------------------------
311 typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
313 typedef std::map<vtkIdType,vtkIdType> TElemID2FamilyID;
314 typedef std::map<MED::EGeometrieElement,TElemID2FamilyID> TGeom2ElemID2FamilyID;
316 struct VISU_CONVERTOR_EXPORT TMEDMeshOnEntity: virtual TMeshOnEntityImpl
318 TFamilyID2CellsSize myFamilyID2CellsSize;
319 TGeom2ElemID2FamilyID myGeom2ElemID2FamilyID;
320 MED::TGeom2Size myGeom2Size;
322 typedef MED::SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
325 //---------------------------------------------------------------
326 struct VISU_CONVERTOR_EXPORT TMEDFamily: virtual TFamilyImpl
328 typedef MED::SharedPtr<TMEDFamily> PMEDFamily;
331 //---------------------------------------------------------------
332 struct VISU_CONVERTOR_EXPORT TMEDGroup: virtual TGroupImpl
334 typedef MED::SharedPtr<TMEDGroup> PMEDGroup;
337 //---------------------------------------------------------------
338 struct VISU_CONVERTOR_EXPORT TMEDField: virtual TFieldImpl
340 typedef MED::SharedPtr<TMEDField> PMEDField;
343 //---------------------------------------------------------------
344 struct VISU_CONVERTOR_EXPORT TMEDValForTime: virtual TValForTimeImpl
346 typedef MED::SharedPtr<TMEDValForTime> PMEDValForTime;
350 class VISU_MedConvertor: public VISU_Convertor_impl
353 VISU_MedConvertor(const VISU_MedConvertor&);
355 bool myIsEntitiesDone;
361 VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed);
380 MED::PWrapper myMed; // mpv : bug 13568: one med per converter
384 LoadMeshOnEntity(VISU::PMeshImpl theMesh,
385 VISU::PMeshOnEntityImpl theMeshOnEntity);
389 LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
390 VISU::PMeshOnEntityImpl theMeshOnEntity,
391 VISU::PFamilyImpl theFamily);
395 LoadMeshOnGroup(VISU::PMeshImpl theMesh,
396 const VISU::TFamilySet& theFamilySet);
400 LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
401 VISU::PMeshOnEntityImpl theMeshOnEntity,
402 VISU::PFieldImpl theField,
403 VISU::PValForTimeImpl theValForTime);
407 LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
408 VISU::PMeshOnEntityImpl theMeshOnEntity,
409 VISU::PFieldImpl theField,
410 VISU::PValForTimeImpl theValForTime);
413 LoadPoints(const MED::PWrapper& theMed,
414 const VISU::PMEDMesh theMesh);
417 LoadPointsOnFamily(const MED::PWrapper& theMed,
418 const VISU::PMEDMesh theMesh,
419 const VISU::PMEDFamily theFamily);
422 LoadCellsOnEntity(const MED::PWrapper& theMed,
423 const VISU::PMEDMesh theMesh,
424 const VISU::PMEDMeshOnEntity theMeshOnEntity);
427 LoadCellsOnFamily(const MED::PWrapper& theMed,
428 const VISU::PMEDMesh theMesh,
429 const VISU::PMEDMeshOnEntity theMeshOnEntity,
430 const VISU::PMEDFamily theFamily);
433 LoadValForTimeOnMesh(const MED::PWrapper& theMed,
434 VISU::PMEDMesh theMesh,
435 VISU::PMEDMeshOnEntity theMeshOnEntity,
436 VISU::PMEDField theField,
437 VISU::PMEDValForTime theValForTime);
440 LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
441 VISU::PMEDMesh theMesh,
442 VISU::PMEDMeshOnEntity theMeshOnEntity,
443 VISU::PMEDField theField,
444 VISU::PMEDValForTime theValForTime);