Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / CONVERTOR / VISU_Structures_impl.cxx
index a00e8e90930efc9e23327189fc558fd6846ee4c1..a0c1012b66523b3498974573bcd694152465c256 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.
 //
-//  File:    
+//  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
-
+//
 #include "VISU_Structures_impl.hxx"
 #include "VISU_PointCoords.hxx"
 #include "VISU_MeshValue.hxx"
@@ -44,26 +44,26 @@ namespace VISU
 {
   /*  vtkIdType
   VISUGeom2NbNodes(EGeometry theGeom)
-  { 
+  {
     switch(theGeom){
 #ifndef VISU_ENABLE_QUADRATIC
-    case VISU::eSEG3: 
+    case VISU::eSEG3:
       return 2;
-    case VISU::eTRIA6: 
+    case VISU::eTRIA6:
       return 3;
-    case VISU::eQUAD8: 
+    case VISU::eQUAD8:
       return 4;
-    case VISU::eTETRA10: 
+    case VISU::eTETRA10:
       return 4;
-    case VISU::eHEXA20: 
+    case VISU::eHEXA20:
       return 8;
-    case VISU::ePENTA15: 
+    case VISU::ePENTA15:
       return 6;
-    case VISU::ePYRA13: 
+    case VISU::ePYRA13:
       return 5;
 #endif
-    case VISU::ePOLYGONE: 
-    case VISU::ePOLYEDRE: 
+    case VISU::ePOLYGONE:
+    case VISU::ePOLYEDRE:
       return -1;
     default:
       return theGeom % 100;
@@ -72,91 +72,91 @@ namespace VISU
 
   vtkIdType
   VISUGeom2VTK(EGeometry theGeom)
-  { 
+  {
     switch(theGeom){
-    case VISU::ePOINT1: 
+    case VISU::ePOINT1:
       return VTK_VERTEX;
-    case VISU::eSEG2: 
+    case VISU::eSEG2:
       return VTK_LINE;
-    case VISU::eTRIA3: 
+    case VISU::eTRIA3:
       return VTK_TRIANGLE;
-    case VISU::eQUAD4: 
+    case VISU::eQUAD4:
       return VTK_QUAD;
-    case VISU::eTETRA4: 
+    case VISU::eTETRA4:
       return VTK_TETRA;
-    case VISU::eHEXA8: 
+    case VISU::eHEXA8:
       return VTK_HEXAHEDRON;
-    case VISU::ePENTA6: 
+    case VISU::ePENTA6:
       return VTK_WEDGE;
-    case VISU::ePYRA5: 
+    case VISU::ePYRA5:
       return VTK_PYRAMID;
 
-    case VISU::ePOLYGONE: 
+    case VISU::ePOLYGONE:
       return VTK_POLYGON;
-    case VISU::ePOLYEDRE: 
+    case VISU::ePOLYEDRE:
       return VTK_CONVEX_POINT_SET;
 
 #ifndef VISU_ENABLE_QUADRATIC
-    case VISU::eSEG3: 
+    case VISU::eSEG3:
       return VTK_LINE;
-    case VISU::eTRIA6: 
+    case VISU::eTRIA6:
       return VTK_TRIANGLE;
-    case VISU::eQUAD8: 
+    case VISU::eQUAD8:
       return VTK_QUAD;
-    case VISU::eTETRA10: 
+    case VISU::eTETRA10:
       return VTK_TETRA;
-    case VISU::eHEXA20: 
+    case VISU::eHEXA20:
       return VTK_HEXAHEDRON;
-    case VISU::ePENTA15: 
+    case VISU::ePENTA15:
       return VTK_WEDGE;
-    case VISU::ePYRA13: 
+    case VISU::ePYRA13:
       return VTK_PYRAMID;
 
 #else
 
-    case VISU::eSEG3: 
+    case VISU::eSEG3:
 #if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
       return VTK_QUADRATIC_EDGE;
 #else
       return VTK_POLY_LINE;
 #endif
 
-    case VISU::eTRIA6: 
+    case VISU::eTRIA6:
 #if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
       return VTK_QUADRATIC_TRIANGLE;
 #else
       return VTK_POLYGON;
 #endif
 
-    case VISU::eQUAD8: 
+    case VISU::eQUAD8:
 #if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
       return VTK_QUADRATIC_QUAD;
 #else
       return VTK_POLYGON;
 #endif
 
-    case VISU::eTETRA10: 
+    case VISU::eTETRA10:
 #if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
       return VTK_QUADRATIC_TETRA;
 #else
       return VTK_CONVEX_POINT_SET;
 #endif
 
-    case VISU::eHEXA20: 
+    case VISU::eHEXA20:
 #if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
       return VTK_QUADRATIC_HEXAHEDRON;
 #else
       return VTK_CONVEX_POINT_SET;
 #endif
 
-    case VISU::ePENTA15: 
+    case VISU::ePENTA15:
 #if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
       return VTK_QUADRATIC_WEDGE;
 #else
       return VTK_CONVEX_POINT_SET;
 #endif
 
-    case VISU::ePYRA13: 
+    case VISU::ePYRA13:
 #if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
       return VTK_QUADRATIC_PYRAMID;
 #else
@@ -173,63 +173,63 @@ namespace VISU
 
   EGeometry
   VTKGeom2VISU(vtkIdType theGeom)
-  { 
+  {
     switch(theGeom){
-    case VTK_VERTEX: 
+    case VTK_VERTEX:
       return VISU::ePOINT1;
-    case VTK_LINE: 
+    case VTK_LINE:
       return VISU::eSEG2;
-    case VTK_TRIANGLE: 
+    case VTK_TRIANGLE:
       return VISU::eTRIA3;
-    case VTK_QUAD: 
+    case VTK_QUAD:
       return VISU::eQUAD4;
-    case VTK_TETRA: 
+    case VTK_TETRA:
       return VISU::eTETRA4;
-    case VTK_HEXAHEDRON: 
+    case VTK_HEXAHEDRON:
       return VISU::eHEXA8;
-    case VTK_WEDGE: 
+    case VTK_WEDGE:
       return VISU::ePENTA6;
-    case VTK_PYRAMID: 
+    case VTK_PYRAMID:
       return VISU::ePYRA5;
 
-    case VTK_POLYGON: 
+    case VTK_POLYGON:
       return VISU::ePOLYGONE;
-    case VTK_CONVEX_POINT_SET: 
+    case VTK_CONVEX_POINT_SET:
       return VISU::ePOLYEDRE;
 
 #if defined(VISU_ENABLE_QUADRATIC) && defined(VISU_USE_VTK_QUADRATIC)
   #if defined(VTK_QUADRATIC_EDGE)
-    case VTK_QUADRATIC_EDGE: 
+    case VTK_QUADRATIC_EDGE:
       return VISU::eSEG3;
   #endif
 
   #if defined(VTK_QUADRATIC_TRIANGLE)
-    case VTK_QUADRATIC_TRIANGLE: 
+    case VTK_QUADRATIC_TRIANGLE:
       return VISU::eTRIA6;
   #endif
 
   #if defined(VTK_QUADRATIC_QUAD)
-    case VTK_QUADRATIC_QUAD: 
+    case VTK_QUADRATIC_QUAD:
       return VISU::eQUAD8;
   #endif
 
   #if defined(VTK_QUADRATIC_TETRA)
-    case VTK_QUADRATIC_TETRA: 
+    case VTK_QUADRATIC_TETRA:
       return VISU::eTETRA10;
   #endif
 
   #if defined(VTK_QUADRATIC_HEXAHEDRON)
-    case VTK_QUADRATIC_HEXAHEDRON: 
+    case VTK_QUADRATIC_HEXAHEDRON:
       return VISU::eHEXA20;
   #endif
 
   #if defined(VTK_QUADRATIC_WEDGE)
-    case VTK_QUADRATIC_WEDGE: 
+    case VTK_QUADRATIC_WEDGE:
       return VISU::ePENTA15;
   #endif
 
   #if defined(VTK_QUADRATIC_PYRAMID)
-    case VTK_QUADRATIC_PYRAMID: 
+    case VTK_QUADRATIC_PYRAMID:
       return VISU::ePYRA13;
   #endif
 
@@ -256,9 +256,9 @@ namespace VISU
    */
   size_t
   GetDataSetSize(size_t theNbOfPoints,
-                size_t theNbOfCells,
-                size_t theCellsSize,
-                bool theComputeLinks)
+                 size_t theNbOfCells,
+                 size_t theCellsSize,
+                 bool theComputeLinks)
   {
     size_t aPointsSize = 3*theNbOfPoints*sizeof(VISU::TCoord);
     size_t aConnectivityAndTypesSize = theCellsSize*sizeof(vtkIdType);
@@ -284,7 +284,7 @@ namespace VISU
   ::TPolyDataHolder()
   {}
 
-  const PPolyData& 
+  const PPolyData&
   TPolyDataHolder
   ::GetSource() const
   {
@@ -295,7 +295,7 @@ namespace VISU
     return mySource;
   }
 
-  vtkPolyData* 
+  vtkPolyData*
   TPolyDataHolder
   ::GetPolyDataOutput()
   {
@@ -323,7 +323,7 @@ namespace VISU
   ::TUnstructuredGridHolder()
   {}
 
-  const PUnstructuredGrid& 
+  const PUnstructuredGrid&
   TUnstructuredGridHolder
   ::GetSource() const
   {
@@ -334,7 +334,7 @@ namespace VISU
     return mySource;
   }
 
-  vtkUnstructuredGrid* 
+  vtkUnstructuredGrid*
   TUnstructuredGridHolder
   ::GetUnstructuredGridOutput()
   {
@@ -364,8 +364,8 @@ namespace VISU
   {
     if(myIsVTKDone){
       if(vtkDataSet* anOutput = GetOutput()){
-       anOutput->Update();
-       return anOutput->GetActualMemorySize() * 1024;
+        anOutput->Update();
+        return anOutput->GetActualMemorySize() * 1024;
       }
     }
     throw std::runtime_error("TMemoryCheckIDMapper::GetMemorySize - myIsVTKDone == false !!!");
@@ -378,7 +378,7 @@ namespace VISU
   ::TAppendFilterHolder()
   {}
 
-  const PAppendFilter& 
+  const PAppendFilter&
   TAppendFilterHolder
   ::GetFilter() const
   {
@@ -390,7 +390,7 @@ namespace VISU
     return myFilter;
   }
 
-  vtkUnstructuredGrid* 
+  vtkUnstructuredGrid*
   TAppendFilterHolder
   ::GetUnstructuredGridOutput()
   {
@@ -403,7 +403,7 @@ namespace VISU
   ::TAppendPolyDataHolder()
   {}
 
-  const PAppendPolyData& 
+  const PAppendPolyData&
   TAppendPolyDataHolder
   ::GetFilter() const
   {
@@ -415,7 +415,7 @@ namespace VISU
     return myFilter;
   }
 
-  vtkPolyData* 
+  vtkPolyData*
   TAppendPolyDataHolder
   ::GetPolyDataOutput()
   {
@@ -429,7 +429,7 @@ namespace VISU
   ::TMergeFilterHolder()
   {}
 
-  const PMergeFilter& 
+  const PMergeFilter&
   TMergeFilterHolder
   ::GetFilter() const
   {
@@ -440,7 +440,7 @@ namespace VISU
     return myFilter;
   }
 
-  vtkDataSet* 
+  vtkDataSet*
   TMergeFilterHolder
   ::GetOutput()
   {
@@ -451,7 +451,7 @@ namespace VISU
 
   //---------------------------------------------------------------
   TMeshImpl
-  ::TMeshImpl(): 
+  ::TMeshImpl():
     myNbPoints(0)
   {}
 
@@ -461,14 +461,14 @@ namespace VISU
   {
     return myNbPoints;
   }
-  
+
   vtkIdType
   TMeshImpl::
   GetDim() const
   {
     return myDim;
   }
-  
+
   vtkPointSet*
   TMeshImpl::
   GetPointSet()
@@ -490,7 +490,7 @@ namespace VISU
   {
     if ( !mySubMeshID.empty() )
       return mySubMeshID[theID];
-    
+
     return theID;
   }
 
@@ -500,9 +500,9 @@ namespace VISU
   ::GetElemVTKID(vtkIdType theID) const
   {
     if ( !mySubMeshID.empty() )
-      for ( size_t anId = 0; anId < mySubMeshID.size(); anId++ ) 
-       if ( mySubMeshID[ anId ] == theID ) 
-         return anId;
+      for ( size_t anId = 0; anId < mySubMeshID.size(); anId++ )
+        if ( mySubMeshID[ anId ] == theID )
+          return anId;
 
     return theID;
   }
@@ -546,7 +546,7 @@ namespace VISU
   {
     return myNamedPointCoords->GetObjID(theID);
   }
-  
+
   vtkIdType
   TProfileImpl
   ::GetNodeVTKID(vtkIdType theID) const
@@ -554,7 +554,7 @@ namespace VISU
     return myNamedPointCoords->GetVTKID(theID);
   }
 
-  vtkFloatingPointType*  
+  vtkFloatingPointType*
   TProfileImpl
   ::GetNodeCoord(vtkIdType theObjID)
   {
@@ -579,7 +579,7 @@ namespace VISU
     return VISU::GetElemVTKID(GetFilter()->GetOutput(), theID);
   }
 
-  vtkCell* 
+  vtkCell*
   TProfileImpl
   ::GetElemCell(vtkIdType theObjID)
   {
@@ -589,8 +589,8 @@ namespace VISU
     vtkIdType aVtkID = GetElemVTKID(theObjID);
     return GetFilter()->GetOutput()->GetCell(aVtkID);
   }
-  
-  vtkUnstructuredGrid* 
+
+  vtkUnstructuredGrid*
   TProfileImpl
   ::GetUnstructuredGridOutput()
   {
@@ -615,14 +615,14 @@ namespace VISU
     return aSize;
   }
 
-  std::string 
+  std::string
   TProfileImpl
   ::GetNodeName(vtkIdType theObjID) const
   {
     return myNamedPointCoords->GetNodeName(theObjID);
   }
 
-  std::string 
+  std::string
   TProfileImpl
   ::GetElemName(vtkIdType theObjID) const
   {
@@ -631,13 +631,10 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  
-  
   TUnstructuredGridIDMapperImpl
-  ::TUnstructuredGridIDMapperImpl():
-    myIsSpecialKey(false)
+  ::TUnstructuredGridIDMapperImpl()
   {
-    if(!myCommonCellsFilter.GetPointer()){
+    if ( !myCommonCellsFilter.GetPointer() ) {
       myCommonCellsFilter = VISU_CommonCellsFilter::New();
       myCommonCellsFilter->Delete();
     }
@@ -649,7 +646,7 @@ namespace VISU
   {
     return myIDMapper->GetNodeObjID(theID);
   }
-  
+
   vtkIdType
   TUnstructuredGridIDMapperImpl
   ::GetNodeVTKID(vtkIdType theID) const
@@ -657,7 +654,7 @@ namespace VISU
     return myIDMapper->GetNodeVTKID(theID);
   }
 
-  vtkFloatingPointType*  
+  vtkFloatingPointType*
   TUnstructuredGridIDMapperImpl
   ::GetNodeCoord(vtkIdType theObjID)
   {
@@ -678,74 +675,83 @@ namespace VISU
     return myIDMapper->GetElemVTKID(theID);
   }
 
-  vtkCell* 
+  vtkCell*
   TUnstructuredGridIDMapperImpl
   ::GetElemCell(vtkIdType theObjID)
   {
     return myIDMapper->GetElemCell(theObjID);
   }
-  
-  vtkUnstructuredGrid* 
+
+  void
   TUnstructuredGridIDMapperImpl
-  ::GetUnstructuredGridOutput()
+  ::SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper )
   {
-    if(!myFilter.GetPointer()){
-      
+    myCommonCellsFilter->SetCellsUG( theNamedIDMapper->GetUnstructuredGridOutput() );
+  }
+
+  void
+  TUnstructuredGridIDMapperImpl
+  ::Build()
+  {
+    if ( !myFilter.GetPointer() ) {
       const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
-      vtkUnstructuredGrid* aGeometry;
 
+      vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput();
       const PUnstructuredGrid& aSource = mySource.GetSource();
-      vtkUnstructuredGrid* aDataSet;
-      
-      if(myIsSpecialKey){
-        PNamedIDMapperMap::iterator aIter;
-        aIter = myMappers.find(VISU::CELL_ENTITY);
-        if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
-        else {
-          aIter = myMappers.find(VISU::FACE_ENTITY);
-          if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
-          else {
-            aIter = myMappers.find(VISU::EDGE_ENTITY);
-            if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
-          }
-        }
-      }
-      
-      aGeometry = anAppendFilter->GetOutput();
-      aDataSet = aSource.GetPointer();
-      aDataSet->ShallowCopy(aGeometry);
+      vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
+      aDataSet->ShallowCopy( aGeometry );
 
       const PMergeFilter& aFilter = GetFilter();
-      aFilter->SetGeometry(aGeometry);
-      aFilter->SetScalars(aDataSet);
-      aFilter->SetVectors(aDataSet);
-      aFilter->AddField("VISU_FIELD",aDataSet);
-      aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
-      aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
-
-      myCommonCellsFilter->SetProfileUG(aFilter->GetUnstructuredGridOutput());
-    } 
+      aFilter->SetGeometry( aGeometry );
+      aFilter->SetScalars( aDataSet );
+      aFilter->SetVectors( aDataSet );
+      aFilter->AddField( "VISU_FIELD", aDataSet );
+      aFilter->AddField( "VISU_FIELD_GAUSS_MIN", aDataSet );
+      aFilter->AddField( "VISU_FIELD_GAUSS_MAX", aDataSet );
+      aFilter->AddField( "VISU_FIELD_GAUSS_MOD", aDataSet );
+      aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
+      aFilter->AddField( "ELNO_FIELD", aDataSet );
+      aFilter->AddField( "ELNO_COMPONENT_MAPPER", aDataSet );
+      aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
+
+      myCommonCellsFilter->SetProfileUG( aFilter->GetUnstructuredGridOutput() );
+    }
+  }
+
+  vtkUnstructuredGrid*
+  TUnstructuredGridIDMapperImpl
+  ::GetUnstructuredGridOutput()
+  {
+    Build();
     return myCommonCellsFilter->GetOutput();
   }
 
-  vtkDataSet* 
+  vtkDataSet*
   TUnstructuredGridIDMapperImpl
   ::GetOutput()
   {
     return GetUnstructuredGridOutput();
   }
 
+  PUnstructuredGrid
+  TUnstructuredGridIDMapperImpl
+  ::GetSource()
+  {
+    Build();
+    return mySource.GetSource();
+  }
+
   unsigned long int
   TUnstructuredGridIDMapperImpl
   ::GetMemorySize()
   {
     size_t aSize = myIDMapper->GetMemorySize();
+
     aSize += mySource.GetMemorySize();
-    if(vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput())
+
+    if ( vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput() )
       aSize += anOutput->GetActualMemorySize() * 1024;
-    PNamedIDMapperMap::const_iterator aIter = myMappers.begin();
-    for(;aIter!=myMappers.end();aIter++)
-      aSize += (aIter->second)->GetMemorySize();
+
     return aSize;
   }
 
@@ -756,7 +762,7 @@ namespace VISU
   {
     return myIDMapper->GetNodeObjID(theID);
   }
-  
+
   vtkIdType
   TPolyDataIDMapperImpl
   ::GetNodeVTKID(vtkIdType theID) const
@@ -764,7 +770,7 @@ namespace VISU
     return myIDMapper->GetNodeVTKID(theID);
   }
 
-  vtkFloatingPointType*  
+  vtkFloatingPointType*
   TPolyDataIDMapperImpl
   ::GetNodeCoord(vtkIdType theObjID)
   {
@@ -785,43 +791,61 @@ namespace VISU
     return myIDMapper->GetElemVTKID(theID);
   }
 
-  vtkCell* 
+  vtkCell*
   TPolyDataIDMapperImpl
   ::GetElemCell(vtkIdType theObjID)
   {
     return myIDMapper->GetElemCell(theObjID);
   }
-  
-  vtkPolyData* 
+
+  void
   TPolyDataIDMapperImpl
-  ::GetPolyDataOutput()
+  ::Build()
   {
-    if(!myFilter.GetPointer()){
+    if ( !myFilter.GetPointer() ) {
       const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter();
       vtkPolyData* aGeometry = anAppendFilter->GetOutput();
-      
+
       const PPolyData& aSource = mySource.GetSource();
       vtkPolyData* aDataSet = aSource.GetPointer();
-      aDataSet->ShallowCopy(aGeometry);
-      
+      aDataSet->ShallowCopy( aGeometry );
+
       const PMergeFilter& aFilter = GetFilter();
-      aFilter->SetGeometry(aGeometry);
-      aFilter->SetScalars(aDataSet);
-      aFilter->SetVectors(aDataSet);
-      aFilter->AddField("VISU_FIELD",aDataSet);
-      aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
-      aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
+      aFilter->SetGeometry( aGeometry );
+      aFilter->SetScalars( aDataSet );
+      aFilter->SetVectors( aDataSet );
+      aFilter->AddField( "VISU_FIELD", aDataSet );
+      aFilter->AddField( "VISU_FIELD_GAUSS_MIN", aDataSet );
+      aFilter->AddField( "VISU_FIELD_GAUSS_MAX", aDataSet );
+      aFilter->AddField( "VISU_FIELD_GAUSS_MOD", aDataSet );
+      aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
+      aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
     }
+  }
+
+  vtkPolyData*
+  TPolyDataIDMapperImpl
+  ::GetPolyDataOutput()
+  {
+    Build();
     return myFilter->GetPolyDataOutput();
   }
 
-  vtkDataSet* 
+  vtkDataSet*
   TPolyDataIDMapperImpl
   ::GetOutput()
   {
     return GetPolyDataOutput();
   }
 
+  PPolyData
+  TPolyDataIDMapperImpl
+  ::GetSource()
+  {
+    Build();
+    return mySource.GetSource();
+  }
+
   unsigned long int
   TPolyDataIDMapperImpl
   ::GetMemorySize()
@@ -838,11 +862,11 @@ namespace VISU
     myGeom(EGeometry(-1)),
     myNbPoints(0)
   {}
-  
+
   void
   TGaussImpl
   ::LessThan(const PGaussImpl& theGauss,
-            bool& theResult) const
+             bool& theResult) const
   {
     theResult = false;
   }
@@ -855,14 +879,14 @@ namespace VISU
     myStatus(eNone),
     myStartID(0)
   {}
-  
+
   TGaussPointID
   TGaussSubMeshImpl
   ::GetObjID(vtkIdType theID) const
   {
     TCellID aCellID = myStartID + theID / myGauss->myNbPoints;
     TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
-    
+
     return TGaussPointID(aCellID, aLocalPntID);
   }
 
@@ -874,7 +898,7 @@ namespace VISU
 
     TCellID aCellID = theID.first;
     TLocalPntID aLocalPntID = theID.second;
-    
+
     vtkIdType aNbPoints = myGauss->myNbPoints;
     if ( aLocalPntID >= aNbPoints )
       return aResult;
@@ -888,8 +912,8 @@ namespace VISU
   {
     return mySubProfile->GetElemObjID( theID );
   }
-  
-  
+
+
   vtkIdType
   VISU::TGaussSubMeshImpl
   ::GetElemVTKID(vtkIdType theID) const
@@ -897,7 +921,7 @@ namespace VISU
     return mySubProfile->GetElemVTKID( theID );
   }
 
-  vtkIdType 
+  vtkIdType
   TGaussSubMeshImpl
   ::GetGlobalID(vtkIdType theID) const
   {
@@ -920,7 +944,7 @@ namespace VISU
     PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
     const PGaussImpl& aGaussLeft = aLeft->myGauss;
     const PGaussImpl& aGaussRight = aRight->myGauss;
-    
+
     if(aGaussLeft->myGeom != aGaussRight->myGeom)
       return aGaussLeft->myGeom < aGaussRight->myGeom;
 
@@ -940,7 +964,7 @@ namespace VISU
     myParent(NULL)
   {}
 
-  TGaussPointID 
+  TGaussPointID
   TGaussMeshImpl
   ::GetObjID(vtkIdType theID) const
   {
@@ -948,7 +972,7 @@ namespace VISU
     return VISU::GetObjID(aFilter->GetOutput(), theID);
   }
 
-  vtkIdType 
+  vtkIdType
   TGaussMeshImpl
   ::GetVTKID(const TGaussPointID& theID) const
   {
@@ -957,35 +981,34 @@ namespace VISU
     TCellID aCellID = theID.first;
 
     vtkIdType aVTKCellId = GetParent()->GetElemVTKID( aCellID );
-    if ( aVTKCellId < 0 ) 
+    if ( aVTKCellId < 0 )
       return aResult;
-      
+
     vtkCell* aCell = GetParent()->GetElemCell( aCellID );
     if ( !aCell )
       return aResult;
 
     EGeometry aVGeom = VISU::VTKGeom2VISU( aCell->GetCellType() );
-    if ( aVGeom < EGeometry(0) ) 
+    if ( aVGeom < EGeometry(0) )
       return aResult;
-    
+
     TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.find( aVGeom );
     if ( anIter == myGeom2GaussSubMesh.end() )
       return aResult;
-      
+
     size_t aSubMeshEnd = myGaussSubMeshArr.size();
-    const PAppendFilter& anAppendFilter = GetFilter();
     const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
     for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) {
       const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId];
       if ( aGaussSubMesh.get() == aSubMesh.get() ) {
-       return aGaussSubMesh->GetVTKID(theID);
+        return aGaussSubMesh->GetVTKID(theID);
       }
     }
 
     return aResult;
   }
 
-  vtkPolyData* 
+  vtkPolyData*
   TGaussMeshImpl
   ::GetPolyDataOutput()
   {
@@ -1007,7 +1030,7 @@ namespace VISU
     return aSize;
   }
 
-  TNamedIDMapper* 
+  TNamedIDMapper*
   TGaussMeshImpl
   ::GetParent() const
   {
@@ -1016,35 +1039,35 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  TGaussPointID 
+  TGaussPointID
   TGaussPtsIDFilter
   ::GetObjID(vtkIdType theID) const
   {
     return myGaussPtsIDMapper->GetObjID(theID);
   }
 
-  vtkIdType 
+  vtkIdType
   TGaussPtsIDFilter
   ::GetVTKID(const TGaussPointID& theID) const
   {
     return myGaussPtsIDMapper->GetVTKID(theID);
   }
-  
-  TNamedIDMapper* 
+
+  TNamedIDMapper*
   TGaussPtsIDFilter
   ::GetParent() const
   {
     return myGaussPtsIDMapper->GetParent();
   }
 
-  vtkPolyData* 
+  vtkPolyData*
   TGaussPtsIDFilter
   ::GetPolyDataOutput()
   {
     return TPolyDataIDMapperImpl::GetPolyDataOutput();
   }
 
-  vtkDataSet* 
+  vtkDataSet*
   TGaussPtsIDFilter
   ::GetOutput()
   {
@@ -1058,6 +1081,16 @@ namespace VISU
     myStartID(0)
   {}
 
+  void
+  TSubMeshImpl
+  ::CopyStructure( PStructured theStructured )
+  {
+    TStructured::CopyStructure( theStructured );
+
+    if ( PMeshImpl aMesh = theStructured )
+      GetSource()->ShallowCopy( aMesh->GetPointSet() );
+  }
+
   vtkIdType
   TSubMeshImpl
   ::GetElemObjID(vtkIdType theID) const
@@ -1065,7 +1098,7 @@ namespace VISU
     return myStartID + theID;
   }
 
-  std::string 
+  std::string
   TSubMeshImpl
   ::GetElemName(vtkIdType theObjID) const
   {
@@ -1092,6 +1125,16 @@ namespace VISU
     anAppendFilter->SetMappingInputs(true);
   }
 
+  void
+  TMeshOnEntityImpl
+  ::CopyStructure( PStructured theStructured )
+  {
+    TStructured::CopyStructure( theStructured );
+
+    if ( PMeshImpl aMesh = theStructured )
+      myNamedPointCoords = aMesh->myNamedPointCoords;
+  }
+
   vtkIdType
   TMeshOnEntityImpl
   ::GetNodeVTKID(vtkIdType theID) const
@@ -1120,14 +1163,14 @@ namespace VISU
     return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
   }
 
-  std::string 
+  std::string
   TMeshOnEntityImpl
   ::GetNodeName(vtkIdType theObjID) const
   {
     return myNamedPointCoords->GetNodeName(theObjID);
   }
 
-  std::string 
+  std::string
   TMeshOnEntityImpl
   ::GetElemName(vtkIdType theObjID) const
   {
@@ -1136,7 +1179,7 @@ namespace VISU
     return aSubMesh->GetElemName(anInputCellID.second);
   }
 
-  vtkUnstructuredGrid* 
+  vtkUnstructuredGrid*
   TMeshOnEntityImpl
   ::GetUnstructuredGridOutput()
   {
@@ -1161,6 +1204,18 @@ namespace VISU
   }
 
   //---------------------------------------------------------------
+  void
+  TFamilyImpl
+  ::CopyStructure( PStructured theStructured )
+  {
+    TStructured::CopyStructure( theStructured );
+
+    if ( PMeshImpl aMesh = theStructured ) {
+      myNamedPointCoords = aMesh->myNamedPointCoords;
+      GetSource()->ShallowCopy( aMesh->GetPointSet() );
+    }
+  }
+
   vtkIdType
   TFamilyImpl
   ::GetElemVTKID(vtkIdType theID) const
@@ -1170,7 +1225,7 @@ namespace VISU
     else{
       TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
       if(anIter != myElemObj2VTKID.end())
-       return anIter->second;
+        return anIter->second;
     }
     return -1;
   }
@@ -1182,21 +1237,21 @@ namespace VISU
     return myMeshID[theID];
   }
 
-  vtkIdType 
+  vtkIdType
   TFamilyImpl
-  ::GetNodeObjID(vtkIdType theID) const 
+  ::GetNodeObjID(vtkIdType theID) const
   {
     return myNamedPointCoords->GetObjID(theID);
   }
 
   vtkIdType
   TFamilyImpl
-  ::GetNodeVTKID(vtkIdType theID) const 
+  ::GetNodeVTKID(vtkIdType theID) const
   {
     return myNamedPointCoords->GetVTKID(theID);
   }
 
-  vtkUnstructuredGrid* 
+  vtkUnstructuredGrid*
   TFamilyImpl
   ::GetUnstructuredGridOutput()
   {
@@ -1223,14 +1278,24 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  TNbASizeCells 
+  void
+  TGroupImpl
+  ::CopyStructure( PStructured theStructured )
+  {
+    TStructured::CopyStructure( theStructured );
+
+    if ( PMeshImpl aMesh = theStructured )
+      myNamedPointCoords = aMesh->myNamedPointCoords;
+  }
+
+  TNbASizeCells
   TGroupImpl
   ::GetNbASizeCells() const
   {
     vtkIdType aNbCells = 0, aCellsSize = 0;
     TFamilySet::const_iterator anIter = myFamilySet.begin();
     for(; anIter != myFamilySet.end(); anIter++){
-      PFamilyImpl aFamily = *anIter; 
+      PFamilyImpl aFamily = (*anIter).second;
       aNbCells += aFamily->myNbCells;
       aCellsSize += aFamily->myCellsSize;
     }
@@ -1246,7 +1311,7 @@ namespace VISU
     else{
       TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
       if(anIter != myElemObj2VTKID.end())
-       return anIter->second;
+        return anIter->second;
     }
     return -1;
   }
@@ -1258,21 +1323,21 @@ namespace VISU
     return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
   }
 
-  vtkIdType 
+  vtkIdType
   TGroupImpl
-  ::GetNodeObjID(vtkIdType theID) const 
+  ::GetNodeObjID(vtkIdType theID) const
   {
     return myNamedPointCoords->GetObjID(theID);
   }
 
   vtkIdType
   TGroupImpl
-  ::GetNodeVTKID(vtkIdType theID) const 
+  ::GetNodeVTKID(vtkIdType theID) const
   {
     return myNamedPointCoords->GetVTKID(theID);
   }
 
-  vtkUnstructuredGrid* 
+  vtkUnstructuredGrid*
   TGroupImpl
   ::GetUnstructuredGridOutput()
   {
@@ -1294,48 +1359,117 @@ namespace VISU
   }
 
 
-  
+
   //---------------------------------------------------------------
   TFieldImpl
-  ::TFieldImpl()
-    myDataSize(0),
-    myDataType(0)
+  ::TFieldImpl()
+    : myDataSize( 0 )
+    , myDataType( 0 )
   {}
 
-  void 
+  void
   TFieldImpl
   ::Init(vtkIdType theNbComp,
-        vtkIdType theDataType)
+         vtkIdType theDataType)
   {
     myNbComp = theNbComp;
     myDataType = theDataType;
     myCompNames.resize(theNbComp);
     myUnitNames.resize(theNbComp);
-    myMinMaxArr.resize(theNbComp + 1);
-    for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
-      TMinMax& aMinMax = myMinMaxArr[iComp];
-      aMinMax.first = VTK_LARGE_FLOAT;
-      aMinMax.second = -VTK_LARGE_FLOAT;
+
+    myMetric2Comp2MinMax.resize(3);
+    myMetric2Comp2AverageMinMax.resize(3);
+    myMetric2Comp2Group2MinMax.resize(3);
+    myMetric2Comp2Group2AverageMinMax.resize(3);
+    for(int aGaussMetric = (int)VISU::AVERAGE_METRIC; aGaussMetric <= (int)VISU::MAXIMUM_METRIC; aGaussMetric++){
+      TComp2MinMax& aComp2MinMax = myMetric2Comp2MinMax[aGaussMetric];
+      TComp2MinMax& aComp2AverageMinMax = myMetric2Comp2AverageMinMax[aGaussMetric];
+      TComp2Group2MinMax& aComp2Group2MinMax = myMetric2Comp2Group2MinMax[aGaussMetric];
+      TComp2Group2MinMax& aComp2Group2AverageMinMax = myMetric2Comp2Group2AverageMinMax[aGaussMetric];
+
+      aComp2MinMax.resize(theNbComp + 1);
+      aComp2AverageMinMax.resize(theNbComp + 1);
+      aComp2Group2MinMax.resize(theNbComp + 1);
+      aComp2Group2AverageMinMax.resize(theNbComp + 1);
+      for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
+        TMinMax& aMinMax = aComp2MinMax[iComp];
+        aMinMax.first = VTK_LARGE_FLOAT;
+        aMinMax.second = -VTK_LARGE_FLOAT;
+        TMinMax& anAverageMinMax = aComp2AverageMinMax[iComp];
+        anAverageMinMax.first = VTK_LARGE_FLOAT;
+        anAverageMinMax.second = -VTK_LARGE_FLOAT;
+      }
     }
   }
 
-  vtkIdType 
+  vtkIdType
   TFieldImpl
   ::GetDataType() const
   {
     return myDataType;
   }
 
-  TMinMax 
+  TMinMax
   TFieldImpl
-  ::GetMinMax(vtkIdType theCompID)
+  ::GetMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric)
   {
-    return myMinMaxArr[theCompID];
+    TMinMax aMinMax;
+    bool anIsMinMaxInitialized = false;
+    if( !theGroupNames.empty() ) {
+      aMinMax.first = VTK_LARGE_FLOAT;
+      aMinMax.second = -VTK_LARGE_FLOAT;
+
+      const TGroup2MinMax& aGroup2MinMax = myMetric2Comp2Group2MinMax[theGaussMetric][theCompID];
+      TNames::const_iterator aNameIter = theGroupNames.begin();
+      for( ; aNameIter != theGroupNames.end(); aNameIter++ ) {
+        TGroup2MinMax::const_iterator aGroup2MinMaxIter = aGroup2MinMax.find( *aNameIter );
+        if( aGroup2MinMaxIter != aGroup2MinMax.end() ) {
+          const TMinMax& aGroupMinMax = aGroup2MinMaxIter->second;
+          aMinMax.first = std::min( aMinMax.first, aGroupMinMax.first );
+          aMinMax.second = std::max( aMinMax.second, aGroupMinMax.second );
+          anIsMinMaxInitialized = true;
+        }
+      }
+    }
+
+    if( !anIsMinMaxInitialized )
+      aMinMax = myMetric2Comp2MinMax[theGaussMetric][theCompID];
+
+    return aMinMax;
   }
 
 
+  TMinMax
+  TFieldImpl
+  ::GetAverageMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric)
+  {
+    TMinMax aMinMax;
+    bool anIsMinMaxInitialized = false;
+    if( !theGroupNames.empty() ) {
+      aMinMax.first = VTK_LARGE_FLOAT;
+      aMinMax.second = -VTK_LARGE_FLOAT;
+
+      const TGroup2MinMax& aGroup2MinMax = myMetric2Comp2Group2AverageMinMax[theGaussMetric][theCompID];
+      TNames::const_iterator aNameIter = theGroupNames.begin();
+      for( ; aNameIter != theGroupNames.end(); aNameIter++ ) {
+        TGroup2MinMax::const_iterator aGroup2MinMaxIter = aGroup2MinMax.find( *aNameIter );
+        if( aGroup2MinMaxIter != aGroup2MinMax.end() ) {
+          const TMinMax& aGroupMinMax = aGroup2MinMaxIter->second;
+          aMinMax.first = std::min( aMinMax.first, aGroupMinMax.first );
+          aMinMax.second = std::max( aMinMax.second, aGroupMinMax.second );
+          anIsMinMaxInitialized = true;
+        }
+      }
+    }
+
+    if( !anIsMinMaxInitialized )
+      aMinMax = myMetric2Comp2AverageMinMax[theGaussMetric][theCompID];
+
+    return aMinMax;
+  }
+
   //----------------------------------------------------------------------------
-  const PMeshValue& 
+  const PMeshValue&
   TGeom2Value
   ::GetMeshValue(EGeometry theGeom) const
   {
@@ -1344,8 +1478,8 @@ namespace VISU
       EXCEPTION(std::runtime_error,"TGeom2Value::GetMeshValue - myGeom2MeshValue.find(theGeom) fails");
     return anIter->second;
   }
-  
-  PMeshValue& 
+
+  PMeshValue&
   TGeom2Value
   ::GetMeshValue(EGeometry theGeom)
   {
@@ -1354,21 +1488,21 @@ namespace VISU
 
 
   //----------------------------------------------------------------------------
-  TGeom2MeshValue& 
+  TGeom2MeshValue&
   TGeom2Value
   ::GetGeom2MeshValue()
   {
     return myGeom2MeshValue;
   }
-    
-  const TGeom2MeshValue& 
+
+  const TGeom2MeshValue&
   TGeom2Value
   ::GetGeom2MeshValue() const
   {
     return myGeom2MeshValue;
   }
 
-  PMeshValue 
+  PMeshValue
   TGeom2Value
   ::GetFirstMeshValue() const
   {
@@ -1385,35 +1519,35 @@ namespace VISU
     myUnstructuredGridIDMapper(new TUnstructuredGridIDMapperImpl())
   {}
 
-  const PMeshValue& 
+  const PMeshValue&
   TValForTimeImpl
   ::GetMeshValue(EGeometry theGeom) const
   {
     return myGeom2Value.GetMeshValue(theGeom);
   }
-  
-  PMeshValue& 
+
+  PMeshValue&
   TValForTimeImpl
   ::GetMeshValue(EGeometry theGeom)
   {
     return myGeom2Value.GetMeshValue(theGeom);
   }
 
-  TGeom2MeshValue& 
+  TGeom2MeshValue&
   TValForTimeImpl
   ::GetGeom2MeshValue()
   {
     return myGeom2Value.GetGeom2MeshValue();
   }
 
-  const TGeom2MeshValue& 
+  const TGeom2MeshValue&
   TValForTimeImpl
   ::GetGeom2MeshValue() const
   {
     return myGeom2Value.GetGeom2MeshValue();
   }
 
-  PMeshValue 
+  PMeshValue
   TValForTimeImpl
   ::GetFirstMeshValue() const
   {
@@ -1430,7 +1564,19 @@ namespace VISU
     }
     return anIter->second;
   }
-  
+
+  int
+  TValForTimeImpl
+  ::GetMaxNbGauss() const
+  {
+    int aNbGauss = 1;
+    TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.begin();
+    for(; anIter != myGeom2NbGauss.end(); anIter++){
+      aNbGauss = std::max<int>(aNbGauss, anIter->second);
+    }
+    return aNbGauss;
+  }
+
   unsigned long int
   TValForTimeImpl
   ::GetMemorySize()
@@ -1447,6 +1593,5 @@ namespace VISU
     return aSize;
   }
 
-
   //---------------------------------------------------------------
 }