Salome HOME
Fix of 0021175: EDF 1692 VISU: Scalar bar range is not good.
[modules/visu.git] / src / CONVERTOR / VISU_Convertor.hxx
index 4a5ac9938b7fbae890518416cf237ed3be38c058..99e778c587ce2994076116b7ac3de80ecee3c005 100644 (file)
-//  VISU CONVERTOR :
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  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.
 //
-//  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 
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  VISU CONVERTOR :
 //  File   : VISU_Convertor.hxx
 //  Author : Alexey PETROV
 //  Module : VISU
-
+//
 #ifndef VISU_Convertor_HeaderFile
 #define VISU_Convertor_HeaderFile
 
 /*! 
   \file VISU_Convertor.hxx
-  \brief The file contains definitions for basic classes of the VISU CONVERTER package
+  \brief The file represents definition of basic interface of the VISU CONVERTER package
 */
 
-#include "VISU_IDMapper.hxx"
-#include "VISU_ConvertorDef.hxx"
-
-#include "MED_Vector.hxx"
-
-#include <map>
-#include <set>
-#include <utility>
-#include <string>
-#include <stdexcept>
-
-namespace VISU
-{
-  using MED::TVector;
-
-  //---------------------------------------------------------------
-  typedef std::string TName;
-
-  typedef TVector<TName> TNames;
-
-  //---------------------------------------------------------------
-  //! Define a basic class for all MED entites which can be identified by its number
-  struct TIntId: virtual TBaseStructure
-  {
-    vtkIdType myId;
-
-    TIntId(): myId(0)
-    {}
-  };
-
-
-  //---------------------------------------------------------------
-  typedef std::map<TEntity,PMeshOnEntity> TMeshOnEntityMap;
-  typedef std::map<TName,PGroup> TGroupMap;
-
-  //! Define a basic class which corresponds to MED MESH entity
-  /*!
-    This class in its turn contains map of TMeshOnEntity and TGroup substructures,
-    also it keeps name and dimention of corresponding MED MESH entity.
-  */
-  struct TMesh: virtual TBaseStructure
-  {
-    TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES
-    TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS
-    TName myName; //! Name of the corresponding MED MESH
-    int myDim; //! Dimension of the corresponding MED MESH
-
-    TMesh(): myDim(0)
-    {}
-  };
-  typedef std::map<std::string,PMesh> TMeshMap;
-
-
-  //---------------------------------------------------------------
-  //! Define a basic class which corresponds to MED PROFILE entity
-  struct TSubProfile: virtual TBaseStructure
-  {};
-
-
-  //---------------------------------------------------------------
-  //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY
-  struct TProfile: virtual TNamedIDMapper
-  {};
-
-
-  //---------------------------------------------------------------
-  bool
-  operator<(const PSubProfile& theLeft, const PSubProfile& theRight);
-
-  typedef std::set<PSubProfile> TProfileKey;
-  typedef std::map<TProfileKey,PProfile> TProfileMap;
-
-
-  //---------------------------------------------------------------
-  //! Define a basic class for MED GAUSS entity
-  struct TGauss: virtual TBaseStructure
-  {};
-
-
-  //---------------------------------------------------------------
-  //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE
-  struct TGaussSubMesh: virtual TBaseStructure
-  {
-    PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located
-  };
-
-  
-  //---------------------------------------------------------------
-  //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY
-  struct TGaussMesh: virtual TGaussPtsIDMapper
-  {};
-
-
-  //---------------------------------------------------------------
-  bool
-  operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight);
-
-  typedef std::set<PGaussSubMesh> TGaussKey;
-  typedef std::map<TGaussKey,PGaussMesh> TGaussMeshMap;
-
-
-  //---------------------------------------------------------------
-
-  typedef std::map<TName,PFamily> TFamilyMap;
-  typedef std::map<TName,PField> TFieldMap;
-
-  //! Define a basic class which corresponds to MED ENTITY
-  /*!
-    This class in its turn contains map of TGaussMesh and TProfile substructures,
-    also it keeps corresponding map of MED FAMILIES and FIELDS.
-  */
-  struct TMeshOnEntity: virtual TNamedIDMapper
-  {
-    TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it
-    TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it
-
-    TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it
-    TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it
-
-    TName myMeshName; //!< Contains name of the MED MESH where the it belongs to.
-    TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to.
-  };
-
-
-  //---------------------------------------------------------------
-  //! Define a basic class for MED FAMILY entity
-  struct TFamily: virtual TIntId,
-                 virtual TIDMapper
-  {
-    TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to.
-    TName myName; //!< Contains name of the corresponding MED FAMILY
-  };
-
-
-  //---------------------------------------------------------------
-  typedef std::set<PFamily> TFamilySet;
-
-  //! Define a basic class for MED GROUP entity
-  struct TGroup: virtual TIDMapper
-  {
-    TFamilySet myFamilySet;
-  };
-
-
-  //---------------------------------------------------------------
-  typedef std::map<vtkIdType,PValForTime> TValField;
-  typedef std::pair<float,float> TMinMax;
-
-  //! Define a basic class for MED FIELD entity
-  struct TField: virtual TIntId
-  {
-    TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
-    TName myName; //!< Contains name of the corresponding MED FIELD
-    TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
-    TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS
-    TNames myCompNames; //!< Contains names of components of the MED FIELD
-    TNames myUnitNames; //!< Contains names of units of the MED FIELD
-    vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD
-
-    //! Calculate min/max values for each of the MED FIELD components among all its timestamps
-    /*!
-      Numeration of the components starts from 1.
-      Zero component contains min/max value for modulus of corresponding vector
-    */
-    virtual
-    TMinMax 
-    GetMinMax(vtkIdType theCompID) = 0;
-    
-    bool myIsMinMaxInitilized; //!< Is the min / max values are calculated
-
-    TField(): 
-      myNbComp(0),
-      myIsMinMaxInitilized(false)
-    {}
-  };
-
-  //---------------------------------------------------------------
-  typedef std::pair<double,std::string> TTime;
-
-  //! Define a basic class for MED TIMESTAMP entity
-  struct TValForTime: virtual TIntId
-  {
-    TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
-    TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
-    TName myFieldName; //!< Contains name of the MED FIELD where it belongs to.
-    TTime myTime;
-
-    PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to
-    PGaussMesh myGaussMesh;
-  };
-
-
-  //---------------------------------------------------------------
-  //! The utility function allows to write vtkUnstructuredGrid to a file with defined name
-  void 
-  WriteToFile(vtkUnstructuredGrid* theDataSet, 
-             const std::string& theFileName);
-};
+#include "VISU_Structures.hxx"
 
 
 //---------------------------------------------------------------
@@ -246,32 +49,19 @@ namespace VISU
   1. Perfrom parsing of MED file to get known what MED entities are pressent in it
   2. Get VTK representation for any existing MED entity
   Also, it can perform some additional work to calculate expected amount of memory to build defined VTK representation
-  
 */
-class VISU_Convertor
+class VISU_CONVERTOR_EXPORT VISU_Convertor
 {
-protected:
-  std::string myName;
-  VISU::TMeshMap myMeshMap;
-  int myIsDone;
-
 public:
-  virtual 
-  ~VISU_Convertor()
-  {};
-  
   //! Get brief name of the corresponding source MED file
   virtual
   const std::string& 
-  GetName(){ return myName;}
+  GetName();
 
   //! Let known whether the source MED file parsed or not
   virtual
   int
-  IsDone() const { return myIsDone; }
-
-  //! Defines what subtype of vtkDataSet is used for MED to VTK mapping
-  typedef VISU::TVTKOutput TOutput;
+  IsDone() const;
 
   //! This method perform first parsing of MED file to get known what MED entities are pressent in it
   virtual
@@ -305,92 +95,102 @@ public:
 
   //! Get amount of memory to build VTK representations for all existing MED entities
   virtual
-  float
+  size_t
   GetSize() = 0;
 
   //! Get mesh for corresponding MED ENTITY
   virtual
   VISU::PNamedIDMapper 
   GetMeshOnEntity(const std::string& theMeshName, 
-                 const VISU::TEntity& theEntity) = 0;
+                  const VISU::TEntity& theEntity) = 0;
   
   //! Get amount of memory to build mesh for corresponding MED ENTITY
   virtual
-  float
+  size_t
   GetMeshOnEntitySize(const std::string& theMeshName, 
-                     const VISU::TEntity& theEntity) = 0;
+                      const VISU::TEntity& theEntity) = 0;
   
   //! Get mesh for corresponding MED FAMILY
   virtual 
-  VISU::PIDMapper 
+  VISU::PUnstructuredGridIDMapper 
   GetFamilyOnEntity(const std::string& theMeshName, 
-                   const VISU::TEntity& theEntity,
-                   const std::string& theFamilyName) = 0;
+                    const VISU::TEntity& theEntity,
+                    const std::string& theFamilyName) = 0;
 
   //! Get amount of memory to build mesh for corresponding MED FAMILY
   virtual 
-  floa
+  size_
   GetFamilyOnEntitySize(const std::string& theMeshName, 
-                       const VISU::TEntity& theEntity,
-                       const std::string& theFamilyName) = 0;
+                        const VISU::TEntity& theEntity,
+                        const std::string& theFamilyName) = 0;
 
   //! Get mesh for corresponding MED GROUP
   virtual
-  VISU::PIDMapper
+  VISU::PUnstructuredGridIDMapper
   GetMeshOnGroup(const std::string& theMeshName, 
-                const std::string& theGroupName) = 0;
+                 const std::string& theGroupName) = 0;
   
   //! Get amount of memory to build mesh for corresponding MED GROUP
   virtual
-  float
+  size_t
   GetMeshOnGroupSize(const std::string& theMeshName, 
-                    const std::string& theGroupName) = 0;
+                     const std::string& theGroupName) = 0;
   
   //! Get mesh with attached values for corresponding MED TIMESTAMP
   virtual
-  VISU::PIDMapper 
+  VISU::PUnstructuredGridIDMapper 
   GetTimeStampOnMesh(const std::string& theMeshName, 
-                    const VISU::TEntity& theEntity,
-                    const std::string& theFieldName,
-                    int theStampsNum) = 0;
+                     const VISU::TEntity& theEntity,
+                     const std::string& theFieldName,
+                     int theTimeStampNumber) = 0;
 
   //! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP
   virtual
   VISU::PGaussPtsIDMapper 
   GetTimeStampOnGaussPts(const std::string& theMeshName, 
-                        const VISU::TEntity& theEntity,
-                        const std::string& theFieldName,
-                        int theStampsNum) = 0;
+                         const VISU::TEntity& theEntity,
+                         const std::string& theFieldName,
+                         int theTimeStampNumber) = 0;
    
-  //! Get amount of memory to build mesh for corresponding MED TIMESTAMP
+  //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh
   virtual 
-  float
-  GetTimeStampSize(const std::string& theMeshName, 
-                  const VISU::TEntity& theEntity,
-                  const std::string& theFieldName,
-                  int theStampsNum) = 0;
+  size_t
+  GetTimeStampOnMeshSize(const std::string& theMeshName, 
+                         const VISU::TEntity& theEntity,
+                         const std::string& theFieldName,
+                         int theTimeStampNumber,
+                         bool& theIsEstimated) = 0;
+    
+  //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on Gauss Points
+  virtual 
+  size_t
+  GetTimeStampOnGaussPtsSize(const std::string& theMeshName, 
+                             const VISU::TEntity& theEntity,
+                             const std::string& theFieldName,
+                             int theTimeStampNumber,
+                             bool& theIsEstimated) = 0;
     
   //! Get amount of memory to build all MED TIMESTAMPS for corresponding MED FIELD
   virtual 
-  float
+  size_t
   GetFieldOnMeshSize(const std::string& theMeshName, 
-                    const VISU::TEntity& theEntity,
-                    const std::string& theFieldName) = 0;
+                     const VISU::TEntity& theEntity,
+                     const std::string& theFieldName) = 0;
   
   //! Find MED FIELD container
   virtual
   const VISU::PField 
   GetField(const std::string& theMeshName, 
-          VISU::TEntity theEntity, 
-          const std::string& theFieldName) = 0;
+           VISU::TEntity theEntity, 
+           const std::string& theFieldName) = 0;
   
   //! Find MED TIMESTAMP container
   virtual
   const VISU::PValForTime 
   GetTimeStamp(const std::string& theMeshName, 
-              const VISU::TEntity& theEntity,
-              const std::string& theFieldName,
-              int theStampsNum) = 0;
+               const VISU::TEntity& theEntity,
+               const std::string& theFieldName,
+               int theTimeStampNumber) = 0;
     
   //! Allow to generate pretty name for MED TIMESTAMP
   static 
@@ -400,12 +200,20 @@ public:
   static 
   std::string 
   GenerateName(const std::string& theName, unsigned int theTimeId);
+
+protected:
+  VISU_Convertor();
+  
+  std::string myName;
+  VISU::TMeshMap myMeshMap;
+  int myIsDone;
 };
 
 extern "C"
 {
   //! Instatiate proper VISU_Convertor subclass
-  VISU_Convertor* 
+  VISU_CONVERTOR_EXPORT
+  VISU_Convertor*
   CreateConvertor(const std::string& theFileName);
 };