]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
MPV: Merge V1_2d
authorsmh <smh@opencascade.com>
Thu, 29 Jan 2004 12:36:42 +0000 (12:36 +0000)
committersmh <smh@opencascade.com>
Thu, 29 Jan 2004 12:36:42 +0000 (12:36 +0000)
12 files changed:
src/CONVERTOR/Makefile.in
src/CONVERTOR/VISUConvertor.cxx
src/CONVERTOR/VISU_Convertor.cxx
src/CONVERTOR/VISU_Convertor.hxx
src/CONVERTOR/VISU_ConvertorUtils.cxx
src/CONVERTOR/VISU_ConvertorUtils.hxx
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx [new file with mode: 0644]
src/CONVERTOR/VISU_ExtractUnstructuredGrid.hxx [new file with mode: 0644]
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx

index d5b5d3912bc1ef3800b992e4f72626e6a0ec3c66..2473978cb01aa64aa00b27c05f8ea0e8d6b046d2 100644 (file)
@@ -32,12 +32,12 @@ VPATH=.:@srcdir@
 
 @COMMENCE@
 
-EXPORT_HEADERS = VISU_Convertor.hxx  VISU_Convertor_impl.hxx
+EXPORT_HEADERS = VISU_Convertor.hxx  VISU_Convertor_impl.hxx  VISU_ConvertorUtils.hxx  VISU_ExtractUnstructuredGrid.hxx
 
 # Libraries targets
 
 LIB = libVisuConvertor.la
-LIB_SRC = VISU_Convertor.cxx VISU_Convertor_impl.cxx VISU_ConvertorUtils.cxx \
+LIB_SRC = VISU_Convertor.cxx VISU_Convertor_impl.cxx VISU_ConvertorUtils.cxx VISU_ExtractUnstructuredGrid.cxx \
        VISU_MedConvertor.cxx VISU_DatConvertor.cxx 
 
 # Executables targets
@@ -47,6 +47,6 @@ BIN_SRC =
 CPPFLAGS+= -ftemplate-depth-32 $(VTK_INCLUDES) $(MED2_INCLUDES) $(QT_INCLUDES) \
        -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS+= $(VTK_LIBS) $(MED2_LIBS) $(HDF5_LIBS) $(QT_LIBS) \
-        -L${KERNEL_ROOT_DIR}/lib/salome
+       -L${KERNEL_ROOT_DIR}/lib/salome
 
 @CONCLUDE@
index c8b2e55a5171c080a522c27e5d49cf5de39eec52..4afe4b27cd4f550ac73540c5a48625a29914132f 100644 (file)
@@ -25,6 +25,7 @@
 //  Module : VISU
 
 #include "VISU_Convertor.hxx"
+#include "VISU_ConvertorUtils.hxx"
 
 #include <fstream>     
 #include <strstream>
@@ -44,10 +45,11 @@ static int MYDEBUG = 0;
 
 void parseFile(const char* theFileName) throw(std::runtime_error&){
   try{
-    cout<<"'"<<theFileName<<"'...";
+    cout<<"'"<<theFileName<<"'...\n";
     auto_ptr<VISU_Convertor> aCon(CreateConvertor(theFileName));
-    const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap();
+    //aCon->GetSize();
     //return;
+    const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap();
     VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
     for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
       const string& aMeshName = aMeshMapIter->first;
@@ -57,48 +59,51 @@ void parseFile(const char* theFileName) throw(std::runtime_error&){
       //Import fields
       aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
-       const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
-       const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap;
-       VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
-       for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
-         const string& aFieldName = aFieldMapIter->first;
-         const VISU::TField& aField = aFieldMapIter->second;
-         const VISU::TField::TValField& aValField = aField.myValField;
-         VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin();
-         for(; aValFieldIter != aValField.end(); aValFieldIter++){
-           int aTimeStamp = aValFieldIter->first;
-           aCon->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
-         }
-       }
+       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+       const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap;
+       VISU::TFieldMap::const_reverse_iterator aFieldMapIter = aFieldMap.rbegin();
+       for(; aFieldMapIter != aFieldMap.rend(); aFieldMapIter++){
+         const string& aFieldName = aFieldMapIter->first;
+         const VISU::TField& aField = aFieldMapIter->second;
+         const VISU::TField::TValField& aValField = aField.myValField;
+         VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin();
+         for(; aValFieldIter != aValField.end(); aValFieldIter++){
+           int aTimeStamp = aValFieldIter->first;
+           aCon->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
+           //goto OK;
+         }
+       }
       }
+      //continue;
       //Importing groups
       const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
       VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
       for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
-       const string& aGroupName = aGroupMapIter->first;
-       aCon->GetMeshOnGroup(aMeshName,aGroupName);
+       const string& aGroupName = aGroupMapIter->first;
+       aCon->GetMeshOnGroup(aMeshName,aGroupName);
       }
       //Import families
       aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
-       const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
-       //aCon->GetMeshOnEntity(aMeshName,anEntity);
-       const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
-       VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
-       for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
-         const string& aFamilyName = aFamilyMapIter->first;
-         aCon->GetMeshOnEntity(aMeshName,anEntity,aFamilyName);
-       }
+       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+       //aCon->GetMeshOnEntity(aMeshName,anEntity);
+       const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
+       VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+       for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+         const string& aFamilyName = aFamilyMapIter->first;
+         aCon->GetMeshOnEntity(aMeshName,anEntity,aFamilyName);
+       }
       }
       //Import mesh on entity
       aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
-       aCon->GetMeshOnEntity(aMeshName,anEntity);
+       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+       aCon->GetMeshOnEntity(aMeshName,anEntity);
       }
     }
+  OK:
     cout<<"OK"<<endl;
   }catch(std::runtime_error& exc){
     MESSAGE("Follow exception was accured in file:"<<theFileName<<"\n"<<exc.what());
index 82f2463dbc06b5f78cd7bcdc0bf0e8515d112f86..c9dbdb411965af4cae63cf3fa3e6e7890203226b 100644 (file)
@@ -27,8 +27,6 @@
 #include "VISU_Convertor.hxx"
 #include "VISU_ConvertorUtils.hxx"
 
-#include <vtkUnstructuredGridWriter.h>
-
 using namespace std;
 
 #ifdef _DEBUG_
@@ -46,29 +44,20 @@ extern "C" {
   }
 }
 
-void VISU::WriteToFile(vtkUnstructuredGrid* theDataSet, const string& theFileName){
-//  vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
-//  //aWriter->DebugOn();
-//  //aWriter->SetFileType(VTK_BINARY);
-//  aWriter->SetFileName(theFileName.c_str());
-//  aWriter->SetInput(theDataSet);
-//  //aWriter->Print(cout);
-//  aWriter->Write();
-//  aWriter->Delete();
-}
-
 namespace VISU{
-  TVtkCellInfoMap aVtkCellInfoMap;
-  static int INIT = (
-                    aVtkCellInfoMap[VTK_VERTEX] = TVtkCellInfo("VTK_VERTEX",1),
-                    aVtkCellInfoMap[VTK_LINE] = TVtkCellInfo("VTK_LINE",2),
-                    aVtkCellInfoMap[VTK_TRIANGLE] = TVtkCellInfo("VTK_TRIANGLE",3),
-                    aVtkCellInfoMap[VTK_QUAD] = TVtkCellInfo("VTK_QUAD",4),
-                    aVtkCellInfoMap[VTK_TETRA] = TVtkCellInfo("VTK_TETRA",4),
-                    aVtkCellInfoMap[VTK_HEXAHEDRON] = TVtkCellInfo("VTK_HEXAHEDRON",8),
-                    aVtkCellInfoMap[VTK_WEDGE] = TVtkCellInfo("VTK_WEDGE",6),
-                    aVtkCellInfoMap[VTK_PYRAMID] = TVtkCellInfo("VTK_PYRAMID",5),
-                    1);
+  inline int GetNbOfPoints(int theVTKCellType){
+    switch(theVTKCellType){
+    case VTK_VERTEX : return 1;
+    case VTK_LINE : return 2;
+    case VTK_TRIANGLE : return 3;
+    case VTK_QUAD : return 4;
+    case VTK_TETRA : return 4;
+    case VTK_HEXAHEDRON : return 8;
+    case VTK_WEDGE : return 6;
+    case VTK_PYRAMID : return 5;
+    default: return -1;
+    }
+  }
 
   pair<int,int> TMeshOnEntity::GetCellsDims(const string& theFamilyName) const
     throw(std::runtime_error&)
@@ -97,7 +86,7 @@ namespace VISU{
          int tmp = aSubMeshOnCellType.size();
          aNbCells += tmp;
          int aVtkType = aSubMeshIter->first;
-         int aVtkSize = aVtkCellInfoMap[aVtkType].mySize;
+         int aVtkSize = GetNbOfPoints(aVtkType);
          aCellsSize += tmp*(aVtkSize+1);
        }
       }
@@ -125,7 +114,7 @@ namespace VISU{
     if(aFamilyMapIter == aFamilyMap.end())
       throw std::runtime_error("GetFamily >> There is no family on the mesh with entity !!!");
     const VISU::TFamily& aFamily = aFamilyMapIter->second;
-       return &aFamily;
+    return &aFamily;
   }
   
   TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName)
index 490ae99fcbe406962895fb00957d2ea0f80d6701..65d2d6a32288896fc05027f94f4db47c488048f7 100644 (file)
@@ -1,4 +1,4 @@
-//  VISU OBJECT : interactive object for VISU entities implementation
+//  VISU CONVERTOR :
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
@@ -33,7 +33,6 @@
 #include <iterator>
 #include <list>
 #include <map>
-#include <memory>
 #include <numeric>
 #include <set>
 #include <utility>
 #include <string>
 #include <stdexcept>
 
-#ifndef MESSAGE
-#define MESSAGE(msg) std::cout<<msg<<endl
-#endif
-
-#include <vtkUnstructuredGrid.h>
-#include <vtkSystemIncludes.h>
 #include <vtkPoints.h>
+#include <vtkSystemIncludes.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkMergeDataObjectFilter.h>
+#include <vtkFieldDataToAttributeDataFilter.h>
 
-namespace VISU{
-  class TVtkCellInfo{
-  public:
-    TVtkCellInfo() {}
-    TVtkCellInfo(const char* theName, vtkIdType theSize) : 
-      myName(theName), mySize(theSize) {}
-    const char* myName;
-    vtkIdType mySize;
-  };
-  typedef std::map<vtkIdType,TVtkCellInfo> TVtkCellInfoMap;
-  extern TVtkCellInfoMap aVtkCellInfoMap;
+#include "VISU_ExtractUnstructuredGrid.hxx"
+
+#include <vtkSmartPointer.h>
 
+namespace VISU{
   enum  TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY};
-  template <class _Tp> class vtk_ptr {
-  private:
-    _Tp* _M_ptr;
-  public:
-    typedef _Tp element_type;
-    explicit vtk_ptr(_Tp* __p = 0) : _M_ptr(__p) {}
-    vtk_ptr(const vtk_ptr& __a) : _M_ptr(0) {}
-    vtk_ptr(vtk_ptr& __a) : _M_ptr(__a.release()) {}
-    vtk_ptr& operator=(const vtk_ptr& __a) { return *this;}
-    vtk_ptr& operator=(vtk_ptr& __a) {
-      if (&__a != this) {
-       if(_M_ptr) _M_ptr->Delete(); 
-       _M_ptr = __a.release();
-      }
-      return *this;
-    }
-    ~vtk_ptr() { 
-      if(_M_ptr) _M_ptr->Delete(); 
-      _M_ptr = 0;
-    }
-    _Tp& operator*() const { return *_M_ptr;}
-    _Tp* operator->() const { return _M_ptr;}
-    _Tp* get() const { return _M_ptr;}
-    _Tp* release() {
-      _Tp* __tmp = _M_ptr;
-      _M_ptr = 0;
-      return __tmp;
-    }
-    void reset(_Tp* __p = 0) {
-      if(_M_ptr) _M_ptr->Delete();
-      _M_ptr = __p;
-    }
-  };
-  typedef vtk_ptr<vtkUnstructuredGrid> TVTKSource;
-  typedef vtk_ptr<vtkPoints> TVTKPoints;
 
+  typedef vtkSmartPointer<vtkPoints> TVTKPoints;
+  typedef vtkSmartPointer<vtkUnstructuredGrid> TVTKSource;
+  typedef vtkSmartPointer<vtkMergeDataObjectFilter> TVTKMergetFilter;
+  typedef vtkSmartPointer<VISU_ExtractUnstructuredGrid> TVTKExtractFilter;
+  typedef vtkSmartPointer<vtkFieldDataToAttributeDataFilter> TVTKAttribyteFilter;
   typedef std::set<std::string> TBindGroups;
 
   struct TFamily{
@@ -115,17 +75,20 @@ namespace VISU{
   typedef std::map<std::string,TFamily> TFamilyMap;
 
   struct TField{
+    TVTKExtractFilter myExtractFilter;
     vtkIdType myId;
     std::string myName;
     TEntity myEntity;
     std::string myMeshName;
-    vtkIdType myNbComp, myNbValField, myDataSize;
+    vtkIdType myNbComp, myNbValField, myDataSize, myIsTrimmed;
     typedef std::vector<float> TValForCellsWithType;
     typedef std::map<vtkIdType,TValForCellsWithType> TValForCells;
     typedef std::pair<double,std::string> TTime;
     typedef std::vector<std::string> TCompNames;
     typedef std::vector<std::string> TUnitNames;
     struct TValForTime{
+      TVTKAttribyteFilter myAttribyteFilter;
+      TVTKMergetFilter myMergeFilter;
       TVTKSource myStorage;
       vtkIdType myId;
       std::string myMeshName;
@@ -135,16 +98,26 @@ namespace VISU{
       TTime myTime;
       TValForCells myValForCells;
       TValForTime() : myNbComp(0) {}
+      ~TValForTime() { 
+       if(myMergeFilter.GetPointer())
+         myMergeFilter->UnRegisterAllOutputs();
+       if(myAttribyteFilter.GetPointer())
+         myAttribyteFilter->UnRegisterAllOutputs();
+      }
     };
     typedef std::map<vtkIdType,TValForTime> TValField;
     TValField myValField;
     TCompNames myCompNames;
     TUnitNames myUnitNames;
-    TField() : myNbComp(0), myNbValField(0), myDataSize(0) {}
+    TField() : myNbComp(0), myNbValField(0), myDataSize(0), myIsTrimmed(0) {}
     void ShallowCopy(const TField& aField);
+    ~TField() { 
+      if(myExtractFilter.GetPointer())
+       myExtractFilter->UnRegisterAllOutputs();
+    }
   };
   typedef std::map<std::string,TField> TFieldMap;
-
   struct TMeshOnEntity{
     TVTKSource myStorage;
     std::string myMeshName;
@@ -209,23 +182,23 @@ public:
 
   virtual VISU_Convertor* Build() throw (std::runtime_error&) = 0;
   virtual const VISU::TMeshMap& GetMeshMap() throw(std::runtime_error&);
-
+  virtual float GetSize() throw (std::runtime_error&) = 0;
 
   virtual TOutput* GetMeshOnEntity(const std::string& theMeshName, 
                                   const VISU::TEntity& theEntity,
                                   const std::string& theFamilyName = "")
     throw(std::runtime_error&) = 0;
-  virtual vtkIdType GetMeshOnEntitySize(const std::string& theMeshName, 
-                                       const VISU::TEntity& theEntity,
-                                       const std::string& theFamilyName = "")
+  virtual float GetMeshOnEntitySize(const std::string& theMeshName, 
+                                   const VISU::TEntity& theEntity,
+                                   const std::string& theFamilyName = "")
     throw (std::runtime_error&) = 0;
   
   
   virtual TOutput* GetMeshOnGroup(const std::string& theMeshName, 
                                  const std::string& theGroupName)
     throw(std::runtime_error&) = 0;
-  virtual vtkIdType GetMeshOnGroupSize(const std::string& theMeshName, 
-                                      const std::string& theGroupName)
+  virtual float GetMeshOnGroupSize(const std::string& theMeshName, 
+                                  const std::string& theGroupName)
     throw(std::runtime_error&) = 0;
   
 
@@ -234,14 +207,14 @@ public:
                                      const std::string& theFieldName,
                                      int theStampsNum)
     throw(std::runtime_error&) = 0;
-  virtual vtkIdType GetTimeStampSize(const std::string& theMeshName, 
-                                    const VISU::TEntity& theEntity,
-                                    const std::string& theFieldName,
-                                    int theStampsNum)
+  virtual float GetTimeStampSize(const std::string& theMeshName, 
+                                const VISU::TEntity& theEntity,
+                                const std::string& theFieldName,
+                                int theStampsNum)
     throw(std::runtime_error&) = 0;
-  virtual vtkIdType GetFieldOnMeshSize(const std::string& theMeshName, 
-                                      const VISU::TEntity& theEntity,
-                                      const std::string& theFieldName)
+  virtual float GetFieldOnMeshSize(const std::string& theMeshName, 
+                                  const VISU::TEntity& theEntity,
+                                  const std::string& theFieldName)
     throw(std::runtime_error&) = 0;
   virtual const VISU::TField& GetField(const std::string& theMeshName, 
                                       VISU::TEntity theEntity, 
index 22cb5b2f68edf7d3848b3cb2e4893408b62d2d94..60c0a962eaa5172b61971d28ec7ac855998960a6 100644 (file)
@@ -24,7 +24,8 @@
 //  Author : Alexey PETROV
 //  Module : VISU
 
-#include "VISU_Convertor_impl.hxx"
+#include "VISU_Convertor.hxx"
+#include "VISU_ConvertorUtils.hxx"
 
 #include <vtkCellType.h>
 
index bc6dcad716908079253a29601c3de6a409e74e43..80ad171f09aa489b7a0395c682f0c8d36ee4e8ae 100644 (file)
@@ -33,12 +33,24 @@ extern "C"{
 
 #include <fstream>     
 #include <strstream>   
+#include <string>
 
 #include <vtkCellType.h>
 
 #include <qstring.h>
 #include <qfileinfo.h>
 
+#ifndef MESSAGE
+#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl
+
+#undef EXCEPT
+#define EXCEPT(msg) QString(QString(__FILE__) + "[" + QString::number(__LINE__) + "]::" + msg)
+
+#undef EXCEPTION
+#define EXCEPTION(msg) EXCEPT(msg).latin1()
+
+#endif
+
 template<class T> std::string dtos(const std::string& fmt, T val){
   static QString aString;
   aString.sprintf(fmt.c_str(),val);
index 8f6ed718c8b525d776c91fd5b71ac67a4aa1d0d5..81a76c9779548384b70d96f4637c817d6dc47e73 100644 (file)
@@ -25,6 +25,7 @@
 //  Module : VISU
 
 #include "VISU_Convertor_impl.hxx"
+#include "VISU_ConvertorUtils.hxx"
 
 #include <vtkIdList.h>
 #include <vtkCellType.h>
 #include <vtkUnsignedCharArray.h>
 #include <vtkPointData.h>
 #include <vtkCellData.h>
+#include <vtkCellLinks.h>
+
+#include <vtkMergeDataObjectFilter.h>
+
+#include <vtkUnstructuredGridWriter.h>
 
 #include <qstring.h>
 #include <qfileinfo.h>
 
 using namespace std;
 
+static float ERR_SIZE_CALC = 1.00;
+
+static int MYVTKDEBUG = 0;
+
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
@@ -51,6 +61,349 @@ static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
 #endif
 
+void VISU::WriteToFile(vtkUnstructuredGrid* theDataSet, const string& theFileName){
+  //vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
+  //if(MYVTKDEBUG) aWriter->DebugOn();
+  ////aWriter->SetFileType(VTK_BINARY);
+  //aWriter->SetFileName(theFileName.c_str());
+  //aWriter->SetInput(theDataSet);
+  //aWriter->Write();
+  //aWriter->Delete();
+}
+
+namespace{
+  void GetPoints(VISU::TVTKSource& theStorage, VISU::TMesh& theMesh) 
+    throw (std::runtime_error&)
+  {
+    vtkPoints* aPoints = theMesh.myPoints.GetPointer();
+    if(!aPoints){
+      aPoints = vtkPoints::New();
+      if(MYVTKDEBUG) aPoints->DebugOn();
+      const VISU::TMesh::TPointsCoord& anArray = theMesh.myPointsCoord;
+      vtkIdType iEnd = theMesh.myPointsCoord.size();
+      vtkIdType aNbPoints = iEnd / theMesh.myDim;
+      aPoints->SetNumberOfPoints(aNbPoints);
+      if(MYDEBUG) 
+       MESSAGE("GetPoints - aNbPoints = "<<aNbPoints<<"; myDim = "<<theMesh.myDim);
+      switch(theMesh.myDim) {
+      case 1:
+       for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++) 
+         aPoints->SetPoint(j,anArray[i],0.0,0.0);
+       break;
+      case 2:
+       for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++) 
+         aPoints->SetPoint(j,anArray[i],anArray[i+1],0.0);
+       break;
+      case 3: 
+       for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++) 
+         aPoints->SetPoint(j,anArray[i],anArray[i+1],anArray[i+2]);
+       break;
+      }
+      theMesh.myPoints = aPoints;
+    }
+    theStorage->SetPoints(aPoints);
+  }
+  
+  
+  inline void PrintCells(int& theStartId,
+                        vtkCellArray* theConnectivity, 
+                        const VISU::TMeshOnEntity::TConnect& theVector)
+  {
+    vtkIdList *anIdList = vtkIdList::New();
+    int kEnd = theVector.size();
+    anIdList->SetNumberOfIds(kEnd);
+    for(int k = 0; k < kEnd; k++)
+      anIdList->SetId(k,theVector[k]);
+    theConnectivity->InsertNextCell(anIdList);
+    anIdList->Delete();
+  }
+
+  void GetCellsOnEntity(VISU::TVTKSource& theStorage,
+                       const VISU::TMeshOnEntity& theMeshOnEntity, 
+                       const string& theFamilyName) 
+    throw (std::runtime_error&)
+  {
+    //Check on existing family
+    const VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName);
+    bool isFamilyPresent = (pFamily != NULL);
+    const VISU::TFamily& aFamily = *pFamily;
+    //Main part of code
+    pair<int,int> aCellsDim = theMeshOnEntity.GetCellsDims(theFamilyName);
+    int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second;
+    vtkCellArray* aConnectivity = vtkCellArray::New();
+    aConnectivity->Allocate(aCellsSize,0);
+    vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+    aCellTypesArray->SetNumberOfComponents(1);
+    aCellTypesArray->SetNumberOfTuples(aNbCells);
+    if(MYDEBUG) MESSAGE("GetCellsOnEntity - isFamilyPresent = "<<isFamilyPresent);
+    const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn;
+    VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+    for(int i = 0, j = 0; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
+      const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second;
+      int aVtkType = aCellsConnIter->first;
+      if(MYDEBUG) 
+       MESSAGE("GetCellsOnEntity - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
+      if(!isFamilyPresent)
+       for(int k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){
+         PrintCells(i,aConnectivity,anArray[k]);
+         aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
+       }
+      else{
+       const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
+       if(aSubMesh.empty()) 
+         throw std::runtime_error(EXCEPTION("GetCells >> There is no elements on the family !!!"));
+       VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
+       if(aSubMeshIter == aSubMesh.end()) continue;
+       const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
+       if(MYDEBUG) 
+         MESSAGE("GetCellsOnEntity - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
+       VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
+       for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
+         PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
+         aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
+       }
+      }
+    }
+    vtkIdType *pts = 0, npts = 0;
+    vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+    aCellLocationsArray->SetNumberOfComponents(1);
+    aCellLocationsArray->SetNumberOfTuples(aNbCells);
+    aConnectivity->InitTraversal();
+    for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
+      aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+    theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+    if(MYVTKDEBUG) aConnectivity->DebugOn();
+    aCellLocationsArray->Delete();
+    aCellTypesArray->Delete();
+    aConnectivity->Delete();
+  } 
+  
+  
+  void GetCellsOnGroup(VISU::TVTKSource& theStorage,
+                      const VISU::TMesh& theMesh,
+                      const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) 
+    throw (std::runtime_error&)
+  {
+    //Calculate dimentions of the group
+    int aNbCells = 0, aCellsSize = 0;
+    VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
+    for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
+      const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter;
+      const string& aFamilyName = aFamilyAndEntity.first;
+      const VISU::TEntity& anEntity = aFamilyAndEntity.second;
+      const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second;
+      pair<int,int> aCellsDim = aMeshOnEntity.GetCellsDims(aFamilyName);
+      aNbCells += aCellsDim.first;
+      aCellsSize += aCellsDim.second;
+    }
+    vtkCellArray* aConnectivity = vtkCellArray::New();
+    aConnectivity->Allocate(aCellsSize,0);
+    vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+    aCellTypesArray->SetNumberOfComponents(1);
+    aCellTypesArray->SetNumberOfTuples(aNbCells);
+    aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
+    for(int i = 0, j = 0; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
+      const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter;
+      const string& aFamilyName = aFamilyAndEntity.first;
+      const VISU::TEntity& anEntity = aFamilyAndEntity.second;
+      const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second;
+      const VISU::TFamily& aFamily = *(VISU::GetFamily(aMeshOnEntity,aFamilyName));
+      const VISU::TMeshOnEntity::TCellsConn &aCellsConn = aMeshOnEntity.myCellsConn;
+      VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+      for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
+       const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second;
+       int aVtkType = aCellsConnIter->first;
+       if(MYDEBUG) 
+         MESSAGE("GetCellsOnGroup - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
+       const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
+       if(aSubMesh.empty()) 
+         throw std::runtime_error(EXCEPTION("GetCells >> There is no elements on the family !!!"));
+       VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
+       if(aSubMeshIter == aSubMesh.end()) continue;
+       const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
+       if(MYDEBUG) 
+         MESSAGE("GetCellsOnGroup - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
+       VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
+       for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
+         PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
+         aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
+       }
+      }
+    }
+    vtkIdType *pts = 0, npts = 0;
+    vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+    aCellLocationsArray->SetNumberOfComponents(1);
+    aCellLocationsArray->SetNumberOfTuples(aNbCells);
+    aConnectivity->InitTraversal();
+    for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
+      aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+    theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+    aCellLocationsArray->Delete();
+    aCellTypesArray->Delete();
+    aConnectivity->Delete();
+  } 
+  
+  
+  void InitProfile(VISU::TVTKExtractFilter& theFilter,
+                  const VISU::TMeshOnEntity& theMeshOnEntity, 
+                  const VISU::TField::TValForTime& theValForTime)
+    throw (std::runtime_error&)
+  {
+    const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells;
+    const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn;
+    VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+    for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
+      const vtkIdType& aCellType = aCellsConnIter->first;
+      if(aValForCells.find(aCellType) == aValForCells.end())
+       theFilter->RemoveCellsWithType(aCellType);
+    }
+  }
+
+
+  void GetValsOnTimeStamp(vtkFloatArray *theFloatArray, 
+                         const vtkIdType& theNumberOfTuples,
+                         const std::string& theFieldName,
+                         const VISU::TField& theField,
+                         const VISU::TField::TValForTime& theValForTime)
+    throw (std::runtime_error&)
+  {
+    //theFloatArray->DebugOn();
+    theFloatArray->SetNumberOfTuples(theNumberOfTuples);
+    theFloatArray->SetName(theFieldName.c_str());
+    if(MYDEBUG) MESSAGE("GetValsOnTimeStamp - theNumberOfTuples = "<<theNumberOfTuples);
+    const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells;
+    VISU::TField::TValForCells::const_iterator aValForCellsIter = aValForCells.begin();
+    for(int k = 0; aValForCellsIter != aValForCells.end(); aValForCellsIter++) {
+      const VISU::TField::TValForCellsWithType& anArray = aValForCellsIter->second;
+      int iEnd = anArray.size()/theField.myNbComp;
+      int aVtkType = aValForCellsIter->first;
+      if(MYDEBUG) MESSAGE("GetValsOnTimeStamp -  iEnd = "<<iEnd<<"; aVtkType = "<<aVtkType);
+      switch(theField.myNbComp) {
+      case 1:
+       for (int i = 0; i < iEnd; i++) 
+         theFloatArray->SetTuple1(k++,anArray[i]);
+       break;
+      case 2:
+       for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*2)
+         theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+1],0.0);
+       break;
+      case 3:
+       for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*3)
+         theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+1],anArray[ji+2]);
+       break;
+      case 4:
+       for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*4)
+         theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+2],0.0);
+       break;
+      case 6:
+       for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*4)
+         theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+2],anArray[ji+5]);
+       break;
+      default:
+       throw std::runtime_error(EXCEPTION("GetValsOnTimeStamp - There is no an algorithm for representation of the field !!!"));
+      }
+    }
+  }
+
+  string GenerateFieldName(const VISU::TField& theField,
+                          const VISU::TField::TValForTime& theValForTime)
+  {
+    const VISU::TField::TTime& aTime = theValForTime.myTime;
+    string aFieldName = theField.myMeshName + ", " + theField.myName + ": " + 
+      VISU_Convertor::GenerateName(aTime);
+    return aFieldName;
+  }
+
+  void GetTimeStamp(VISU::TVTKSource& theStorage,
+                   const VISU::TMesh& theMesh,
+                   const VISU::TMeshOnEntity& theMeshOnEntity, 
+                   const VISU::TField& theField, 
+                   const VISU::TField::TValForTime& theValForTime)
+    throw (std::runtime_error&)
+  {
+    int aNumberOfTuples = theField.myDataSize/theField.myNbComp;
+    string aFieldName = GenerateFieldName(theField,theValForTime);
+    if(MYDEBUG) 
+      MESSAGE("GetTimeStamp(TVTKSource) - aFieldName = "<<aFieldName<<
+             "; aNumberOfTuples = "<<aNumberOfTuples);
+
+    vtkDataSetAttributes* aDataSetAttributes;
+    switch(theField.myEntity){
+    case VISU::NODE_ENTITY : 
+      aDataSetAttributes = theStorage->GetPointData();
+      break;
+    default: 
+      aDataSetAttributes = theStorage->GetCellData();
+    }
+
+    vtkFloatArray *aFloatArray = vtkFloatArray::New();
+    switch(theField.myNbComp) {
+    case 1:
+      aFloatArray->SetNumberOfComponents(1);
+      aDataSetAttributes->SetScalars(aFloatArray);
+      break;
+    default:
+      aFloatArray->SetNumberOfComponents(3);
+      aDataSetAttributes->SetVectors(aFloatArray);
+    }
+
+    GetValsOnTimeStamp(aFloatArray,aNumberOfTuples,aFieldName,theField,theValForTime);
+  }
+
+  void GetTimeStamp(VISU::TVTKAttribyteFilter& theAttribyteFilter,
+                   VISU::TVTKMergetFilter& theMergeFilter,
+                   VISU::TVTKExtractFilter& theExtractFilter,
+                   const VISU::TMesh& theMesh,
+                   const VISU::TMeshOnEntity& theMeshOnEntity, 
+                   const VISU::TField& theField, 
+                   const VISU::TField::TValForTime& theValForTime)
+    throw (std::runtime_error&)
+  {
+    int aNumberOfTuples = theField.myDataSize/theField.myNbComp;
+    string aFieldName = GenerateFieldName(theField,theValForTime);
+    if(MYDEBUG) 
+      MESSAGE("GetTimeStamp(TVTKAttribyteFilter) - aFieldName = "<<aFieldName<<
+             "; aNumberOfTuples = "<<aNumberOfTuples);
+
+    vtkDataObject* aDataObject = vtkDataObject::New();
+    theMergeFilter->SetDataObject(aDataObject);
+    aDataObject->Delete();
+
+    theMergeFilter->SetInput(theExtractFilter->GetOutput());
+    theAttribyteFilter->SetInput(theMergeFilter->GetOutput());
+
+    switch(theField.myEntity){
+    case VISU::NODE_ENTITY : 
+      theMergeFilter->SetOutputFieldToPointDataField();
+      theAttribyteFilter->SetInputFieldToPointDataField();
+      theAttribyteFilter->SetOutputAttributeDataToPointData();
+      break;
+    default: 
+      theMergeFilter->SetOutputFieldToCellDataField();
+      theAttribyteFilter->SetInputFieldToCellDataField();
+      theAttribyteFilter->SetOutputAttributeDataToCellData();
+    }
+
+    vtkFloatArray *aFloatArray = vtkFloatArray::New();
+    switch(theField.myNbComp) {
+    case 1:
+      aFloatArray->SetNumberOfComponents(1);
+      theAttribyteFilter->SetScalarComponent(0,aFieldName.c_str(),0);
+      break;
+    default:
+      aFloatArray->SetNumberOfComponents(3);
+      theAttribyteFilter->SetVectorComponent(0,aFieldName.c_str(),0);
+      theAttribyteFilter->SetVectorComponent(1,aFieldName.c_str(),1);
+      theAttribyteFilter->SetVectorComponent(2,aFieldName.c_str(),2);
+    }
+
+    vtkFieldData* aFieldData = aDataObject->GetFieldData();
+    aFieldData->AddArray(aFloatArray);
+    aFloatArray->Delete();
+
+    GetValsOnTimeStamp(aFloatArray,aNumberOfTuples,aFieldName,theField,theValForTime);
+  }
+}
 
 VISU_Convertor_impl::VISU_Convertor_impl() {
   myIsDone = false;
@@ -81,20 +434,39 @@ VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName,
     pSource = &(aMeshOnEntity.myStorage);
   VISU::TVTKSource& aSource = *pSource;
   //Main part of code
-  if(aSource.get() == NULL){
-    aSource.reset(TOutput::New());
-    LoadMeshOnEntity(aMeshOnEntity,theFamilyName);
-    GetPoints(aSource,aMesh);
-    GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName);
-    if(MYDEBUGWITHFILES){
-      string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
-      string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
-      string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
-      aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
-      VISU::WriteToFile(aSource.get(),aFileName);
+  try{
+    if(aSource.GetPointer() == NULL){
+      aSource = TOutput::New();
+      aSource->Delete();
+      if(MYVTKDEBUG) aSource->DebugOn();
+      LoadMeshOnEntity(aMeshOnEntity,theFamilyName);
+      GetPoints(aSource,aMesh);
+      GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName);
+      if(MYDEBUGWITHFILES){
+       string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+       string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
+       string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+       aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
+       VISU::WriteToFile(aSource.GetPointer(),aFileName);
+      }
+    }
+    if(MYVTKDEBUG){
+      GetMeshOnEntitySize(theMeshName,theEntity,theFamilyName);
+      vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
+      aDataSet->Update();
+      MESSAGE("GetMeshOnEntity - GetPoints() = "<<float(aDataSet->GetPoints()->GetActualMemorySize()*1000));
+      MESSAGE("GetMeshOnEntity - GetCells() = "<<float(aDataSet->GetCells()->GetActualMemorySize()*1000));
+      MESSAGE("GetMeshOnEntity - GetCellTypesArray() = "<<float(aDataSet->GetCellTypesArray()->GetActualMemorySize()*1000));
+      MESSAGE("GetMeshOnEntity - GetCellLocationsArray() = "<<float(aDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000));
+      aDataSet->BuildLinks();
+      MESSAGE("GetMeshOnEntity - GetCellLinks() = "<<float(aDataSet->GetCellLinks()->GetActualMemorySize()*1000));
+      MESSAGE("GetMeshOnEntity - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
     }
+  }catch(...){
+    aSource = vtkSmartPointerBase();
+    throw;
   }
-  return aSource.get();
+  return aSource.GetPointer();
 }
 
 VISU_Convertor::TOutput* 
@@ -113,20 +485,26 @@ VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName,
   const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet;
   VISU::TVTKSource& aSource = aGroup.myStorage;
   //Main part of code
-  if(aSource.get() == NULL){
-    aSource.reset(TOutput::New());
-    LoadMeshOnGroup(aMesh,aFamilyAndEntitySet);
-    GetPoints(aSource,aMesh);
-    GetCellsOnGroup(aSource,aMesh,aFamilyAndEntitySet);
-    if(MYDEBUGWITHFILES){
-      string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
-      string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
-      string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
-      aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk";
-      VISU::WriteToFile(aSource.get(),aFileName);
+  try{
+    if(aSource.GetPointer() == NULL){
+      aSource = TOutput::New();
+      aSource->Delete();
+      LoadMeshOnGroup(aMesh,aFamilyAndEntitySet);
+      GetPoints(aSource,aMesh);
+      GetCellsOnGroup(aSource,aMesh,aFamilyAndEntitySet);
+      if(MYDEBUGWITHFILES){
+       string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+       string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
+       string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+       aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk";
+       VISU::WriteToFile(aSource.GetPointer(),aFileName);
+      }
     }
+  }catch(...){
+    aSource = vtkSmartPointerBase();
+    throw;
   }
-  return aSource.get();
+  return aSource.GetPointer();
 }
 
 VISU_Convertor::TOutput* 
@@ -149,306 +527,175 @@ VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName,
                theFieldName,pField,theStampsNum,pValForTime);
   VISU::TMesh& aMesh = *pMesh;
   VISU::TMeshOnEntity& aMeshOnEntity = *pMeshOnEntity;
-  VISU::TMeshOnEntity& aVTKMeshOnEntity = *pVTKMeshOnEntity;
   VISU::TField& aField = *pField;
   VISU::TField::TValForTime& aValForTime = *pValForTime;
+  VISU::TVTKAttribyteFilter& anAttribyteFilter = aValForTime.myAttribyteFilter;
   VISU::TVTKSource& aSource = aValForTime.myStorage;
+  TOutput* anOutput = NULL;
   //Main part of code
-  if(aSource.get() == NULL){
-    aSource.reset(TOutput::New());
-    LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
-    try{
-      LoadMeshOnEntity(aVTKMeshOnEntity);
-    }catch(std::runtime_error& exc){
-      aVTKMeshOnEntity = aMeshOnEntity;
-      MESSAGE("Follow exception was accured :\n"<<exc.what());
-    }catch(...){
-      aVTKMeshOnEntity = aMeshOnEntity;
-      MESSAGE("Unknown exception was accured!");
-    }
-    GetMeshOnEntity(aVTKMeshOnEntity.myMeshName,aVTKMeshOnEntity.myEntity);
-    aSource->ShallowCopy(aVTKMeshOnEntity.myStorage.get());
-    GetField(aSource,aMesh,aVTKMeshOnEntity,aField,aValForTime);
-    if(MYDEBUGWITHFILES){
-      string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
-      string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
-      string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
-      aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
-      VISU::WriteToFile(aSource.get(),aFileName);
-    }
-  }
-  return aSource.get();
-}
-
-inline void PrintCells(int& theStartId,
-                      vtkCellArray* theConnectivity, 
-                      const VISU::TMeshOnEntity::TConnect& theVector)
-{
-  vtkIdList *anIdList = vtkIdList::New();
-  int kEnd = theVector.size();
-  anIdList->SetNumberOfIds(kEnd);
-  for(int k = 0; k < kEnd; k++){
-    anIdList->SetId(k,theVector[k]);
-    //anIdList->InsertNextId(theVector[k]);
-  }
-  theConnectivity->InsertNextCell(anIdList);
-  anIdList->Delete();
-}
-
-void VISU_Convertor_impl::GetCellsOnEntity(VISU::TVTKSource& theStorage,
-                                          const VISU::TMeshOnEntity& theMeshOnEntity, 
-                                          const string& theFamilyName) 
-  const throw (std::runtime_error&)
-{
-  //Check on existing family
-  const VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName);
-  bool isFamilyPresent = (pFamily != NULL);
-  const VISU::TFamily& aFamily = *pFamily;
-  //Main part of code
-  pair<int,int> aCellsDim = theMeshOnEntity.GetCellsDims(theFamilyName);
-  int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second;
-  vtkCellArray* aConnectivity = vtkCellArray::New();
-  //vtkIdType *anIdArray = aConnectivity->WritePointer(0,aCellsSize);
-  aConnectivity->Allocate(aCellsSize,0);
-  vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
-  aCellTypesArray->SetNumberOfComponents(1);
-  aCellTypesArray->SetNumberOfTuples(aNbCells);
-  if(MYDEBUG) MESSAGE("GetCellsOnEntity - isFamilyPresent = "<<isFamilyPresent);
-  const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn;
-  VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
-  for(int i = 0, j = 0; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
-    const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second;
-    int aVtkType = aCellsConnIter->first;
-    if(MYDEBUG) MESSAGE("GetCellsOnEntity - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
-    if(!isFamilyPresent)
-      for(int k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){
-       PrintCells(i,aConnectivity,anArray[k]);
-       aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
-       //aCellTypesArray->InsertNextValue((unsigned char)aVtkType);
-      }
+  try{
+    if(aSource.GetPointer())
+      return aSource.GetPointer();
+    else if(anAttribyteFilter.GetPointer())
+      return anAttribyteFilter->GetUnstructuredGridOutput();
     else{
-      const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
-      if(aSubMesh.empty()) throw std::runtime_error("GetCells >> There is no elements on the family !!!");
-      VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
-      if(aSubMeshIter == aSubMesh.end()) continue;
-      const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
-      if(MYDEBUG) MESSAGE("GetCellsOnEntity - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
-      VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
-      for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
-       PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
-       aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
-       //aCellTypesArray->InsertNextValue((unsigned char)aVtkType);
+      LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
+
+      VISU::TVTKExtractFilter& anExtractFilter = aField.myExtractFilter;
+      if(anExtractFilter.GetPointer() == NULL){
+       anExtractFilter = VISU_ExtractUnstructuredGrid::New();
+       anExtractFilter->Delete();
+       //anExtractFilter->DebugOn();
+       try{
+         LoadMeshOnEntity(*pVTKMeshOnEntity);
+       }catch(std::runtime_error& exc){
+         pVTKMeshOnEntity = pMeshOnEntity;
+         MESSAGE("Follow exception was accured :\n"<<exc.what());
+       }catch(...){
+         pVTKMeshOnEntity = pMeshOnEntity;
+         MESSAGE("Unknown exception was accured!");
+       }
+       GetMeshOnEntity(pVTKMeshOnEntity->myMeshName,pVTKMeshOnEntity->myEntity);
+       
+       anExtractFilter->SetInput(pVTKMeshOnEntity->myStorage.GetPointer());
+       ::InitProfile(anExtractFilter,*pMeshOnEntity,aValForTime);
+      }      
+      if(!anExtractFilter->IsRemoving()){
+       aSource = TOutput::New();
+       aSource->Delete();
+       aSource->ShallowCopy(pVTKMeshOnEntity->myStorage.GetPointer());
+       ::GetTimeStamp(aSource,aMesh,*pVTKMeshOnEntity,aField,aValForTime);
+       anOutput = aSource.GetPointer();
+      }else{
+       anAttribyteFilter = vtkFieldDataToAttributeDataFilter::New();
+       anAttribyteFilter->Delete();
+       //anAttribyteFilter->DebugOn();
+       
+       VISU::TVTKMergetFilter& aMergeFilter = aValForTime.myMergeFilter;
+       aMergeFilter = vtkMergeDataObjectFilter::New();
+       aMergeFilter->Delete();
+       //aMergeFilter->DebugOn();
+
+       ::GetTimeStamp(anAttribyteFilter,aMergeFilter,anExtractFilter,
+                      aMesh,*pVTKMeshOnEntity,aField,aValForTime);
+       anOutput = anAttribyteFilter->GetUnstructuredGridOutput();
       }
-    }
-  }
-  vtkIdType *pts = 0, npts = 0;
-  vtkIntArray* aCellLocationsArray = vtkIntArray::New();
-  aCellLocationsArray->SetNumberOfComponents(1);
-  aCellLocationsArray->SetNumberOfTuples(aNbCells);
-  aConnectivity->InitTraversal();
-  for(int i=0; aConnectivity->GetNextCell(npts,pts); i++){
-    aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
-    //aCellLocationsArray->InsertNextValue(aConnectivity->GetTraversalLocation(npts));
-  }
-  theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
-} 
-
-
-void VISU_Convertor_impl::GetCellsOnGroup(VISU::TVTKSource& theStorage,
-                                         const VISU::TMesh& theMesh,
-                                         const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) 
-  const throw (std::runtime_error&)
-{
-  //Calculate dimentions of the group
-  int aNbCells = 0, aCellsSize = 0;
-  VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
-  for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
-    const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter;
-    const string& aFamilyName = aFamilyAndEntity.first;
-    const VISU::TEntity& anEntity = aFamilyAndEntity.second;
-    const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second;
-    pair<int,int> aCellsDim = aMeshOnEntity.GetCellsDims(aFamilyName);
-    aNbCells += aCellsDim.first;
-    aCellsSize += aCellsDim.second;
-  }
-  vtkCellArray* aConnectivity = vtkCellArray::New();
-  //vtkIdType *anIdArray = aConnectivity->WritePointer(0,aCellsSize);
-  aConnectivity->Allocate(aCellsSize,0);
-  vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
-  aCellTypesArray->SetNumberOfComponents(1);
-  aCellTypesArray->SetNumberOfTuples(aNbCells);
-  aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
-  for(int i = 0, j = 0; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
-    const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter;
-    const string& aFamilyName = aFamilyAndEntity.first;
-    const VISU::TEntity& anEntity = aFamilyAndEntity.second;
-    const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second;
-    const VISU::TFamily& aFamily = *(VISU::GetFamily(aMeshOnEntity,aFamilyName));
-    const VISU::TMeshOnEntity::TCellsConn &aCellsConn = aMeshOnEntity.myCellsConn;
-    VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
-    for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
-      const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second;
-      int aVtkType = aCellsConnIter->first;
-      if(MYDEBUG) MESSAGE("GetCellsOnGroup - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
-      const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
-      if(aSubMesh.empty()) throw std::runtime_error("GetCells >> There is no elements on the family !!!");
-      VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
-      if(aSubMeshIter == aSubMesh.end()) continue;
-      const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
-      if(MYDEBUG) MESSAGE("GetCellsOnGroup - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
-      VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
-      for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
-       PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
-       aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
-       //aCellTypesArray->InsertNextValue((unsigned char)aVtkType);
+      if(MYDEBUGWITHFILES){
+       string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+       string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
+       string aPrefix = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+       string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + 
+         aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
+       VISU::WriteToFile(anOutput,aFileName);
+      }
+      if(MYVTKDEBUG){
+       GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
+       vtkUnstructuredGrid *aDataSet = anAttribyteFilter->GetUnstructuredGridOutput();
+       aDataSet->Update();
+       if(theEntity == VISU::NODE_ENTITY)
+         MESSAGE("GetTimeStampOnMesh - GetData() = "<<float(aDataSet->GetPointData()->GetActualMemorySize()*1000));
+       else
+         MESSAGE("GetMeshOnEntity - GetData() = "<<float(aDataSet->GetCellData()->GetActualMemorySize()*1000));
+       MESSAGE("GetTimeStampOnMesh - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
       }
     }
+  }catch(...){
+    aSource = vtkSmartPointerBase();
+    anAttribyteFilter = vtkSmartPointerBase();
+    throw;
   }
-  vtkIdType *pts = 0, npts = 0;
-  vtkIntArray* aCellLocationsArray = vtkIntArray::New();
-  aCellLocationsArray->SetNumberOfComponents(1);
-  aCellLocationsArray->SetNumberOfTuples(aNbCells);
-  aConnectivity->InitTraversal();
-  for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++){
-    aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
-    //aCellLocationsArray->InsertNextValue(aConnectivity->GetTraversalLocation(npts));
-  }
-  theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
-} 
-
-
-void VISU_Convertor_impl::GetPoints(VISU::TVTKSource& theStorage, const VISU::TMesh& theMesh) 
-  const throw (std::runtime_error&)
-{
-  vtkPoints* aPoints = theMesh.myPoints.get();
-  if(!aPoints){
-    aPoints = vtkPoints::New();
-    const VISU::TMesh::TPointsCoord& anArray = theMesh.myPointsCoord;
-    vtkIdType iEnd = theMesh.myPointsCoord.size();
-    vtkIdType aNbPoints = iEnd / theMesh.myDim;
-    aPoints->SetNumberOfPoints(aNbPoints);
-    if(MYDEBUG) 
-      MESSAGE("GetPoints - aNbPoints = "<<aNbPoints<<"; myDim = "<<theMesh.myDim);
-    switch(theMesh.myDim) {
-    case 1:
-      for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++) 
-       aPoints->SetPoint(j,anArray[i],0.0,0.0);
-      break;
-    case 2:
-      for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++) 
-       aPoints->SetPoint(j,anArray[i],anArray[i+1],0.0);
-      break;
-    case 3: 
-      for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++) 
-       aPoints->SetPoint(j,anArray[i],anArray[i+1],anArray[i+2]);
-      break;
-    }
-  }
-  theStorage->SetPoints(aPoints);
-}
-
-void VISU_Convertor_impl::GetField(VISU::TVTKSource& theStorage,
-                                  const VISU::TMesh& theMesh,
-                                  const VISU::TMeshOnEntity& theMeshOnEntity, 
-                                  const VISU::TField& theField, 
-                                  const VISU::TField::TValForTime& theValForTime)
-  const throw (std::runtime_error&)
-{
-  if(MYDEBUG) MESSAGE("GetField - aTime = "<<theValForTime.myId<<"; theField.myName = "<<theField.myName);
-  int aNumberOfTuples;
-  vtkDataSetAttributes* aDataSetAttributes;
-  switch(theField.myEntity) {
-  case VISU::NODE_ENTITY : 
-    {
-      int aNbPoints = theMesh.myPointsCoord.size()/theMesh.myDim;
-      aNumberOfTuples = aNbPoints;
-      aDataSetAttributes = theStorage->GetPointData();
-      break;
-    }
-  default: 
-    {
-      pair<int,int> aCellsDim = theMeshOnEntity.GetCellsDims();
-      int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second;
-      aNumberOfTuples = aNbCells;
-      aDataSetAttributes = theStorage->GetCellData();
-    }
-  }
-  vtkFloatArray *aFloatArray = vtkFloatArray::New();
-  switch(theField.myNbComp) {
-  case 1:
-    aFloatArray->SetNumberOfComponents(1);
-    aDataSetAttributes->SetScalars(aFloatArray);
-    break;
-  default:
-    aFloatArray->SetNumberOfComponents(3);
-    aDataSetAttributes->SetVectors(aFloatArray);
-  }
-  aFloatArray->SetNumberOfTuples(aNumberOfTuples);
-  //const VISU::TField::TTime& aTime = theValForTime.myTime;
-  //string aFieldName = theField.myMeshName + ", " + theField.myName + ": " + GenerateName(aTime);
-  //aFloatArray->SetName(aFieldName.c_str());
-  if(MYDEBUG) MESSAGE("GetField - aNumberOfTuples = "<<aNumberOfTuples);
-  const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells;
-  VISU::TField::TValForCells::const_iterator aValForCellsIter = aValForCells.begin();
-  for(int k = 0; aValForCellsIter != aValForCells.end(); aValForCellsIter++) {
-    const VISU::TField::TValForCellsWithType& anArray = aValForCellsIter->second;
-    int iEnd = anArray.size()/theField.myNbComp;
-    int aVtkType = aValForCellsIter->first;
-    if(MYDEBUG) MESSAGE("GetField -  iEnd = "<<iEnd<<"; aVtkType = "<<aVtkType);
-    switch(theField.myNbComp) {
-    case 1:
-      for (int i = 0; i < iEnd; i++) 
-       aFloatArray->SetTuple1(k++,anArray[i]);
-      break;
-    case 2:
-      for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*2)
-       aFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+1],0.0);
-      break;
-    case 3:
-      for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*3)
-       aFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+1],anArray[ji+2]);
-      break;
-    default:
-      throw std::runtime_error("GetField - There is algorithm for representation the field !!!");
-    }
-  }
+  return anOutput;
 }
 
-
 void VISU_Convertor_impl::FindMesh(const string& theMeshName, VISU::TMesh*& theMesh)
   throw (std::runtime_error&)
 {
   GetMeshMap();
   if(myMeshMap.find(theMeshName) == myMeshMap.end())
-    throw std::runtime_error("FindMesh >> There is no mesh with the name!!!");
+    throw std::runtime_error(EXCEPT("FindMesh >> There is no mesh with the name - '%1'!!!").
+                            arg(theMeshName.c_str()).latin1());
   theMesh = &myMeshMap[theMeshName];
 }
 
 
-void VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName, VISU::TMesh*& theMesh,
-                                          const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity,
-                                          const string& theFamilyName, VISU::TFamily*& theFamily)
+void VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName, 
+                                          VISU::TMesh*& theMesh,
+                                          const VISU::TEntity& theEntity, 
+                                          VISU::TMeshOnEntity*& theMeshOnEntity,
+                                          const string& theFamilyName, 
+                                          VISU::TFamily*& theFamily)
   throw (std::runtime_error&)
 {
   FindMesh(theMeshName,theMesh);
   VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
   if(aMeshOnEntityMap.find(theEntity) == aMeshOnEntityMap.end())
-    throw std::runtime_error("FindMeshOnEntity >> There is no mesh on the entity!!!");
+    throw std::runtime_error(EXCEPT("FindMeshOnEntity >> There is no mesh on the entity - %1!!!").
+                            arg(int(theEntity)).latin1());
   theMeshOnEntity = &aMeshOnEntityMap[theEntity];
   theFamily = VISU::GetFamily(*theMeshOnEntity,theFamilyName);
 }
 
 
-vtkIdType VISU_Convertor_impl::GetMeshOnEntitySize(const std::string& theMeshName, 
-                                                  const VISU::TEntity& theEntity,
-                                                  const std::string& theFamilyName)
+float VISU_Convertor_impl::GetSize() throw (std::runtime_error&){
+  float aResult = 0.0;
+  const VISU::TMeshMap& aMeshMap = GetMeshMap();
+  VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+  for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+    const string& aMeshName = aMeshMapIter->first;
+    const VISU::TMesh& aMesh = aMeshMapIter->second;
+    const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap;
+    VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
+    //Import fields
+    aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+    for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+      const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+      const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+      const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap;
+      VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
+      for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
+       const string& aFieldName = aFieldMapIter->first;
+       const VISU::TField& aField = aFieldMapIter->second;
+       const VISU::TField::TValField& aValField = aField.myValField;
+       VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin();
+       for(; aValFieldIter != aValField.end(); aValFieldIter++){
+         int aTimeStamp = aValFieldIter->first;
+         aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
+       }
+      }
+      //Importing groups
+      const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
+      VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
+      for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
+       const string& aGroupName = aGroupMapIter->first;
+       aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
+      }
+      //Import families
+      const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
+      VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+      for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+       const string& aFamilyName = aFamilyMapIter->first;
+       aResult += GetMeshOnEntitySize(aMeshName,anEntity,aFamilyName);
+      }
+      //Import mesh on entity
+      aResult += GetMeshOnEntitySize(aMeshName,anEntity);
+    }
+  }
+  if(MYDEBUG)
+    MESSAGE("GetSize - aResult = "<<float(aResult));
+  return aResult;
+}
+
+
+float VISU_Convertor_impl::GetMeshOnEntitySize(const std::string& theMeshName, 
+                                              const VISU::TEntity& theEntity,
+                                              const std::string& theFamilyName)
   throw (std::runtime_error&)
 {
   VISU::TMesh* pMesh = NULL;
   VISU::TFamily* pFamily = NULL;
   VISU::TMeshOnEntity* pMeshOnEntity = NULL;
   FindMeshOnEntity(theMeshName,pMesh,theEntity,pMeshOnEntity,theFamilyName,pFamily);
-  vtkIdType aResult = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord);
+  vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord);
   vtkIdType aNbCells, aCellsSize;
   if(!pFamily){
     aNbCells = pMeshOnEntity->myNbCells;
@@ -457,10 +704,26 @@ vtkIdType VISU_Convertor_impl::GetMeshOnEntitySize(const std::string& theMeshNam
     aNbCells = pFamily->myNbCells;
     aCellsSize = pFamily->myCellsSize;
   }
-  //that is Connectivity + (Types + Locations + Links)
-  aResult += aCellsSize*sizeof(vtkIdType) + 
-    aNbCells*(sizeof(char) + sizeof(int) + (sizeof(short) + sizeof(vtkIdType)));
-  if(MYDEBUG) cout<<"VISU_Convertor_impl::GetMeshOnEntitySize = "<<aResult<<endl;
+  vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+  vtkIdType aTypesSize = aNbCells*sizeof(char);
+  vtkIdType aLocationsSize = aNbCells*sizeof(int);
+  float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+  vtkIdType aLinksSize = pMesh->myNbPoints * 
+    (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
+  aLinksSize = 0;
+  vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+  if(MYDEBUG){
+    if(MYVTKDEBUG){
+      MESSAGE("GetMeshOnEntitySize - aPointsSize = "<<float(aPointsSize));
+      MESSAGE("GetMeshOnEntitySize - aConnectivitySize = "<<float(aConnectivitySize));
+      MESSAGE("GetMeshOnEntitySize - aTypesSize = "<<float(aTypesSize));
+      MESSAGE("GetMeshOnEntitySize - aLocationsSize = "<<float(aLocationsSize));
+      MESSAGE("GetMeshOnEntitySize - aLinksSize = "<<float(aLinksSize));
+    }
+    MESSAGE("GetMeshOnEntitySize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
+           "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+  }
+  aResult = vtkIdType(aResult*ERR_SIZE_CALC);
   return aResult;
 }
 
@@ -473,21 +736,38 @@ void VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName, VISU::
   VISU::TGroupMap& aGroupMap = theMesh->myGroupMap;
   VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
   if(aGroupMapIter == aGroupMap.end())
-    throw std::runtime_error("FindMeshOnGroup >> There is no the group in the mesh!!!");
+    throw std::runtime_error(EXCEPT("FindMesh >> There is no the group in the mesh!!! - '%1'").arg(theGroupName.c_str()).latin1());
   theGroup = &aGroupMapIter->second;
 }
 
 
-vtkIdType VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, 
-                                                 const std::string& theGroupName)
+float VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, 
+                                             const std::string& theGroupName)
   throw (std::runtime_error&)
 {
   VISU::TMesh* pMesh = NULL;
   VISU::TGroup* pGroup = NULL;
   FindMeshOnGroup(theMeshName,pMesh,theGroupName,pGroup);
-  vtkIdType aResult = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord);
-  aResult += pGroup->myCellsSize*sizeof(vtkIdType);
-  if(MYDEBUG) cout<<"VISU_Convertor_impl::GetMeshOnGroupSize = "<<aResult<<endl;
+  vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord);
+  vtkIdType aNbCells = pGroup->myNbCells, aCellsSize = pGroup->myCellsSize;
+  vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
+  vtkIdType aLocationsSize = aNbCells*sizeof(int);
+  float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+  vtkIdType aLinksSize = pMesh->myNbPoints * 
+    (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
+  aLinksSize = 0;
+  vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
+  if(MYDEBUG){
+    if(MYVTKDEBUG){
+      MESSAGE("GetMeshOnGroupSize - aPointsSize = "<<float(aPointsSize));
+      MESSAGE("GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<float(aConnectivityAndTypesSize));
+      MESSAGE("GetMeshOnGroupSize - aLocationsSize = "<<float(aLocationsSize));
+      MESSAGE("GetMeshOnGroupSize - aLinksSize = "<<float(aLinksSize));
+    }
+    MESSAGE("GetMeshOnGroupSize - aResult = "<<float(aResult)<<"; theMeshName = '"
+           <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
+  }
+  aResult = vtkIdType(aResult*ERR_SIZE_CALC);
   return aResult;
 }
 
@@ -505,21 +785,24 @@ void VISU_Convertor_impl::FindField(const string& theMeshName, VISU::TMesh*& the
   theMeshOnEntity = pMeshOnEntity;
   VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
   if(theEntity == VISU::NODE_ENTITY){
-    if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) == aMeshOnEntityMap.end())
-      throw std::runtime_error("FindField >> There is no mesh on CELL_ENTITY!!!");
-    pMeshOnEntity = &aMeshOnEntityMap[VISU::CELL_ENTITY];
+    if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
+      pMeshOnEntity = &aMeshOnEntityMap[VISU::CELL_ENTITY];
+    else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end())
+      pMeshOnEntity = &aMeshOnEntityMap[VISU::FACE_ENTITY];
+    else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
+      pMeshOnEntity = &aMeshOnEntityMap[VISU::EDGE_ENTITY];
   }
   theVTKMeshOnEntity = pMeshOnEntity;
   VISU::TFieldMap& aFieldMap = theMeshOnEntity->myFieldMap;
   if(aFieldMap.find(theFieldName) == aFieldMap.end())
-    throw std::runtime_error("FindField >> There is no field on the mesh!!!");
+    throw std::runtime_error(EXCEPTION("FindField >> There is no field on the mesh!!!"));
   theField = &aFieldMap[theFieldName];
 }
 
 
-vtkIdType VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, 
-                                                 const VISU::TEntity& theEntity,
-                                                 const std::string& theFieldName)
+float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, 
+                                             const VISU::TEntity& theEntity,
+                                             const std::string& theFieldName)
   throw(std::runtime_error&)
 {
   VISU::TMesh* pMesh = NULL;
@@ -527,10 +810,15 @@ vtkIdType VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName
   VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
   FindField(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
            theFieldName,pField);
-  
-  vtkIdType aResult = GetMeshOnEntitySize(theMeshName,theEntity);
-  aResult += pField->myDataSize*sizeof(float)*pField->myNbValField;
-  if(MYDEBUG) cout<<"VISU_Convertor_impl::GetFieldOnMeshSize = "<<aResult<<endl;
+  float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity);
+  float aFieldOnMeshSize = float(pField->myDataSize*sizeof(float)*pField->myNbValField * ERR_SIZE_CALC);
+  float aResult = aMeshSize + aFieldOnMeshSize;
+  if(MYDEBUG){
+    if(MYVTKDEBUG)
+      MESSAGE("GetFieldOnMeshSize - aFieldOnMeshSize = "<<float(aFieldOnMeshSize));
+    MESSAGE("GetFieldOnMeshSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
+           "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
+  }
   return aResult;
 }
 
@@ -546,15 +834,15 @@ void VISU_Convertor_impl::FindTimeStamp(const std::string& theMeshName, VISU::TM
   FindField(theMeshName,theMesh,theEntity,theMeshOnEntity,theVTKMeshOnEntity,theFieldName,theField);
   VISU::TField::TValField& aValField = theField->myValField;
   if(aValField.find(theStampsNum) == aValField.end())
-    throw std::runtime_error("FindTimeStamp >> There is no field with the timestamp!!!");
+    throw std::runtime_error(EXCEPTION("FindTimeStamp >> There is no field with the timestamp!!!"));
   theValForTime = &aValField[theStampsNum];
 }
 
 
-vtkIdType VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, 
-                                               const VISU::TEntity& theEntity,
-                                               const std::string& theFieldName,
-                                               int theStampsNum)
+float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, 
+                                           const VISU::TEntity& theEntity,
+                                           const std::string& theFieldName,
+                                           int theStampsNum)
   throw (std::runtime_error&)
 {
   VISU::TMesh* pMesh = NULL;
@@ -563,10 +851,15 @@ vtkIdType VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName,
   VISU::TField::TValForTime* pValForTime = NULL;
   FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
                theFieldName,pField,theStampsNum,pValForTime);
-
-  vtkIdType aResult = GetMeshOnEntitySize(theMeshName,theEntity);
-  aResult += pField->myDataSize*sizeof(float);
-  if(MYDEBUG) cout<<"VISU_Convertor_impl::GetTimeStampSize = "<<aResult<<endl;
+  float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity);
+  float aTimeStampSize = float(pField->myDataSize*sizeof(float) * ERR_SIZE_CALC);
+  float aResult = aMeshSize + aTimeStampSize;
+  if(MYDEBUG){
+    if(MYVTKDEBUG)
+      MESSAGE("GetTimeStampSize - aTimeStampSize = "<<float(aTimeStampSize));
+    MESSAGE("GetTimeStampSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
+           "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
+  }
   return aResult;
 }
 
@@ -574,7 +867,7 @@ vtkIdType VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName,
 const VISU::TField& 
 VISU_Convertor_impl::GetField(const string& theMeshName, 
                              VISU::TEntity theEntity, 
-                             const string& theFieldName) 
+                             const string& theFieldName) 
   throw (std::runtime_error&)
 {
   VISU::TMesh* pMesh = NULL;
index 9ea6d9d8da49e6dcee8e3740d903569cdf40fded..cd1518916a1c77dc67ec7ad3f7be8749e000eb91 100644 (file)
@@ -19,74 +19,34 @@ extern "C"{
 #include <qfileinfo.h>
 
 class VISU_Convertor_impl: public VISU_Convertor{
-private:
-  void GetPoints(VISU::TVTKSource& theStorage, 
-                const VISU::TMesh& theMesh) 
-    const throw (std::runtime_error&);
-  void GetCellsOnEntity(VISU::TVTKSource& theStorage,
-                       const VISU::TMeshOnEntity& theMeshOnEntity, 
-                       const std::string& theFamilyName) 
-    const throw (std::runtime_error&);
-  void GetCellsOnGroup(VISU::TVTKSource& theStorage,
-                      const VISU::TMesh& theMesh,
-                      const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) 
-    const throw (std::runtime_error&);
-  void GetField(VISU::TVTKSource& theStorage,
-               const VISU::TMesh& theMesh,
-               const VISU::TMeshOnEntity& theMeshOnEntity, 
-               const VISU::TField& theField, 
-               const VISU::TField::TValForTime& theValForTime) 
-    const throw (std::runtime_error&);
-
+public:
+  virtual float GetSize() throw (std::runtime_error&);
 
-protected:
-  void FindMesh(const std::string& theMeshName, VISU::TMesh*& theMesh)
-    throw(std::runtime_error&);
-  void FindMeshOnEntity(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                       const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity,
-                       const std::string& theFamilyName, VISU::TFamily*& theFamily)
+  virtual float GetMeshOnEntitySize(const std::string& theMeshName, 
+                                   const VISU::TEntity& theEntity,
+                                   const std::string& theFamilyName = "")
     throw (std::runtime_error&);
 
-  void FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                      const std::string& theGroupName, VISU::TGroup*& theGroup)
-    throw (std::runtime_error&);
-
-  void FindField(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                const VISU::TEntity& theEntity, 
-                VISU::TMeshOnEntity*& theMeshOnEntity,
-                VISU::TMeshOnEntity*& theVTKMeshOnEntity,
-                const std::string& theFieldName, VISU::TField*& theField)
-    throw (std::runtime_error&);
-  void FindTimeStamp(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                    const VISU::TEntity& theEntity, 
-                    VISU::TMeshOnEntity*& theMeshOnEntity,
-                    VISU::TMeshOnEntity*& theVTKMeshOnEntity,
-                    const std::string& theFieldName, VISU::TField*& theField,
-                    int theStampsNum, VISU::TField::TValForTime*& theValForTime)
-    throw (std::runtime_error&);
-
-
-public:
-  virtual vtkIdType GetMeshOnEntitySize(const std::string& theMeshName, 
-                                       const VISU::TEntity& theEntity,
-                                       const std::string& theFamilyName = "")
-    throw (std::runtime_error&);
-  virtual vtkIdType GetMeshOnGroupSize(const std::string& theMeshName, 
-                                      const std::string& theGroupName)
+  virtual float GetMeshOnGroupSize(const std::string& theMeshName, 
+                                  const std::string& theGroupName)
     throw(std::runtime_error&);
-  virtual vtkIdType GetTimeStampSize(const std::string& theMeshName, 
-                                    const VISU::TEntity& theEntity,
-                                    const std::string& theFieldName,
-                                    int theStampsNum)
+
+  virtual float GetTimeStampSize(const std::string& theMeshName, 
+                                const VISU::TEntity& theEntity,
+                                const std::string& theFieldName,
+                                int theStampsNum)
     throw(std::runtime_error&);
-  virtual vtkIdType GetFieldOnMeshSize(const std::string& theMeshName, 
-                                      const VISU::TEntity& theEntity,
-                                      const std::string& theFieldName)
+
+  virtual float GetFieldOnMeshSize(const std::string& theMeshName, 
+                                  const VISU::TEntity& theEntity,
+                                  const std::string& theFieldName)
     throw(std::runtime_error&);
+
   virtual const VISU::TField& GetField(const std::string& theMeshName, 
                                       VISU::TEntity theEntity, 
                                       const std::string& theFieldName)
     throw(std::runtime_error&);
+
   virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName, 
                                                        const VISU::TEntity& theEntity,
                                                        const std::string& theFieldName,
@@ -95,28 +55,63 @@ public:
 
 public:
   VISU_Convertor_impl();
+
   virtual ~VISU_Convertor_impl();
+
   virtual VISU_Convertor* Build() throw (std::runtime_error&) { return this;};
+
   virtual TOutput* GetMeshOnEntity(const std::string& theMeshName, 
                                   const VISU::TEntity& theEntity,
                                   const std::string& theFamilyName = "")
     throw(std::runtime_error&);
+
   virtual TOutput* GetMeshOnGroup(const std::string& theMeshName, 
                                  const std::string& theGroupName)
     throw(std::runtime_error&);
+
   virtual TOutput* GetTimeStampOnMesh(const std::string& theMeshName, 
                                      const VISU::TEntity& theEntity,
                                      const std::string& theFieldName,
                                      int theStampsNum)
     throw(std::runtime_error&);
 
- protected:
+protected:
+  void FindMesh(const std::string& theMeshName, VISU::TMesh*& theMesh)
+    throw(std::runtime_error&);
+
+  void FindMeshOnEntity(const std::string& theMeshName, VISU::TMesh*& theMesh,
+                       const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity,
+                       const std::string& theFamilyName, VISU::TFamily*& theFamily)
+    throw (std::runtime_error&);
+
+  void FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
+                      const std::string& theGroupName, VISU::TGroup*& theGroup)
+    throw (std::runtime_error&);
+
+  void FindField(const std::string& theMeshName, VISU::TMesh*& theMesh,
+                const VISU::TEntity& theEntity, 
+                VISU::TMeshOnEntity*& theMeshOnEntity,
+                VISU::TMeshOnEntity*& theVTKMeshOnEntity,
+                const std::string& theFieldName, VISU::TField*& theField)
+    throw (std::runtime_error&);
+
+  void FindTimeStamp(const std::string& theMeshName, VISU::TMesh*& theMesh,
+                    const VISU::TEntity& theEntity, 
+                    VISU::TMeshOnEntity*& theMeshOnEntity,
+                    VISU::TMeshOnEntity*& theVTKMeshOnEntity,
+                    const std::string& theFieldName, VISU::TField*& theField,
+                    int theStampsNum, VISU::TField::TValForTime*& theValForTime)
+    throw (std::runtime_error&);
+
+protected:
   virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, 
                               const std::string& theFamilyName = "")
     throw (std::runtime_error&) = 0;
+
   virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, 
                              const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
     throw (std::runtime_error&) = 0;
+
   virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, 
                              VISU::TMeshOnEntity& theMeshOnEntity, 
                              VISU::TField& theField, 
@@ -124,27 +119,4 @@ public:
     throw (std::runtime_error&) = 0;
 };
 
-template<class T> std::string dtos(const std::string& fmt, T val){
-  static QString aString;
-  aString.sprintf(fmt.c_str(),val);
-  return aString.latin1();
-}
-
-extern "C"{
-  int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim);
-  int getNbMedNodes(int theMedType);
-  int med2vtkCellType(int theMedType);
-  int vtk2medCellType(int theVtkType);
-  int getIdMedType(int medType);
-}
-
-struct Med2vtk {
-  med_geometrie_element medType;
-  const char *medName;
-  int medNbNodes;
-  int vtkType;
-  const char *vtkName;
-  int vtkNbNodes;
-};
-extern Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE];
 #endif
diff --git a/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx
new file mode 100644 (file)
index 0000000..a8ba1e3
--- /dev/null
@@ -0,0 +1,101 @@
+//  VISU CONVERTOR :
+//
+//  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_ExtractUnstructuredGrid.cxx
+// Author:  Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_ExtractUnstructuredGrid.hxx"
+#include "VISU_ConvertorUtils.hxx"
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkObjectFactory.h>
+#include <vtkIdList.h>
+#include <vtkCell.h>
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+vtkStandardNewMacro(VISU_ExtractUnstructuredGrid);
+
+VISU_ExtractUnstructuredGrid::VISU_ExtractUnstructuredGrid(){}
+
+VISU_ExtractUnstructuredGrid::~VISU_ExtractUnstructuredGrid(){}
+
+void VISU_ExtractUnstructuredGrid::RemoveCell(vtkIdType theCellId){
+  myRemovedCellIds.insert(theCellId);
+  Modified();
+}
+
+void VISU_ExtractUnstructuredGrid::RemoveCellsWithType(vtkIdType theCellType){
+  myRemovedCellTypes.insert(theCellType);
+  Modified();
+}
+
+namespace{
+  inline void InsertCell(vtkUnstructuredGrid *theInput, 
+                         vtkUnstructuredGrid *theOutput,
+                         vtkIdType theCellId, vtkIdList *theCellIds)
+  {
+    theCellIds->Reset();
+    vtkCell *aCell = theInput->GetCell(theCellId);
+    vtkIdType aNbIds = aCell->PointIds->GetNumberOfIds();
+    for(vtkIdType i = 0; i < aNbIds; i++)
+      theCellIds->InsertNextId(aCell->GetPointIds()->GetId(i));
+    theOutput->InsertNextCell(theInput->GetCellType(theCellId), theCellIds);
+  }
+}
+
+void VISU_ExtractUnstructuredGrid::Execute(){
+  vtkUnstructuredGrid *anInput = this->GetInput(), *anOutput = this->GetOutput();
+  vtkIdType aNbCells = anInput->GetNumberOfCells();
+  anOutput->Allocate(aNbCells);
+  if(MYDEBUG) MESSAGE("Execute - anInput->GetNumberOfCells() = "<<anInput->GetNumberOfCells());
+  vtkIdList *aCellIds = vtkIdList::New();
+  if(MYDEBUG) 
+    MESSAGE("Execute - myRemovedCellIds.empty() = "<<myRemovedCellIds.empty()<<
+           "; myRemovedCellTypes.empty() = "<<myRemovedCellTypes.empty());
+  if(myRemovedCellIds.empty() && myRemovedCellTypes.empty())
+    anOutput->CopyStructure(anInput);
+  else if(!myRemovedCellIds.empty() && myRemovedCellTypes.empty()){
+    for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++)
+      if(myRemovedCellIds.find(aCellId) == myRemovedCellIds.end())
+       InsertCell(anInput,anOutput,aCellId,aCellIds);
+  }else if(myRemovedCellIds.empty() && !myRemovedCellTypes.empty()){
+    for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++)
+      if(myRemovedCellTypes.find(anInput->GetCellType(aCellId)) == myRemovedCellTypes.end())
+       InsertCell(anInput,anOutput,aCellId,aCellIds);
+  }else if(!myRemovedCellIds.empty() && !myRemovedCellTypes.empty())
+    for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++)
+      if(myRemovedCellTypes.find(anInput->GetCellType(aCellId)) == myRemovedCellTypes.end())
+       if(myRemovedCellIds.find(aCellId) == myRemovedCellIds.end())
+         InsertCell(anInput,anOutput,aCellId,aCellIds);
+  aCellIds->Delete();
+  anOutput->SetPoints(anInput->GetPoints());
+  if(MYDEBUG) MESSAGE("Execute - anOutput->GetNumberOfCells() = "<<anOutput->GetNumberOfCells());
+}
diff --git a/src/CONVERTOR/VISU_ExtractUnstructuredGrid.hxx b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.hxx
new file mode 100644 (file)
index 0000000..2839674
--- /dev/null
@@ -0,0 +1,70 @@
+//  VISU CONVERTOR :
+//
+//  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_ExtractUnstructuredGrid.hxx
+//  Author : Alexey PETROV
+//  Module : VISU
+
+#ifndef VISU_ExtractUnstructuredGrid_HeaderFile
+#define VISU_ExtractUnstructuredGrid_HeaderFile
+
+#include <vtkUnstructuredGridToUnstructuredGridFilter.h>
+
+#include <set>
+
+class VISU_ExtractUnstructuredGrid : public vtkUnstructuredGridToUnstructuredGridFilter{
+public:
+  vtkTypeMacro(VISU_ExtractUnstructuredGrid,vtkUnstructuredGridToUnstructuredGridFilter);
+
+  // Description:
+  // Construct with all types of clipping turned off.
+  static VISU_ExtractUnstructuredGrid *New();
+
+  // Description:
+  // Remove the cell from the output
+  void RemoveCell(vtkIdType theCellId);
+  int IsRemoveCells() { return !myRemovedCellIds.empty();}
+
+  // Remove every cells with the type from the output
+  void RemoveCellsWithType(vtkIdType theCellType);
+  int IsRemoveCellsWithType() { return !myRemovedCellTypes.empty();}
+
+  // Do the filter do some real work
+  int IsRemoving() { return IsRemoveCells() || IsRemoveCellsWithType();}
+
+protected:
+  VISU_ExtractUnstructuredGrid();
+  ~VISU_ExtractUnstructuredGrid();
+
+  void Execute();
+  
+  std::set<vtkIdType> myRemovedCellIds;
+  std::set<vtkIdType> myRemovedCellTypes;
+
+private:
+  VISU_ExtractUnstructuredGrid(const VISU_ExtractUnstructuredGrid&);  // Not implemented.
+  void operator=(const VISU_ExtractUnstructuredGrid&);  // Not implemented.
+};
+
+#endif
+
+
index 9587f53f9c48aaf8517fe0c34b0ff291b3379ec9..ab1e1026099b0db74674acd7f62b841498dc2e80 100644 (file)
 
 
 #include "VISU_MedConvertor.hxx"
+#include "VISU_ConvertorUtils.hxx"
+
 #include <valarray>    
 #include <vtkCellType.h>
+
 #define USER_INTERLACE MED_FULL_INTERLACE
 
 using namespace std;
@@ -38,6 +41,7 @@ static int MYDEBUG = 0;
 static int MYDEBUG = 0;
 #endif
 
+
 static med_err ret = 0;
 
 typedef map<VISU::TEntity,med_entite_maillage> TVisu2MedEntity;
@@ -118,6 +122,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
   MedFile aMedFile(myFileInfo.absFilePath());
   med_idt fid = aMedFile.GetFid();
   med_int iMeshEnd = MEDnMaa(fid);  //Get number of meshes
+  if (iMeshEnd < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDnMaa(...)"));
   if(MYDEBUG) MESSAGE("ImportInfo - MEDnMaa = "<<iMeshEnd<<"; myFileInfo = "<<myFileInfo.filePath());
   for(int iMesh = 1; iMesh <= iMeshEnd; iMesh++){
     med_int aMeshDim;
@@ -168,7 +173,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
            ret = MEDnoeudsLire(fid,aMeshName,aMesh.myDim,&coord[0],MED_FULL_INTERLACE,&rep,
                                &name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem,
                                &num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd);
-           if(ret < 0) throw std::runtime_error("ImportInfo >> MEDnoeudsLire(...)");
+           if(ret < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDnoeudsLire(...)"));
            for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
              if(num_fam_elem[iNumElem] != 0){
                aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity;
@@ -199,7 +204,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
          ret = MEDelementsLire(fid,aMeshName,aMesh.myDim,&conn[0],MED_FULL_INTERLACE,
                                &name_elem[0],&iname_elem,&num_elem[0],&inum_elem,
                                &num_fam_elem[0],iNumElemEnd,aMedEntity,aMedType,MED_NOD);
-         if (ret < 0) throw std::runtime_error("ImportInfo >> MEDelementsLire(...)");
+         if (ret < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDelementsLire(...)"));
          for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
            if(num_fam_elem[iNumElem] != 0){
              aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity;
@@ -224,7 +229,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
       ret = MEDfamInfo(fid,aMeshName,aFamInd,aFamilyName,&aFamilyNum,
                       &anAttId[0],&anAttVal[0],&anAttDesc[0],&aNbAttrib,
                       &aGroupNames[0],&aNbGroup);
-      if(ret < 0) throw std::runtime_error("ImportInfo >> MEDfamInfo");
+      if(ret < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDfamInfo"));
       if(0 && MYDEBUG) 
        MESSAGE("ImportInfo - aFamilyNum = "<<aFamilyNum<<"; aNbGroup = "<<aNbGroup);
       if(aFamily2EntityMap.find(aFamilyNum) == aFamily2EntityMap.end()) {
@@ -301,17 +306,17 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
   }
   //Reading information about fields
   med_int iFieldEnd = MEDnChamp(fid,0);
-  if (iFieldEnd < 0) throw std::runtime_error("ImportChamps >> MEDnChamp(fid,0)");
+  if (iFieldEnd < 0) throw std::runtime_error(EXCEPTION("ImportChamps >> MEDnChamp(fid,0)"));
   if(MYDEBUG) MESSAGE("ImportInfo - iFieldEnd = "<<iFieldEnd);
   for(med_int iField = 1; iField <= iFieldEnd; iField++){
     med_int ncomp = MEDnChamp(fid,iField);
-    if(ncomp < 0) throw std::runtime_error("ImportChamps >> MEDnChamp(fid,i)");
+    if(ncomp < 0) throw std::runtime_error(EXCEPTION("ImportChamps >> MEDnChamp(fid,i)"));
     valarray<char> aCompNames('\0',ncomp*MED_TAILLE_PNOM + 1);
     valarray<char> aUnitNames('\0',ncomp*MED_TAILLE_PNOM + 1);
     char name_field[MED_TAILLE_NOM + 1] = "";
     med_type_champ type_field;
     if(MEDchampInfo(fid,iField,name_field,&type_field,&aCompNames[0],&aUnitNames[0],ncomp) < 0)
-      throw std::runtime_error(string("ImportInfo >> MEDchampInfo(...)"));
+      throw std::runtime_error(EXCEPTION("ImportInfo >> MEDchampInfo(...)"));
     //if(type_field != MED_REEL64) continue; //There is some problem in reading INTXX values
     TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin();
     for(; aVisu2MedEntityIter != aVisu2MedEntity.end(); aVisu2MedEntityIter++) {
@@ -323,7 +328,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
       for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
        med_geometrie_element& aGeom = aGeomElemVector[iGeomElem];
        med_int iTimeStampEnd = MEDnPasdetemps(fid,name_field,aMedEntity,aGeom);
-       if(iTimeStampEnd < 0) throw std::runtime_error("ImportInfo >> MEDnPasdetemps(...)");
+       if(iTimeStampEnd < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDnPasdetemps(...)"));
        if(iTimeStampEnd > 0) {
          for(med_int iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++) {
            char aMeshName[MED_TAILLE_NOM+1] = "";
@@ -332,9 +337,9 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
            med_float dt = 0;
            ret = MEDpasdetempsInfo(fid,name_field,aMedEntity,aGeom,iTimeStamp,
                                    aMeshName,&ngauss,&numdt,dt_unit,&dt,&numo);
-           if(ret < 0) throw std::runtime_error("ImportInfo >> MEDpasdetempsInfo(...) < 0");
+           if(ret < 0) throw std::runtime_error(EXCEPTION("ImportInfo >> MEDpasdetempsInfo(...) < 0"));
            if(myMeshMap.find(aMeshName) == myMeshMap.end())
-             throw std::runtime_error("ImportInfo >> MEDpasdetempsInfo(...)");
+             throw std::runtime_error(EXCEPTION("ImportInfo >> MEDpasdetempsInfo(...)"));
            VISU::TMesh &aMesh = myMeshMap[aMeshName];
            VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
            VISU::TFieldMap::iterator aFieldMapIter = aMeshOnEntity.myFieldMap.find(name_field);
@@ -376,7 +381,7 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
            aValForTime.myMeshName = aField.myMeshName;
            aValForTime.myNbComp = aField.myNbComp;
            aValForTime.myTime = VISU::TField::TTime(dt,dt_unit);
-           if(MYDEBUG && iGeomElem == 0
+           if(MYDEBUG) 
              MESSAGE("ImportInfo -\t aValForTime.myTime = "<<dt<<", "<<dt_unit);
          }
        }
@@ -475,7 +480,7 @@ int VISU_MedConvertor::LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, cons
     med_geometrie_element typgeo = (med_geometrie_element)0; //MED_POINT1
     med_connectivite typco = (med_connectivite)0; //MED_NOD
     med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_COOR,MED_NOEUD,typgeo,typco);
-    if (iNumElemEnd <= 0) throw std::runtime_error("LoadPoints >> MEDnEntMaa(...)");
+    if (iNumElemEnd <= 0) throw std::runtime_error(EXCEPTION("LoadPoints >> MEDnEntMaa(...)"));
     if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
     med_repere rep;
     med_booleen iname_elem, inum_elem;
@@ -487,18 +492,18 @@ int VISU_MedConvertor::LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, cons
     ret = MEDnoeudsLire(fid,aMeshName,theMesh.myDim,&coord[0],MED_FULL_INTERLACE,&rep,
                        &name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem,
                        &num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd);
-    if(ret < 0) throw std::runtime_error("LoadPoints >> MEDnoeudsLire(...)");
+    if(ret < 0) throw std::runtime_error(EXCEPTION("LoadPoints >> MEDnoeudsLire(...)"));
     if(!isPointsLoaded){
       VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord;
       aPointsCoord.resize(iNumElemEnd*theMesh.myDim);
       if(MYDEBUG) MESSAGE("LoadPoints - Filling coordinates of the mesh - inum_elem = "<<inum_elem);
-      inum_elem = MED_FAUX; // It is workaround
+      inum_elem = MED_FAUX; // It is workaround 
       if(inum_elem == MED_FAUX)
        for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
          for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++)
            aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
       else
-       for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
+       for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
          for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++)
            aPointsCoord[num_elem[iNumElem2Dim]] = coord[iNumElem2Dim];
       if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
@@ -520,7 +525,7 @@ int VISU_MedConvertor::LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, cons
     throw std::runtime_error(exc.what());
   }catch(...){
     theMesh.myPointsCoord.clear();
-    throw std::runtime_error("Unknown exception !!!");
+    throw std::runtime_error(EXCEPTION("Unknown exception !!!"));
   }
   return 0;
 }
@@ -556,6 +561,14 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity
              "; iGeomElemEnd = "<<iGeomElemEnd<<"; theFamilyName = '"<<theFamilyName<<"'");
     VISU::TMesh &aMesh = myMeshMap[theMeshOnEntity.myMeshName];
     int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim;
+    valarray<med_int>  num_node(aNbPoints);
+    med_booleen inum_node = 
+      med_booleen(MEDnumLire(fid,aMeshName,&num_node[0],aNbPoints,MED_NOEUD,med_geometrie_element(0)) >= 0);
+    if(MYDEBUG) MESSAGE("LoadCellsOnEntity - inum_node = "<<inum_node);
+    map<med_int,med_int> node_map;
+    if(inum_node) 
+      for(int i = 0; i < aNbPoints; i++) 
+       node_map[num_node[i]-1] = i;
     for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
       int medId = getIdMedType(aGeomElemVector[iGeomElem]);
       int nbMedNodes = med2vtk[medId].medNbNodes;
@@ -574,7 +587,7 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity
        ret = MEDelementsLire(fid,aMeshName,aMesh.myDim,&conn[0],MED_FULL_INTERLACE,
                              &name_elem[0],&iname_elem,&num_elem[0],&inum_elem,
                              &num_fam_elem[0],iNumElemEnd,aMedEntity,aMedType,MED_NOD);
-       if (ret < 0) throw std::runtime_error("LoadCellsOnEntity >> MEDelementsLire(...)");
+       if (ret < 0) throw std::runtime_error(EXCEPTION("LoadCellsOnEntity >> MEDelementsLire(...)"));
        if(!isCellsLoaded){
          VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType];
          aConnForCellType.resize(iNumElemEnd);
@@ -582,9 +595,12 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity
          for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
            VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem];
            anArray.resize(nbVtkNodes);
-           for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) {
-             aConnect[k] = conn[kj+k] - 1;
-           }
+           if(inum_node)
+             for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++)
+               aConnect[k] = node_map[conn[kj+k]-1];
+           else
+             for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++)
+               aConnect[k] = conn[kj+k] - 1;
            switch(aMedType){
            case MED_TETRA4 :
            case MED_TETRA10 :
@@ -606,11 +622,9 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity
                anArray[k] = aConnect[k];
            }
            for (int k = 0; k < nbVtkNodes; k++) 
-             if(anArray[k] < 0 || aNbPoints <= anArray[k]){
-               static QString aString;
-               aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d](%d) < 0",aNbPoints,iNumElem,k,anArray[k]);
-               throw std::runtime_error(aString.latin1());
-             }
+             if(anArray[k] < 0 || aNbPoints <= anArray[k])
+               throw std::runtime_error(EXCEPT("ImportCells >> aNbPoints(%1) <= anArray[%2][%3](%4) < 0").
+                                        arg(aNbPoints).arg(iNumElem).arg(k).arg(anArray[k]).latin1());
          }
        }
        //Filling aFamily SubMesh
@@ -628,67 +642,93 @@ int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity
     throw std::runtime_error(exc.what());
   }catch(...){
     theMeshOnEntity.myCellsConn.clear();
-    throw std::runtime_error("Unknown exception !!!");
+    throw std::runtime_error(EXCEPTION("Unknown exception !!!"));
   }
   return 0;
 }
 
 int VISU_MedConvertor::LoadField(const med_idt& fid, const VISU::TMeshOnEntity& theMeshOnEntity,
-                                const VISU::TField& theField, VISU::TField::TValForTime& theValForTime)
+                                VISU::TField& theField, VISU::TField::TValForTime& theValForTime)
      throw (std::runtime_error&)
 {
   //Check on loading already done
   if(!theValForTime.myValForCells.empty()) return 0;
   //Main part of code
   med_int ncomp = MEDnChamp(fid,theField.myId);
-  if(ncomp < 0) throw std::runtime_error("LoadField >> MEDnChamp(fid,i)");
+  if(ncomp < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDnChamp(fid,i)"));
   valarray<char> comp('\0',ncomp*MED_TAILLE_PNOM + 1);
   valarray<char> unit('\0',ncomp*MED_TAILLE_PNOM + 1);
   char aFieldName[MED_TAILLE_NOM + 1] = "";
+  char aMeshName[MED_TAILLE_NOM+1] = "";
+  strcpy(aMeshName,theValForTime.myMeshName.c_str());
   med_type_champ type_field;
   if(MEDchampInfo(fid,theField.myId,aFieldName,&type_field,&comp[0],&unit[0],ncomp) < 0)
-    throw std::runtime_error(string("LoadField >> MEDchampInfo(...)"));
+    throw std::runtime_error(EXCEPTION("LoadField >> MEDchampInfo(...)"));
   int iGeomElemEnd;
   med_geometrie_element* aGeomElemVector;
   const VISU::TEntity& anEntity = theField.myEntity;
   GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
   med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity];
-  if(MYDEBUG) {
-    MESSAGE("LoadField - aFieldName = '"<<aFieldName<<"'; anEntity = "<<anEntity<<"; iGeomElemEnd = "<<iGeomElemEnd);
-    MESSAGE("LoadField - ncomp = "<<ncomp<<"; type_field = "<<type_field<<"; myId = "<<theValForTime.myId);
+  const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMeshOnEntity.myCellsConn;
+  if(MYDEBUG){
+    MESSAGE("LoadField - aMeshName = '"<<aMeshName<<"' aFieldName = '"<<aFieldName<<"'; anEntity = "<<anEntity);
+    MESSAGE("LoadField - iGeomElemEnd = "<<iGeomElemEnd<<"; ncomp = "<<ncomp<<"; type_field = "<<type_field);
   }
   for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
-    med_geometrie_element& aGeom = aGeomElemVector[iGeomElem];
+    const med_geometrie_element& aGeom = aGeomElemVector[iGeomElem];
     med_int iTimeStampEnd = MEDnPasdetemps(fid,aFieldName,aMedEntity,aGeom);
-    if(iTimeStampEnd > 0) {
-      char aMeshName[MED_TAILLE_NOM+1] = "";
+    //Checking for accordance between the mesh and the field data
+    med_int iNumElemEnd = 0;
+    if(aMedEntity == MED_NOEUD)
+      iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_COOR,MED_NOEUD,med_geometrie_element(0),med_connectivite(0));
+    else
+      iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aGeom,MED_NOD);
+    int medId = getIdMedType(aGeomElemVector[iGeomElem]);
+    int aVtkType = med2vtk[medId].vtkType;
+    if(iTimeStampEnd <= 0){
+      if(iNumElemEnd > 0){
+       if(!theField.myIsTrimmed){
+         theField.myIsTrimmed = true;
+         theField.myDataSize -= iNumElemEnd*theField.myNbComp;
+       }
+       //throw std::runtime_error(EXCEPT("VISU_MedConvertor::LoadField - There is no the data "
+       //                              "for cells with type %1 of the mesh !!!").
+       //                       arg(med2vtk[medId].medName).latin1());
+      }
+    }else{
       med_int ngauss = 0, numdt = 0, numo = 0;
       char dt_unit[MED_TAILLE_PNOM+1] = "";
       med_float dt = 0;
       ret = MEDpasdetempsInfo(fid,aFieldName,aMedEntity,aGeom,theValForTime.myId,
                              aMeshName,&ngauss,&numdt,dt_unit,&dt,&numo);
-      if(ret < 0) throw std::runtime_error("LoadField >> MEDpasdetempsInfo(...)");
+      if(ret < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDpasdetempsInfo(...)"));
       med_int nval = MEDnVal(fid,aFieldName,aMedEntity,aGeom,numdt,numo);
-      if (nval <= 0) throw std::runtime_error("LoadField >> MEDnVal(...) - nval <= 0");
+      if(nval <= 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDnVal(...) - nval <= 0"));
       else{
-       //Checking for accordance between the mesh and the field on number of geomterical elements 
-       int aVtkType = med2vtkCellType(aGeom);
-       const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMeshOnEntity.myCellsConn;
-       VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.find(aVtkType);
-       if(aCellsConnIter == aCellsConn.end()) throw std::runtime_error("LoadField - There is no the geom. elem. on the mesh !!!");
-       const VISU::TMeshOnEntity::TConnForCellType aConnForCellType = aCellsConnIter->second;
-       if(aConnForCellType.size() != nval) throw std::runtime_error("LoadField - Size of values and size of mesh not equal !!!");
-       if(MYDEBUG) MESSAGE("LoadField - aGeom = "<<aGeom<<"; nval = "<<nval<<"; iTimeStampEnd = "<<iTimeStampEnd);
+       //Checking for accordance between the mesh and the field data
+       if(iNumElemEnd <= 0) 
+         throw std::runtime_error(EXCEPTION("LoadField - There is no the geom. elem. on the mesh !!!"));
+       static int aMaxNbGaussPts = 52;  // the workaround for broken files
+       if(ngauss > aMaxNbGaussPts) ngauss = 1;
+       if(iNumElemEnd*ngauss != nval) 
+         throw std::runtime_error(EXCEPT("LoadField - Size of values (%1) and size of mesh (%2) not equal !!!").
+                                  arg(nval).arg(iNumElemEnd*ngauss).latin1());
        VISU::TField::TValForCellsWithType &anArray = theValForTime.myValForCells[aVtkType];
        int jEnd = theField.myNbComp*nval;
-       anArray.resize(jEnd);
+       int kEnd = jEnd/ngauss;
+       anArray.resize(kEnd);
        char pflname[MED_TAILLE_NOM + 1] = "";
        switch(type_field){
        case MED_REEL64 : {
          valarray<med_float> valr(jEnd);
          ret = MEDchampLire(fid,aMeshName,aFieldName,(unsigned char*)&valr[0],MED_FULL_INTERLACE,MED_ALL,
                             pflname,aMedEntity,aGeom,numdt,numo);
-         for (med_int j = 0; j < jEnd; j++) anArray[j] = valr[j];
+         if(ret < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDchampLire(...)"));
+         for (med_int k = 0, j = 0; k < kEnd; k++, j += ngauss){
+           for (med_int iGauss = 0; iGauss < ngauss; iGauss++)
+             anArray[k] = valr[j+iGauss];
+           anArray[k] /= ngauss;
+         }
          break;
        }
        //case MED_INT64 : //valarray<long long> valr(jEnd);
@@ -697,13 +737,19 @@ int VISU_MedConvertor::LoadField(const med_idt& fid, const VISU::TMeshOnEntity&
          valarray<med_int> valr(jEnd);
          ret = MEDchampLire(fid,aMeshName,aFieldName,(unsigned char*)&valr[0],MED_FULL_INTERLACE,MED_ALL,
                             pflname,aMedEntity,aGeom,numdt,numo);
-         for (med_int j = 0; j < jEnd; j++) anArray[j] = valr[j];
+         if(ret < 0) throw std::runtime_error(EXCEPTION("LoadField >> MEDchampLire(...)"));
+         for (med_int k = 0, j = 0; k < kEnd; k++, j += ngauss){
+           for (med_int iGauss = 0; iGauss < ngauss; iGauss++)
+             anArray[k] = valr[j+iGauss];
+           anArray[k] /= ngauss;
+         }
          break;
        }
-         default :
-           throw std::runtime_error("LoadField >> Value of med_type_champ for the field is wrong !!!");
+       default :
+         throw std::runtime_error(EXCEPTION("LoadField >> Value of med_type_champ for the field is wrong !!!"));
        }
-       if(ret < 0) throw std::runtime_error("ChampLire >> MEDchampLire(...)");
+       if(MYDEBUG) MESSAGE("LoadField - aGeom = "<<aGeom<<"; nval = "<<nval<<"; ngauss = "<<ngauss
+                           <<"; iTimeStampEnd = "<<iTimeStampEnd<<"; pflname = '"<<pflname<<"'");
       }
     }
   }
index 742b085207776ffbd5e2dca054ac4493d4521c05..4549b2582a4712f86a85e51de86439bd7b13553a 100644 (file)
@@ -43,7 +43,7 @@ protected:
                        const std::string& theFamilyName = "")
     throw (std::runtime_error&);
   int LoadField(const med_idt& fid, const VISU::TMeshOnEntity& theMeshOnEntity,
-               const VISU::TField& theField, VISU::TField::TValForTime& theValForTime)
+               VISU::TField& theField, VISU::TField::TValForTime& theValForTime)
     throw (std::runtime_error&);
 };