Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / CONVERTOR / VISU_MedConvertor.hxx
index c467f0c13339ff24e35fbf8b9fed52f5d6ea1c54..20ee98a6e8cee72857dc50886bf15ca8d6eb40f1 100644 (file)
 #ifndef VISU_MedConvertor_HeaderFile
 #define VISU_MedConvertor_HeaderFile
 
+#include "VISUConvertor.hxx"
 #include "VISU_Convertor_impl.hxx"
+#include "VISU_Structures_impl.hxx"
+#include "VISU_PointCoords.hxx"
+#include "VISU_MeshValue.hxx"
 
+#include "MED_Wrapper.hxx"
 #include "MED_Common.hxx"
 #include "MED_Structures.hxx"
+#include "MED_GaussUtils.hxx"
 
 #include <boost/thread/mutex.hpp>
-#include <qfileinfo.h>
 
 namespace VISU
 {
-  typedef TVector<TName> TNames;
+  //---------------------------------------------------------------
+  struct VISU_CONVERTOR_EXPORT TMEDCoordHolder: TCoordHolder<MED::PNodeCoord>
+  {
+    virtual
+    const TCoord*
+    GetPointer() const
+    {
+      return &(*myCoord)[0];
+    }
+
+    virtual
+    TCoord*
+    GetPointer()
+    {
+      return &(*myCoord)[0];
+    }
+  };
+
 
   //---------------------------------------------------------------
+  struct VISU_CONVERTOR_EXPORT TMEDGaussCoordHolder: TCoordHolderBase
+  {
+    MED::PGaussCoord myGaussCoord;
+
+    //! To initilize the instance
+    void
+    Init(const MED::PGaussCoord& theGaussCoord)
+    {
+      MED::TInt aNbGauss = theGaussCoord->GetNbGauss();
+      MED::TInt aNbElem = theGaussCoord->GetNbElem();
+      MED::TInt aDim = theGaussCoord->GetDim();
+      MED::TInt aNbCells = aNbElem * aNbGauss;
+      TCoordHolderBase::Init(aNbCells, aDim);
+      myGaussCoord = theGaussCoord;
+    }
+
+    //! Get slice of coordinates for defined node (const version)
+    virtual
+    TCCoordSlice
+    GetCoordSlice(vtkIdType theNodeId) const
+    {
+      MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
+      MED::TCCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
+      MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
+      return aCoordSliceArr[aGaussId];
+    }
+
+    //! Get slice of coordinates for defined node
+    virtual
+    TCoordSlice 
+    GetCoordSlice(vtkIdType theNodeId)
+    {
+      MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
+      MED::TCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
+      MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
+      return aCoordSliceArr[aGaussId];
+    }
+
+    virtual
+    unsigned char*
+    GetValuePtr()
+    {
+      return myGaussCoord->GetValuePtr();
+    }
+  };
+
+
+  //---------------------------------------------------------------
+  template<class TValueType>
+  struct VISU_CONVERTOR_EXPORT TTMEDMeshValue: TTMeshValueHolder<TValueType, 
+                                          MED::SharedPtr<MED::TTMeshValue<MED::TVector<TValueType> > > >
+  {
+    virtual
+    const TValueType*
+    GetPointer() const
+    {
+      return this->myContainer->GetPointer();
+    }
+
+    virtual
+    TValueType*
+    GetPointer()
+    {
+      return this->myContainer->GetPointer();
+    }
+  };
+
+
+  //---------------------------------------------------------------
+  typedef std::map<vtkIdType, vtkIdType> TObj2VTKID;
+
   class TMEDNamedPointCoords: public virtual TNamedPointCoords
   {
-    MED::PNodeInfo myNodeInfo;
-    TNames myPointNames;
+    MED::EBooleen myIsElemNum; //!< Keeps whether the numeration exists or not
+    MED::PElemNum myElemNum; //!< Keeps objects numeration
+    mutable TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
+
+    MED::EVersion myVersion;
+    MED::PString myElemNames; //!< Keeps whether the names exists or not
+    MED::EBooleen myIsElemNames; //!< Keeps objects names
+
   public:
+    TMEDNamedPointCoords():
+      myIsElemNum(MED::eFAUX),
+      myIsElemNames(MED::eFAUX)
+    {}
+
     void
-    Init(vtkIdType theNbPoints,
-        vtkIdType theDim,
-        const MED::PNodeInfo& theNodeInfo);
+    Init(const MED::PNodeInfo& theNodeInfo,
+        MED::EVersion theVersion);
 
     void
-    Init(vtkIdType theNbPoints,
-        vtkIdType theDim,
-        const MED::PGrilleInfo& theGrilleInfo);
+    Init(const MED::PGrilleInfo& theGrilleInfo);
+
+    //! Get object number for node by its VTK one
+    virtual
+    vtkIdType
+    GetObjID(vtkIdType theID) const;
 
+    //! Get VTK number for node by its object one
+    virtual
+    vtkIdType
+    GetVTKID(vtkIdType theID) const;
+
+    //! Get name of node by its object number
     virtual
     std::string 
     GetNodeName(vtkIdType theObjID) const;
+
+    //! Gets memory size used by the instance (bytes).
+    virtual
+    unsigned long int
+    GetMemorySize();
   };
-  typedef SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
+  typedef MED::SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
 
 
   //---------------------------------------------------------------
-  struct TMEDMesh: virtual TMeshImpl
+  struct VISU_CONVERTOR_EXPORT TMEDMesh: virtual TMeshImpl
   {
     MED::PMeshInfo myMeshInfo;
     MED::TEntityInfo myEntityInfo;
   };
-  typedef SharedPtr<TMEDMesh> PMEDMesh;
+  typedef MED::SharedPtr<TMEDMesh> PMEDMesh;
 
 
   //---------------------------------------------------------------
-  struct TMEDSubProfile: virtual TSubProfileImpl
+  struct VISU_CONVERTOR_EXPORT TMEDSubProfile: virtual TSubProfileImpl
   {
     MED::EGeometrieElement myMGeom;
 
@@ -73,23 +190,33 @@ namespace VISU
     {}
 
     MED::EBooleen myIsElemNum;
-    MED::TElemNum myElemNum;
+    MED::PElemNum myElemNum;
 
     virtual 
     vtkIdType 
     GetElemObjID(vtkIdType theID) const;
+
+   //! Reimplement the TSubProfileImpl::GetElemVTKID
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+    
+    //! Gets memory size used by the instance (bytes).
+    virtual
+    unsigned long int
+    GetMemorySize();
   };
-  typedef SharedPtr<TMEDSubProfile> PMEDSubProfile;
+  typedef MED::SharedPtr<TMEDSubProfile> PMEDSubProfile;
 
 
   //---------------------------------------------------------------
-  struct TMEDProfile: virtual TProfileImpl
+  struct VISU_CONVERTOR_EXPORT TMEDProfile: virtual TProfileImpl
   {};
-  typedef SharedPtr<TMEDProfile> PMEDProfile;
+  typedef MED::SharedPtr<TMEDProfile> PMEDProfile;
 
 
   //---------------------------------------------------------------
-  struct TMEDGauss: virtual TGaussImpl
+  struct VISU_CONVERTOR_EXPORT TMEDGauss: virtual TGaussImpl
   {
     MED::PGaussInfo myGaussInfo;
 
@@ -99,46 +226,60 @@ namespace VISU
     LessThan(const PGaussImpl& theGauss,
             bool& theResult) const;
   };
-  typedef SharedPtr<TMEDGauss> PMEDGauss;
+  typedef MED::SharedPtr<TMEDGauss> PMEDGauss;
 
 
   //---------------------------------------------------------------
-  struct TMEDGaussSubMesh: virtual TGaussSubMeshImpl
+  struct VISU_CONVERTOR_EXPORT TMEDGaussSubMesh: virtual TGaussSubMeshImpl
   {
     TMEDGaussSubMesh():
       myIsElemNum(MED::eFAUX)
     {}
 
     MED::EBooleen myIsElemNum;
-    MED::TElemNum myElemNum;
+    MED::PElemNum myElemNum;
 
     virtual
     TGaussPointID
-    GetObjID(vtkIdType theID,
-            vtkIdType theStartID) const;
+    GetObjID(vtkIdType theID) const;
+    
+    virtual
+    vtkIdType
+    GetVTKID(const TGaussPointID& theID,
+            vtkIdType theStartID) const;  
+
+    //! Gets memory size used by the instance (bytes).
+    virtual
+    unsigned long int
+    GetMemorySize();
   };
-  typedef SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
+  typedef MED::SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
 
 
   //---------------------------------------------------------------
-  struct TMEDGaussMesh: virtual TGaussMeshImpl
+  struct VISU_CONVERTOR_EXPORT TMEDGaussMesh: virtual TGaussMeshImpl
   {};
-  typedef SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
+  typedef MED::SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
 
 
   //---------------------------------------------------------------
-  struct TMEDSubMesh: virtual TSubMeshImpl
+  struct VISU_CONVERTOR_EXPORT TMEDSubMesh: virtual TSubMeshImpl
   {
     TMEDSubMesh():
-      myIsElemNum(MED::eFAUX)
+      myIsElemNum(MED::eFAUX),
+      myIsElemNames(MED::eFAUX)
     {}
 
     MED::EBooleen myIsElemNum;
-    MED::TElemNum myElemNum;
-    MED::PElemInfo myElemInfo;
+    MED::PElemNum myElemNum;
+
+    MED::EVersion myVersion;
+    MED::PString myElemNames;
+    MED::EBooleen myIsElemNames;
 
     void
-    Init(const MED::PElemInfo& theElemInfo);
+    Init(const MED::PElemInfo& theElemInfo,
+        MED::EVersion theVersion);
 
     void
     Init(const MED::PGrilleInfo& theGrilleInfo);
@@ -150,43 +291,48 @@ namespace VISU
     virtual
     std::string 
     GetElemName(vtkIdType theObjID) const;
+
+    //! Gets memory size used by the instance (bytes).
+    virtual
+    unsigned long int
+    GetMemorySize();
   };
-  typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;
+  typedef MED::SharedPtr<TMEDSubMesh> PMEDSubMesh;
 
 
   //---------------------------------------------------------------
   typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
 
-  struct TMEDMeshOnEntity: virtual TMeshOnEntityImpl
+  struct VISU_CONVERTOR_EXPORT TMEDMeshOnEntity: virtual TMeshOnEntityImpl
   {
     TFamilyID2CellsSize myFamilyID2CellsSize;
     MED::TGeom2Size myGeom2Size;
   };
-  typedef SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
+  typedef MED::SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
 
 
   //---------------------------------------------------------------
-  struct TMEDFamily: virtual TFamilyImpl
+  struct VISU_CONVERTOR_EXPORT TMEDFamily: virtual TFamilyImpl
   {};
-  typedef SharedPtr<TMEDFamily> PMEDFamily;
+  typedef MED::SharedPtr<TMEDFamily> PMEDFamily;
   
 
   //---------------------------------------------------------------
-  struct TMEDGroup: virtual TGroupImpl
+  struct VISU_CONVERTOR_EXPORT TMEDGroup: virtual TGroupImpl
   {};
-  typedef SharedPtr<TMEDGroup> PMEDGroup;
+  typedef MED::SharedPtr<TMEDGroup> PMEDGroup;
 
 
   //---------------------------------------------------------------
-  struct TMEDField: virtual TFieldImpl
+  struct VISU_CONVERTOR_EXPORT TMEDField: virtual TFieldImpl
   {};
-  typedef SharedPtr<TMEDField> PMEDField;
+  typedef MED::SharedPtr<TMEDField> PMEDField;
 
 
   //---------------------------------------------------------------
-  struct TMEDValForTime: virtual TValForTimeImpl
+  struct VISU_CONVERTOR_EXPORT TMEDValForTime: virtual TValForTimeImpl
   {};
-  typedef SharedPtr<TMEDValForTime> PMEDValForTime;
+  typedef MED::SharedPtr<TMEDValForTime> PMEDValForTime;
 
 }
 
@@ -201,7 +347,7 @@ class VISU_MedConvertor: public VISU_Convertor_impl
   bool myIsMinMaxDone;
 
 public:
-  VISU_MedConvertor(const std::string& theFileName);
+  VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed);
 
   virtual
   VISU_Convertor* 
@@ -220,7 +366,7 @@ public:
   BuildGroups();
 
 protected:
-  QFileInfo myFileInfo;
+  MED::PWrapper myMed; // mpv : bug 13568: one med per converter
 
   virtual
   int