Salome HOME
Update copyright information
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.cxx
1 // Copyright (C) 2007-2012  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                       const bool checkEntity = true)
336   {
337     INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
338
339     //rnv to fix the: 21040: [CEA 428] Bug of visualization of node field on profile
340     //throw exception in case if the profile on node.
341     //This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh(...) function.
342     if( theMeshOnEntity->myEntity == VISU::CELL_ENTITY && 
343               theSubProfile->myGeom == VISU::ePOINT1 &&
344               !theSubProfile->isDefault() && checkEntity ) 
345           EXCEPTION(std::runtime_error,"theMeshOnEntity->myEntity == VISU::CELL_ENTITY && theSubProfile->myGeom == VISU::ePOINT1 && theSubProfile->isDefault()");
346     
347     const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource();
348     if(theSubProfile->myIsVTKDone)
349       return;
350     
351     aSource->ShallowCopy(theMesh->GetPointSet());
352     INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
353     GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
354     BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
355     
356     theSubProfile->myIsVTKDone = true;
357   }
358   
359   
360   //---------------------------------------------------------------
361   bool
362   GetMeshOnProfile(const VISU::PMeshImpl& theMesh,
363                    const VISU::PMeshOnEntityImpl& theMeshOnEntity,
364                    const VISU::PProfileImpl& theProfile,
365                    const bool checkEntity = true)
366   {
367     //rnv fix for bug IPAL18514 4x (CRASH after trying to build of presentation):
368     // throw exection in case if pointer on profile =0
369     if(!theProfile.get())
370       EXCEPTION(std::runtime_error,"GetMeshOnProfile: theProfile.get() == NULL");
371
372     // rnv fix for issue 19999:
373     // Throw exception in case if mesh on entity from profile is not equal
374     // input mesh on entity. This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh
375     // function.
376     if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
377       EXCEPTION(std::runtime_error,"GetMeshOnProfile >> theProfile->myMeshOnEntity != theMeshOnEntity.get()");
378
379     if(theProfile->myIsVTKDone)
380       return true;
381    
382     //    if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
383     //      return false;
384       
385     VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
386     INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<std::endl);
387
388     const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
389     anAppendFilter->SetSharedPointSet(theMesh->GetPointSet());
390
391     if(theProfile->myIsAll){
392       vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput();
393       anAppendFilter->AddInput(aDataSet);
394     }else{
395       const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
396
397       VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
398
399       VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
400       aSubProfileArr.resize(aGeom2SubProfile.size());
401
402       VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
403       for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
404         VISU::PSubProfileImpl aSubProfile = anIter->second;
405         if(aSubProfile->myStatus == VISU::eRemoveAll)
406           continue;
407         
408         GetMeshOnSubProfile(theMesh,
409                             theMeshOnEntity,
410                             theProfile,
411                             aSubProfile,
412                             checkEntity);
413         
414         const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource();
415         anAppendFilter->AddInput(aSource.GetPointer());
416
417         vtkIdType aNbCells = aSource->GetNumberOfCells();
418         for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
419           vtkIdType anObjID = aSubProfile->GetElemObjID(aCell);
420           anElemObj2VTKID[anObjID] = aCellID;
421         }
422
423         aSubProfileArr[anInputID++] = aSubProfile;
424       }
425     }
426     anAppendFilter->Update(); // Fix on VTK
427     theProfile->myMeshOnEntity = theMeshOnEntity.get();
428     theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
429     
430     theProfile->myIsVTKDone = true;
431     return true;
432   }
433   
434   
435   //---------------------------------------------------------------
436   void
437   GetGaussSubMeshSource(const VISU::PPolyData& theSource,
438                         const VISU::PGaussSubMeshImpl& theGaussSubMesh,
439                         const VISU::PMeshOnEntityImpl& theMeshOnEntity)
440   {
441     vtkCellArray* aConnectivity = vtkCellArray::New();
442     vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
443     aConnectivity->Allocate(aCellsSize, 0);
444     
445     vtkIdList *anIdList = vtkIdList::New();
446     anIdList->SetNumberOfIds(1);
447
448     const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
449     vtkIdType aNbPoints = aCoords.GetNbPoints();
450     for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
451       anIdList->SetId(0, aPointId);
452       aConnectivity->InsertNextCell(anIdList);
453     }
454     anIdList->Delete();
455     
456     const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
457     aSource->ShallowCopy(aCoords.GetPointSet());
458     aSource->SetVerts(aConnectivity);
459     
460     aConnectivity->Delete();
461
462     {
463       vtkIdType aNbTuples = aNbPoints;
464       vtkIntArray *aDataArray = vtkIntArray::New();
465       aDataArray->SetName("VISU_POINTS_MAPPER");
466       aDataArray->SetNumberOfComponents(2);
467       aDataArray->SetNumberOfTuples(aNbTuples);
468       int *aDataArrayPtr = aDataArray->GetPointer(0);
469       for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
470         vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId);
471         *aDataArrayPtr++ = aGlobalID;
472         *aDataArrayPtr++ = 0;
473       }
474       aSource->GetPointData()->AddArray(aDataArray);
475       aDataArray->Delete();
476     }
477
478     {
479       vtkIdType aNbTuples = aNbPoints;
480       vtkIntArray *aDataArray = vtkIntArray::New();
481       aDataArray->SetName("VISU_CELLS_MAPPER");
482       aDataArray->SetNumberOfComponents(2);
483       aDataArray->SetNumberOfTuples(aNbTuples);
484       int *aDataArrayPtr = aDataArray->GetPointer(0);
485       for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
486         VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId);
487         *aDataArrayPtr++ = aGaussPointID.first;
488         *aDataArrayPtr++ = aGaussPointID.second;
489       }
490       aSource->GetCellData()->AddArray(aDataArray);
491       aDataArray->Delete();
492     }
493   }
494   
495   
496   //---------------------------------------------------------------
497   void
498   GetGaussSubMesh(const VISU::PMeshImpl& theMesh,
499                   const VISU::PMeshOnEntityImpl& theMeshOnEntity,
500                   const VISU::PGaussMeshImpl& theGaussMesh,
501                   const VISU::PGaussSubMeshImpl& theGaussSubMesh)
502   {
503     VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss;
504     
505     if(!theGaussSubMesh->myIsDone)
506       return;
507     
508     if(theGaussSubMesh->myIsVTKDone)
509       return;
510     
511     VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
512     INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
513
514     const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
515     GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity);
516
517     INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
518     BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
519     
520     theGaussSubMesh->myIsVTKDone = true;
521   }
522   
523
524   //---------------------------------------------------------------
525   void
526   BuildGaussMesh(const VISU::PMeshImpl& theMesh,
527                  const VISU::PMeshOnEntityImpl& theMeshOnEntity,
528                  const VISU::PGaussMeshImpl& theGaussMesh)
529   {
530     if(theGaussMesh->myIsVTKDone)
531       return;
532
533     VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
534     const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter();
535     const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
536     VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
537     for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
538       VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
539       if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
540         continue;
541
542       aGaussSubMesh->myStartID = aStartID;
543
544       GetGaussSubMesh(theMesh,
545                       theMeshOnEntity,
546                       theGaussMesh,
547                       aGaussSubMesh);
548       
549       const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
550       aStartID += aSource->GetNumberOfCells();
551
552       anAppendFilter->AddInput(aSource.GetPointer());
553     }
554     anAppendFilter->Update(); // Fix on VTK
555
556     theMeshOnEntity->GetOutput()->Update();
557
558     vtkDataSet* aSource = anAppendFilter->GetOutput();
559     INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
560     BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
561     
562     theGaussMesh->myIsVTKDone = true;
563   }
564
565
566   //---------------------------------------------------------------
567   void
568   PrintMemorySize(vtkUnstructuredGrid* theDataSet)
569   {
570     theDataSet->Update();
571     BEGMSG(1,"GetPoints() = "<<vtkFloatingPointType(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
572     BEGMSG(1,"GetCells() = "<<vtkFloatingPointType(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
573     BEGMSG(1,"GetCellTypesArray() = "<<vtkFloatingPointType(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
574     BEGMSG(1,"GetCellLocationsArray() = "<<vtkFloatingPointType(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
575     theDataSet->BuildLinks();
576     BEGMSG(1,"GetCellLinks() = "<<vtkFloatingPointType(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
577     BEGMSG(1,"GetPointData() = "<<vtkFloatingPointType(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
578     BEGMSG(1,"GetCellData() = "<<vtkFloatingPointType(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
579     BEGMSG(1,"GetActualMemorySize() = "<<vtkFloatingPointType(theDataSet->GetActualMemorySize()*1000)<<endl);
580   }
581 }
582
583
584 //---------------------------------------------------------------
585 VISU_Convertor_impl
586 ::VISU_Convertor_impl()
587 {}
588
589
590 //---------------------------------------------------------------
591 VISU_Convertor_impl
592 ::~VISU_Convertor_impl() 
593 {}
594
595
596 //---------------------------------------------------------------
597 VISU_Convertor* 
598 VISU_Convertor_impl
599 ::Build() 
600
601   if(!myIsDone){ 
602     myIsDone = true;  
603     BuildEntities();
604     BuildFields();
605     BuildMinMax();
606     BuildGroups();
607   }
608   return this;
609 }
610
611 VISU_Convertor* 
612 VISU_Convertor_impl
613 ::BuildEntities() 
614
615   return this;
616 }
617
618 VISU_Convertor* 
619 VISU_Convertor_impl
620 ::BuildFields() 
621
622   BuildEntities();
623   return this;
624 }
625
626 VISU_Convertor* 
627 VISU_Convertor_impl
628 ::BuildMinMax() 
629
630   BuildFields();
631   return this;
632 }
633
634 VISU_Convertor* 
635 VISU_Convertor_impl
636 ::BuildGroups() 
637
638   return this;
639 }
640
641
642 //---------------------------------------------------------------
643 VISU::PNamedIDMapper 
644 VISU_Convertor_impl
645 ::GetMeshOnEntity(const std::string& theMeshName, 
646                   const VISU::TEntity& theEntity)
647 {
648   INITMSG(MYDEBUG,"GetMeshOnEntity"<<
649           "; theMeshName = '"<<theMeshName<<"'"<<
650           "; theEntity = "<<theEntity<<
651           endl);
652
653   //Cheching possibility do the query
654   TFindMeshOnEntity aFindMeshOnEntity = 
655     FindMeshOnEntity(theMeshName,theEntity);
656   
657   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
658   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
659   
660   //Main part of code
661 #ifndef _DEXCEPT_
662   try{
663 #endif
664     if(!aMeshOnEntity->myIsVTKDone){
665       VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
666       const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
667       if(MYVTKDEBUG) anAppendFilter->DebugOn();
668
669       LoadMeshOnEntity(aMesh,aMeshOnEntity);
670       anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
671       
672       const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
673       VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
674
675       VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
676       VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
677       aSubMeshArr.resize(aGeom2SubMesh.size());
678
679       for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
680         VISU::EGeometry aEGeom = anIter->first;
681         vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
682         VISU::PSubMeshImpl aSubMesh = anIter->second;
683
684         aSubMesh->CopyStructure( aMesh );
685
686         aSubMesh->myStartID = aCellID;
687
688         const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
689         GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom);
690         anAppendFilter->AddInput(aSource.GetPointer());
691         
692         vtkIdType aNbCells = aSource->GetNumberOfCells();
693         for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
694           vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
695           anElemObj2VTKID[anObjID] = aCellID;
696         }
697
698         aSubMeshArr[anID] = aSubMesh;
699       }
700       
701       aMeshOnEntity->CopyStructure( aMesh );
702
703       aMeshOnEntity->myIsVTKDone = true;
704
705       if(MYDEBUGWITHFILES){
706         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
707         std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
708         aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk";
709         VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
710       }
711
712       if(MYVTKDEBUG){
713         GetMeshOnEntitySize(theMeshName,theEntity);
714         PrintMemorySize(anAppendFilter->GetOutput());
715       }
716     }
717
718 #ifndef _DEXCEPT_
719   }catch(...){
720     throw;
721   }
722 #endif
723
724   return aMeshOnEntity;
725 }
726
727
728 //---------------------------------------------------------------
729 VISU::PUnstructuredGridIDMapper 
730 VISU_Convertor_impl
731 ::GetFamilyOnEntity(const std::string& theMeshName, 
732                     const VISU::TEntity& theEntity,
733                     const std::string& theFamilyName)
734 {
735   INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
736           "; theMeshName = '"<<theMeshName<<"'"<<
737           "; theEntity = "<<theEntity<<
738           "; theFamilyName = '"<<theFamilyName<<"'"<<
739           endl);
740
741   //Cheching possibility do the query
742   TFindFamilyOnEntity aFindFamilyOnEntity = 
743     FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
744
745   VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
746   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
747   VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
748
749   //Main part of code
750 #ifndef _DEXCEPT_
751   try{
752 #endif
753     if ( !aFamily->myIsVTKDone ) {
754       GetMeshOnEntity( theMeshName, theEntity );
755
756       LoadFamilyOnEntity( aMesh, aMeshOnEntity, aFamily );
757
758       aFamily->CopyStructure( aMesh );
759
760       const VISU::PUnstructuredGrid& aSource = aFamily->GetSource();
761       GetCellsOnFamily( aSource, aMeshOnEntity, aFamily );
762
763       aFamily->myIsVTKDone = true;
764
765       if(MYDEBUGWITHFILES){
766         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
767         std::string aFamilyName = (const char*)QString(theFamilyName.c_str()).simplified().toLatin1();
768         std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
769         aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk";
770         VISU::WriteToFile(aSource.GetPointer(),aFileName);
771       }
772
773       if(MYVTKDEBUG){
774         GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
775         PrintMemorySize(aSource.GetPointer());
776       }
777     }
778
779 #ifndef _DEXCEPT_
780   }catch(...){
781     throw;
782   }
783 #endif
784
785   return aFamily;
786 }
787
788
789 //---------------------------------------------------------------
790 VISU::PUnstructuredGridIDMapper 
791 VISU_Convertor_impl
792 ::GetMeshOnGroup(const std::string& theMeshName, 
793                  const std::string& theGroupName)
794 {
795   INITMSG(MYDEBUG,"GetMeshOnGroup\n");
796   INITMSGA(MYDEBUG,0,
797            "- theMeshName = '"<<theMeshName<<
798            "'; theGroupName = '"<<theGroupName<<"'"<<
799            endl);
800
801   //Cheching possibility do the query
802   TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
803   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
804   VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
805
806   //Main part of code
807 #ifndef _DEXCEPT_
808   try{
809 #endif
810     if(!aGroup->myIsVTKDone){
811       const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter();
812       const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
813
814       LoadMeshOnGroup(aMesh,aFamilySet);
815       anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
816
817       VISU::TFamilySet::const_iterator anIter = aFamilySet.begin();
818
819       VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
820       VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
821       aFamilyArr.resize(aFamilySet.size());
822
823       for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){
824         VISU::PFamilyImpl aFamily = (*anIter).second;
825         const std::string& aFamilyName = aFamily->myName;
826         const VISU::TEntity& anEntity = aFamily->myEntity;
827
828         VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
829         vtkDataSet* anOutput = anIDMapper->GetOutput();
830         anAppendFilter->AddInput(anOutput);
831
832         vtkIdType aStartID = anElemObj2VTKID.size();
833         vtkIdType aNbCells = anOutput->GetNumberOfCells();
834         for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
835           anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aStartID + aCellID;
836         }
837         aFamilyArr[anID] = aFamily;
838       }
839
840       aGroup->CopyStructure( aMesh );
841
842       aGroup->myIsVTKDone = true;
843
844       if(MYDEBUGWITHFILES){
845         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
846         std::string aGroupName = (const char*)QString(theGroupName.c_str()).simplified().toLatin1();
847         std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
848         aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk";
849         VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
850       }
851     }
852 #ifndef _DEXCEPT_
853   }catch(...){
854     throw;
855   }
856 #endif
857
858   return aGroup;
859 }
860
861
862 //---------------------------------------------------------------
863 vtkUnstructuredGrid*
864 VISU_Convertor_impl
865 ::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
866                          const VISU::PMeshOnEntityImpl& theMeshOnEntity,
867                          const VISU::PFieldImpl& theField,
868                          const VISU::PValForTimeImpl& theValForTime,
869                          const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
870                          const VISU::PProfileImpl& theProfile,
871                          const VISU::TEntity& theEntity )
872 {
873   LoadMeshOnEntity( theMesh, theMeshOnEntity );
874   GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity );
875   GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile );
876   
877   theUnstructuredGridIDMapper->myIDMapper = theProfile;
878
879   if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) {
880     // add geometry elements to output,
881     // if timestamp on NODE_ENTITY and
882     // on profiles with status eAddPart
883     const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
884     VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin();
885     for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) {
886       const VISU::EGeometry& aGeom = aSubProfileIter->first;
887       const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second;
888       if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) {
889         const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
890         VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin();
891         for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) {
892           VISU::TEntity anEntity = aMeshOnEntityIter->first;
893           if ( anEntity == VISU::NODE_ENTITY )
894             continue;
895           VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity );
896           if( aNamedIDMapper ) {
897             theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper );
898             VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
899             VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
900             
901             return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
902           }
903         }
904       }
905     }
906   }
907
908   VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
909   VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
910
911   return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
912 }
913
914
915 //---------------------------------------------------------------
916 VISU::PUnstructuredGridIDMapper 
917 VISU_Convertor_impl
918 ::GetTimeStampOnMesh( const std::string& theMeshName, 
919                       const VISU::TEntity& theEntity,
920                       const std::string& theFieldName,
921                       int theStampsNum )
922 {
923   INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
924           "; theMeshName = '"<<theMeshName<<"'"<<
925           "; theEntity = "<<theEntity<<
926           "; theFieldName = '"<<theFieldName<<"'"<<
927           "; theStampsNum = "<<theStampsNum<<
928           endl);
929
930   //Cheching possibility do the query
931   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
932                                                 theEntity,
933                                                 theFieldName,
934                                                 theStampsNum);
935
936   VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
937   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
938   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
939   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
940   VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
941
942   //Main part of code
943   VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
944 #ifndef _DEXCEPT_
945   try{
946 #endif
947     if(!anUnstructuredGridIDMapper->myIsVTKDone){
948       VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
949       LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
950
951       vtkUnstructuredGrid* anOutput = NULL;
952       try{
953         anOutput = GetTimeStampOnProfile(aMesh,
954                                          aVTKMeshOnEntity,
955                                          aField,
956                                          aValForTime,
957                                          anUnstructuredGridIDMapper,
958                                          aValForTime->myProfile,
959                                          aMeshOnEntity->myEntity);
960       }catch(std::exception& exc){
961         MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
962         anOutput = GetTimeStampOnProfile(aMesh,
963                                          aMeshOnEntity,
964                                          aField,
965                                          aValForTime,
966                                          anUnstructuredGridIDMapper,
967                                          aValForTime->myProfile,
968                                          aVTKMeshOnEntity->myEntity);
969       }
970
971       anUnstructuredGridIDMapper->CopyStructure( aMesh );
972
973       anUnstructuredGridIDMapper->myIsVTKDone = true;
974
975       if(MYDEBUGWITHFILES){
976         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
977         std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
978         std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
979         std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + 
980           aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk";
981         VISU::WriteToFile(anOutput,aFileName);
982       }
983       if(MYVTKDEBUG){
984         GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
985         anOutput->Update();
986         if(theEntity == VISU::NODE_ENTITY)
987           BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
988         else
989           BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
990         BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
991       }
992       }
993 #ifndef _DEXCEPT_
994     }catch(std::exception& exc){
995     throw;
996   }catch(...){
997     throw;
998   }
999 #endif
1000
1001   return anUnstructuredGridIDMapper;
1002 }
1003
1004
1005 //---------------------------------------------------------------
1006 VISU::PGaussPtsIDMapper 
1007 VISU_Convertor_impl
1008 ::GetTimeStampOnGaussPts(const std::string& theMeshName, 
1009                          const VISU::TEntity& theEntity,
1010                          const std::string& theFieldName,
1011                          int theStampsNum)
1012 {
1013   INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
1014           "; theMeshName = '"<<theMeshName<<"'"<<
1015           "; theEntity = "<<theEntity<<
1016           "; theFieldName = '"<<theFieldName<<"'"<<
1017           "; theStampsNum = "<<theStampsNum<<
1018           endl);
1019
1020   if(theEntity == VISU::NODE_ENTITY)
1021     EXCEPTION(std::runtime_error, "It is impossible to reate Gauss Points on NODE_ENTITY !!!");
1022
1023   //Cheching possibility do the query
1024   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1025                                                 theEntity,
1026                                                 theFieldName,
1027                                                 theStampsNum);
1028   
1029   VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
1030   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
1031   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1032   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1033   VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1034
1035   //Main part of code
1036   VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1037 #ifndef _DEXCEPT_
1038   try{
1039 #endif
1040     if(!aGaussPtsIDFilter->myIsVTKDone){
1041       VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
1042       LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime);
1043       
1044       GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity);
1045       
1046       VISU::PProfileImpl aProfile = aValForTime->myProfile;
1047       GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile, false);
1048
1049       VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
1050       if(!aGaussMesh->myIsVTKDone){
1051         BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh);
1052         aGaussMesh->myParent = aProfile.get();
1053         aGaussMesh->myIsVTKDone = true;
1054       }
1055
1056       aGaussPtsIDFilter->myIDMapper = aGaussMesh;
1057       aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
1058       VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource();
1059       VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
1060       vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
1061
1062       aGaussPtsIDFilter->myIsVTKDone = true;
1063
1064       if(MYDEBUGWITHFILES){
1065         std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
1066         std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
1067         std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
1068         std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + 
1069           aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk";
1070         VISU::WriteToFile(anOutput, aFileName);
1071       }
1072       if(MYVTKDEBUG){
1073         GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
1074         anOutput->Update();
1075         if(theEntity == VISU::NODE_ENTITY)
1076           BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
1077         else
1078           BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
1079         BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
1080       }
1081     }
1082 #ifndef _DEXCEPT_
1083   }catch(std::exception& exc){
1084     throw;
1085   }catch(...){
1086     throw;
1087   }
1088 #endif
1089
1090   return aGaussPtsIDFilter;
1091 }
1092
1093 //---------------------------------------------------------------
1094 VISU::PMeshImpl 
1095 VISU_Convertor_impl
1096 ::FindMesh(const std::string& theMeshName)
1097 {
1098   GetMeshMap();
1099   VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
1100   if(aMeshMapIter == myMeshMap.end())
1101     EXCEPTION(std::runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
1102
1103   VISU::PMeshImpl aMesh = aMeshMapIter->second;
1104   return aMesh;
1105 }
1106
1107
1108 //---------------------------------------------------------------
1109 VISU_Convertor_impl::TFindMeshOnEntity
1110 VISU_Convertor_impl
1111 ::FindMeshOnEntity(const std::string& theMeshName,
1112                    const VISU::TEntity& theEntity)
1113 {
1114   VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1115   VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1116   VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1117   if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1118     EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1119
1120   VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1121   
1122   return TFindMeshOnEntity(aMesh,
1123                            aMeshOnEntity);
1124 }
1125
1126
1127 //---------------------------------------------------------------
1128 VISU_Convertor_impl::TFindFamilyOnEntity
1129 VISU_Convertor_impl
1130 ::FindFamilyOnEntity(const std::string& theMeshName,
1131                      const VISU::TEntity& theEntity,
1132                      const std::string& theFamilyName)
1133 {
1134   if(theFamilyName != ""){
1135     VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1136     VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1137     VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1138     if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1139       EXCEPTION(std::runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1140
1141     VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1142
1143     VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1144     VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
1145     if(aFamilyMapIter != aFamilyMap.end()){
1146       const VISU::PFamily& aFamily = aFamilyMapIter->second;
1147       return TFindFamilyOnEntity(aMesh,
1148                                  aMeshOnEntity,
1149                                  aFamily);
1150     }
1151   }
1152   return TFindFamilyOnEntity();
1153 }
1154
1155
1156 //---------------------------------------------------------------
1157 size_t
1158 VISU_Convertor_impl
1159 ::GetSize() 
1160 {
1161   size_t aResult = 0;
1162   const VISU::TMeshMap& aMeshMap = GetMeshMap();
1163   VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
1164   for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
1165     const std::string& aMeshName = aMeshMapIter->first;
1166     const VISU::PMesh aMesh = aMeshMapIter->second;
1167     const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1168     VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
1169     //Import fields
1170     aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
1171     for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
1172       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
1173       const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1174       const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1175       VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
1176       for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
1177         const std::string& aFieldName = aFieldMapIter->first;
1178         const VISU::PField aField = aFieldMapIter->second;
1179         const VISU::TValField& aValField = aField->myValField;
1180         VISU::TValField::const_iterator aValFieldIter = aValField.begin();
1181         for(; aValFieldIter != aValField.end(); aValFieldIter++){
1182           int aTimeStamp = aValFieldIter->first;
1183           aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
1184         }
1185       }
1186       //Importing groups
1187       const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1188       VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
1189       for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
1190         const std::string& aGroupName = aGroupMapIter->first;
1191         aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
1192       }
1193       //Import families
1194       const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1195       VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1196       for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1197         const std::string& aFamilyName = aFamilyMapIter->first;
1198         aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
1199       }
1200       //Import mesh on entity
1201       aResult += GetMeshOnEntitySize(aMeshName,anEntity);
1202     }
1203   }
1204   MSG(MYDEBUG,"GetSize - aResult = "<<vtkFloatingPointType(aResult));
1205   return aResult;
1206 }
1207
1208
1209 //---------------------------------------------------------------
1210 size_t
1211 VISU_Convertor_impl
1212 ::GetMeshOnEntitySize(const std::string& theMeshName, 
1213                       const VISU::TEntity& theEntity)
1214 {
1215   TFindMeshOnEntity aFindMeshOnEntity = 
1216     FindMeshOnEntity(theMeshName, theEntity);
1217
1218   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
1219   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1220
1221   size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1222   size_t aNbCells = aMeshOnEntity->myNbCells;
1223   size_t aCellsSize = aMeshOnEntity->myCellsSize;
1224
1225   size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1226   size_t aTypesSize = aNbCells*sizeof(char);
1227   size_t aLocationsSize = aNbCells*sizeof(int);
1228   vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1229   size_t aLinksSize = aMesh->GetNbPoints() * 
1230     (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1231   aLinksSize = 0;
1232   size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1233
1234   MSG(MYDEBUG,"GetMeshOnEntitySize "<<
1235       "- aResult = "<<vtkFloatingPointType(aResult)<<
1236       "; theMeshName = '"<<theMeshName<<"'"<<
1237       "; theEntity = "<<theEntity);
1238   if(MYDEBUG){
1239     INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1240     BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1241     BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1242     BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1243     BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1244   }
1245
1246   aResult = size_t(aResult*ERR_SIZE_CALC);
1247   return aResult;
1248 }
1249
1250
1251 //---------------------------------------------------------------
1252 size_t
1253 VISU_Convertor_impl
1254 ::GetFamilyOnEntitySize(const std::string& theMeshName, 
1255                         const VISU::TEntity& theEntity,
1256                         const std::string& theFamilyName)
1257 {
1258   TFindFamilyOnEntity aFindFamilyOnEntity = 
1259     FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1260   VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
1261   VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1262   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1263
1264   size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1265   size_t aNbCells = aFamily->myNbCells;
1266   size_t aCellsSize = aFamily->myCellsSize;
1267
1268   size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1269   size_t aTypesSize = aNbCells*sizeof(char);
1270   size_t aLocationsSize = aNbCells*sizeof(int);
1271   vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1272   size_t aLinksSize = aMesh->GetNbPoints() * 
1273     (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1274   aLinksSize = 0;
1275   size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1276
1277   MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
1278       "- aResult = "<<vtkFloatingPointType(aResult)<<
1279       "; theMeshName = '"<<theMeshName<<"'"<<
1280       "; theEntity = "<<theEntity<<
1281       "; theFamilyName = '"<<theFamilyName<<"'");
1282   if(MYDEBUG){
1283     INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1284     BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1285     BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1286     BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1287     BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1288   }
1289
1290   aResult = size_t(aResult*ERR_SIZE_CALC);
1291   return aResult;
1292 }
1293
1294
1295 //---------------------------------------------------------------
1296 VISU_Convertor_impl::TFindMeshOnGroup
1297 VISU_Convertor_impl
1298 ::FindMeshOnGroup(const std::string& theMeshName, 
1299                   const std::string& theGroupName)
1300 {
1301   VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1302   VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1303   VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
1304   if(aGroupMapIter == aGroupMap.end())
1305     EXCEPTION(std::runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
1306
1307   VISU::PGroupImpl aGroup = aGroupMapIter->second;
1308   return TFindMeshOnGroup(aMesh,aGroup);
1309 }
1310
1311
1312 size_t
1313 VISU_Convertor_impl
1314 ::GetMeshOnGroupSize(const std::string& theMeshName, 
1315                      const std::string& theGroupName)
1316 {
1317   TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
1318   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
1319   VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
1320
1321   size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1322   VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
1323   size_t aNbCells = aNbASizeCells.first;
1324   size_t aCellsSize = aNbASizeCells.second;
1325   size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
1326   size_t aLocationsSize = aNbCells*sizeof(int);
1327   vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1328   size_t aLinksSize = aMesh->GetNbPoints() * 
1329     (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
1330   aLinksSize = 0;
1331   size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
1332   if(MYDEBUG){
1333     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
1334     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
1335     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<vtkFloatingPointType(aLocationsSize));
1336     MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<vtkFloatingPointType(aLinksSize));
1337   }
1338   MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
1339       <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
1340
1341   aResult = size_t(aResult*ERR_SIZE_CALC);
1342   return aResult;
1343 }
1344
1345
1346 VISU_Convertor_impl::TFindField
1347 VISU_Convertor_impl
1348 ::FindField(const std::string& theMeshName, 
1349             const VISU::TEntity& theEntity, 
1350             const std::string& theFieldName)
1351 {
1352   TFindMeshOnEntity aFindMeshOnEntity = 
1353     FindMeshOnEntity(theMeshName,theEntity);
1354
1355   VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1356   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1357
1358   VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1359   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1360   if ( theEntity == VISU::NODE_ENTITY ) {
1361     if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end())
1362       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ];
1363     else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() )
1364       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ];
1365     else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() )
1366       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ];
1367     else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() )
1368       aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ];
1369   }else
1370     aVTKMeshOnEntity = aMeshOnEntity;
1371   
1372   VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1373   VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName );
1374   if(aFieldIter == aFieldMap.end())
1375     EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
1376   
1377   VISU::PFieldImpl aField = aFieldIter->second;
1378
1379   return TFindField( aMesh,
1380                      aMeshOnEntity,
1381                      aVTKMeshOnEntity,
1382                      aField );
1383 }
1384
1385
1386 size_t
1387 VISU_Convertor_impl
1388 ::GetFieldOnMeshSize(const std::string& theMeshName, 
1389                      const VISU::TEntity& theEntity,
1390                      const std::string& theFieldName)
1391 {
1392   TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1393   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1394   VISU::PFieldImpl aField = boost::get<3>(aFindField);
1395
1396   size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
1397   size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
1398   size_t aResult = aMeshSize + aFieldOnMeshSize;
1399   if(MYDEBUG)
1400     MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
1401   MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
1402       "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
1403
1404   return aResult;
1405 }
1406
1407
1408 VISU_Convertor_impl::TFindTimeStamp
1409 VISU_Convertor_impl
1410 ::FindTimeStamp(const std::string& theMeshName, 
1411                 const VISU::TEntity& theEntity, 
1412                 const std::string& theFieldName, 
1413                 int theStampsNum)
1414 {
1415   TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1416   VISU::PField aField = boost::get<3>(aFindField);
1417
1418   VISU::TValField& aValField = aField->myValField;
1419   VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
1420   if(aValFieldIter == aValField.end())
1421     EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
1422   
1423   VISU::PMeshImpl aMesh = boost::get<0>(aFindField);
1424   VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
1425   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1426   VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
1427
1428   return TFindTimeStamp(aMesh,
1429                         aMeshOnEntity,
1430                         aVTKMeshOnEntity,
1431                         aField,
1432                         aValForTime);
1433 }
1434
1435
1436 size_t
1437 VISU_Convertor_impl
1438 ::GetTimeStampSize(const std::string& theMeshName, 
1439                    const VISU::TEntity& theEntity,
1440                    const std::string& theFieldName,
1441                    int theStampsNum)
1442 {
1443   TFindTimeStamp aFindTimeStamp = 
1444     FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1445   VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
1446   VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1447   
1448   size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity);
1449   size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
1450   size_t aResult = aMeshSize + aTimeStampSize;
1451
1452   MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
1453   MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
1454       "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
1455       "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
1456
1457   return aResult;
1458 }
1459
1460
1461 size_t
1462 VISU_Convertor_impl
1463 ::GetTimeStampOnMeshSize(const std::string& theMeshName, 
1464                          const VISU::TEntity& theEntity,
1465                          const std::string& theFieldName,
1466                          int theTimeStampNumber,
1467                          bool& theIsEstimated)
1468 {
1469   size_t aSize = 0;
1470
1471   //Cheching possibility do the query
1472   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1473                                                 theEntity,
1474                                                 theFieldName,
1475                                                 theTimeStampNumber);
1476
1477   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1478   VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
1479   if(anUnstructuredGridIDMapper->myIsVTKDone){
1480     VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName, 
1481                                                     theEntity, 
1482                                                     theFieldName, 
1483                                                     theTimeStampNumber);
1484     anIDMapper->GetOutput();
1485     aSize += anIDMapper->GetMemorySize();
1486   }else
1487     aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1488
1489   theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone);
1490
1491   //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
1492   return aSize;
1493 }
1494
1495
1496 size_t
1497 VISU_Convertor_impl
1498 ::GetTimeStampOnGaussPtsSize(const std::string& theMeshName, 
1499                              const VISU::TEntity& theEntity,
1500                              const std::string& theFieldName,
1501                              int theTimeStampNumber,
1502                              bool& theIsEstimated)
1503 {
1504   size_t aSize = 0;
1505
1506   //Cheching possibility do the query
1507   TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1508                                                 theEntity,
1509                                                 theFieldName,
1510                                                 theTimeStampNumber);
1511
1512   VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1513   VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1514   if(aGaussPtsIDFilter->myIsVTKDone){
1515     VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName, 
1516                                                                        theEntity, 
1517                                                                        theFieldName, 
1518                                                                        theTimeStampNumber);
1519     aGaussPtsIDMapper->GetOutput();
1520     aSize += aGaussPtsIDMapper->GetMemorySize();
1521   }else
1522     aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1523
1524   theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone);
1525
1526   //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
1527   return aSize;
1528 }
1529
1530
1531 const VISU::PField
1532 VISU_Convertor_impl
1533 ::GetField(const std::string& theMeshName, 
1534            VISU::TEntity theEntity, 
1535            const std::string& theFieldName) 
1536 {
1537   TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1538   VISU::PField aField = boost::get<3>(aFindField);
1539   return aField;
1540 }
1541
1542
1543 const VISU::PValForTime 
1544 VISU_Convertor_impl
1545 ::GetTimeStamp(const std::string& theMeshName, 
1546                const VISU::TEntity& theEntity,
1547                const std::string& theFieldName,
1548                int theStampsNum)
1549 {
1550   TFindTimeStamp aFindTimeStamp = 
1551     FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1552   VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp);
1553   return aValForTime;
1554 }