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 struct VISU_CONVERTOR_EXPORT TMEDMeshOnEntity: virtual TMeshOnEntityImpl
314 TFamilyID2CellsSize myFamilyID2CellsSize;
315 MED::TGeom2Size myGeom2Size;
317 typedef MED::SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
320 //---------------------------------------------------------------
321 struct VISU_CONVERTOR_EXPORT TMEDFamily: virtual TFamilyImpl
323 typedef MED::SharedPtr<TMEDFamily> PMEDFamily;
326 //---------------------------------------------------------------
327 struct VISU_CONVERTOR_EXPORT TMEDGroup: virtual TGroupImpl
329 typedef MED::SharedPtr<TMEDGroup> PMEDGroup;
332 //---------------------------------------------------------------
333 struct VISU_CONVERTOR_EXPORT TMEDField: virtual TFieldImpl
335 typedef MED::SharedPtr<TMEDField> PMEDField;
338 //---------------------------------------------------------------
339 struct VISU_CONVERTOR_EXPORT TMEDValForTime: virtual TValForTimeImpl
341 typedef MED::SharedPtr<TMEDValForTime> PMEDValForTime;
345 class VISU_MedConvertor: public VISU_Convertor_impl
348 VISU_MedConvertor(const VISU_MedConvertor&);
350 bool myIsEntitiesDone;
356 VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed);
375 MED::PWrapper myMed; // mpv : bug 13568: one med per converter
379 LoadMeshOnEntity(VISU::PMeshImpl theMesh,
380 VISU::PMeshOnEntityImpl theMeshOnEntity);
384 LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
385 VISU::PMeshOnEntityImpl theMeshOnEntity,
386 VISU::PFamilyImpl theFamily);
390 LoadMeshOnGroup(VISU::PMeshImpl theMesh,
391 const VISU::TFamilySet& theFamilySet);
395 LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
396 VISU::PMeshOnEntityImpl theMeshOnEntity,
397 VISU::PFieldImpl theField,
398 VISU::PValForTimeImpl theValForTime);
402 LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
403 VISU::PMeshOnEntityImpl theMeshOnEntity,
404 VISU::PFieldImpl theField,
405 VISU::PValForTimeImpl theValForTime);
408 LoadPoints(const MED::PWrapper& theMed,
409 const VISU::PMEDMesh theMesh);
412 LoadPointsOnFamily(const MED::PWrapper& theMed,
413 const VISU::PMEDMesh theMesh,
414 const VISU::PMEDFamily theFamily);
417 LoadCellsOnEntity(const MED::PWrapper& theMed,
418 const VISU::PMEDMesh theMesh,
419 const VISU::PMEDMeshOnEntity theMeshOnEntity);
422 LoadCellsOnFamily(const MED::PWrapper& theMed,
423 const VISU::PMEDMesh theMesh,
424 const VISU::PMEDMeshOnEntity theMeshOnEntity,
425 const VISU::PMEDFamily theFamily);
428 LoadValForTimeOnMesh(const MED::PWrapper& theMed,
429 VISU::PMEDMesh theMesh,
430 VISU::PMEDMeshOnEntity theMeshOnEntity,
431 VISU::PMEDField theField,
432 VISU::PMEDValForTime theValForTime);
435 LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
436 VISU::PMEDMesh theMesh,
437 VISU::PMEDMeshOnEntity theMeshOnEntity,
438 VISU::PMEDField theField,
439 VISU::PMEDValForTime theValForTime);