Salome HOME
Fix on Bug PAL7927
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.cxx
index 8f6ed718c8b525d776c91fd5b71ac67a4aa1d0d5..5fcb2f9e5983cc7236200e4369ca021d2115d0c3 100644 (file)
@@ -25,6 +25,7 @@
 //  Module : VISU
 
 #include "VISU_Convertor_impl.hxx"
+#include "VISU_ConvertorUtils.hxx"
 
 #include <vtkIdList.h>
 #include <vtkCellType.h>
@@ -34,6 +35,9 @@
 #include <vtkUnsignedCharArray.h>
 #include <vtkPointData.h>
 #include <vtkCellData.h>
+#include <vtkCellLinks.h>
+
+#include <vtkMergeDataObjectFilter.h>
 
 #include <qstring.h>
 #include <qfileinfo.h>
 #include <memory>
 
 using namespace std;
+using namespace VISU;
+
+static float ERR_SIZE_CALC = 1.00;
+
+static int MYVTKDEBUG = 0;
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
@@ -52,6 +61,439 @@ static int MYDEBUGWITHFILES = 0;
 #endif
 
 
+namespace{
+
+  template<class T> 
+  std::string dtos(const std::string& fmt, T val){
+    static QString aString;
+    aString.sprintf(fmt.c_str(),val);
+    return aString.latin1();
+  }
+
+  enum ECoordName{eX, eY, eZ, eNone};
+  typedef VISU::TCoord (*TGetCoord)(const VISU::TMeshImpl::TPointsCoord&, int);
+  
+  template<ECoordName TheCoordId>
+  VISU::TCoord 
+  GetCoord(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, 
+          int theStartPos)
+  {
+    return thePointsCoord[theStartPos+TheCoordId];
+  }
+  
+  template<>
+  VISU::TCoord 
+  GetCoord<eNone>(const VISU::TMeshImpl::TPointsCoord& thePointsCoord, 
+                 int theStartPos)
+  {
+    return 0.0;
+  }
+  
+  
+  TGetCoord aXYZGetCoord[3] = {
+    &GetCoord<eX>, 
+    &GetCoord<eY>, 
+    &GetCoord<eZ>
+  };
+  
+  
+  TGetCoord aXYGetCoord[3] = {
+    &GetCoord<eX>, 
+    &GetCoord<eY>, 
+    &GetCoord<eNone>
+  };
+  
+  TGetCoord aYZGetCoord[3] = {
+    &GetCoord<eNone>,
+    &GetCoord<eX>, 
+    &GetCoord<eY>
+  };
+  
+  TGetCoord aXZGetCoord[3] = {
+    &GetCoord<eX>, 
+    &GetCoord<eNone>,
+    &GetCoord<eY>
+  };
+  
+  
+  TGetCoord aXGetCoord[3] = {
+    &GetCoord<eX>, 
+    &GetCoord<eNone>,
+    &GetCoord<eNone>
+  };
+  
+  TGetCoord aYGetCoord[3] = {
+    &GetCoord<eNone>,
+    &GetCoord<eX>, 
+    &GetCoord<eNone>
+  };
+
+  TGetCoord aZGetCoord[3] = {
+    &GetCoord<eNone>,
+    &GetCoord<eNone>,
+    &GetCoord<eX>
+  };
+
+  
+  class TCoordHelper{
+    const VISU::TMeshImpl::TPointsCoord& myPointsCoord;
+    TGetCoord* myGetCoord;
+  public:
+    TCoordHelper(const VISU::TMeshImpl::TPointsCoord& thePointsCoord,
+                TGetCoord* theGetCoord):
+      myPointsCoord(thePointsCoord),
+      myGetCoord(theGetCoord)
+    {}
+    virtual ~TCoordHelper(){}
+    VISU::TCoord 
+    GetCoord(int theStartPos, int theCoodId)
+    {
+      return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos);
+    }
+  };
+  typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
+  
+  void GetPoints(VISU::TVTKSource& theStorage, VISU::PMeshImpl theMesh) 
+  {
+    vtkPoints* aPoints = theMesh->myPoints.GetPointer();
+    if(!aPoints){
+      aPoints = vtkPoints::New();
+      TCoordHelperPtr aCoordHelperPtr;
+      const VISU::TMeshImpl::TPointsCoord& anArray = theMesh->myPointsCoord;
+      {
+       int aMeshDimension = theMesh->myDim;
+       bool anIsDimPresent[3] = {false, false, false};
+       for(int iDim = 0; iDim < aMeshDimension; iDim++){
+         string aDimName = theMesh->myPointsDim[iDim];
+         if(aDimName == "x" || aDimName == "X")
+           anIsDimPresent[eX] = true;
+         else if(aDimName == "y" || aDimName == "Y")
+           anIsDimPresent[eY] = true;
+         else if(aDimName == "z" || aDimName == "Z")
+           anIsDimPresent[eZ] = true;
+       }
+
+       switch(aMeshDimension){
+       case 3:
+         aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYZGetCoord));
+         break;
+       case 2:
+         if(anIsDimPresent[eY] && anIsDimPresent[eZ])
+           aCoordHelperPtr.reset(new TCoordHelper(anArray,aYZGetCoord));
+         else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
+           aCoordHelperPtr.reset(new TCoordHelper(anArray,aXZGetCoord));
+         else
+           aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYGetCoord));
+         break;
+       case 1:
+         if(anIsDimPresent[eY])
+           aCoordHelperPtr.reset(new TCoordHelper(anArray,aYGetCoord));
+         else if(anIsDimPresent[eZ])
+           aCoordHelperPtr.reset(new TCoordHelper(anArray,aZGetCoord));
+         else
+           aCoordHelperPtr.reset(new TCoordHelper(anArray,aXGetCoord));
+         break;
+       }
+      }
+
+      if(MYVTKDEBUG) aPoints->DebugOn();
+      vtkIdType iEnd = theMesh->myPointsCoord.size();
+      vtkIdType aNbPoints = iEnd / theMesh->myDim;
+      aPoints->SetNumberOfPoints(aNbPoints);
+      MSG(MYDEBUG,"GetPoints - aNbPoints = "<<aNbPoints<<"; myDim = "<<theMesh->myDim);
+      for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh->myDim, j++) 
+       aPoints->SetPoint(j,
+                         aCoordHelperPtr->GetCoord(i,eX),
+                         aCoordHelperPtr->GetCoord(i,eY),
+                         aCoordHelperPtr->GetCoord(i,eZ));
+      theMesh->myPoints = aPoints;
+    }
+    theStorage->SetPoints(aPoints);
+  }
+  
+  
+  inline void PrintCells(int& theStartId,
+                        vtkCellArray* theConnectivity, 
+                        const VISU::TMeshOnEntityImpl::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::PMeshOnEntityImpl theMeshOnEntity, 
+                       const string& theFamilyName) 
+  {
+    //Check on existing family
+    PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
+    //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);
+    MSG(MYDEBUG,"GetCellsOnEntity - isFamilyPresent = "<<bool(aFamily));
+    const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = theMeshOnEntity->myCellsConn;
+    VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+    for(int i = 0, j = 0; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
+      const VISU::TMeshOnEntityImpl::TConnForCellType& anArray = aCellsConnIter->second;
+      int aVtkType = aCellsConnIter->first;
+      MSG(MYDEBUG,"GetCellsOnEntity - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
+      if(!aFamily)
+       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::TFamilyImpl::TSubMesh& aSubMesh = aFamily->mySubMesh;
+       if(aSubMesh.empty()) 
+         EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
+       VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
+       if(aSubMeshIter == aSubMesh.end()) continue;
+       const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
+       MSG(MYDEBUG,"GetCellsOnEntity - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
+       VISU::TFamilyImpl::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,
+                      VISU::PMeshImpl theMesh,
+                      const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) 
+  {
+    //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::PMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
+      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;
+      PMeshOnEntityImpl aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
+      PFamilyImpl aFamily = GetFamily(aMeshOnEntity,aFamilyName);
+      const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = aMeshOnEntity->myCellsConn;
+      VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+      for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
+       const VISU::TMeshOnEntityImpl::TConnForCellType& anArray = aCellsConnIter->second;
+       int aVtkType = aCellsConnIter->first;
+       MSG(MYDEBUG,"GetCellsOnGroup - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
+       const VISU::TFamilyImpl::TSubMesh& aSubMesh = aFamily->mySubMesh;
+       if(aSubMesh.empty()) 
+         EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
+       VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
+       if(aSubMeshIter == aSubMesh.end()) continue;
+       const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
+       MSG(MYDEBUG,"GetCellsOnGroup - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
+       VISU::TFamilyImpl::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,
+                  PMeshOnEntityImpl theMeshOnEntity, 
+                  PValForTimeImpl theValForTime)
+  {
+    const VISU::TValForTimeImpl::TValForCells& aValForCells = theValForTime->myValForCells;
+    const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = theMeshOnEntity->myCellsConn;
+    VISU::TMeshOnEntityImpl::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,
+                         VISU::PFieldImpl theField,
+                         VISU::PValForTimeImpl theValForTime)
+  {
+    //theFloatArray->DebugOn();
+    theFloatArray->SetNumberOfTuples(theNumberOfTuples);
+    theFloatArray->SetName(theFieldName.c_str());
+    MSG(MYDEBUG,"GetValsOnTimeStamp - theNumberOfTuples = "<<theNumberOfTuples);
+    const VISU::TValForTimeImpl::TValForCells& aValForCells = theValForTime->myValForCells;
+    VISU::TValForTimeImpl::TValForCells::const_iterator aValForCellsIter = aValForCells.begin();
+    for(int k = 0; aValForCellsIter != aValForCells.end(); aValForCellsIter++) {
+      const VISU::TValForTimeImpl::TValForCellsWithType& anArray = aValForCellsIter->second;
+      int iEnd = anArray.size()/theField->myNbComp;
+      int aVtkType = aValForCellsIter->first;
+      MSG(MYDEBUG,"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:
+       EXCEPTION(runtime_error,"GetValsOnTimeStamp - There is no an algorithm for representation of the field !!!");
+      }
+    }
+  }
+
+  string GenerateFieldName(const VISU::PFieldImpl theField,
+                          const VISU::PValForTimeImpl theValForTime)
+  {
+    const VISU::TTime& aTime = theValForTime->myTime;
+    string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + 
+      VISU_Convertor::GenerateName(aTime);
+    return aFieldName;
+  }
+
+  void GetTimeStamp(VISU::TVTKSource& theStorage,
+                   const VISU::PFieldImpl theField, 
+                   const VISU::PValForTimeImpl theValForTime)
+  {
+    int aNumberOfTuples = theField->myDataSize/theField->myNbComp;
+    string aFieldName = GenerateFieldName(theField,theValForTime);
+    MSG(MYDEBUG,"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::PFieldImpl theField, 
+                   const VISU::PValForTimeImpl theValForTime)
+  {
+    int aNumberOfTuples = theField->myDataSize/theField->myNbComp;
+    string aFieldName = GenerateFieldName(theField,theValForTime);
+    MSG(MYDEBUG,"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;
 }
@@ -62,71 +504,90 @@ VISU_Convertor::TOutput*
 VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName, 
                                     const VISU::TEntity& theEntity,
                                     const string& theFamilyName)
-  throw (std::runtime_error&)
 {
-  if(MYDEBUG) 
-    MESSAGE("GetMeshOnEntity - theMeshName = '"<<theMeshName<<
-           "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+  MSG(MYDEBUG,"GetMeshOnEntity - theMeshName = '"<<theMeshName<<
+      "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
   //Cheching possibility do the query
-  VISU::TMesh* pMesh = NULL;
-  VISU::TFamily* pFamily = NULL;
-  VISU::TMeshOnEntity* pMeshOnEntity = NULL;
-  FindMeshOnEntity(theMeshName,pMesh,theEntity,pMeshOnEntity,theFamilyName,pFamily);
-  VISU::TMesh& aMesh = *pMesh;
-  VISU::TMeshOnEntity& aMeshOnEntity = *pMeshOnEntity;
+  TFindMeshOnEntity aFindMeshOnEntity = 
+    FindMeshOnEntity(theMeshName,theEntity,theFamilyName);
   VISU::TVTKSource* pSource;
-  if(pFamily != NULL)
-    pSource = &(pFamily->myStorage);
+  PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
+  PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
+  PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+  if(aFamily)
+    pSource = &(aFamily->myStorage);
   else
-    pSource = &(aMeshOnEntity.myStorage);
+    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();
+      MSG(MYVTKDEBUG,"GetMeshOnEntity - GetPoints() = "<<float(aDataSet->GetPoints()->GetActualMemorySize()*1000));
+      MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCells() = "<<float(aDataSet->GetCells()->GetActualMemorySize()*1000));
+      MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellTypesArray() = "<<float(aDataSet->GetCellTypesArray()->GetActualMemorySize()*1000));
+      MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLocationsArray() = "<<float(aDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000));
+      aDataSet->BuildLinks();
+      MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLinks() = "<<float(aDataSet->GetCellLinks()->GetActualMemorySize()*1000));
+      MSG(MYVTKDEBUG,"GetMeshOnEntity - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
+    }
+  }catch(...){
+    aSource = vtkSmartPointerBase();
+    throw;
   }
-  return aSource.get();
+  return aSource.GetPointer();
 }
 
 VISU_Convertor::TOutput* 
 VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName, 
                                    const string& theGroupName)
-     throw(std::runtime_error&)
 {
-  if(MYDEBUG) MESSAGE("GetMeshOnGroup - theMeshName = '"<<theMeshName<<
-                     "'; theGroupName = '"<<theGroupName<<"'");
+  MSG(MYDEBUG,"GetMeshOnGroup - theMeshName = '"<<theMeshName<<
+      "'; theGroupName = '"<<theGroupName<<"'");
   //Cheching possibility do the query
-  VISU::TMesh* pMesh = NULL;
-  VISU::TGroup* pGroup = NULL;
-  FindMeshOnGroup(theMeshName,pMesh,theGroupName,pGroup);
-  VISU::TMesh& aMesh = *pMesh;
-  VISU::TGroup& aGroup = *pGroup;
-  const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet;
-  VISU::TVTKSource& aSource = aGroup.myStorage;
+  TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
+  PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
+  PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
+  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* 
@@ -134,473 +595,391 @@ VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName,
                                        const VISU::TEntity& theEntity,
                                        const string& theFieldName,
                                        int theStampsNum)
-     throw(std::runtime_error&)
 {
-  if(MYDEBUG){
-    MESSAGE("GetTimeStampOnMesh - theMeshName = '"<<theMeshName<<"; theEntity = "<<theEntity);
-    MESSAGE("GetTimeStampOnMesh - theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
-  }
+  MSG(MYDEBUG,"GetTimeStampOnMesh - theMeshName = '"<<theMeshName<<"; theEntity = "<<theEntity);
+  MSG(MYDEBUG,"GetTimeStampOnMesh - theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
+
   //Cheching possibility do the query
-  VISU::TMesh* pMesh = NULL;
-  VISU::TField* pField = NULL;
-  VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
-  VISU::TField::TValForTime* pValForTime = NULL;
-  FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
-               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::TVTKSource& aSource = aValForTime.myStorage;
+  TFindTimeStamp aFindTimeStamp = 
+    FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+  PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
+  PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
+  PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
+  PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+  PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+
+  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);
+  try{
+    if(aSource.GetPointer())
+      return aSource.GetPointer();
+    else if(anAttribyteFilter.GetPointer())
+      return anAttribyteFilter->GetUnstructuredGridOutput();
+    else{
+      LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
+
+      VISU::TVTKExtractFilter& anExtractFilter = aField->myExtractFilter;
+      if(anExtractFilter.GetPointer() == NULL){
+       anExtractFilter = VISU_ExtractUnstructuredGrid::New();
+       anExtractFilter->Delete();
+       //anExtractFilter->DebugOn();
+       try{
+         LoadMeshOnEntity(aVTKMeshOnEntity);
+       }catch(std::exception& exc){
+         aVTKMeshOnEntity = aMeshOnEntity;
+         MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
+       }catch(...){
+         aVTKMeshOnEntity = aMeshOnEntity;
+         MSG(MYDEBUG,"Unknown exception was occured!");
+       }
+       GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
+       
+       anExtractFilter->SetInput(aVTKMeshOnEntity->myStorage.GetPointer());
+       ::InitProfile(anExtractFilter,aMeshOnEntity,aValForTime);
+      }      
+      if(!anExtractFilter->IsRemoving()){
+       aSource = TOutput::New();
+       aSource->Delete();
+       aSource->ShallowCopy(aVTKMeshOnEntity->myStorage.GetPointer());
+       ::GetTimeStamp(aSource,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,
+                      aField,aValForTime);
+       anOutput = anAttribyteFilter->GetUnstructuredGridOutput();
+      }
+      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)
+         MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetData() = "<<float(aDataSet->GetPointData()->GetActualMemorySize()*1000));
+       else
+         MSG(MYVTKDEBUG,"GetMeshOnEntity - GetData() = "<<float(aDataSet->GetCellData()->GetActualMemorySize()*1000));
+       MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
+      }
     }
+  }catch(...){
+    aSource = vtkSmartPointerBase();
+    anAttribyteFilter = vtkSmartPointerBase();
+    throw;
   }
-  return aSource.get();
+  return anOutput;
 }
 
-inline void PrintCells(int& theStartId,
-                      vtkCellArray* theConnectivity, 
-                      const VISU::TMeshOnEntity::TConnect& theVector)
+VISU::PMeshImpl 
+VISU_Convertor_impl::FindMesh(const string& theMeshName)
 {
-  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();
-}
+  GetMeshMap();
+  TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
+  if(aMeshMapIter == myMeshMap.end())
+    EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
 
-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);
-      }
-    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);
-      }
-    }
-  }
-  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);
-} 
+  PMeshImpl aMesh = aMeshMapIter->second;
+  return aMesh;
+}
 
 
-void VISU_Convertor_impl::GetCellsOnGroup(VISU::TVTKSource& theStorage,
-                                         const VISU::TMesh& theMesh,
-                                         const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) 
-  const throw (std::runtime_error&)
+VISU_Convertor_impl::TFindMeshOnEntity
+VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName,
+                                     const VISU::TEntity& theEntity,
+                                     const string& theFamilyName)
 {
-  //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);
-      }
-    }
-  }
-  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);
-} 
+  PMeshImpl aMesh = FindMesh(theMeshName);
+  VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+  VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
+  if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+    EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
 
+  PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
 
-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);
+  return TFindMeshOnEntity(aMesh,
+                          aMeshOnEntityMap[theEntity],
+                          GetFamily(aMeshOnEntity,theFamilyName));
 }
 
-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 !!!");
+
+float VISU_Convertor_impl::GetSize() {
+  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::PMesh 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::PMeshOnEntity 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::PField aField = aFieldMapIter->second;
+       const VISU::TValField& aValField = aField->myValField;
+       VISU::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);
     }
   }
+  MSG(MYDEBUG,"GetSize - aResult = "<<float(aResult));
+  return aResult;
 }
 
 
-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!!!");
-  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)
-  throw (std::runtime_error&)
+float VISU_Convertor_impl::GetMeshOnEntitySize(const std::string& theMeshName, 
+                                              const VISU::TEntity& theEntity,
+                                              const std::string& theFamilyName)
 {
-  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!!!");
-  theMeshOnEntity = &aMeshOnEntityMap[theEntity];
-  theFamily = VISU::GetFamily(*theMeshOnEntity,theFamilyName);
-}
-
+  TFindMeshOnEntity aFindMeshOnEntity = 
+    FindMeshOnEntity(theMeshName,theEntity,theFamilyName);
+  PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
+  PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
+  PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
 
-vtkIdType 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*aMesh->myNbPoints*sizeof(VISU::TCoord);
   vtkIdType aNbCells, aCellsSize;
-  if(!pFamily){
-    aNbCells = pMeshOnEntity->myNbCells;
-    aCellsSize = pMeshOnEntity->myCellsSize;
+
+  if(!aFamily){
+    aNbCells = aMeshOnEntity->myNbCells;
+    aCellsSize = aMeshOnEntity->myCellsSize;
   }else{
-    aNbCells = pFamily->myNbCells;
-    aCellsSize = pFamily->myCellsSize;
+    aNbCells = aFamily->myNbCells;
+    aCellsSize = aFamily->myCellsSize;
+  }
+
+  vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+  vtkIdType aTypesSize = aNbCells*sizeof(char);
+  vtkIdType aLocationsSize = aNbCells*sizeof(int);
+  float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+  vtkIdType aLinksSize = aMesh->myNbPoints * 
+    (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
+  aLinksSize = 0;
+  vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+  if(MYDEBUG){
+    MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aPointsSize = "<<float(aPointsSize));
+    MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aConnectivitySize = "<<float(aConnectivitySize));
+    MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aTypesSize = "<<float(aTypesSize));
+    MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLocationsSize = "<<float(aLocationsSize));
+    MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLinksSize = "<<float(aLinksSize));
   }
-  //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;
+  MSG(MYDEBUG,"GetMeshOnEntitySize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
+      "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+
+  aResult = vtkIdType(aResult*ERR_SIZE_CALC);
   return aResult;
 }
 
 
-void VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                                         const std::string& theGroupName, VISU::TGroup*& theGroup)
-  throw (std::runtime_error&)
+VISU_Convertor_impl::TFindMeshOnGroup
+VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName, 
+                                    const std::string& theGroupName)
 {
-  FindMesh(theMeshName,theMesh);
-  VISU::TGroupMap& aGroupMap = theMesh->myGroupMap;
+  PMeshImpl aMesh = FindMesh(theMeshName);
+  VISU::TGroupMap& aGroupMap = aMesh->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!!!");
-  theGroup = &aGroupMapIter->second;
+    EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
+
+  VISU::PGroupImpl aGroup = aGroupMapIter->second;
+  return TFindMeshOnGroup(aMesh,aGroup);
 }
 
 
-vtkIdType VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, 
-                                                 const std::string& theGroupName)
-  throw (std::runtime_error&)
+float VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName, 
+                                             const std::string& theGroupName)
 {
-  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;
+  TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
+  PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
+  PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
+
+  vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+  vtkIdType aNbCells = aGroup->myNbCells, aCellsSize = aGroup->myCellsSize;
+  vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
+  vtkIdType aLocationsSize = aNbCells*sizeof(int);
+  float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+  vtkIdType aLinksSize = aMesh->myNbPoints * 
+    (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
+  aLinksSize = 0;
+  vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
+  if(MYDEBUG){
+    MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<float(aPointsSize));
+    MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<float(aConnectivityAndTypesSize));
+    MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<float(aLocationsSize));
+    MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<float(aLinksSize));
+  }
+  MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<float(aResult)<<"; theMeshName = '"
+      <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
+
+  aResult = vtkIdType(aResult*ERR_SIZE_CALC);
   return aResult;
 }
 
-
-void VISU_Convertor_impl::FindField(const string& theMeshName, VISU::TMesh*& theMesh,
-                                   const VISU::TEntity& theEntity, 
-                                   VISU::TMeshOnEntity*& theMeshOnEntity,
-                                   VISU::TMeshOnEntity*& theVTKMeshOnEntity,
-                                   const string& theFieldName, VISU::TField*& theField)
-  throw (std::runtime_error&)
+VISU_Convertor_impl::TFindField
+VISU_Convertor_impl::FindField(const string& theMeshName, 
+                              const VISU::TEntity& theEntity, 
+                              const string& theFieldName)
 {
-  VISU::TFamily* pFamily = NULL;
-  VISU::TMeshOnEntity* pMeshOnEntity = NULL;
-  FindMeshOnEntity(theMeshName,theMesh,theEntity,pMeshOnEntity,"",pFamily);
-  theMeshOnEntity = pMeshOnEntity;
-  VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+  TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName,theEntity,"");
+  PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
+  PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
+  PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+
+  VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+  PMeshOnEntityImpl aVTKMeshOnEntity;
   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];
-  }
-  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!!!");
-  theField = &aFieldMap[theFieldName];
+    if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
+      aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY];
+    else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end())
+      aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY];
+    else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
+      aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY];
+  }else
+    aVTKMeshOnEntity = aMeshOnEntity;
+  
+  VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+  VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName);
+  if(aFieldIter == aFieldMap.end())
+    EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!");
+  
+  PFieldImpl aField = aFieldIter->second;
+
+  return TFindField(aMesh,
+                   aMeshOnEntity,
+                   aVTKMeshOnEntity,
+                   aField);
 }
 
 
-vtkIdType VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, 
-                                                 const VISU::TEntity& theEntity,
-                                                 const std::string& theFieldName)
-  throw(std::runtime_error&)
+float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName, 
+                                             const VISU::TEntity& theEntity,
+                                             const std::string& theFieldName)
 {
-  VISU::TMesh* pMesh = NULL;
-  VISU::TField* pField = NULL;
-  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;
+  TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
+  PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
+  PField aField = boost::get<3>(aFindField);
+
+  float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
+  float aFieldOnMeshSize = float(aField->myDataSize*sizeof(float)*aField->myValField.size()*ERR_SIZE_CALC);
+  float aResult = aMeshSize + aFieldOnMeshSize;
+  if(MYDEBUG)
+    MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<float(aFieldOnMeshSize));
+  MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
+      "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
+
   return aResult;
 }
 
 
-void VISU_Convertor_impl::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&)
+VISU_Convertor_impl::TFindTimeStamp
+VISU_Convertor_impl::FindTimeStamp(const std::string& theMeshName, 
+                                  const VISU::TEntity& theEntity, 
+                                  const std::string& theFieldName, 
+                                  int theStampsNum)
 {
-  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!!!");
-  theValForTime = &aValField[theStampsNum];
+  TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
+  PField aField = boost::get<3>(aFindField);
+
+  VISU::TValField& aValField = aField->myValField;
+  VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
+  if(aValFieldIter == aValField.end())
+    EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
+  
+  PMeshImpl aMesh = boost::get<0>(aFindField);
+  PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
+  PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
+  PValForTimeImpl aValForTime = aValFieldIter->second;
+
+  return TFindTimeStamp(aMesh,
+                       aMeshOnEntity,
+                       aVTKMeshOnEntity,
+                       aField,
+                       aValForTime);
 }
 
 
-vtkIdType VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, 
-                                               const VISU::TEntity& theEntity,
-                                               const std::string& theFieldName,
-                                               int theStampsNum)
-  throw (std::runtime_error&)
+float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName, 
+                                           const VISU::TEntity& theEntity,
+                                           const std::string& theFieldName,
+                                           int theStampsNum)
 {
-  VISU::TMesh* pMesh = NULL;
-  VISU::TField* pField = NULL;
-  VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
-  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;
+  TFindTimeStamp aFindTimeStamp = 
+    FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+  PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
+  PField aField = boost::get<3>(aFindTimeStamp);
+  
+  float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
+  float aTimeStampSize = float(aField->myDataSize*sizeof(float) * ERR_SIZE_CALC);
+  float aResult = aMeshSize + aTimeStampSize;
+
+  MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<float(aTimeStampSize));
+  MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<float(aResult)<<
+      "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
+      "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
+
   return aResult;
 }
 
 
-const VISU::TField& 
+const VISU::PField
 VISU_Convertor_impl::GetField(const string& theMeshName, 
                              VISU::TEntity theEntity, 
-                             const string& theFieldName) 
-  throw (std::runtime_error&)
+                             const string& theFieldName) 
 {
-  VISU::TMesh* pMesh = NULL;
-  VISU::TField* pField = NULL;
-  VISU::TFamily* pFamily = NULL;
-  VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
-  FindField(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
-           theFieldName,pField);
-  return *pField;
+  TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
+  PField aField = boost::get<3>(aFindField);
+  return aField;
 }
 
 
-const VISU::TField::TValForTime& 
+const VISU::PValForTime 
 VISU_Convertor_impl::GetTimeStamp(const std::string& theMeshName, 
                                  const VISU::TEntity& theEntity,
                                  const std::string& theFieldName,
                                  int theStampsNum)
-  throw (std::runtime_error&)
 {
-  VISU::TMesh* pMesh = NULL;
-  VISU::TField* pField = NULL;
-  VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
-  VISU::TField::TValForTime* pValForTime = NULL;
-  FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
-               theFieldName,pField,theStampsNum,pValForTime);
-  return *pValForTime;
+  TFindTimeStamp aFindTimeStamp = 
+    FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+  PValForTime aValForTime = boost::get<4>(aFindTimeStamp);
+  return aValForTime;
 }
-
-