Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.hxx
index 46284cba0cab26d047f6b2bc59202fec10e5121e..c4efc7d25c80c2471f5f83b6b4651e4869cdcbad 100644 (file)
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
 //
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
 //
 //
-//  File   : VISU_Convertor_impl.hxx
-//  Author : Alexey PETROV
-//  Module : VISU
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
 
 #ifndef VISU_Convertor_impl_HeaderFile
 #define VISU_Convertor_impl_HeaderFile
 
+#include <vtkSmartPointer.h>
+
+#include <boost/tuple/tuple.hpp>
+
+class vtkCell;
+class vtkPoints;
+class vtkUnstructuredGrid;
+class VTKViewer_AppendFilter;
+class VISU_MergeFilter;
+
 #include "VISU_Convertor.hxx"
+#include "MED_SliceArray.hxx"
 
-#include <vtkSystemIncludes.h>
+#ifndef VISU_ENABLE_QUADRATIC
+#define VISU_ENABLE_QUADRATIC
+#define VISU_USE_VTK_QUADRATIC
+#endif
 
-#include <vtkPoints.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkMergeDataObjectFilter.h>
-#include <vtkFieldDataToAttributeDataFilter.h>
-#include "VISU_ExtractUnstructuredGrid.hxx"
+namespace VISU
+{
+  //! Defines VISU enumeration of geometrical types
+  enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
+                 eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304,
+                 ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310, 
+                 ePYRA13=313, ePENTA15=315, eHEXA20=320, 
+                 ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1};
 
-#include <qstring.h>
-#include <qfileinfo.h>
+  //! Get number of nodes for defined geometrical type
+  vtkIdType
+  VISUGeom2NbNodes(EGeometry theGeom);
 
-#include <vtkSmartPointer.h>
+  //! Maps VISU geometrical type to VTK one
+  vtkIdType
+  VISUGeom2VTK(EGeometry theGeom);
 
-#include <boost/tuple/tuple.hpp>
+  //---------------------------------------------------------------
+  using MED::TCSlice;
+  using MED::TSlice;
 
-namespace VISU{
+  typedef vtkUnstructuredGrid TDataSet;
 
+  typedef vtkSmartPointer<TDataSet> TVTKSource;
   typedef vtkSmartPointer<vtkPoints> TVTKPoints;
-  typedef vtkSmartPointer<vtkUnstructuredGrid> TVTKSource;
-  typedef vtkSmartPointer<vtkMergeDataObjectFilter> TVTKMergetFilter;
-  typedef vtkSmartPointer<VISU_ExtractUnstructuredGrid> TVTKExtractFilter;
-  typedef vtkSmartPointer<vtkFieldDataToAttributeDataFilter> TVTKAttribyteFilter;
+  typedef vtkSmartPointer<VISU_MergeFilter> TVTKMergeFilter;
+
+  typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
 
   typedef float TCoord;
 
-  struct TMeshImpl: TMesh{
-    TVTKPoints myPoints;
+  //---------------------------------------------------------------
+  //! Define an utility base class which is repsonsible for preventing repetion
+  struct TIsVTKDone: virtual TBaseStructure
+  {
+    TIsVTKDone();
+    bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure 
+    bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation  
+  };
+
+  
+  //---------------------------------------------------------------
+  //! Define an utility base class which allow to keep calculated number of cells and their size
+  struct TSizeCounter: virtual TIsVTKDone
+  {
+    TSizeCounter();
+    vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass
+    vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass
+  };
+
+
+  //---------------------------------------------------------------
+  //! Define a container for VTK representation
+  class TSource: public virtual TSizeCounter
+  {
+  protected:
+    mutable TVTKSource mySource;
+  public:
+    TSource();
+
+    //! This method allow to create corresponding VTK data set by demand (not at once)
+    const TVTKSource& 
+    GetSource() const;
+
+    //! Reimplement the TIDMapper::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+  };
+
+
+  //---------------------------------------------------------------
+  //! Define a container for VTK representation
+  /*!
+    This container allow to combine other VTK representation into single one.
+  */
+  class TAppendFilter: public virtual TIsVTKDone,
+                      public virtual TIDMapper
+  {
+  protected:
+    mutable TVTKAppendFilter myFilter;
+  public:
+    TAppendFilter();
+
+    //! This method allow to create corresponding VTK filter by demand (not at once)
+    const TVTKAppendFilter& 
+    GetFilter() const;
+
+    //! Reimplement the TIDMapper::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+  };
+
+
+  //---------------------------------------------------------------
+  //! Define a container for VTK representation
+  /*!
+    This container allow to assign data to mesh and represent them into single VTK representation
+  */
+  class TMergeFilter: public virtual TIsVTKDone,
+                     public virtual TIDMapper
+  {
+  protected:
+    mutable TVTKMergeFilter myFilter;
+  public:
+    TMergeFilter();
+
+    //! This method allow to create corresponding VTK filter by demand (not at once)
+    const TVTKMergeFilter& 
+    GetFilter() const;
+
+    //! Reimplement the TIDMapper::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+  };
+
+
+  //---------------------------------------------------------------
+  typedef TVector<TCoord> TCoordArray;
+  typedef TSlice<TCoordArray> TCoordSlice;
+  typedef TCSlice<TCoordArray> TCCoordSlice;
+
+  //! This class is responsible for representation of mesh nodes
+  class TPointCoords: public virtual TBaseStructure
+  {
+  protected:
+    vtkIdType myDim; //!< Dimension of the nodal coordinates
+    vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
+
+    //! An container for coordinates of the nodes
+    /*!
+      Usage of slices allow to minimize amount of memory to store the nodal coordinates and
+      provide unifirm way of conversation with this coordinates (independant from mesh dimension)
+    */
+    TCoordArray myCoord; 
+    TVTKPoints myPoints; //!< VTK representation for the mesh nodes
+
+  public:
+    TPointCoords();
+
+    //! To initilize the class
+    void
+    Init(vtkIdType theNbPoints,
+        vtkIdType theDim);
+
+    //! Get slice of coordinates for defined node (const version)
+    TCCoordSlice
+    GetCoordSlice(vtkIdType theNodeId) const;
+
+    //! Get slice of coordinates for defined node
+    TCoordSlice 
+    GetCoordSlice(vtkIdType theNodeId);
+
+    vtkIdType
+    GetNbPoints() const { return myNbPoints; }
+
+    vtkIdType
+    GetDim() const { return myDim; }
+
+    vtkIdType
+    size() const { return GetNbPoints(); }
+
+    const TVTKPoints&
+    GetPoints() const { return myPoints;}
+  };
+  typedef SharedPtr<TPointCoords> PPointCoords;
+
+
+  //---------------------------------------------------------------
+  typedef TVector<vtkIdType> TVectorID;
+  typedef std::map<vtkIdType,vtkIdType> TObj2VTKID;
+
+  //! This class is responsible for representation of mesh nodes
+  /*!
+    In additition to its base functionlity it support mapping of VTK to object numeration and
+    keeps names for each of nodes.
+  */
+  class TNamedPointCoords: public virtual TPointCoords
+  {
+  protected:
+    typedef TVector<std::string> TPointsDim;
+    TPointsDim myPointsDim; //!< Keeps name of each dimension
+    TVectorID myVectorID; //!< Keeps object¶ numeration
+    TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
+
+  public:
+
+    //! To initilize the class (numeration of the nodes can be missed)
+    void
+    Init(vtkIdType theNbPoints,
+        vtkIdType theDim,
+        const TVectorID& theVectorID = TVectorID());
+    
+    //! Get name for defined dimension
+    std::string&
+    GetName(vtkIdType theDim);
+    
+    //! Get name for defined dimension (const version)
+    const std::string&
+    GetName(vtkIdType theDim) const;
+
+    //! 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;
+  };
+  typedef SharedPtr<TNamedPointCoords> PNamedPointCoords;
+
 
-    typedef std::vector<TCoord> TPointsCoord;
-    TPointsCoord myPointsCoord;
+  //---------------------------------------------------------------
+  //! Specialize TMesh to provide VTK mapping for nodes
+  struct TMeshImpl: virtual TMesh, 
+                   virtual TIsVTKDone
+  {
+    PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
 
-    typedef std::vector<std::string> TPointsDim;
-    TPointsDim myPointsDim;
+    TVTKPoints myPoints; //!< Keeps VTK representation of the nodes
+    vtkIdType myNbPoints; //!< Keeps number of the nodes
+
+    TMeshImpl();
+  };
+  typedef SharedPtr<TMeshImpl> PMeshImpl;
+
+
+  //---------------------------------------------------------------
+  typedef TVector<vtkIdType> TSubMeshID;
+  typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus; 
+
+  //! Specialize TSubProfile to provide VTK mapping
+  struct TSubProfileImpl: virtual TSubProfile, 
+                         virtual TSource
+  {
+    TSubProfileImpl();
+
+    EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
+    std::string myName; //!< Keeps its name
+
+    //! Get object number of mesh cell by its VTK one
+    virtual 
+    vtkIdType 
+    GetElemObjID(int theVtkI) const;
+
+    //! Keeps status of the structure
+    /*!
+      In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
+      in order to construct mesh for MED TIEMSTAMPS in uniform way.
+    */
+    ESubMeshStatus myStatus; 
+    TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
   };
-  typedef shared_ptr<TMeshImpl> PMeshImpl;
+  typedef SharedPtr<TSubProfileImpl> PSubProfileImpl;
+
+
+  //---------------------------------------------------------------
+  struct TMeshOnEntityImpl;
+
+  typedef std::map<vtkIdType,vtkIdType> TID2ID;
+  typedef TVector<PSubProfileImpl> TSubProfileArr;
+  typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
+
+  //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
+  struct TProfileImpl: virtual TProfile, 
+                      virtual TAppendFilter
+  {
+    TProfileImpl();
+    bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
+   
+    //! Reimplement the TIDMapper::GetNodeObjID
+    virtual 
+    vtkIdType 
+    GetNodeObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetNodeVTKID
+    virtual 
+    vtkIdType 
+    GetNodeVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetNodeCoord
+    virtual 
+    float*  
+    GetNodeCoord(vtkIdType theObjID);
+
+    //! Reimplement the TIDMapper::GetElemObjID
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemVTKID
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemCell
+    virtual
+    vtkCell* 
+    GetElemCell(vtkIdType theObjID);
+    
+    //! Reimplement the TIDMapper::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+
+    //! Reimplement the TNamedIDMapper::GetNodeName
+    virtual
+    std::string 
+    GetNodeName(vtkIdType theObjID) const;
+
+    //! Reimplement the TNamedIDMapper::GetElemName
+    virtual
+    std::string 
+    GetElemName(vtkIdType theObjID) const;
+
+    TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
+    TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilter
+    PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
+    TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
+
+    TSource mySource; //!< Keeps VTK representation of the MED TIMESTAMP mesh
+    TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
+  };
+  typedef SharedPtr<TProfileImpl> PProfileImpl;
+
+
+  //---------------------------------------------------------------
+  //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+  struct TIDMapperFilter: virtual TMergeFilter
+  {
+    TAppendFilter myIDMapper; //!< Responsible for numbering
+    TSource mySource; //!< Keeps assigned data
+
+    //! Reimplement the TIDMapper::GetNodeObjID
+    virtual 
+    vtkIdType 
+    GetNodeObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetNodeVTKID
+    virtual 
+    vtkIdType 
+    GetNodeVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetNodeCoord
+    virtual 
+    float*  
+    GetNodeCoord(vtkIdType theObjID);
+
+    //! Reimplement the TIDMapper::GetElemObjID
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemVTKID
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemCell
+    virtual
+    vtkCell* 
+    GetElemCell(vtkIdType theObjID);
+    
+    //! Reimplement the TIDMapper::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+  };
+  typedef SharedPtr<TIDMapperFilter> PIDMapperFilter;
+
+
+  //---------------------------------------------------------------
+  struct TGaussImpl;
+  typedef SharedPtr<TGaussImpl> PGaussImpl;
+
+  //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
+  struct TGaussImpl: virtual TGauss
+  {
+    EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
+    std::string myName; //!< Keeps name of the MED GAUSS entity
+    vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
 
-  struct TMeshOnEntityImpl: TMeshOnEntity{
-    TVTKSource myStorage;
-    typedef std::vector<vtkIdType> TConnect;
-    typedef std::vector<TConnect> TConnForCellType;
-    typedef std::map<vtkIdType,TConnForCellType> TCellsConn;
-    TCellsConn myCellsConn;
+    //! To define a way to implement more detail comparision of the TGaussSubMesh instances
+    virtual
+    void
+    LessThan(const PGaussImpl& theGauss,
+            bool& theResult) const;
   };
-  typedef shared_ptr<TMeshOnEntityImpl> PMeshOnEntityImpl;
 
-  struct TFamilyImpl: TFamily{
-    TVTKSource myStorage;
 
-    typedef std::set<vtkIdType> TSubMeshOnCellType;
-    typedef std::map<vtkIdType,TSubMeshOnCellType> TSubMesh;
-    TSubMesh mySubMesh;
+  //---------------------------------------------------------------
+  //! Specialize TGaussSubMesh to provide VTK mapping for the entity
+  struct TGaussSubMeshImpl: virtual TGaussSubMesh, 
+                           virtual TSource
+  {
+    TGaussSubMeshImpl();
+
+    //! To implement the TGaussPtsIDMapper::GetObjID
+    virtual
+    TGaussPointID
+    GetObjID(vtkIdType theID) const;
+    
+    PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
+
+    //! Keeps status of the structure
+    /*!
+      In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
+      in order to construct mesh for MED TIEMSTAMPS in uniform way.
+    */
+    ESubMeshStatus myStatus;
+
+    TPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
   };
-  typedef shared_ptr<TFamilyImpl> PFamilyImpl;
+  typedef SharedPtr<TGaussSubMeshImpl> PGaussSubMeshImpl;
+
+
+  //---------------------------------------------------------------
+  typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
+  typedef std::map<EGeometry,PGaussSubMeshImpl> TGeom2GaussSubMesh;
+
+  //! Specialize TGaussMesh to provide VTK mapping for the entity
+  struct TGaussMeshImpl: virtual TGaussMesh, 
+                        virtual TAppendFilter
+  {
+    TGaussMeshImpl();
+
+    //! Reimplement the TGaussPtsIDMapper::GetObjID
+    virtual
+    TGaussPointID
+    GetObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+
+    //! Reimplement the TGaussPtsIDMapper::GetParent
+    virtual 
+    TNamedIDMapper*
+    GetParent();
+
+    TSource mySource; //!< Keeps VTK representation of the Gauss Points
+    TNamedIDMapper* myParent; //!< Refer to parent mesh
+    TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilter
+    TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
+  };
+  typedef SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
+
+
+  //---------------------------------------------------------------
+  //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+  struct TGaussPtsIDFilter: virtual TIDMapperFilter,
+                           virtual TGaussPtsIDMapper
+  { 
+    PGaussPtsIDMapper myGaussPtsIDMapper;
 
-  struct TGroupImpl: TGroup{
-    TVTKSource myStorage;
+    //! Reimplement the TGaussPtsIDMapper::GetObjID
+    virtual 
+    TGaussPointID 
+    GetObjID(vtkIdType theID) const;
+
+    //! Reimplement the TGaussPtsIDMapper::GetParent
+    virtual 
+    TNamedIDMapper*
+    GetParent();
   };
-  typedef shared_ptr<TGroupImpl> PGroupImpl;
+  typedef SharedPtr<TGaussPtsIDFilter> PGaussPtsIDFilter;
+
+
+  //---------------------------------------------------------------
+  typedef TVector<vtkIdType> TConnect;
+  typedef TVector<TConnect> TCell2Connect;
+
+  //! The class is responsible for mapping of cells of defined geometrical type  
+  struct TSubMeshImpl: virtual TSource
+  {
+    
+    //! To implement the TIDMapper::GetElemObjID
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
+
+    //! To implement the TNamedIDMapper::GetElemName
+    virtual
+    std::string 
+    GetElemName(vtkIdType theObjID) const;
+
+    vtkIdType myStartID;
+    TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
+  };
+  typedef SharedPtr<TSubMeshImpl> PSubMeshImpl;
+
+
+  //---------------------------------------------------------------
+  typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
+  typedef TVector<PSubMeshImpl> TSubMeshArr;
+
+  //! Specialize TMeshOnEntity to provide VTK mapping for the entity
+  struct TMeshOnEntityImpl: virtual TMeshOnEntity, 
+                           virtual TAppendFilter, 
+                           virtual TSizeCounter
+  {
+    //! Reimplement the TIDMapper::GetNodeVTKID
+    virtual 
+    vtkIdType 
+    GetNodeVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetNodeObjID
+    virtual 
+    vtkIdType 
+    GetNodeObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemVTKID
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemObjID
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
+
+    //! Reimplement the TNamedIDMapper::GetNodeName
+    virtual
+    std::string 
+    GetNodeName(vtkIdType theObjID) const;
+
+    //! Reimplement the TNamedIDMapper::GetElemName
+    virtual
+    std::string 
+    GetElemName(vtkIdType theObjID) const;
+
+    TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping 
+    TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilter
+    PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+
+    TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
+  };
+  typedef SharedPtr<TMeshOnEntityImpl> PMeshOnEntityImpl;
+
+
+  //---------------------------------------------------------------
+  typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
+
+  //! Specialize TFamily to provide VTK mapping for the entity
+  struct TFamilyImpl: virtual TFamily, 
+                     virtual TSource
+  {
+    //! Reimplement the TIDMapper::GetNodeObjID
+    vtkIdType 
+    GetNodeObjID(vtkIdType theID) const ;
+
+    //! Reimplement the TIDMapper::GetNodeVTKID
+    virtual 
+    vtkIdType 
+    GetNodeVTKID(vtkIdType theID) const ;
+
+    //! Reimplement the TIDMapper::GetElemVTKID
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemObjID
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+
+    PNamedPointCoords myNamedPointCoords;  //!< Share the same instance with TMesh to implement nodal mapping
+    TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+    TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
+
+    TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
+  };
+  typedef SharedPtr<TFamilyImpl> PFamilyImpl;
+
+
+  //---------------------------------------------------------------
+  typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
+  typedef TVector<PFamilyImpl> TFamilyArr;
+
+  //! Specialize TGroup to provide VTK mapping for the entity
+  struct TGroupImpl: virtual TGroup, 
+                    virtual TAppendFilter
+  {
+    //! Calculate pair of values - number of cells and its size
+    TNbASizeCells 
+    GetNbASizeCells() const;
+
+    //! Reimplement the TIDMapper::GetElemVTKID
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetElemObjID
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetNodeObjID
+    virtual 
+    vtkIdType 
+    GetNodeObjID(vtkIdType theID) const;
+
+    //! Reimplement the TIDMapper::GetNodeVTKID
+    virtual 
+    vtkIdType 
+    GetNodeVTKID(vtkIdType theID) const;
+
+    TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+    TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilter
+    PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+  };
+  typedef SharedPtr<TGroupImpl> PGroupImpl;
+
+
+  //---------------------------------------------------------------
+  typedef TVector<TMinMax> TMinMaxArr;
+
+  //! Specialize TField to provide VTK mapping for the entity
+  struct TFieldImpl: virtual TField
+  {
+    vtkIdType myDataSize; //!< Keeps size of the assigned data
+
+    TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
+
+    //! Implement the TField::GetMinMax
+    virtual
+    TMinMax 
+    GetMinMax(vtkIdType theCompID);
 
-  struct TFieldImpl: TField{
-    TVTKExtractFilter myExtractFilter;
-    ~TFieldImpl()
-    { 
-      if(myExtractFilter.GetPointer())
-       myExtractFilter->UnRegisterAllOutputs();
-    }
+    //! To initialize the data structure    
+    void 
+    InitArrays(vtkIdType theNbComp);
+
+    TFieldImpl();
   };
-  typedef shared_ptr<TFieldImpl> PFieldImpl;
+  typedef SharedPtr<TFieldImpl> PFieldImpl;
+
+
+  //---------------------------------------------------------------
+  typedef TVector<float> TValue;
+  typedef TSlice<TValue> TValueSlice;
+  typedef TCSlice<TValue> TCValueSlice;
+
+  typedef TVector<TCValueSlice> TCValueSliceArr;
+  typedef TVector<TValueSlice> TValueSliceArr;
+
+  //! Define a container to get access to data assigned to mesh
+  struct TMeshValue
+  {
+    TValue myValue; //!< Keeps all values as one dimensional sequence
 
-  struct TValForTimeImpl: TValForTime{
-    TVTKAttribyteFilter myAttribyteFilter;
-    TVTKMergetFilter myMergeFilter;
-    TVTKSource myStorage;
+    vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
+    vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
+    vtkIdType myNbGauss; //!< Defines number of Gauss Points
+    vtkIdType myStep; //! Internal variable
 
-    typedef std::vector<float> TValForCellsWithType;
-    typedef std::map<vtkIdType,TValForCellsWithType> TValForCells;
-    TValForCells myValForCells;
+    //! To intitilize the data strucutre
+    void
+    Init(vtkIdType theNbElem,
+        vtkIdType theNbGauss,
+        vtkIdType theNbComp);
 
-    ~TValForTimeImpl()
-    { 
-      if(myMergeFilter.GetPointer())
-       myMergeFilter->UnRegisterAllOutputs();
-      if(myAttribyteFilter.GetPointer())
-       myAttribyteFilter->UnRegisterAllOutputs();
-    }
+    //! To get assigned values first by Gauss Points and then by components (constant version)
+    TCValueSliceArr
+    GetGaussValueSliceArr(vtkIdType theElemId) const;
+
+    //! To get assigned values first by Gauss Points and then by components
+    TValueSliceArr 
+    GetGaussValueSliceArr(vtkIdType theElemId);
+
+    //! To get assigned values first by components and then by Gauss Points (constant version)
+    TCValueSliceArr
+    GetCompValueSliceArr(vtkIdType theElemId) const;
+
+    //! To get assigned values first by components and then by Gauss Points
+    TValueSliceArr 
+    GetCompValueSliceArr(vtkIdType theElemId);
   };
-  typedef shared_ptr<TValForTimeImpl> PValForTimeImpl;
+  
 
+  //---------------------------------------------------------------
+  typedef std::map<EGeometry,TMeshValue> TGeom2Value;
+  typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
+
+  //! Specialize TValForTime to provide VTK mapping for the entity
+  struct TValForTimeImpl: virtual TValForTime
+  {
+    PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
+    PIDMapperFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data
+    TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
+    TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
+   
+    TValForTimeImpl();
+
+    //! Get mesh data for defined geometrical type (constant version)
+    const TMeshValue& 
+    GetMeshValue(EGeometry theGeom) const;
+
+    //! Get mesh data for defined geometrical type
+    TMeshValue& 
+    GetMeshValue(EGeometry theGeom);
+
+    //! Get number of Gauss Points for defined geometrical type
+    virtual
+    int
+    GetNbGauss(EGeometry theGeom) const;
+  };
+  typedef SharedPtr<TValForTimeImpl> PValForTimeImpl;
 }
 
-class VISU_Convertor_impl: public VISU_Convertor{
+
+//! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation
+/*!
+  It implements VISU_Convertor public interface and declare new pure virtual functions
+  to fill its intermediate data structure from a MED source
+*/
+class VISU_Convertor_impl: public VISU_Convertor
+{
 public:
-  virtual float GetSize() ;
+  VISU_Convertor_impl();
 
+  virtual
+  ~VISU_Convertor_impl();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  Build();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildEntities();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildFields();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildMinMax();
+
+  //! Just to define default behaviour
+  virtual
+  VISU_Convertor* 
+  BuildGroups();
+
+  //! Implemention of the VISU_Convertor::GetSize
+  virtual 
+  float
+  GetSize();
+
+  //! Implemention of the VISU_Convertor::GetMeshOnEntity
+  virtual 
+  VISU::PNamedIDMapper 
+  GetMeshOnEntity(const std::string& theMeshName, 
+                 const VISU::TEntity& theEntity);
+
+  //! Implemention of the VISU_Convertor::GetMeshOnEntitySize
   virtual 
   float 
   GetMeshOnEntitySize(const std::string& theMeshName, 
-                     const VISU::TEntity& theEntity,
-                     const std::string& theFamilyName = "");
+                      const VISU::TEntity& theEntity);
+
+  //! Implemention of the VISU_Convertor::GetFamilyOnEntity
+  virtual 
+  VISU::PIDMapper 
+  GetFamilyOnEntity(const std::string& theMeshName, 
+                   const VISU::TEntity& theEntity,
+                   const std::string& theFamilyName);
 
+  //! Implemention of the VISU_Convertor::GetFamilyOnEntitySize
+  virtual 
+  float 
+  GetFamilyOnEntitySize(const std::string& theMeshName, 
+                       const VISU::TEntity& theEntity,
+                       const std::string& theFamilyName);
+
+  //! Implemention of the VISU_Convertor::GetMeshOnGroup
+  virtual 
+  VISU::PIDMapper 
+  GetMeshOnGroup(const std::string& theMeshName, 
+                const std::string& theGroupName);
+  
+  //! Implemention of the VISU_Convertor::GetMeshOnGroupSize
   virtual 
   float 
   GetMeshOnGroupSize(const std::string& theMeshName, 
                     const std::string& theGroupName);
 
+  //! Implemention of the VISU_Convertor::GetTimeStampOnMesh
+  virtual
+  VISU::PIDMapper 
+  GetTimeStampOnMesh(const std::string& theMeshName, 
+                    const VISU::TEntity& theEntity,
+                    const std::string& theFieldName,
+                    int theStampsNum);
+
+  //! Implemention of the VISU_Convertor::GetTimeStampSize
   virtual 
   float 
   GetTimeStampSize(const std::string& theMeshName, 
@@ -123,18 +870,29 @@ public:
                   const std::string& theFieldName,
                   int theStampsNum);
 
+  //! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts
+  virtual
+  VISU::PGaussPtsIDMapper 
+  GetTimeStampOnGaussPts(const std::string& theMeshName, 
+                        const VISU::TEntity& theEntity,
+                        const std::string& theFieldName,
+                        int theStampsNum);
+  
+  //! Implemention of the VISU_Convertor::GetFieldOnMeshSize
   virtual 
   float 
   GetFieldOnMeshSize(const std::string& theMeshName, 
                     const VISU::TEntity& theEntity,
                     const std::string& theFieldName);
 
+  //! Implemention of the VISU_Convertor::GetField
   virtual 
   const VISU::PField 
   GetField(const std::string& theMeshName, 
           VISU::TEntity theEntity, 
           const std::string& theFieldName);
 
+  //! Implemention of the VISU_Convertor::GetTimeStamp
   virtual 
   const VISU::PValForTime 
   GetTimeStamp(const std::string& theMeshName, 
@@ -142,46 +900,31 @@ public:
               const std::string& theFieldName,
               int theStampsNum);
 
-public:
-  VISU_Convertor_impl();
-
-  virtual ~VISU_Convertor_impl();
-
-  virtual VISU_Convertor* Build()  { return this;};
-
-  virtual 
-  TOutput* 
-  GetMeshOnEntity(const std::string& theMeshName, 
-                 const VISU::TEntity& theEntity,
-                 const std::string& theFamilyName = "");
-
-  virtual 
-  TOutput* 
-  GetMeshOnGroup(const std::string& theMeshName, 
-                const std::string& theGroupName);
-  
-  virtual
-  TOutput* 
-  GetTimeStampOnMesh(const std::string& theMeshName, 
-                    const VISU::TEntity& theEntity,
-                    const std::string& theFieldName,
-                    int theStampsNum);
-
 protected:
+  //! An utility method to find TMesh by its name
   VISU::PMeshImpl 
   FindMesh(const std::string& theMeshName);
 
-  typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindMeshOnEntity;
+  //! An utility method to find TMeshOnEntity by name of its parent mesh and entity
+  typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
   TFindMeshOnEntity
   FindMeshOnEntity(const std::string& theMeshName,
-                  const VISU::TEntity& theEntity,
-                  const std::string& theFamilyName);
+                  const VISU::TEntity& theEntity);
 
+  //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
+  typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
+  TFindFamilyOnEntity
+  FindFamilyOnEntity(const std::string& theMeshName,
+                   const VISU::TEntity& theEntity,
+                   const std::string& theFamilyName);
+
+  //! An utility method to find Group by name of its parent mesh and its name
   typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
   TFindMeshOnGroup
   FindMeshOnGroup(const std::string& theMeshName, 
                  const std::string& theGroupName);
 
+  //! An utility method to find TField by name of its parent mesh, corresponding entity and its name
   typedef boost::tuple<VISU::PMeshImpl,
                       VISU::PMeshOnEntityImpl,
                       VISU::PMeshOnEntityImpl,
@@ -191,6 +934,7 @@ protected:
            const VISU::TEntity& theEntity, 
            const std::string& theFieldName);
 
+  //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number
   typedef boost::tuple<VISU::PMeshImpl,
                       VISU::PMeshOnEntityImpl,
                       VISU::PMeshOnEntityImpl,
@@ -201,18 +945,51 @@ protected:
                const VISU::TEntity& theEntity, 
                const std::string& theFieldName, 
                int theStampsNum);
+
+  VISU::TVTKOutput*
+  GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
+                       const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+                       const VISU::PFieldImpl& theField,
+                       const VISU::PValForTimeImpl& theValForTime,
+                       const VISU::PIDMapperFilter& theIDMapperFilter,
+                       const VISU::PProfileImpl& theProfile,
+                       const VISU::TEntity& theEntity);
   
 protected:
-  virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, 
-                              const std::string& theFamilyName = "") = 0;
+  //! To fill intermeiate representation of TMeshOnEntity from a MED source
+  virtual
+  int
+  LoadMeshOnEntity(VISU::PMeshImpl theMesh,
+                  VISU::PMeshOnEntityImpl theMeshOnEntity) = 0;
 
-  virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
-                             const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0;
+  //! To fill intermeiate representation of TFamily from a MED source
+  virtual
+  int
+  LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
+                    VISU::PMeshOnEntityImpl theMeshOnEntity, 
+                    VISU::PFamilyImpl theFamily) = 0;
 
-  virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, 
-                             VISU::PMeshOnEntityImpl theMeshOnEntity, 
-                             VISU::PFieldImpl theField, 
-                             VISU::PValForTimeImpl theValForTime) = 0;
+  //! To fill intermeiate representation of TGroup from a MED source
+  virtual 
+  int
+  LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
+                 const VISU::TFamilySet& theFamilySet) = 0;
+
+  //! To fill intermeiate representation of TValForTime for ordinary mesh from a MED source
+  virtual 
+  int
+  LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
+                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
+                      VISU::PFieldImpl theField, 
+                      VISU::PValForTimeImpl theValForTime) = 0;
+
+  //! To fill intermeiate representation of TValForTime for mesh on Gauss Points from a MED source
+  virtual 
+  int
+  LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
+                          VISU::PMeshOnEntityImpl theMeshOnEntity, 
+                          VISU::PFieldImpl theField, 
+                          VISU::PValForTimeImpl theValForTime) = 0;
 };
 
 #endif