Salome HOME
Fix of 0021175: EDF 1692 VISU: Scalar bar range is not good.
[modules/visu.git] / src / CONVERTOR / VISU_Structures_impl.hxx
index 71b078b873dba68a9369e127802effa8cd033496..5ae6a2f5f1abcf180918b879acd17df2fb5a5f7a 100644 (file)
@@ -1,29 +1,29 @@
-//  
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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.
 //
+//  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
+//
+
 //  File   : 
 //  Author : Alexey PETROV
 //  Module : VISU
-
+//
 #ifndef VISU_Structures_impl_HeaderFile
 #define VISU_Structures_impl_HeaderFile
 
@@ -103,7 +103,7 @@ namespace VISU
   //---------------------------------------------------------------
   //! Define an intermediate class which unifies memory size calculation
   struct VISU_CONVERTOR_EXPORT TMemoryCheckIDMapper: public virtual TIsVTKDone,
-                              public virtual TIDMapper
+                               public virtual TIDMapper
   {
     //! Gets memory size used by the instance (bytes).
     virtual
@@ -137,36 +137,6 @@ namespace VISU
   /*!
     This container allow to combine other VTK representation into single one.
   */
-  class VISU_CONVERTOR_EXPORT TCommonCellsFilterHolder: public virtual TMemoryCheckIDMapper
-  {
-  protected:
-    mutable PCommonCellsFilter myFilter;
-    mutable PMergeFilter myMergeFilter;
-  public:
-    TCommonCellsFilterHolder();
-
-    //! This method allow to create corresponding VTK filter by demand (not at once)
-    const PCommonCellsFilter& 
-    GetFilter() const;
-
-    //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
-    virtual
-    vtkUnstructuredGrid* 
-    GetUnstructuredGridOutput();
-
-    virtual
-    unsigned long int
-    GetMemorySize();
-
-    //! if false, TIDCommonCellsFilter - same as TIDMapperFilter
-    //! if true, TIDCommonCellsFilter - use VISU_CommonCellsFilter
-    bool myIsSpecialKey;
-
-    //! Vector of id mappers, which consist of meshonentity in next sequence:
-    //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
-    PNamedIDMapperMap myMappers;
-  };
-
   //---------------------------------------------------------------
   //! Define a container for VTK representation
   /*!
@@ -216,7 +186,7 @@ namespace VISU
   //---------------------------------------------------------------
   //! Specialize TMesh to provide VTK mapping for nodes
   struct VISU_CONVERTOR_EXPORT TMeshImpl: virtual TMesh, 
-                   virtual TIsVTKDone
+                    virtual TIsVTKDone
   {
     PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
     vtkIdType myNbPoints; //!< Keeps number of the nodes
@@ -240,7 +210,7 @@ namespace VISU
 
   //! Specialize TSubProfile to provide VTK mapping
   struct VISU_CONVERTOR_EXPORT TSubProfileImpl: virtual TSubProfile, 
-                         virtual TUnstructuredGridHolder
+                          virtual TUnstructuredGridHolder
   {
     TSubProfileImpl();
 
@@ -250,12 +220,18 @@ namespace VISU
     //! Get object number of mesh cell by its VTK one
     virtual 
     vtkIdType 
-    GetElemObjID(int theVtkI) const;
+    GetElemObjID(vtkIdType theVtkI) const;
 
     //! Get cell VTK ID for corresponding object ID
     virtual
     vtkIdType 
     GetElemVTKID(vtkIdType theID) const;
+    
+    //! Return true in case if it is default profile,
+    //! i.e myName == "" (MED_NOPFL, see med.h)
+    virtual
+    bool 
+    isDefault() const;
 
     //! Gets memory size used by the instance (bytes).
     virtual
@@ -279,7 +255,7 @@ namespace VISU
 
   //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
   struct VISU_CONVERTOR_EXPORT TProfileImpl: virtual TProfile, 
-                      virtual TAppendFilterHolder
+                       virtual TAppendFilterHolder
   {
     TProfileImpl();
     bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
@@ -346,11 +322,10 @@ namespace VISU
   //---------------------------------------------------------------
   //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
   struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder,
-                                       virtual TUnstructuredGridIDMapper
+                                        virtual TUnstructuredGridIDMapper
   {
-    PAppendFilterHolder       myIDMapper; //!< Responsible for numbering
-    PCommonCellsFilter        myCommonCellsFilter;
-    TUnstructuredGridHolder   mySource; //!< Keeps assigned data
+    PAppendFilterHolder myIDMapper; //!< Responsible for numbering
+    PCommonCellsFilter myCommonCellsFilter;
 
     TUnstructuredGridIDMapperImpl();
     
@@ -399,22 +374,24 @@ namespace VISU
     unsigned long int
     GetMemorySize();
     
-    //! if false, Not using CommonCellsFilter
-    //! if true,  Using CommonCellsFilter
-    bool myIsSpecialKey;
+    void 
+    SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper );
+
+    PUnstructuredGrid 
+    GetSource();
 
-    //! Vector of id mappers, which consist of meshonentity in next sequence:
-    //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
-    PNamedIDMapperMap myMappers;
+  protected:
+    void Build();
+
+    TUnstructuredGridHolder mySource; //!< Keeps assigned data
   };
 
   //---------------------------------------------------------------
   //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
   struct TPolyDataIDMapperImpl: virtual TMergeFilterHolder,
-                               virtual TPolyDataIDMapper
+                                virtual TPolyDataIDMapper
   {
     PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering
-    TPolyDataHolder mySource; //!< Keeps assigned data
 
     //! Reimplement the TIDMapper::GetNodeObjID
     virtual 
@@ -460,6 +437,14 @@ namespace VISU
     virtual
     unsigned long int
     GetMemorySize();
+
+    PPolyData 
+    GetSource();
+
+  protected:
+    void Build();
+
+    TPolyDataHolder mySource; //!< Keeps assigned data
   };
 
 
@@ -477,14 +462,14 @@ namespace VISU
     virtual
     void
     LessThan(const PGaussImpl& theGauss,
-            bool& theResult) const;
+             bool& theResult) const;
   };
 
 
   //---------------------------------------------------------------
   //! Specialize TGaussSubMesh to provide VTK mapping for the entity
   struct VISU_CONVERTOR_EXPORT TGaussSubMeshImpl: virtual TGaussSubMesh, 
-                           virtual TPolyDataHolder
+                            virtual TPolyDataHolder
   {
     TGaussSubMeshImpl();
 
@@ -535,7 +520,7 @@ namespace VISU
 
   //! Specialize TGaussMesh to provide VTK mapping for the entity
   struct VISU_CONVERTOR_EXPORT TGaussMeshImpl: virtual TGaussMesh, 
-                        virtual TAppendPolyDataHolder
+                         virtual TAppendPolyDataHolder
   {
     TGaussMeshImpl();
 
@@ -573,7 +558,7 @@ namespace VISU
   //---------------------------------------------------------------
   //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
   struct VISU_CONVERTOR_EXPORT TGaussPtsIDFilter: virtual TPolyDataIDMapperImpl,
-                           virtual TGaussPtsIDMapper
+                            virtual TGaussPtsIDMapper
   { 
     PGaussPtsIDMapper myGaussPtsIDMapper;
 
@@ -588,6 +573,7 @@ namespace VISU
     GetVTKID(const TGaussPointID& theID) const;
 
     //! Reimplements the TGaussPtsIDMapper::GetParent
+    //! Reimplement the TGaussPtsIDMapper::GetParent
     virtual 
     TNamedIDMapper*
     GetParent() const;
@@ -613,6 +599,11 @@ namespace VISU
   {
     TSubMeshImpl();
 
+    //! Reimplements the TStructured::CopyStructure
+    virtual
+    void
+    CopyStructure( PStructured theStructured );
+
     //! To implement the TIDMapper::GetElemObjID
     virtual 
     vtkIdType 
@@ -639,11 +630,16 @@ namespace VISU
 
   //! Specialize TMeshOnEntity to provide VTK mapping for the entity
   struct VISU_CONVERTOR_EXPORT TMeshOnEntityImpl: virtual TMeshOnEntity, 
-                           virtual TAppendFilterHolder, 
-                           virtual TSizeCounter
+                            virtual TAppendFilterHolder, 
+                            virtual TSizeCounter
   {
     TMeshOnEntityImpl();
 
+    //! Reimplements the TStructured::CopyStructure
+    virtual
+    void
+    CopyStructure( PStructured theStructured );
+
     //! Reimplement the TIDMapper::GetNodeVTKID
     virtual 
     vtkIdType 
@@ -697,8 +693,13 @@ namespace VISU
 
   //! Specialize TFamily to provide VTK mapping for the entity
   struct VISU_CONVERTOR_EXPORT TFamilyImpl: virtual TFamily, 
-                     virtual TUnstructuredGridHolder
+                      virtual TUnstructuredGridHolder
   {
+    //! Reimplements the TStructured::CopyStructure
+    virtual
+    void
+    CopyStructure( PStructured theStructured );
+
     //! Reimplement the TIDMapper::GetNodeObjID
     vtkIdType 
     GetNodeObjID(vtkIdType theID) const ;
@@ -733,6 +734,8 @@ namespace VISU
     TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
 
     TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
+
+    TNames myGroupNames; //!< Keeps names of groups that refer to the family
   };
 
 
@@ -742,8 +745,13 @@ namespace VISU
 
   //! Specialize TGroup to provide VTK mapping for the entity
   struct VISU_CONVERTOR_EXPORT TGroupImpl: virtual TGroup, 
-                    virtual TAppendFilterHolder
+                     virtual TAppendFilterHolder
   {
+    //! Reimplements the TStructured::CopyStructure
+    virtual
+    void
+    CopyStructure( PStructured theStructured );
+
     //! Calculate pair of values - number of cells and its size
     TNbASizeCells 
     GetNbASizeCells() const;
@@ -785,7 +793,12 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  typedef TVector<TMinMax> TMinMaxArr;
+  typedef            TVector<TMinMax>              TComp2MinMax;
+  typedef       TVector<TComp2MinMax>       TMetric2Comp2MinMax;
+
+  typedef     std::map<TName,TMinMax>             TGroup2MinMax;
+  typedef      TVector<TGroup2MinMax>        TComp2Group2MinMax;
+  typedef TVector<TComp2Group2MinMax> TMetric2Comp2Group2MinMax;
 
   //! Specialize TField to provide VTK mapping for the entity
   struct VISU_CONVERTOR_EXPORT TFieldImpl: virtual TField
@@ -795,7 +808,7 @@ namespace VISU
     //! To initialize the data structure    
     void 
     Init(vtkIdType theNbComp,
-        vtkIdType theDataType);
+         vtkIdType theDataType);
 
     //! Gets type idetificator of the mesh data.
     vtkIdType
@@ -804,11 +817,21 @@ namespace VISU
     //! Implement the TField::GetMinMax
     virtual
     TMinMax 
-    GetMinMax(vtkIdType theCompID);
+    GetMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric = VISU::AVERAGE_METRIC);
+
+    //! Implement the TField::GetAverageMinMax
+    virtual
+    TMinMax 
+    GetAverageMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric = VISU::AVERAGE_METRIC);
 
     vtkIdType myDataSize; //!< Keeps size of the assigned data
     vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
-    TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
+    TMetric2Comp2MinMax myMetric2Comp2MinMax; //!< Keeps min/max values for each component of the MED FIELD
+    TMetric2Comp2MinMax myMetric2Comp2AverageMinMax; //!< Keeps average by Gauss Points min/max values for each component of the MED FIELD
+                                                     //!< If Nb of Gauss Points <=1 myAverageMinMaxArr equal myMinMaxArr
+
+    TMetric2Comp2Group2MinMax myMetric2Comp2Group2MinMax;
+    TMetric2Comp2Group2MinMax myMetric2Comp2Group2AverageMinMax;
   };
 
 
@@ -852,6 +875,7 @@ namespace VISU
     PUnstructuredGridIDMapperImpl myUnstructuredGridIDMapper; //!< 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
+    bool myIsFilled;              //!< Keep the status of the TValForTime (true - already filled, false - not filled);
    
     TValForTimeImpl();
 
@@ -878,6 +902,11 @@ namespace VISU
     int
     GetNbGauss(EGeometry theGeom) const;
 
+    //! Get maximum number of Gauss Points among all geometrical types (provided for convenience)
+    virtual
+    int
+    GetMaxNbGauss() const;
+
     //! Gets memory size used by the instance (bytes).
     virtual
     unsigned long int