1 // License as published by the Free Software Foundation; either
2 // version 2.1 of the License.
4 // This library is distributed in the hope that it will be useful,
5 // but WITHOUT ANY WARRANTY; without even the implied warranty of
6 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7 // Lesser General Public License for more details.
9 // You should have received a copy of the GNU Lesser General Public
10 // License along with this library; if not, write to the Free Software
11 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
15 // File : VISU_MedConvertor.hxx
16 // Author : Alexey PETROV
19 #ifndef VISU_MedConvertor_HeaderFile
20 #define VISU_MedConvertor_HeaderFile
22 #include "VISUConvertor.hxx"
23 #include "VISU_Convertor_impl.hxx"
24 #include "VISU_Structures_impl.hxx"
25 #include "VISU_PointCoords.hxx"
26 #include "VISU_MeshValue.hxx"
28 #include "MED_Wrapper.hxx"
29 #include "MED_Common.hxx"
30 #include "MED_Structures.hxx"
31 #include "MED_GaussUtils.hxx"
33 #include <boost/thread/mutex.hpp>
37 //---------------------------------------------------------------
38 struct VISU_CONVERTOR_EXPORT TMEDCoordHolder: TCoordHolder<MED::PNodeCoord>
44 return &(*myCoord)[0];
51 return &(*myCoord)[0];
56 //---------------------------------------------------------------
57 struct VISU_CONVERTOR_EXPORT TMEDGaussCoordHolder: TCoordHolderBase
59 MED::PGaussCoord myGaussCoord;
61 //! To initilize the instance
63 Init(const MED::PGaussCoord& theGaussCoord)
65 MED::TInt aNbGauss = theGaussCoord->GetNbGauss();
66 MED::TInt aNbElem = theGaussCoord->GetNbElem();
67 MED::TInt aDim = theGaussCoord->GetDim();
68 MED::TInt aNbCells = aNbElem * aNbGauss;
69 TCoordHolderBase::Init(aNbCells, aDim);
70 myGaussCoord = theGaussCoord;
73 //! Get slice of coordinates for defined node (const version)
76 GetCoordSlice(vtkIdType theNodeId) const
78 MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
79 MED::TCCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
80 MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
81 return aCoordSliceArr[aGaussId];
84 //! Get slice of coordinates for defined node
87 GetCoordSlice(vtkIdType theNodeId)
89 MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
90 MED::TCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
91 MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
92 return aCoordSliceArr[aGaussId];
99 return myGaussCoord->GetValuePtr();
104 //---------------------------------------------------------------
105 template<class TValueType>
106 struct VISU_CONVERTOR_EXPORT TTMEDMeshValue: TTMeshValueHolder<TValueType,
107 MED::SharedPtr<MED::TTMeshValue<MED::TVector<TValueType> > > >
113 return this->myContainer->GetPointer();
120 return this->myContainer->GetPointer();
125 //---------------------------------------------------------------
126 typedef std::map<vtkIdType, vtkIdType> TObj2VTKID;
128 class TMEDNamedPointCoords: public virtual TNamedPointCoords
130 MED::EBooleen myIsElemNum; //!< Keeps whether the numeration exists or not
131 MED::PElemNum myElemNum; //!< Keeps objects numeration
132 mutable TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
134 MED::EVersion myVersion;
135 MED::PString myElemNames; //!< Keeps whether the names exists or not
136 MED::EBooleen myIsElemNames; //!< Keeps objects names
139 TMEDNamedPointCoords():
140 myIsElemNum(MED::eFAUX),
141 myIsElemNames(MED::eFAUX)
145 Init(const MED::PNodeInfo& theNodeInfo,
146 MED::EVersion theVersion);
149 Init(const MED::PGrilleInfo& theGrilleInfo);
151 //! Get object number for node by its VTK one
154 GetObjID(vtkIdType theID) const;
156 //! Get VTK number for node by its object one
159 GetVTKID(vtkIdType theID) const;
161 //! Get name of node by its object number
164 GetNodeName(vtkIdType theObjID) const;
166 //! Gets memory size used by the instance (bytes).
171 typedef MED::SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
174 //---------------------------------------------------------------
175 struct VISU_CONVERTOR_EXPORT TMEDMesh: virtual TMeshImpl
177 MED::PMeshInfo myMeshInfo;
178 MED::TEntityInfo myEntityInfo;
180 typedef MED::SharedPtr<TMEDMesh> PMEDMesh;
183 //---------------------------------------------------------------
184 struct VISU_CONVERTOR_EXPORT TMEDSubProfile: virtual TSubProfileImpl
186 MED::EGeometrieElement myMGeom;
189 myIsElemNum(MED::eFAUX)
192 MED::EBooleen myIsElemNum;
193 MED::PElemNum myElemNum;
197 GetElemObjID(vtkIdType theID) const;
199 //! Reimplement the TSubProfileImpl::GetElemVTKID
202 GetElemVTKID(vtkIdType theID) const;
204 //! Gets memory size used by the instance (bytes).
209 typedef MED::SharedPtr<TMEDSubProfile> PMEDSubProfile;
212 //---------------------------------------------------------------
213 struct VISU_CONVERTOR_EXPORT TMEDProfile: virtual TProfileImpl
215 typedef MED::SharedPtr<TMEDProfile> PMEDProfile;
218 //---------------------------------------------------------------
219 struct VISU_CONVERTOR_EXPORT TMEDGauss: virtual TGaussImpl
221 MED::PGaussInfo myGaussInfo;
223 //! To define a way to implement more detail comparision of the TGaussSubMesh instances
226 LessThan(const PGaussImpl& theGauss,
227 bool& theResult) const;
229 typedef MED::SharedPtr<TMEDGauss> PMEDGauss;
232 //---------------------------------------------------------------
233 struct VISU_CONVERTOR_EXPORT TMEDGaussSubMesh: virtual TGaussSubMeshImpl
236 myIsElemNum(MED::eFAUX)
239 MED::EBooleen myIsElemNum;
240 MED::PElemNum myElemNum;
244 GetObjID(vtkIdType theID) const;
248 GetVTKID(const TGaussPointID& theID,
249 vtkIdType theStartID) const;
251 //! Gets memory size used by the instance (bytes).
256 typedef MED::SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
259 //---------------------------------------------------------------
260 struct VISU_CONVERTOR_EXPORT TMEDGaussMesh: virtual TGaussMeshImpl
262 typedef MED::SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
265 //---------------------------------------------------------------
266 struct VISU_CONVERTOR_EXPORT TMEDSubMesh: virtual TSubMeshImpl
269 myIsElemNum(MED::eFAUX),
270 myIsElemNames(MED::eFAUX)
273 MED::EBooleen myIsElemNum;
274 MED::PElemNum myElemNum;
276 MED::EVersion myVersion;
277 MED::PString myElemNames;
278 MED::EBooleen myIsElemNames;
281 Init(const MED::PElemInfo& theElemInfo,
282 MED::EVersion theVersion);
285 Init(const MED::PGrilleInfo& theGrilleInfo);
289 GetElemObjID(vtkIdType theID) const;
293 GetElemName(vtkIdType theObjID) const;
295 //! Gets memory size used by the instance (bytes).
300 typedef MED::SharedPtr<TMEDSubMesh> PMEDSubMesh;
303 //---------------------------------------------------------------
304 typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
306 struct VISU_CONVERTOR_EXPORT TMEDMeshOnEntity: virtual TMeshOnEntityImpl
308 TFamilyID2CellsSize myFamilyID2CellsSize;
309 MED::TGeom2Size myGeom2Size;
311 typedef MED::SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
314 //---------------------------------------------------------------
315 struct VISU_CONVERTOR_EXPORT TMEDFamily: virtual TFamilyImpl
317 typedef MED::SharedPtr<TMEDFamily> PMEDFamily;
320 //---------------------------------------------------------------
321 struct VISU_CONVERTOR_EXPORT TMEDGroup: virtual TGroupImpl
323 typedef MED::SharedPtr<TMEDGroup> PMEDGroup;
326 //---------------------------------------------------------------
327 struct VISU_CONVERTOR_EXPORT TMEDField: virtual TFieldImpl
329 typedef MED::SharedPtr<TMEDField> PMEDField;
332 //---------------------------------------------------------------
333 struct VISU_CONVERTOR_EXPORT TMEDValForTime: virtual TValForTimeImpl
335 typedef MED::SharedPtr<TMEDValForTime> PMEDValForTime;
339 class VISU_MedConvertor: public VISU_Convertor_impl
342 VISU_MedConvertor(const VISU_MedConvertor&);
344 bool myIsEntitiesDone;
350 VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed);
369 MED::PWrapper myMed; // mpv : bug 13568: one med per converter
373 LoadMeshOnEntity(VISU::PMeshImpl theMesh,
374 VISU::PMeshOnEntityImpl theMeshOnEntity);
378 LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
379 VISU::PMeshOnEntityImpl theMeshOnEntity,
380 VISU::PFamilyImpl theFamily);
384 LoadMeshOnGroup(VISU::PMeshImpl theMesh,
385 const VISU::TFamilySet& theFamilySet);
389 LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
390 VISU::PMeshOnEntityImpl theMeshOnEntity,
391 VISU::PFieldImpl theField,
392 VISU::PValForTimeImpl theValForTime);
396 LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
397 VISU::PMeshOnEntityImpl theMeshOnEntity,
398 VISU::PFieldImpl theField,
399 VISU::PValForTimeImpl theValForTime);
402 LoadPoints(const MED::PWrapper& theMed,
403 const VISU::PMEDMesh theMesh);
406 LoadPointsOnFamily(const MED::PWrapper& theMed,
407 const VISU::PMEDMesh theMesh,
408 const VISU::PMEDFamily theFamily);
411 LoadCellsOnEntity(const MED::PWrapper& theMed,
412 const VISU::PMEDMesh theMesh,
413 const VISU::PMEDMeshOnEntity theMeshOnEntity);
416 LoadCellsOnFamily(const MED::PWrapper& theMed,
417 const VISU::PMEDMesh theMesh,
418 const VISU::PMEDMeshOnEntity theMeshOnEntity,
419 const VISU::PMEDFamily theFamily);
422 LoadValForTimeOnMesh(const MED::PWrapper& theMed,
423 VISU::PMEDMesh theMesh,
424 VISU::PMEDMeshOnEntity theMeshOnEntity,
425 VISU::PMEDField theField,
426 VISU::PMEDValForTime theValForTime);
429 LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
430 VISU::PMEDMesh theMesh,
431 VISU::PMEDMeshOnEntity theMeshOnEntity,
432 VISU::PMEDField theField,
433 VISU::PMEDValForTime theValForTime);