Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 //  File   : VISU_Convertor_impl.cxx
25 //  Author : Alexey PETROV
26 //  Module : VISU
27 //
28 #include "VISU_Convertor_impl.hxx"
29 #include "VISU_Structures_impl.hxx"
30 #include "VISU_PointCoords.hxx"
31 #include "VISU_MeshValue.hxx"
32
33 #include "VISU_AppendFilter.hxx"
34 #include "VISU_AppendPolyData.hxx"
35 #include "VTKViewer_CellLocationsArray.h"
36 #include "VISU_CommonCellsFilter.hxx"
37
38 #include "VISU_ConvertorUtils.hxx"
39
40 #include <vtkUnstructuredGrid.h>
41 #include <vtkPolyData.h>
42
43 #include <vtkPoints.h>
44 #include <vtkPointData.h>
45 #include <vtkCellData.h>
46
47 #include <vtkIdList.h>
48 #include <vtkCellType.h>
49 #include <vtkCellArray.h>
50 #include <vtkCellLinks.h>
51 #include <vtkUnsignedCharArray.h>
52
53 #include <QString>
54 #include <QFileInfo>
55
56 #include <memory>
57
58 static vtkFloatingPointType ERR_SIZE_CALC = 1.00;
59
60 static int MYVTKDEBUG = 0;
61
62 #ifdef _DEBUG_
63 static int MYDEBUG = 0;
64 static int MYDEBUGWITHFILES = 0;
65 //#define _DEXCEPT_
66 #else
67 static int MYDEBUG = 0;
68 static int MYDEBUGWITHFILES = 0;
69 #endif
70
71
72 namespace
73 {
74   //---------------------------------------------------------------
75   template<class T> 
76   std::string 
77   dtos(const std::string& fmt, T val)
78   {
79     static QString aString;
80     aString.sprintf(fmt.c_str(),val);
81     return (const char*)aString.toLatin1();
82   }
83
84
85   //---------------------------------------------------------------
86   inline
87   void
88   PrintCells( vtkCellArray* theConnectivity, 
89               const VISU::TConnect& theVector)
90   {
91     theConnectivity->InsertNextCell( theVector.size(), &theVector[ 0 ] );
92   }
93
94
95   //---------------------------------------------------------------
96   void
97   GetCellsOnSubMesh(const VISU::PUnstructuredGrid& theSource,
98                     const VISU::PMeshOnEntityImpl& theMeshOnEntity, 
99                     const VISU::PSubMeshImpl& theSubMesh,
100                     const vtkIdType theGeom) 
101   {
102     VISU::TTimerLog aTimerLog(MYDEBUG,"GetCellsOnSubMesh");
103     const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
104     vtkIdType aCellsSize = theSubMesh->myCellsSize;
105     vtkIdType aNbCells = theSubMesh->myNbCells;
106     INITMSG(MYDEBUG,"GetCellsOnSubMesh "<<
107             "- theGeom = "<<theGeom<<
108             "; aNbCells = "<<aNbCells<<
109             endl);
110
111
112     vtkCellArray* aConnectivity = vtkCellArray::New();
113     aConnectivity->Allocate(aCellsSize,0);
114     vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
115     aCellTypesArray->SetNumberOfComponents(1);
116     aCellTypesArray->SetNumberOfTuples(aNbCells);
117
118     for(vtkIdType anID = 0; anID < aNbCells; anID++){
119       PrintCells( aConnectivity, anArray[ anID ] );
120       aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
121     }
122
123     {
124       int aNbTuples = aNbCells;
125       int anEntity = int(theMeshOnEntity->myEntity);
126       vtkIntArray *aDataArray = vtkIntArray::New();
127       aDataArray->SetName("VISU_CELLS_MAPPER");
128       aDataArray->SetNumberOfComponents(2);
129       aDataArray->SetNumberOfTuples(aNbTuples);
130       int *aDataArrayPtr = aDataArray->GetPointer(0);
131       for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
132         int anObjID = theSubMesh->GetElemObjID(aTupleId);
133         *aDataArrayPtr++ = anObjID;
134         *aDataArrayPtr++ = anEntity;
135       }
136       theSource->GetCellData()->AddArray(aDataArray);
137       aDataArray->Delete();
138     }
139
140     vtkIdType *pts = 0, npts = 0;
141     VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
142     aCellLocationsArray->SetNumberOfComponents(1);
143     aCellLocationsArray->SetNumberOfTuples(aNbCells);
144     aConnectivity->InitTraversal();
145     for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
146       aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
147     theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
148
149     if(MYVTKDEBUG) aConnectivity->DebugOn();
150
151     aCellLocationsArray->Delete();
152     aCellTypesArray->Delete();
153     aConnectivity->Delete();
154   } 
155   
156   
157   //---------------------------------------------------------------
158   void
159   GetCellsOnFamily(const VISU::PUnstructuredGrid& theSource,
160                    const VISU::PMeshOnEntityImpl& theMeshOnEntity, 
161                    const VISU::PFamilyImpl& theFamily) 
162   {
163     INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
164
165     vtkIdType aNbCells = theFamily->myNbCells;
166     vtkIdType aCellsSize = theFamily->myCellsSize;
167
168     vtkCellArray* aConnectivity = vtkCellArray::New();
169     aConnectivity->Allocate(aCellsSize,0);
170     vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
171     aCellTypesArray->SetNumberOfComponents(1);
172     aCellTypesArray->SetNumberOfTuples(aNbCells);
173
174     VISU::TSubMeshID& aMeshID = theFamily->myMeshID;
175     aMeshID.resize(aNbCells);
176
177     vtkIntArray *aDataArray = vtkIntArray::New();
178     int anEntity = int(theMeshOnEntity->myEntity);
179     aDataArray->SetName("VISU_CELLS_MAPPER");
180     aDataArray->SetNumberOfComponents(2);
181     aDataArray->SetNumberOfTuples(aNbCells);
182     int *aDataArrayPtr = aDataArray->GetPointer(0);
183
184     VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
185
186     const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
187     VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
188     for(vtkIdType aCellId = 0; anIter != aGeom2SubMesh.end(); anIter++){
189       VISU::EGeometry aEGeom = anIter->first;
190       vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
191
192       const VISU::TSubMeshImpl& aSubMesh = anIter->second;
193       const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
194
195       const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
196       if(aGeom2SubMeshID.empty()) 
197         EXCEPTION(std::runtime_error,"GetCells >> There is no elements on the family !!!");
198
199       VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom);
200       if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end()) 
201         continue;
202
203       const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
204
205       INITMSG(MYDEBUG,
206               " - aEGeom = "<<aEGeom<<
207               "; aVGeom = "<<aVGeom<<
208               "; aSubMeshID.size() = "<<aSubMeshID.size()<<
209               endl);
210
211       VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
212       for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, aCellId++){
213         vtkIdType anID = *aSubMeshIDIter;
214         PrintCells( aConnectivity, anArray[ anID ] );
215         aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom);
216         vtkIdType anObjID = aSubMesh.GetElemObjID(anID);
217         anElemObj2VTKID[anObjID] = aCellId;
218         aMeshID[aCellId] = anObjID;
219         *aDataArrayPtr++ = anObjID;
220         *aDataArrayPtr++ = anEntity;
221       }
222     }
223
224     theSource->GetCellData()->AddArray(aDataArray);
225     aDataArray->Delete();
226
227     vtkIdType *pts = 0, npts = 0;
228     VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
229     aCellLocationsArray->SetNumberOfComponents(1);
230     aCellLocationsArray->SetNumberOfTuples(aNbCells);
231     aConnectivity->InitTraversal();
232     for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
233       aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
234     theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
235
236     if(MYVTKDEBUG) aConnectivity->DebugOn();
237
238     aCellLocationsArray->Delete();
239     aCellTypesArray->Delete();
240     aConnectivity->Delete();
241   }
242   
243   
244   //---------------------------------------------------------------
245   void
246   GetCells(const VISU::PUnstructuredGrid& theSource,
247            const VISU::PSubProfileImpl& theSubProfile,
248            const VISU::PProfileImpl& theProfile,
249            const VISU::PMeshOnEntityImpl& theMeshOnEntity)
250   {
251     vtkIdType aNbCells = theSubProfile->myNbCells;
252     vtkIdType aCellsSize = theSubProfile->myCellsSize;
253     VISU::EGeometry aEGeom = theSubProfile->myGeom;
254     vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom);
255     vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
256
257     INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
258
259     const VISU::TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
260
261     const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
262     VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom);
263     if(anIter == aGeom2SubMesh.end())
264       EXCEPTION(std::runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
265     
266     const VISU::TSubMeshImpl& aSubMesh = anIter->second;
267     const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
268     
269     vtkCellArray* aConnectivity = vtkCellArray::New();
270     aConnectivity->Allocate(aCellsSize,0);
271     vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
272     aCellTypesArray->SetNumberOfComponents(1);
273     aCellTypesArray->SetNumberOfTuples(aNbCells);
274     
275     if(theSubProfile->myStatus == VISU::eAddAll){
276       VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
277       for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
278         const VISU::TConnect& anArray = aCell2Connect[anId];
279         PrintCells( aConnectivity, anArray );
280         aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
281         aConnId += aNbNodes;
282         anId++;
283       }
284     }else{
285       VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
286       for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
287         vtkIdType aSubId = *anIter;
288         const VISU::TConnect& anArray = aCell2Connect[aSubId];
289         PrintCells( aConnectivity, anArray );
290         aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
291         aConnId += aNbNodes;
292         anId++;
293       }
294     }
295     
296     vtkIdType *pts = 0, npts = 0;
297     VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
298     
299     aCellLocationsArray->SetNumberOfComponents(1);
300     aCellLocationsArray->SetNumberOfTuples(aNbCells);
301     aConnectivity->InitTraversal();
302     for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
303       aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
304     theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
305     
306     {
307       int aNbTuples = aNbCells;
308       int anEntity = int(theMeshOnEntity->myEntity);
309       vtkIntArray *aDataArray = vtkIntArray::New();
310       aDataArray->SetName("VISU_CELLS_MAPPER");
311       aDataArray->SetNumberOfComponents(2);
312       aDataArray->SetNumberOfTuples(aNbTuples);
313       int *aDataArrayPtr = aDataArray->GetPointer(0);
314       for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
315         int anObjID = theSubProfile->GetElemObjID(aTupleId);
316         *aDataArrayPtr++ = anObjID;
317         *aDataArrayPtr++ = anEntity;
318       }
319       theSource->GetCellData()->AddArray(aDataArray);
320       aDataArray->Delete();
321     }
322     
323     aCellLocationsArray->Delete();
324     aCellTypesArray->Delete();
325     aConnectivity->Delete();
326   }
327   
328   
329   //---------------------------------------------------------------
330   void
331   GetMeshOnSubProfile(const VISU::PMeshImpl& theMesh,
332                       const VISU::PMeshOnEntityImpl& theMeshOnEntity,
333                       const VISU::PProfileImpl& theProfile,
334                       const VISU::PSubProfileImpl& theSubProfile)
335   {
336     INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
337     
338     const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource();
339     if(theSubProfile->myIsVTKDone)
340       return;
341     
342     aSource->ShallowCopy(theMesh->GetPointSet());
343     INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
344     GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
345     BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
346     
347     theSubProfile->myIsVTKDone = true;
348   }
349   
350   
351   //---------------------------------------------------------------
352   bool
353   GetMeshOnProfile(const VISU::PMeshImpl& theMesh,
354                    const VISU::PMeshOnEntityImpl& theMeshOnEntity,
355                    const VISU::PProfileImpl& theProfile)
356   {
357     //rnv fix for bug IPAL18514 4x (CRASH after trying to build of presentation):
358     // throw exection in case if pointer on profile =0
359     if(!theProfile.get())
360       EXCEPTION(std::runtime_error,"GetMeshOnProfile: theProfile.get() == NULL");
361
362     // rnv fix for issue 19999:
363     // Throw exception in case if mesh on entity from profile is not equal
364     // input mesh on entity. This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh
365     // function.
366     if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
367       EXCEPTION(std::runtime_error,"GetMeshOnProfile >> theProfile->myMeshOnEntity != theMeshOnEntity.get()");
368
369     if(theProfile->myIsVTKDone)
370       return true;
371    
372     //    if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
373     //      return false;
374       
375     VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
376     INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<std::endl);
377
378     const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
379     anAppendFilter->SetSharedPointSet(theMesh->GetPointSet());
380
381     if(theProfile->myIsAll){
382       vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput();
383       anAppendFilter->AddInput(aDataSet);
384     }else{
385       const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
386
387       VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
388
389       VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
390       aSubProfileArr.resize(aGeom2SubProfile.size());
391
392       VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
393       for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
394         VISU::PSubProfileImpl aSubProfile = anIter->second;
395         if(aSubProfile->myStatus == VISU::eRemoveAll)
396           continue;
397         
398         GetMeshOnSubProfile(theMesh,
399                             theMeshOnEntity,
400                             theProfile,
401                             aSubProfile);
402         
403         const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource();
404         anAppendFilter->AddInput(aSource.GetPointer());
405
406         vtkIdType aNbCells = aSource->GetNumberOfCells();
407         for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
408           vtkIdType anObjID = aSubProfile->GetElemObjID(aCell);
409           anElemObj2VTKID[anObjID] = aCellID;
410         }
411
412         aSubProfileArr[anInputID++] = aSubProfile;
413       }
414     }
415     anAppendFilter->Update(); // Fix on VTK
416     theProfile->myMeshOnEntity = theMeshOnEntity.get();
417     theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
418     
419     theProfile->myIsVTKDone = true;
420     return true;
421   }
422   
423   
424   //---------------------------------------------------------------
425   void
426   GetGaussSubMeshSource(const VISU::PPolyData& theSource,
427                         const VISU::PGaussSubMeshImpl& theGaussSubMesh,
428                         const VISU::PMeshOnEntityImpl& theMeshOnEntity)
429   {
430     vtkCellArray* aConnectivity = vtkCellArray::New();
431     vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
432     aConnectivity->Allocate(aCellsSize, 0);
433     
434     vtkIdList *anIdList = vtkIdList::New();
435     anIdList->SetNumberOfIds(1);
436
437     const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
438     vtkIdType aNbPoints = aCoords.GetNbPoints();
439     for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
440       anIdList->SetId(0, aPointId);
441       aConnectivity->InsertNextCell(anIdList);
442     }
443     anIdList->Delete();
444     
445     const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
446     aSource->ShallowCopy(aCoords.GetPointSet());
447     aSource->SetVerts(aConnectivity);
448     
449     aConnectivity->Delete();
450
451     {
452       vtkIdType aNbTuples = aNbPoints;
453       vtkIntArray *aDataArray = vtkIntArray::New();
454       aDataArray->SetName("VISU_POINTS_MAPPER");
455       aDataArray->SetNumberOfComponents(2);
456       aDataArray->SetNumberOfTuples(aNbTuples);
457       int *aDataArrayPtr = aDataArray->GetPointer(0);
458       for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
459         vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId);
460         *aDataArrayPtr++ = aGlobalID;
461         *aDataArrayPtr++ = 0;
462       }
463       aSource->GetPointData()->AddArray(aDataArray);
464       aDataArray->Delete();
465     }
466
467     {
468       vtkIdType aNbTuples = aNbPoints;
469       vtkIntArray *aDataArray = vtkIntArray::New();
470       aDataArray->SetName("VISU_CELLS_MAPPER");
471       aDataArray->SetNumberOfComponents(2);
472       aDataArray->SetNumberOfTuples(aNbTuples);
473       int *aDataArrayPtr = aDataArray->GetPointer(0);
474       for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
475         VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId);
476         *aDataArrayPtr++ = aGaussPointID.first;
477         *aDataArrayPtr++ = aGaussPointID.second;
478       }
479       aSource->GetCellData()->AddArray(aDataArray);
480       aDataArray->Delete();
481     }
482   }
483   
484   
485   //---------------------------------------------------------------
486   void
487   GetGaussSubMesh(const VISU::PMeshImpl& theMesh,
488                   const VISU::PMeshOnEntityImpl& theMeshOnEntity,
489                   const VISU::PGaussMeshImpl& theGaussMesh,
490                   const VISU::PGaussSubMeshImpl& theGaussSubMesh)
491   {
492     VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss;
493     
494     if(!theGaussSubMesh->myIsDone)
495       return;
496     
497     if(theGaussSubMesh->myIsVTKDone)
498       return;
499     
500     VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
501     INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
502
503     const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
504     GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity);
505
506     INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
507     BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
508     
509     theGaussSubMesh->myIsVTKDone = true;
510   }
511   
512
513   //---------------------------------------------------------------
514   void
515   BuildGaussMesh(const VISU::PMeshImpl& theMesh,
516                  const VISU::PMeshOnEntityImpl& theMeshOnEntity,
517                  const VISU::PGaussMeshImpl& theGaussMesh)
518   {
519     if(theGaussMesh->myIsVTKDone)
520       return;
521
522     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
523     const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter();
524     const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
525     VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
526     for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
527       VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
528       if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
529         continue;
530
531       aGaussSubMesh->myStartID = aStartID;
532
533       GetGaussSubMesh(theMesh,
534                       theMeshOnEntity,
535                       theGaussMesh,
536                       aGaussSubMesh);
537       
538       const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
539       aStartID += aSource->GetNumberOfCells();
540
541       anAppendFilter->AddInput(aSource.GetPointer());
542     }
543     anAppendFilter->Update(); // Fix on VTK
544
545     theMeshOnEntity->GetOutput()->Update();
546
547     vtkDataSet* aSource = anAppendFilter->GetOutput();
548     INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
549     BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
550     
551     theGaussMesh->myIsVTKDone = true;
552   }
553
554
555   //---------------------------------------------------------------
556   void
557   PrintMemorySize(vtkUnstructuredGrid* theDataSet)
558   {
559     theDataSet->Update();
560     BEGMSG(1,"GetPoints() = "<<vtkFloatingPointType(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
561     BEGMSG(1,"GetCells() = "<<vtkFloatingPointType(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
562     BEGMSG(1,"GetCellTypesArray() = "<<vtkFloatingPointType(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
563     BEGMSG(1,"GetCellLocationsArray() = "<<vtkFloatingPointType(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
564     theDataSet->BuildLinks();
565     BEGMSG(1,"GetCellLinks() = "<<vtkFloatingPointType(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
566     BEGMSG(1,"GetPointData() = "<<vtkFloatingPointType(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
567     BEGMSG(1,"GetCellData() = "<<vtkFloatingPointType(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
568     BEGMSG(1,"GetActualMemorySize() = "<<vtkFloatingPointType(theDataSet->GetActualMemorySize()*1000)<<endl);
569   }
570 }
571
572
573 //---------------------------------------------------------------
574 VISU_Convertor_impl
575 ::VISU_Convertor_impl()
576 {}
577
578
579 //---------------------------------------------------------------
580 VISU_Convertor_impl
581 ::~VISU_Convertor_impl() 
582 {}
583
584
585 //---------------------------------------------------------------
586 VISU_Convertor* 
587 VISU_Convertor_impl
588 ::Build() 
589
590   if(!myIsDone){ 
591     myIsDone = true;  
592     BuildEntities();
593     BuildFields();
594     BuildMinMax();
595     BuildGroups();
596   }
597   return this;
598 }
599
600 VISU_Convertor* 
601 VISU_Convertor_impl
602 ::BuildEntities() 
603
604   return this;
605 }
606
607 VISU_Convertor* 
608 VISU_Convertor_impl
609 ::BuildFields() 
610
611   BuildEntities();
612   return this;
613 }
614
615 VISU_Convertor* 
616 VISU_Convertor_impl
617 ::BuildMinMax() 
618
619   BuildFields();
620   return this;
621 }
622
623 VISU_Convertor* 
624 VISU_Convertor_impl
625 ::BuildGroups() 
626
627   return this;
628 }
629
630
631 //---------------------------------------------------------------
632 VISU::PNamedIDMapper 
633 VISU_Convertor_impl
634 ::GetMeshOnEntity(const std::string& theMeshName, 
635                   const VISU::TEntity& theEntity)
636 {
637   INITMSG(MYDEBUG,"GetMeshOnEntity"<<
638           "; theMeshName = '"<<theMeshName<<"'"<<
639           "; theEntity = "<<theEntity<<
640           endl);
641
642   //Cheching possibility do the query
643   TFindMeshOnEntity aFindMeshOnEntity = 
644     FindMeshOnEntity(theMeshName,theEntity);
645   
646   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
647   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
648   
649   //Main part of code
650 #ifndef _DEXCEPT_
651   try{
652 #endif
653     if(!aMeshOnEntity->myIsVTKDone){
654       VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
655       const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
656       if(MYVTKDEBUG) anAppendFilter->DebugOn();
657
658       LoadMeshOnEntity(aMesh,aMeshOnEntity);
659       anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
660       
661       const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
662       VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
663
664       VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
665       VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
666       aSubMeshArr.resize(aGeom2SubMesh.size());
667
668       for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
669         VISU::EGeometry aEGeom = anIter->first;
670         vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
671         VISU::PSubMeshImpl aSubMesh = anIter->second;
672
673         aSubMesh->CopyStructure( aMesh );
674
675         aSubMesh->myStartID = aCellID;
676
677         const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
678         GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom);
679         anAppendFilter->AddInput(aSource.GetPointer());
680         
681         vtkIdType aNbCells = aSource->GetNumberOfCells();
682         for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
683           vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
684           anElemObj2VTKID[anObjID] = aCellID;
685         }
686
687         aSubMeshArr[anID] = aSubMesh;
688       }
689       
690       aMeshOnEntity->CopyStructure( aMesh );
691
692       aMeshOnEntity->myIsVTKDone = true;
693
694       if(MYDEBUGWITHFILES){
695         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
696         std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
697         aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk";
698         VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
699       }
700
701       if(MYVTKDEBUG){
702         GetMeshOnEntitySize(theMeshName,theEntity);
703         PrintMemorySize(anAppendFilter->GetOutput());
704       }
705     }
706
707 #ifndef _DEXCEPT_
708   }catch(...){
709     throw;
710   }
711 #endif
712
713   return aMeshOnEntity;
714 }
715
716
717 //---------------------------------------------------------------
718 VISU::PUnstructuredGridIDMapper 
719 VISU_Convertor_impl
720 ::GetFamilyOnEntity(const std::string& theMeshName, 
721                     const VISU::TEntity& theEntity,
722                     const std::string& theFamilyName)
723 {
724   INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
725           "; theMeshName = '"<<theMeshName<<"'"<<
726           "; theEntity = "<<theEntity<<
727           "; theFamilyName = '"<<theFamilyName<<"'"<<
728           endl);
729
730   //Cheching possibility do the query
731   TFindFamilyOnEntity aFindFamilyOnEntity = 
732     FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
733
734   VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
735   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
736   VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
737
738   //Main part of code
739 #ifndef _DEXCEPT_
740   try{
741 #endif
742     if ( !aFamily->myIsVTKDone ) {
743       GetMeshOnEntity( theMeshName, theEntity );
744
745       LoadFamilyOnEntity( aMesh, aMeshOnEntity, aFamily );
746
747       aFamily->CopyStructure( aMesh );
748
749       const VISU::PUnstructuredGrid& aSource = aFamily->GetSource();
750       GetCellsOnFamily( aSource, aMeshOnEntity, aFamily );
751
752       aFamily->myIsVTKDone = true;
753
754       if(MYDEBUGWITHFILES){
755         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
756         std::string aFamilyName = (const char*)QString(theFamilyName.c_str()).simplified().toLatin1();
757         std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
758         aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk";
759         VISU::WriteToFile(aSource.GetPointer(),aFileName);
760       }
761
762       if(MYVTKDEBUG){
763         GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
764         PrintMemorySize(aSource.GetPointer());
765       }
766     }
767
768 #ifndef _DEXCEPT_
769   }catch(...){
770     throw;
771   }
772 #endif
773
774   return aFamily;
775 }
776
777
778 //---------------------------------------------------------------
779 VISU::PUnstructuredGridIDMapper 
780 VISU_Convertor_impl
781 ::GetMeshOnGroup(const std::string& theMeshName, 
782                  const std::string& theGroupName)
783 {
784   INITMSG(MYDEBUG,"GetMeshOnGroup\n");
785   INITMSGA(MYDEBUG,0,
786            "- theMeshName = '"<<theMeshName<<
787            "'; theGroupName = '"<<theGroupName<<"'"<<
788            endl);
789
790   //Cheching possibility do the query
791   TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
792   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
793   VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
794
795   //Main part of code
796 #ifndef _DEXCEPT_
797   try{
798 #endif
799     if(!aGroup->myIsVTKDone){
800       const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter();
801       const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
802
803       LoadMeshOnGroup(aMesh,aFamilySet);
804       anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
805
806       VISU::TFamilySet::const_iterator anIter = aFamilySet.begin();
807
808       VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
809       VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
810       aFamilyArr.resize(aFamilySet.size());
811
812       for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){
813         VISU::PFamilyImpl aFamily = (*anIter).second;
814         const std::string& aFamilyName = aFamily->myName;
815         const VISU::TEntity& anEntity = aFamily->myEntity;
816
817         VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
818         vtkDataSet* anOutput = anIDMapper->GetOutput();
819         anAppendFilter->AddInput(anOutput);
820
821         vtkIdType aStartID = anElemObj2VTKID.size();
822         vtkIdType aNbCells = anOutput->GetNumberOfCells();
823         for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
824           anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aStartID + aCellID;
825         }
826         aFamilyArr[anID] = aFamily;
827       }
828
829       aGroup->CopyStructure( aMesh );
830
831       aGroup->myIsVTKDone = true;
832
833       if(MYDEBUGWITHFILES){
834         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
835         std::string aGroupName = (const char*)QString(theGroupName.c_str()).simplified().toLatin1();
836         std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
837         aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk";
838         VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
839       }
840     }
841 #ifndef _DEXCEPT_
842   }catch(...){
843     throw;
844   }
845 #endif
846
847   return aGroup;
848 }
849
850
851 //---------------------------------------------------------------
852 vtkUnstructuredGrid*
853 VISU_Convertor_impl
854 ::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
855                          const VISU::PMeshOnEntityImpl& theMeshOnEntity,
856                          const VISU::PFieldImpl& theField,
857                          const VISU::PValForTimeImpl& theValForTime,
858                          const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
859                          const VISU::PProfileImpl& theProfile,
860                          const VISU::TEntity& theEntity )
861 {
862   LoadMeshOnEntity( theMesh, theMeshOnEntity );
863   GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity );
864   GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile );
865   
866   theUnstructuredGridIDMapper->myIDMapper = theProfile;
867
868   if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) {
869     // add geometry elements to output,
870     // if timestamp on NODE_ENTITY and
871     // on profiles with status eAddPart
872     const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
873     VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin();
874     for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) {
875       const VISU::EGeometry& aGeom = aSubProfileIter->first;
876       const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second;
877       if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) {
878         const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
879         VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin();
880         for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) {
881           VISU::TEntity anEntity = aMeshOnEntityIter->first;
882           if ( anEntity == VISU::NODE_ENTITY )
883             continue;
884           VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity );
885           if( aNamedIDMapper ) {
886             theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper );
887             VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
888             VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
889             
890             return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
891           }
892         }
893       }
894     }
895   }
896
897   VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
898   VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
899
900   return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
901 }
902
903
904 //---------------------------------------------------------------
905 VISU::PUnstructuredGridIDMapper 
906 VISU_Convertor_impl
907 ::GetTimeStampOnMesh( const std::string& theMeshName, 
908                       const VISU::TEntity& theEntity,
909                       const std::string& theFieldName,
910                       int theStampsNum )
911 {
912   INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
913           "; theMeshName = '"<<theMeshName<<"'"<<
914           "; theEntity = "<<theEntity<<
915           "; theFieldName = '"<<theFieldName<<"'"<<
916           "; theStampsNum = "<<theStampsNum<<
917           endl);
918
919   //Cheching possibility do the query
920   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
921                                                 theEntity,
922                                                 theFieldName,
923                                                 theStampsNum);
924
925   VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
926   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
927   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
928   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
929   VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
930
931   //Main part of code
932   VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
933 #ifndef _DEXCEPT_
934   try{
935 #endif
936     if(!anUnstructuredGridIDMapper->myIsVTKDone){
937       VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
938       LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
939
940       vtkUnstructuredGrid* anOutput = NULL;
941       try{
942         anOutput = GetTimeStampOnProfile(aMesh,
943                                          aVTKMeshOnEntity,
944                                          aField,
945                                          aValForTime,
946                                          anUnstructuredGridIDMapper,
947                                          aValForTime->myProfile,
948                                          aMeshOnEntity->myEntity);
949       }catch(std::exception& exc){
950         MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
951         anOutput = GetTimeStampOnProfile(aMesh,
952                                          aMeshOnEntity,
953                                          aField,
954                                          aValForTime,
955                                          anUnstructuredGridIDMapper,
956                                          aValForTime->myProfile,
957                                          aVTKMeshOnEntity->myEntity);
958       }
959
960       anUnstructuredGridIDMapper->CopyStructure( aMesh );
961
962       anUnstructuredGridIDMapper->myIsVTKDone = true;
963
964       if(MYDEBUGWITHFILES){
965         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
966         std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
967         std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
968         std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + 
969           aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk";
970         VISU::WriteToFile(anOutput,aFileName);
971       }
972       if(MYVTKDEBUG){
973         GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
974         anOutput->Update();
975         if(theEntity == VISU::NODE_ENTITY)
976           BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
977         else
978           BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
979         BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
980       }
981       }
982 #ifndef _DEXCEPT_
983     }catch(std::exception& exc){
984     throw;
985   }catch(...){
986     throw;
987   }
988 #endif
989
990   return anUnstructuredGridIDMapper;
991 }
992
993
994 //---------------------------------------------------------------
995 VISU::PGaussPtsIDMapper 
996 VISU_Convertor_impl
997 ::GetTimeStampOnGaussPts(const std::string& theMeshName, 
998                          const VISU::TEntity& theEntity,
999                          const std::string& theFieldName,
1000                          int theStampsNum)
1001 {
1002   INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
1003           "; theMeshName = '"<<theMeshName<<"'"<<
1004           "; theEntity = "<<theEntity<<
1005           "; theFieldName = '"<<theFieldName<<"'"<<
1006           "; theStampsNum = "<<theStampsNum<<
1007           endl);
1008
1009   if(theEntity == VISU::NODE_ENTITY)
1010     EXCEPTION(std::runtime_error, "It is impossible to reate Gauss Points on NODE_ENTITY !!!");
1011
1012   //Cheching possibility do the query
1013   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1014                                                 theEntity,
1015                                                 theFieldName,
1016                                                 theStampsNum);
1017   
1018   VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
1019   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
1020   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1021   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1022   VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1023
1024   //Main part of code
1025   VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1026 #ifndef _DEXCEPT_
1027   try{
1028 #endif
1029     if(!aGaussPtsIDFilter->myIsVTKDone){
1030       VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
1031       LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime);
1032       
1033       GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity);
1034       
1035       VISU::PProfileImpl aProfile = aValForTime->myProfile;
1036       GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile);
1037
1038       VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
1039       if(!aGaussMesh->myIsVTKDone){
1040         BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh);
1041         aGaussMesh->myParent = aProfile.get();
1042         aGaussMesh->myIsVTKDone = true;
1043       }
1044
1045       aGaussPtsIDFilter->myIDMapper = aGaussMesh;
1046       aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
1047       VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource();
1048       VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
1049       vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
1050
1051       aGaussPtsIDFilter->myIsVTKDone = true;
1052
1053       if(MYDEBUGWITHFILES){
1054         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
1055         std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
1056         std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
1057         std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + 
1058           aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk";
1059         VISU::WriteToFile(anOutput, aFileName);
1060       }
1061       if(MYVTKDEBUG){
1062         GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
1063         anOutput->Update();
1064         if(theEntity == VISU::NODE_ENTITY)
1065           BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
1066         else
1067           BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
1068         BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
1069       }
1070     }
1071 #ifndef _DEXCEPT_
1072   }catch(std::exception& exc){
1073     throw;
1074   }catch(...){
1075     throw;
1076   }
1077 #endif
1078
1079   return aGaussPtsIDFilter;
1080 }
1081
1082 //---------------------------------------------------------------
1083 VISU::PMeshImpl 
1084 VISU_Convertor_impl
1085 ::FindMesh(const std::string& theMeshName)
1086 {
1087   GetMeshMap();
1088   VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
1089   if(aMeshMapIter == myMeshMap.end())
1090     EXCEPTION(std::runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
1091
1092   VISU::PMeshImpl aMesh = aMeshMapIter->second;
1093   return aMesh;
1094 }
1095
1096
1097 //---------------------------------------------------------------
1098 VISU_Convertor_impl::TFindMeshOnEntity
1099 VISU_Convertor_impl
1100 ::FindMeshOnEntity(const std::string& theMeshName,
1101                    const VISU::TEntity& theEntity)
1102 {
1103   VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1104   VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1105   VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1106   if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1107     EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1108
1109   VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1110   
1111   return TFindMeshOnEntity(aMesh,
1112                            aMeshOnEntity);
1113 }
1114
1115
1116 //---------------------------------------------------------------
1117 VISU_Convertor_impl::TFindFamilyOnEntity
1118 VISU_Convertor_impl
1119 ::FindFamilyOnEntity(const std::string& theMeshName,
1120                      const VISU::TEntity& theEntity,
1121                      const std::string& theFamilyName)
1122 {
1123   if(theFamilyName != ""){
1124     VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1125     VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1126     VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1127     if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1128       EXCEPTION(std::runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1129
1130     VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1131
1132     VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1133     VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
1134     if(aFamilyMapIter != aFamilyMap.end()){
1135       const VISU::PFamily& aFamily = aFamilyMapIter->second;
1136       return TFindFamilyOnEntity(aMesh,
1137                                  aMeshOnEntity,
1138                                  aFamily);
1139     }
1140   }
1141   return TFindFamilyOnEntity();
1142 }
1143
1144
1145 //---------------------------------------------------------------
1146 size_t
1147 VISU_Convertor_impl
1148 ::GetSize() 
1149 {
1150   size_t aResult = 0;
1151   const VISU::TMeshMap& aMeshMap = GetMeshMap();
1152   VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
1153   for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
1154     const std::string& aMeshName = aMeshMapIter->first;
1155     const VISU::PMesh aMesh = aMeshMapIter->second;
1156     const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1157     VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
1158     //Import fields
1159     aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
1160     for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
1161       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
1162       const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1163       const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1164       VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
1165       for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
1166         const std::string& aFieldName = aFieldMapIter->first;
1167         const VISU::PField aField = aFieldMapIter->second;
1168         const VISU::TValField& aValField = aField->myValField;
1169         VISU::TValField::const_iterator aValFieldIter = aValField.begin();
1170         for(; aValFieldIter != aValField.end(); aValFieldIter++){
1171           int aTimeStamp = aValFieldIter->first;
1172           aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
1173         }
1174       }
1175       //Importing groups
1176       const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1177       VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
1178       for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
1179         const std::string& aGroupName = aGroupMapIter->first;
1180         aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
1181       }
1182       //Import families
1183       const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1184       VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1185       for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1186         const std::string& aFamilyName = aFamilyMapIter->first;
1187         aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
1188       }
1189       //Import mesh on entity
1190       aResult += GetMeshOnEntitySize(aMeshName,anEntity);
1191     }
1192   }
1193   MSG(MYDEBUG,"GetSize - aResult = "<<vtkFloatingPointType(aResult));
1194   return aResult;
1195 }
1196
1197
1198 //---------------------------------------------------------------
1199 size_t
1200 VISU_Convertor_impl
1201 ::GetMeshOnEntitySize(const std::string& theMeshName, 
1202                       const VISU::TEntity& theEntity)
1203 {
1204   TFindMeshOnEntity aFindMeshOnEntity = 
1205     FindMeshOnEntity(theMeshName, theEntity);
1206
1207   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
1208   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1209
1210   size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1211   size_t aNbCells = aMeshOnEntity->myNbCells;
1212   size_t aCellsSize = aMeshOnEntity->myCellsSize;
1213
1214   size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1215   size_t aTypesSize = aNbCells*sizeof(char);
1216   size_t aLocationsSize = aNbCells*sizeof(int);
1217   vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1218   size_t aLinksSize = aMesh->GetNbPoints() * 
1219     (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1220   aLinksSize = 0;
1221   size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1222
1223   MSG(MYDEBUG,"GetMeshOnEntitySize "<<
1224       "- aResult = "<<vtkFloatingPointType(aResult)<<
1225       "; theMeshName = '"<<theMeshName<<"'"<<
1226       "; theEntity = "<<theEntity);
1227   if(MYDEBUG){
1228     INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1229     BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1230     BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1231     BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1232     BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1233   }
1234
1235   aResult = size_t(aResult*ERR_SIZE_CALC);
1236   return aResult;
1237 }
1238
1239
1240 //---------------------------------------------------------------
1241 size_t
1242 VISU_Convertor_impl
1243 ::GetFamilyOnEntitySize(const std::string& theMeshName, 
1244                         const VISU::TEntity& theEntity,
1245                         const std::string& theFamilyName)
1246 {
1247   TFindFamilyOnEntity aFindFamilyOnEntity = 
1248     FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1249   VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
1250   VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1251   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1252
1253   size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1254   size_t aNbCells = aFamily->myNbCells;
1255   size_t aCellsSize = aFamily->myCellsSize;
1256
1257   size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1258   size_t aTypesSize = aNbCells*sizeof(char);
1259   size_t aLocationsSize = aNbCells*sizeof(int);
1260   vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1261   size_t aLinksSize = aMesh->GetNbPoints() * 
1262     (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1263   aLinksSize = 0;
1264   size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1265
1266   MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
1267       "- aResult = "<<vtkFloatingPointType(aResult)<<
1268       "; theMeshName = '"<<theMeshName<<"'"<<
1269       "; theEntity = "<<theEntity<<
1270       "; theFamilyName = '"<<theFamilyName<<"'");
1271   if(MYDEBUG){
1272     INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1273     BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1274     BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1275     BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1276     BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1277   }
1278
1279   aResult = size_t(aResult*ERR_SIZE_CALC);
1280   return aResult;
1281 }
1282
1283
1284 //---------------------------------------------------------------
1285 VISU_Convertor_impl::TFindMeshOnGroup
1286 VISU_Convertor_impl
1287 ::FindMeshOnGroup(const std::string& theMeshName, 
1288                   const std::string& theGroupName)
1289 {
1290   VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1291   VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1292   VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
1293   if(aGroupMapIter == aGroupMap.end())
1294     EXCEPTION(std::runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
1295
1296   VISU::PGroupImpl aGroup = aGroupMapIter->second;
1297   return TFindMeshOnGroup(aMesh,aGroup);
1298 }
1299
1300
1301 size_t
1302 VISU_Convertor_impl
1303 ::GetMeshOnGroupSize(const std::string& theMeshName, 
1304                      const std::string& theGroupName)
1305 {
1306   TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
1307   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
1308   VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
1309
1310   size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1311   VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
1312   size_t aNbCells = aNbASizeCells.first;
1313   size_t aCellsSize = aNbASizeCells.second;
1314   size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
1315   size_t aLocationsSize = aNbCells*sizeof(int);
1316   vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1317   size_t aLinksSize = aMesh->GetNbPoints() * 
1318     (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
1319   aLinksSize = 0;
1320   size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
1321   if(MYDEBUG){
1322     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
1323     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
1324     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<vtkFloatingPointType(aLocationsSize));
1325     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<vtkFloatingPointType(aLinksSize));
1326   }
1327   MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
1328       <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
1329
1330   aResult = size_t(aResult*ERR_SIZE_CALC);
1331   return aResult;
1332 }
1333
1334
1335 VISU_Convertor_impl::TFindField
1336 VISU_Convertor_impl
1337 ::FindField(const std::string& theMeshName, 
1338             const VISU::TEntity& theEntity, 
1339             const std::string& theFieldName)
1340 {
1341   TFindMeshOnEntity aFindMeshOnEntity = 
1342     FindMeshOnEntity(theMeshName,theEntity);
1343
1344   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1345   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1346
1347   VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1348   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1349   if ( theEntity == VISU::NODE_ENTITY ) {
1350     if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end())
1351       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ];
1352     else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() )
1353       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ];
1354     else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() )
1355       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ];
1356     else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() )
1357       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ];
1358   }else
1359     aVTKMeshOnEntity = aMeshOnEntity;
1360   
1361   VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1362   VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName );
1363   if(aFieldIter == aFieldMap.end())
1364     EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
1365   
1366   VISU::PFieldImpl aField = aFieldIter->second;
1367
1368   return TFindField( aMesh,
1369                      aMeshOnEntity,
1370                      aVTKMeshOnEntity,
1371                      aField );
1372 }
1373
1374
1375 size_t
1376 VISU_Convertor_impl
1377 ::GetFieldOnMeshSize(const std::string& theMeshName, 
1378                      const VISU::TEntity& theEntity,
1379                      const std::string& theFieldName)
1380 {
1381   TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1382   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1383   VISU::PFieldImpl aField = boost::get<3>(aFindField);
1384
1385   size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
1386   size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
1387   size_t aResult = aMeshSize + aFieldOnMeshSize;
1388   if(MYDEBUG)
1389     MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
1390   MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
1391       "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
1392
1393   return aResult;
1394 }
1395
1396
1397 VISU_Convertor_impl::TFindTimeStamp
1398 VISU_Convertor_impl
1399 ::FindTimeStamp(const std::string& theMeshName, 
1400                 const VISU::TEntity& theEntity, 
1401                 const std::string& theFieldName, 
1402                 int theStampsNum)
1403 {
1404   TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1405   VISU::PField aField = boost::get<3>(aFindField);
1406
1407   VISU::TValField& aValField = aField->myValField;
1408   VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
1409   if(aValFieldIter == aValField.end())
1410     EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
1411   
1412   VISU::PMeshImpl aMesh = boost::get<0>(aFindField);
1413   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
1414   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1415   VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
1416
1417   return TFindTimeStamp(aMesh,
1418                         aMeshOnEntity,
1419                         aVTKMeshOnEntity,
1420                         aField,
1421                         aValForTime);
1422 }
1423
1424
1425 size_t
1426 VISU_Convertor_impl
1427 ::GetTimeStampSize(const std::string& theMeshName, 
1428                    const VISU::TEntity& theEntity,
1429                    const std::string& theFieldName,
1430                    int theStampsNum)
1431 {
1432   TFindTimeStamp aFindTimeStamp = 
1433     FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1434   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
1435   VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1436   
1437   size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity);
1438   size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
1439   size_t aResult = aMeshSize + aTimeStampSize;
1440
1441   MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
1442   MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
1443       "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
1444       "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
1445
1446   return aResult;
1447 }
1448
1449
1450 size_t
1451 VISU_Convertor_impl
1452 ::GetTimeStampOnMeshSize(const std::string& theMeshName, 
1453                          const VISU::TEntity& theEntity,
1454                          const std::string& theFieldName,
1455                          int theTimeStampNumber,
1456                          bool& theIsEstimated)
1457 {
1458   size_t aSize = 0;
1459
1460   //Cheching possibility do the query
1461   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1462                                                 theEntity,
1463                                                 theFieldName,
1464                                                 theTimeStampNumber);
1465
1466   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1467   VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
1468   if(anUnstructuredGridIDMapper->myIsVTKDone){
1469     VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName, 
1470                                                     theEntity, 
1471                                                     theFieldName, 
1472                                                     theTimeStampNumber);
1473     anIDMapper->GetOutput();
1474     aSize += anIDMapper->GetMemorySize();
1475   }else
1476     aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1477
1478   theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone);
1479
1480   //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
1481   return aSize;
1482 }
1483
1484
1485 size_t
1486 VISU_Convertor_impl
1487 ::GetTimeStampOnGaussPtsSize(const std::string& theMeshName, 
1488                              const VISU::TEntity& theEntity,
1489                              const std::string& theFieldName,
1490                              int theTimeStampNumber,
1491                              bool& theIsEstimated)
1492 {
1493   size_t aSize = 0;
1494
1495   //Cheching possibility do the query
1496   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1497                                                 theEntity,
1498                                                 theFieldName,
1499                                                 theTimeStampNumber);
1500
1501   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1502   VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1503   if(aGaussPtsIDFilter->myIsVTKDone){
1504     VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName, 
1505                                                                        theEntity, 
1506                                                                        theFieldName, 
1507                                                                        theTimeStampNumber);
1508     aGaussPtsIDMapper->GetOutput();
1509     aSize += aGaussPtsIDMapper->GetMemorySize();
1510   }else
1511     aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1512
1513   theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone);
1514
1515   //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
1516   return aSize;
1517 }
1518
1519
1520 const VISU::PField
1521 VISU_Convertor_impl
1522 ::GetField(const std::string& theMeshName, 
1523            VISU::TEntity theEntity, 
1524            const std::string& theFieldName) 
1525 {
1526   TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1527   VISU::PField aField = boost::get<3>(aFindField);
1528   return aField;
1529 }
1530
1531
1532 const VISU::PValForTime 
1533 VISU_Convertor_impl
1534 ::GetTimeStamp(const std::string& theMeshName, 
1535                const VISU::TEntity& theEntity,
1536                const std::string& theFieldName,
1537                int theStampsNum)
1538 {
1539   TFindTimeStamp aFindTimeStamp = 
1540     FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1541   VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp);
1542   return aValForTime;
1543 }