Salome HOME
Update copyright information
[modules/visu.git] / src / CONVERTOR / VISU_Structures_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 //  File:
24 //  Author:  Alexey PETROV
25 //  Module : VISU
26 //
27 #include "VISU_Structures_impl.hxx"
28 #include "VISU_PointCoords.hxx"
29 #include "VISU_MeshValue.hxx"
30
31 #include "VISU_AppendFilter.hxx"
32 #include "VISU_AppendPolyData.hxx"
33 #include "VISU_MergeFilter.hxx"
34
35 #include "VISU_ConvertorUtils.hxx"
36 #include "VISU_CommonCellsFilter.hxx"
37
38 #include <vtkUnstructuredGrid.h>
39 #include <vtkPolyData.h>
40 #include <vtkCellType.h>
41 #include <vtkCell.h>
42
43 namespace VISU
44 {
45   /*  vtkIdType
46   VISUGeom2NbNodes(EGeometry theGeom)
47   {
48     switch(theGeom){
49 #ifndef VISU_ENABLE_QUADRATIC
50     case VISU::eSEG3:
51       return 2;
52     case VISU::eTRIA6:
53       return 3;
54     case VISU::eQUAD8:
55       return 4;
56     case VISU::eTETRA10:
57       return 4;
58     case VISU::eHEXA20:
59       return 8;
60     case VISU::ePENTA15:
61       return 6;
62     case VISU::ePYRA13:
63       return 5;
64 #endif
65     case VISU::ePOLYGONE:
66     case VISU::ePOLYEDRE:
67       return -1;
68     default:
69       return theGeom % 100;
70     }
71   }
72
73   vtkIdType
74   VISUGeom2VTK(EGeometry theGeom)
75   {
76     switch(theGeom){
77     case VISU::ePOINT1:
78       return VTK_VERTEX;
79     case VISU::eSEG2:
80       return VTK_LINE;
81     case VISU::eTRIA3:
82       return VTK_TRIANGLE;
83     case VISU::eQUAD4:
84       return VTK_QUAD;
85     case VISU::eTETRA4:
86       return VTK_TETRA;
87     case VISU::eHEXA8:
88       return VTK_HEXAHEDRON;
89     case VISU::ePENTA6:
90       return VTK_WEDGE;
91     case VISU::ePYRA5:
92       return VTK_PYRAMID;
93
94     case VISU::ePOLYGONE:
95       return VTK_POLYGON;
96     case VISU::ePOLYEDRE:
97       return VTK_CONVEX_POINT_SET;
98
99 #ifndef VISU_ENABLE_QUADRATIC
100     case VISU::eSEG3:
101       return VTK_LINE;
102     case VISU::eTRIA6:
103       return VTK_TRIANGLE;
104     case VISU::eQUAD8:
105       return VTK_QUAD;
106     case VISU::eTETRA10:
107       return VTK_TETRA;
108     case VISU::eHEXA20:
109       return VTK_HEXAHEDRON;
110     case VISU::ePENTA15:
111       return VTK_WEDGE;
112     case VISU::ePYRA13:
113       return VTK_PYRAMID;
114
115 #else
116
117     case VISU::eSEG3:
118 #if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
119       return VTK_QUADRATIC_EDGE;
120 #else
121       return VTK_POLY_LINE;
122 #endif
123
124     case VISU::eTRIA6:
125 #if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
126       return VTK_QUADRATIC_TRIANGLE;
127 #else
128       return VTK_POLYGON;
129 #endif
130
131     case VISU::eQUAD8:
132 #if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
133       return VTK_QUADRATIC_QUAD;
134 #else
135       return VTK_POLYGON;
136 #endif
137
138     case VISU::eTETRA10:
139 #if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
140       return VTK_QUADRATIC_TETRA;
141 #else
142       return VTK_CONVEX_POINT_SET;
143 #endif
144
145     case VISU::eHEXA20:
146 #if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
147       return VTK_QUADRATIC_HEXAHEDRON;
148 #else
149       return VTK_CONVEX_POINT_SET;
150 #endif
151
152     case VISU::ePENTA15:
153 #if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
154       return VTK_QUADRATIC_WEDGE;
155 #else
156       return VTK_CONVEX_POINT_SET;
157 #endif
158
159     case VISU::ePYRA13:
160 #if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
161       return VTK_QUADRATIC_PYRAMID;
162 #else
163       return VTK_CONVEX_POINT_SET;
164 #endif
165
166 #endif //VISU_ENABLE_QUADRATIC
167
168     default:
169       return -1;
170     }
171     }*/
172
173
174   EGeometry
175   VTKGeom2VISU(vtkIdType theGeom)
176   {
177     switch(theGeom){
178     case VTK_VERTEX:
179       return VISU::ePOINT1;
180     case VTK_LINE:
181       return VISU::eSEG2;
182     case VTK_TRIANGLE:
183       return VISU::eTRIA3;
184     case VTK_QUAD:
185       return VISU::eQUAD4;
186     case VTK_TETRA:
187       return VISU::eTETRA4;
188     case VTK_HEXAHEDRON:
189       return VISU::eHEXA8;
190     case VTK_WEDGE:
191       return VISU::ePENTA6;
192     case VTK_PYRAMID:
193       return VISU::ePYRA5;
194     case VTK_HEXAGONAL_PRISM:
195       return VISU::eOCTA12;
196
197
198     case VTK_POLYGON:
199       return VISU::ePOLYGONE;
200     case VTK_CONVEX_POINT_SET:
201       return VISU::ePOLYEDRE;
202
203 #if defined(VISU_ENABLE_QUADRATIC) && defined(VISU_USE_VTK_QUADRATIC)
204
205     case VTK_QUADRATIC_EDGE:
206       return VISU::eSEG3;
207
208     case VTK_QUADRATIC_TRIANGLE:
209       return VISU::eTRIA6;
210
211     case VTK_QUADRATIC_QUAD:
212       return VISU::eQUAD8;
213
214     case VTK_BIQUADRATIC_QUAD:
215       return VISU::eQUAD9;
216
217     case VTK_QUADRATIC_TETRA:
218       return VISU::eTETRA10;
219
220     case VTK_QUADRATIC_HEXAHEDRON:
221       return VISU::eHEXA20;
222
223     case VTK_TRIQUADRATIC_HEXAHEDRON:
224       return VISU::eHEXA27;
225
226     case VTK_QUADRATIC_WEDGE:
227       return VISU::ePENTA15;
228
229     case VTK_QUADRATIC_PYRAMID:
230       return VISU::ePYRA13;
231       
232 #endif //VISU_ENABLE_QUADRATIC
233
234     default:
235       return EGeometry(-1);
236     }
237   }
238
239   //---------------------------------------------------------------
240   /*! Computes number of points by the given number of cells
241    *  in assumption of regular hexahedral mesh structure
242    */
243   size_t
244   GetNumberOfPoints(size_t theNbCells)
245   {
246     return size_t(pow(pow(theNbCells, 1.0/3.0) + 1.0, 3.0));
247   }
248
249   //---------------------------------------------------------------
250   /*! Computes size dataset the given number of mesh macro metrics
251    *  in assumption of regular hexahedral mesh structure
252    */
253   size_t
254   GetDataSetSize(size_t theNbOfPoints,
255                  size_t theNbOfCells,
256                  size_t theCellsSize,
257                  bool theComputeLinks)
258   {
259     size_t aPointsSize = 3*theNbOfPoints*sizeof(VISU::TCoord);
260     size_t aConnectivityAndTypesSize = theCellsSize*sizeof(vtkIdType);
261     size_t aLocationsSize = theNbOfCells*sizeof(int);
262     vtkFloatingPointType aNbCellsPerPoint = theCellsSize / theNbOfCells - 1;
263     size_t aLinksSize = theNbOfPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
264     if(!theComputeLinks)
265       aLinksSize = 0;
266     size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
267     return aResult;
268   }
269
270   //---------------------------------------------------------------
271   TSizeCounter
272   ::TSizeCounter():
273     myNbCells(0),
274     myCellsSize(0)
275   {}
276
277
278   //---------------------------------------------------------------
279   TPolyDataHolder
280   ::TPolyDataHolder()
281   {}
282
283   const PPolyData&
284   TPolyDataHolder
285   ::GetSource() const
286   {
287     if(!mySource.GetPointer()){
288       mySource = vtkPolyData::New();
289       mySource->Delete();
290     }
291     return mySource;
292   }
293
294   vtkPolyData*
295   TPolyDataHolder
296   ::GetPolyDataOutput()
297   {
298     return GetSource().GetPointer();
299   }
300
301   unsigned long int
302   TPolyDataHolder
303   ::GetMemorySize()
304   {
305     if(vtkDataSet* anOutput = GetPolyDataOutput()){
306       anOutput->Update();
307       return anOutput->GetActualMemorySize() * 1024;
308     }
309     if(myIsDone){
310       size_t aNbPoints = GetNumberOfPoints(myNbCells);
311       return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false);
312     }
313     throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!");
314     return 0;
315   }
316
317   //---------------------------------------------------------------
318   TUnstructuredGridHolder
319   ::TUnstructuredGridHolder()
320   {}
321
322   const PUnstructuredGrid&
323   TUnstructuredGridHolder
324   ::GetSource() const
325   {
326     if(!mySource.GetPointer()){
327       mySource = vtkUnstructuredGrid::New();
328       mySource->Delete();
329     }
330     return mySource;
331   }
332
333   vtkUnstructuredGrid*
334   TUnstructuredGridHolder
335   ::GetUnstructuredGridOutput()
336   {
337     return GetSource().GetPointer();
338   }
339
340   unsigned long int
341   TUnstructuredGridHolder
342   ::GetMemorySize()
343   {
344     if(vtkDataSet* anOutput = GetUnstructuredGridOutput()){
345       anOutput->Update();
346       return anOutput->GetActualMemorySize() * 1024;
347     }
348     if(myIsDone){
349       size_t aNbPoints = GetNumberOfPoints(myNbCells);
350       return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false);
351     }
352     throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!");
353     return 0;
354   }
355
356   //---------------------------------------------------------------
357   unsigned long int
358   TMemoryCheckIDMapper
359   ::GetMemorySize()
360   {
361     if(myIsVTKDone){
362       if(vtkDataSet* anOutput = GetOutput()){
363         anOutput->Update();
364         return anOutput->GetActualMemorySize() * 1024;
365       }
366     }
367     throw std::runtime_error("TMemoryCheckIDMapper::GetMemorySize - myIsVTKDone == false !!!");
368     return 0;
369   }
370
371
372   //---------------------------------------------------------------
373   TAppendFilterHolder
374   ::TAppendFilterHolder()
375   {}
376
377   const PAppendFilter&
378   TAppendFilterHolder
379   ::GetFilter() const
380   {
381     if(!myFilter.GetPointer()){
382       myFilter = VISU_AppendFilter::New();
383       myFilter->Delete();
384       myFilter->SetMappingInputs(true);
385     }
386     return myFilter;
387   }
388
389   vtkUnstructuredGrid*
390   TAppendFilterHolder
391   ::GetUnstructuredGridOutput()
392   {
393     GetFilter()->Update();
394     return GetFilter()->GetOutput();
395   }
396
397   //---------------------------------------------------------------
398   TAppendPolyDataHolder
399   ::TAppendPolyDataHolder()
400   {}
401
402   const PAppendPolyData&
403   TAppendPolyDataHolder
404   ::GetFilter() const
405   {
406     if(!myFilter.GetPointer()){
407       myFilter = VISU_AppendPolyData::New();
408       myFilter->SetMappingInputs(true);
409       myFilter->Delete();
410     }
411     return myFilter;
412   }
413
414   vtkPolyData*
415   TAppendPolyDataHolder
416   ::GetPolyDataOutput()
417   {
418     GetFilter()->Update();
419     return GetFilter()->GetOutput();
420   }
421
422
423   //---------------------------------------------------------------
424   TMergeFilterHolder
425   ::TMergeFilterHolder()
426   {}
427
428   const PMergeFilter&
429   TMergeFilterHolder
430   ::GetFilter() const
431   {
432     if(!myFilter.GetPointer()){
433       myFilter = VISU_MergeFilter::New();
434       myFilter->Delete();
435     }
436     return myFilter;
437   }
438
439   vtkDataSet*
440   TMergeFilterHolder
441   ::GetOutput()
442   {
443     GetFilter()->Update();
444     return GetFilter()->GetOutput();
445   }
446
447
448   //---------------------------------------------------------------
449   TMeshImpl
450   ::TMeshImpl():
451     myNbPoints(0)
452   {}
453
454   vtkIdType
455   TMeshImpl::
456   GetNbPoints() const
457   {
458     return myNbPoints;
459   }
460
461   vtkIdType
462   TMeshImpl::
463   GetDim() const
464   {
465     return myDim;
466   }
467
468   vtkPointSet*
469   TMeshImpl::
470   GetPointSet()
471   {
472     return myNamedPointCoords->GetPointSet();
473   }
474
475
476   //---------------------------------------------------------------
477   TSubProfileImpl::TSubProfileImpl():
478     myStatus(eNone),
479     myGeom(eNONE)
480   {}
481
482
483   vtkIdType
484   TSubProfileImpl
485   ::GetElemObjID(vtkIdType theID) const
486   {
487     if ( !mySubMeshID.empty() )
488       return mySubMeshID[theID];
489
490     return theID;
491   }
492
493
494   vtkIdType
495   TSubProfileImpl
496   ::GetElemVTKID(vtkIdType theID) const
497   {
498     if ( !mySubMeshID.empty() )
499       for ( size_t anId = 0; anId < mySubMeshID.size(); anId++ )
500         if ( mySubMeshID[ anId ] == theID )
501           return anId;
502
503     return theID;
504   }
505
506   unsigned long int
507   TSubProfileImpl
508   ::GetMemorySize()
509   {
510     size_t aSize = TUnstructuredGridHolder::GetMemorySize();
511     aSize += sizeof(vtkIdType) * mySubMeshID.size();
512     return aSize;
513   }
514
515   bool 
516   TSubProfileImpl
517   ::isDefault() const
518   {
519     return strcmp(myName.c_str(),"") == 0;
520   }
521   
522   //---------------------------------------------------------------
523   bool
524   operator<(const PSubProfile& theLeft, const PSubProfile& theRight)
525   {
526     PSubProfileImpl aLeft(theLeft), aRight(theRight);
527
528     if(aLeft->myGeom != aRight->myGeom)
529       return aLeft->myGeom < aRight->myGeom;
530
531     if(aLeft->myStatus != aRight->myStatus)
532       return aLeft->myStatus < aRight->myStatus;
533
534     return aLeft->myName < aRight->myName;
535   }
536
537
538   //---------------------------------------------------------------
539   TProfileImpl
540   ::TProfileImpl():
541     myIsAll(true),
542     myMeshOnEntity(NULL)
543   {}
544
545   vtkIdType
546   TProfileImpl
547   ::GetNodeObjID(vtkIdType theID) const
548   {
549     return myNamedPointCoords->GetObjID(theID);
550   }
551
552   vtkIdType
553   TProfileImpl
554   ::GetNodeVTKID(vtkIdType theID) const
555   {
556     return myNamedPointCoords->GetVTKID(theID);
557   }
558
559   vtkFloatingPointType*
560   TProfileImpl
561   ::GetNodeCoord(vtkIdType theObjID)
562   {
563     if(myIsAll)
564       return myMeshOnEntity->GetNodeCoord(theObjID);
565
566     vtkIdType aVtkID = GetNodeVTKID(theObjID);
567     return GetFilter()->GetOutput()->GetPoint(aVtkID);
568   }
569
570   vtkIdType
571   TProfileImpl
572   ::GetElemObjID(vtkIdType theID) const
573   {
574     return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
575   }
576
577   vtkIdType
578   TProfileImpl
579   ::GetElemVTKID(vtkIdType theID) const
580   {
581     return VISU::GetElemVTKID(GetFilter()->GetOutput(), theID);
582   }
583
584   vtkCell*
585   TProfileImpl
586   ::GetElemCell(vtkIdType theObjID)
587   {
588     if(myIsAll)
589       return myMeshOnEntity->GetElemCell(theObjID);
590
591     vtkIdType aVtkID = GetElemVTKID(theObjID);
592     return GetFilter()->GetOutput()->GetCell(aVtkID);
593   }
594
595   vtkUnstructuredGrid*
596   TProfileImpl
597   ::GetUnstructuredGridOutput()
598   {
599     const PAppendFilter& anAppendFilter = GetFilter();
600     return anAppendFilter->GetOutput();
601   }
602
603   unsigned long int
604   TProfileImpl
605   ::GetMemorySize()
606   {
607     size_t aSize = TAppendFilterHolder::GetMemorySize();
608     aSize += myNamedPointCoords->GetMemorySize();
609     aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
610     TGeom2SubProfile::const_iterator anIter = myGeom2SubProfile.begin();
611     TGeom2SubProfile::const_iterator anIterEnd = myGeom2SubProfile.end();
612     for(; anIter != anIterEnd; anIter++){
613       const PSubProfileImpl& aSubProfile = anIter->second;
614       aSize += aSubProfile->GetMemorySize();
615       aSize += sizeof(EGeometry);
616     }
617     return aSize;
618   }
619
620   std::string
621   TProfileImpl
622   ::GetNodeName(vtkIdType theObjID) const
623   {
624     return myNamedPointCoords->GetNodeName(theObjID);
625   }
626
627   std::string
628   TProfileImpl
629   ::GetElemName(vtkIdType theObjID) const
630   {
631     return myMeshOnEntity->GetElemName(theObjID);
632   }
633
634
635   //---------------------------------------------------------------
636   TUnstructuredGridIDMapperImpl
637   ::TUnstructuredGridIDMapperImpl()
638   {
639     if ( !myCommonCellsFilter.GetPointer() ) {
640       myCommonCellsFilter = VISU_CommonCellsFilter::New();
641       myCommonCellsFilter->Delete();
642     }
643   }
644
645   vtkIdType
646   TUnstructuredGridIDMapperImpl
647   ::GetNodeObjID(vtkIdType theID) const
648   {
649     return myIDMapper->GetNodeObjID(theID);
650   }
651
652   vtkIdType
653   TUnstructuredGridIDMapperImpl
654   ::GetNodeVTKID(vtkIdType theID) const
655   {
656     return myIDMapper->GetNodeVTKID(theID);
657   }
658
659   vtkFloatingPointType*
660   TUnstructuredGridIDMapperImpl
661   ::GetNodeCoord(vtkIdType theObjID)
662   {
663     return myIDMapper->GetNodeCoord(theObjID);
664   }
665
666   vtkIdType
667   TUnstructuredGridIDMapperImpl
668   ::GetElemObjID(vtkIdType theID) const
669   {
670     return myIDMapper->GetElemObjID(theID);
671   }
672
673   vtkIdType
674   TUnstructuredGridIDMapperImpl
675   ::GetElemVTKID(vtkIdType theID) const
676   {
677     return myIDMapper->GetElemVTKID(theID);
678   }
679
680   vtkCell*
681   TUnstructuredGridIDMapperImpl
682   ::GetElemCell(vtkIdType theObjID)
683   {
684     return myIDMapper->GetElemCell(theObjID);
685   }
686
687   void
688   TUnstructuredGridIDMapperImpl
689   ::SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper )
690   {
691     myCommonCellsFilter->SetCellsUG( theNamedIDMapper->GetUnstructuredGridOutput() );
692   }
693
694   void
695   TUnstructuredGridIDMapperImpl
696   ::Build()
697   {
698     if ( !myFilter.GetPointer() ) {
699       const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
700
701       vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput();
702       const PUnstructuredGrid& aSource = mySource.GetSource();
703       vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
704       aDataSet->ShallowCopy( aGeometry );
705
706       const PMergeFilter& aFilter = GetFilter();
707       aFilter->SetGeometry( aGeometry );
708       aFilter->SetScalars( aDataSet );
709       aFilter->SetVectors( aDataSet );
710       aFilter->AddField( "VISU_FIELD", aDataSet );
711       aFilter->AddField( "VISU_FIELD_GAUSS_MIN", aDataSet );
712       aFilter->AddField( "VISU_FIELD_GAUSS_MAX", aDataSet );
713       aFilter->AddField( "VISU_FIELD_GAUSS_MOD", aDataSet );
714       aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
715       aFilter->AddField( "ELNO_FIELD", aDataSet );
716       aFilter->AddField( "ELNO_COMPONENT_MAPPER", aDataSet );
717       aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
718
719       myCommonCellsFilter->SetProfileUG( aFilter->GetUnstructuredGridOutput() );
720     }
721   }
722
723   vtkUnstructuredGrid*
724   TUnstructuredGridIDMapperImpl
725   ::GetUnstructuredGridOutput()
726   {
727     Build();
728     return myCommonCellsFilter->GetOutput();
729   }
730
731   vtkDataSet*
732   TUnstructuredGridIDMapperImpl
733   ::GetOutput()
734   {
735     return GetUnstructuredGridOutput();
736   }
737
738   PUnstructuredGrid
739   TUnstructuredGridIDMapperImpl
740   ::GetSource()
741   {
742     Build();
743     return mySource.GetSource();
744   }
745
746   unsigned long int
747   TUnstructuredGridIDMapperImpl
748   ::GetMemorySize()
749   {
750     size_t aSize = myIDMapper->GetMemorySize();
751
752     aSize += mySource.GetMemorySize();
753
754     if ( vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput() )
755       aSize += anOutput->GetActualMemorySize() * 1024;
756
757     return aSize;
758   }
759
760   //---------------------------------------------------------------
761   vtkIdType
762   TPolyDataIDMapperImpl
763   ::GetNodeObjID(vtkIdType theID) const
764   {
765     return myIDMapper->GetNodeObjID(theID);
766   }
767
768   vtkIdType
769   TPolyDataIDMapperImpl
770   ::GetNodeVTKID(vtkIdType theID) const
771   {
772     return myIDMapper->GetNodeVTKID(theID);
773   }
774
775   vtkFloatingPointType*
776   TPolyDataIDMapperImpl
777   ::GetNodeCoord(vtkIdType theObjID)
778   {
779     return myIDMapper->GetNodeCoord(theObjID);
780   }
781
782   vtkIdType
783   TPolyDataIDMapperImpl
784   ::GetElemObjID(vtkIdType theID) const
785   {
786     return myIDMapper->GetElemObjID(theID);
787   }
788
789   vtkIdType
790   TPolyDataIDMapperImpl
791   ::GetElemVTKID(vtkIdType theID) const
792   {
793     return myIDMapper->GetElemVTKID(theID);
794   }
795
796   vtkCell*
797   TPolyDataIDMapperImpl
798   ::GetElemCell(vtkIdType theObjID)
799   {
800     return myIDMapper->GetElemCell(theObjID);
801   }
802
803   void
804   TPolyDataIDMapperImpl
805   ::Build()
806   {
807     if ( !myFilter.GetPointer() ) {
808       const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter();
809       vtkPolyData* aGeometry = anAppendFilter->GetOutput();
810
811       const PPolyData& aSource = mySource.GetSource();
812       vtkPolyData* aDataSet = aSource.GetPointer();
813       aDataSet->ShallowCopy( aGeometry );
814
815       const PMergeFilter& aFilter = GetFilter();
816       aFilter->SetGeometry( aGeometry );
817       aFilter->SetScalars( aDataSet );
818       aFilter->SetVectors( aDataSet );
819       aFilter->AddField( "VISU_FIELD", aDataSet );
820       aFilter->AddField( "VISU_FIELD_GAUSS_MIN", aDataSet );
821       aFilter->AddField( "VISU_FIELD_GAUSS_MAX", aDataSet );
822       aFilter->AddField( "VISU_FIELD_GAUSS_MOD", aDataSet );
823       aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
824       aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
825     }
826   }
827
828   vtkPolyData*
829   TPolyDataIDMapperImpl
830   ::GetPolyDataOutput()
831   {
832     Build();
833     return myFilter->GetPolyDataOutput();
834   }
835
836   vtkDataSet*
837   TPolyDataIDMapperImpl
838   ::GetOutput()
839   {
840     return GetPolyDataOutput();
841   }
842
843   PPolyData
844   TPolyDataIDMapperImpl
845   ::GetSource()
846   {
847     Build();
848     return mySource.GetSource();
849   }
850
851   unsigned long int
852   TPolyDataIDMapperImpl
853   ::GetMemorySize()
854   {
855     size_t aSize = myIDMapper->GetMemorySize();
856     aSize += mySource.GetMemorySize();
857     return aSize;
858   }
859
860
861   //---------------------------------------------------------------
862   TGaussImpl
863   ::TGaussImpl():
864     myGeom(EGeometry(-1)),
865     myNbPoints(0)
866   {}
867
868   void
869   TGaussImpl
870   ::LessThan(const PGaussImpl& theGauss,
871              bool& theResult) const
872   {
873     theResult = false;
874   }
875
876
877   //---------------------------------------------------------------
878   TGaussSubMeshImpl
879   ::TGaussSubMeshImpl():
880     myPointCoords(new TPointCoords()),
881     myStatus(eNone),
882     myStartID(0)
883   {}
884
885   TGaussPointID
886   TGaussSubMeshImpl
887   ::GetObjID(vtkIdType theID) const
888   {
889     TCellID aCellID = myStartID + theID / myGauss->myNbPoints;
890     TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
891
892     return TGaussPointID(aCellID, aLocalPntID);
893   }
894
895   vtkIdType
896   TGaussSubMeshImpl
897   ::GetVTKID(const TGaussPointID& theID) const
898   {
899     vtkIdType aResult = -1;
900
901     TCellID aCellID = theID.first;
902     TLocalPntID aLocalPntID = theID.second;
903
904     vtkIdType aNbPoints = myGauss->myNbPoints;
905     if ( aLocalPntID >= aNbPoints )
906       return aResult;
907
908     return ( aCellID - myStartID ) * aNbPoints + aLocalPntID;
909   }
910
911   vtkIdType
912   VISU::TGaussSubMeshImpl
913   ::GetElemObjID(vtkIdType theID) const
914   {
915     return mySubProfile->GetElemObjID( theID );
916   }
917
918
919   vtkIdType
920   VISU::TGaussSubMeshImpl
921   ::GetElemVTKID(vtkIdType theID) const
922   {
923     return mySubProfile->GetElemVTKID( theID );
924   }
925
926   vtkIdType
927   TGaussSubMeshImpl
928   ::GetGlobalID(vtkIdType theID) const
929   {
930     return myStartID + theID;
931   }
932
933   unsigned long int
934   TGaussSubMeshImpl
935   ::GetMemorySize()
936   {
937     size_t aSize = TPolyDataHolder::GetMemorySize();
938     aSize += myPointCoords->GetMemorySize();
939     return aSize;
940   }
941
942   //---------------------------------------------------------------
943   bool
944   operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight)
945   {
946     PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
947     const PGaussImpl& aGaussLeft = aLeft->myGauss;
948     const PGaussImpl& aGaussRight = aRight->myGauss;
949
950     if(aGaussLeft->myGeom != aGaussRight->myGeom)
951       return aGaussLeft->myGeom < aGaussRight->myGeom;
952
953     if(aLeft->mySubProfile != aRight->mySubProfile)
954       return aLeft->mySubProfile < aRight->mySubProfile;
955
956     bool aResult;
957     aGaussLeft->LessThan(aGaussRight,aResult);
958
959     return aResult;
960   }
961
962
963   //---------------------------------------------------------------
964   TGaussMeshImpl
965   ::TGaussMeshImpl():
966     myParent(NULL)
967   {}
968
969   TGaussPointID
970   TGaussMeshImpl
971   ::GetObjID(vtkIdType theID) const
972   {
973     const PAppendPolyData& aFilter = GetFilter();
974     return VISU::GetObjID(aFilter->GetOutput(), theID);
975   }
976
977   vtkIdType
978   TGaussMeshImpl
979   ::GetVTKID(const TGaussPointID& theID) const
980   {
981     vtkIdType aResult = -1;
982
983     TCellID aCellID = theID.first;
984
985     vtkIdType aVTKCellId = GetParent()->GetElemVTKID( aCellID );
986     if ( aVTKCellId < 0 )
987       return aResult;
988
989     vtkCell* aCell = GetParent()->GetElemCell( aCellID );
990     if ( !aCell )
991       return aResult;
992
993     EGeometry aVGeom = VISU::VTKGeom2VISU( aCell->GetCellType() );
994     if ( aVGeom < EGeometry(0) )
995       return aResult;
996
997     TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.find( aVGeom );
998     if ( anIter == myGeom2GaussSubMesh.end() )
999       return aResult;
1000
1001     size_t aSubMeshEnd = myGaussSubMeshArr.size();
1002     const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
1003     for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) {
1004       const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId];
1005       if ( aGaussSubMesh.get() == aSubMesh.get() ) {
1006         return aGaussSubMesh->GetVTKID(theID);
1007       }
1008     }
1009
1010     return aResult;
1011   }
1012
1013   vtkPolyData*
1014   TGaussMeshImpl
1015   ::GetPolyDataOutput()
1016   {
1017     return TAppendPolyDataHolder::GetPolyDataOutput();
1018   }
1019
1020   unsigned long int
1021   TGaussMeshImpl
1022   ::GetMemorySize()
1023   {
1024     size_t aSize = TAppendPolyDataHolder::GetMemorySize();
1025     TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.begin();
1026     TGeom2GaussSubMesh::const_iterator anIterEnd = myGeom2GaussSubMesh.end();
1027     for(; anIter != anIterEnd; anIter++){
1028       const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
1029       aSize += aGaussSubMesh->GetMemorySize();
1030       aSize += sizeof(EGeometry);
1031     }
1032     return aSize;
1033   }
1034
1035   TNamedIDMapper*
1036   TGaussMeshImpl
1037   ::GetParent() const
1038   {
1039     return myParent;
1040   }
1041
1042
1043   //---------------------------------------------------------------
1044   TGaussPointID
1045   TGaussPtsIDFilter
1046   ::GetObjID(vtkIdType theID) const
1047   {
1048     return myGaussPtsIDMapper->GetObjID(theID);
1049   }
1050
1051   vtkIdType
1052   TGaussPtsIDFilter
1053   ::GetVTKID(const TGaussPointID& theID) const
1054   {
1055     return myGaussPtsIDMapper->GetVTKID(theID);
1056   }
1057
1058   TNamedIDMapper*
1059   TGaussPtsIDFilter
1060   ::GetParent() const
1061   {
1062     return myGaussPtsIDMapper->GetParent();
1063   }
1064
1065   vtkPolyData*
1066   TGaussPtsIDFilter
1067   ::GetPolyDataOutput()
1068   {
1069     return TPolyDataIDMapperImpl::GetPolyDataOutput();
1070   }
1071
1072   vtkDataSet*
1073   TGaussPtsIDFilter
1074   ::GetOutput()
1075   {
1076     return GetPolyDataOutput();
1077   }
1078
1079
1080   //---------------------------------------------------------------
1081   TSubMeshImpl
1082   ::TSubMeshImpl():
1083     myStartID(0)
1084   {}
1085
1086   void
1087   TSubMeshImpl
1088   ::CopyStructure( PStructured theStructured )
1089   {
1090     TStructured::CopyStructure( theStructured );
1091
1092     if ( PMeshImpl aMesh = theStructured )
1093       GetSource()->ShallowCopy( aMesh->GetPointSet() );
1094   }
1095
1096   vtkIdType
1097   TSubMeshImpl
1098   ::GetElemObjID(vtkIdType theID) const
1099   {
1100     return myStartID + theID;
1101   }
1102
1103   std::string
1104   TSubMeshImpl
1105   ::GetElemName(vtkIdType theObjID) const
1106   {
1107     return "";
1108   }
1109
1110   unsigned long int
1111   TSubMeshImpl
1112   ::GetMemorySize()
1113   {
1114     size_t aSize = TUnstructuredGridHolder::GetMemorySize();
1115     for(size_t anId = 0; anId < myCell2Connect.size(); anId++){
1116       const TConnect& aConnect = myCell2Connect[anId];
1117       aSize += aConnect.size() * sizeof(vtkIdType);
1118     }
1119     return aSize;
1120   }
1121
1122   //---------------------------------------------------------------
1123   TMeshOnEntityImpl
1124   ::TMeshOnEntityImpl()
1125   {
1126     const PAppendFilter& anAppendFilter = GetFilter();
1127     anAppendFilter->SetMappingInputs(true);
1128   }
1129
1130   void
1131   TMeshOnEntityImpl
1132   ::CopyStructure( PStructured theStructured )
1133   {
1134     TStructured::CopyStructure( theStructured );
1135
1136     if ( PMeshImpl aMesh = theStructured )
1137       myNamedPointCoords = aMesh->myNamedPointCoords;
1138   }
1139
1140   vtkIdType
1141   TMeshOnEntityImpl
1142   ::GetNodeVTKID(vtkIdType theID) const
1143   {
1144     return myNamedPointCoords->GetVTKID(theID);
1145   }
1146
1147   vtkIdType
1148   TMeshOnEntityImpl
1149   ::GetNodeObjID(vtkIdType theID) const
1150   {
1151     return myNamedPointCoords->GetObjID(theID);
1152   }
1153
1154   vtkIdType
1155   TMeshOnEntityImpl
1156   ::GetElemVTKID(vtkIdType theID) const
1157   {
1158     return VISU::GetElemVTKID(GetFilter()->GetOutput(), theID);
1159   }
1160
1161   vtkIdType
1162   TMeshOnEntityImpl
1163   ::GetElemObjID(vtkIdType theID) const
1164   {
1165     return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
1166   }
1167
1168   std::string
1169   TMeshOnEntityImpl
1170   ::GetNodeName(vtkIdType theObjID) const
1171   {
1172     return myNamedPointCoords->GetNodeName(theObjID);
1173   }
1174
1175   std::string
1176   TMeshOnEntityImpl
1177   ::GetElemName(vtkIdType theObjID) const
1178   {
1179     TInputCellID anInputCellID = VISU::GetInputCellID(GetFilter()->GetOutput(), theObjID);
1180     const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputCellID.first];
1181     return aSubMesh->GetElemName(anInputCellID.second);
1182   }
1183
1184   vtkUnstructuredGrid*
1185   TMeshOnEntityImpl
1186   ::GetUnstructuredGridOutput()
1187   {
1188     return TAppendFilterHolder::GetUnstructuredGridOutput();
1189   }
1190
1191   unsigned long int
1192   TMeshOnEntityImpl
1193   ::GetMemorySize()
1194   {
1195     size_t aSize = TAppendFilterHolder::GetMemorySize();
1196     aSize += myNamedPointCoords->GetMemorySize();
1197     aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
1198     TGeom2SubMesh::const_iterator anIter = myGeom2SubMesh.begin();
1199     TGeom2SubMesh::const_iterator anIterEnd = myGeom2SubMesh.end();
1200     for(; anIter != anIterEnd; anIter++){
1201       const PSubMeshImpl& aSubMesh = anIter->second;
1202       aSize += aSubMesh->GetMemorySize();
1203       aSize += sizeof(EGeometry);
1204     }
1205     return aSize;
1206   }
1207
1208   //---------------------------------------------------------------
1209   void
1210   TFamilyImpl
1211   ::CopyStructure( PStructured theStructured )
1212   {
1213     TStructured::CopyStructure( theStructured );
1214
1215     if ( PMeshImpl aMesh = theStructured ) {
1216       myNamedPointCoords = aMesh->myNamedPointCoords;
1217       GetSource()->ShallowCopy( aMesh->GetPointSet() );
1218     }
1219   }
1220
1221   vtkIdType
1222   TFamilyImpl
1223   ::GetElemVTKID(vtkIdType theID) const
1224   {
1225     if(myElemObj2VTKID.empty())
1226       return theID;
1227     else{
1228       TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
1229       if(anIter != myElemObj2VTKID.end())
1230         return anIter->second;
1231     }
1232     return -1;
1233   }
1234
1235   vtkIdType
1236   TFamilyImpl
1237   ::GetElemObjID(vtkIdType theID) const
1238   {
1239     return myMeshID[theID];
1240   }
1241
1242   vtkIdType
1243   TFamilyImpl
1244   ::GetNodeObjID(vtkIdType theID) const
1245   {
1246     return myNamedPointCoords->GetObjID(theID);
1247   }
1248
1249   vtkIdType
1250   TFamilyImpl
1251   ::GetNodeVTKID(vtkIdType theID) const
1252   {
1253     return myNamedPointCoords->GetVTKID(theID);
1254   }
1255
1256   vtkUnstructuredGrid*
1257   TFamilyImpl
1258   ::GetUnstructuredGridOutput()
1259   {
1260     return TUnstructuredGridHolder::GetUnstructuredGridOutput();
1261   }
1262
1263   unsigned long int
1264   TFamilyImpl
1265   ::GetMemorySize()
1266   {
1267     size_t aSize = TUnstructuredGridHolder::GetMemorySize();
1268     aSize += myNamedPointCoords->GetMemorySize();
1269     aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
1270     aSize += myMeshID.size() * sizeof(vtkIdType);
1271     TGeom2SubMeshID::const_iterator anIter = myGeom2SubMeshID.begin();
1272     TGeom2SubMeshID::const_iterator anIterEnd = myGeom2SubMeshID.end();
1273     for(; anIter != anIterEnd; anIter++){
1274       const TSubMeshID& aSubMeshID = anIter->second;
1275       aSize += aSubMeshID.size() * sizeof(vtkIdType);
1276       aSize += sizeof(EGeometry);
1277     }
1278     return aSize;
1279   }
1280
1281
1282   //---------------------------------------------------------------
1283   void
1284   TGroupImpl
1285   ::CopyStructure( PStructured theStructured )
1286   {
1287     TStructured::CopyStructure( theStructured );
1288
1289     if ( PMeshImpl aMesh = theStructured )
1290       myNamedPointCoords = aMesh->myNamedPointCoords;
1291   }
1292
1293   TNbASizeCells
1294   TGroupImpl
1295   ::GetNbASizeCells() const
1296   {
1297     vtkIdType aNbCells = 0, aCellsSize = 0;
1298     TFamilySet::const_iterator anIter = myFamilySet.begin();
1299     for(; anIter != myFamilySet.end(); anIter++){
1300       PFamilyImpl aFamily = (*anIter).second;
1301       aNbCells += aFamily->myNbCells;
1302       aCellsSize += aFamily->myCellsSize;
1303     }
1304     return std::make_pair(aNbCells,aCellsSize);
1305   }
1306
1307   vtkIdType
1308   TGroupImpl
1309   ::GetElemVTKID(vtkIdType theID) const
1310   {
1311     if(myElemObj2VTKID.empty())
1312       return theID;
1313     else{
1314       TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
1315       if(anIter != myElemObj2VTKID.end())
1316         return anIter->second;
1317     }
1318     return -1;
1319   }
1320
1321   vtkIdType
1322   TGroupImpl
1323   ::GetElemObjID(vtkIdType theID) const
1324   {
1325     return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
1326   }
1327
1328   vtkIdType
1329   TGroupImpl
1330   ::GetNodeObjID(vtkIdType theID) const
1331   {
1332     return myNamedPointCoords->GetObjID(theID);
1333   }
1334
1335   vtkIdType
1336   TGroupImpl
1337   ::GetNodeVTKID(vtkIdType theID) const
1338   {
1339     return myNamedPointCoords->GetVTKID(theID);
1340   }
1341
1342   vtkUnstructuredGrid*
1343   TGroupImpl
1344   ::GetUnstructuredGridOutput()
1345   {
1346     return TAppendFilterHolder::GetUnstructuredGridOutput();
1347   }
1348
1349   unsigned long int
1350   TGroupImpl
1351   ::GetMemorySize()
1352   {
1353     size_t aSize = TAppendFilterHolder::GetMemorySize();
1354     aSize += myNamedPointCoords->GetMemorySize();
1355     aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
1356     for(size_t anId = 0; anId < myFamilyArr.size(); anId++){
1357       const PFamilyImpl& aFamily = myFamilyArr[anId];
1358       aSize += aFamily->GetMemorySize();
1359     }
1360     return aSize;
1361   }
1362
1363
1364
1365   //---------------------------------------------------------------
1366   TFieldImpl
1367   ::TFieldImpl()
1368     : myDataSize( 0 )
1369     , myDataType( 0 )
1370   {}
1371
1372   void
1373   TFieldImpl
1374   ::Init(vtkIdType theNbComp,
1375          vtkIdType theDataType)
1376   {
1377     myNbComp = theNbComp;
1378     myDataType = theDataType;
1379     myCompNames.resize(theNbComp);
1380     myUnitNames.resize(theNbComp);
1381
1382     myMetric2Comp2MinMax.resize(3);
1383     myMetric2Comp2AverageMinMax.resize(3);
1384     myMetric2Comp2Group2MinMax.resize(3);
1385     myMetric2Comp2Group2AverageMinMax.resize(3);
1386     for(int aGaussMetric = (int)VISU::AVERAGE_METRIC; aGaussMetric <= (int)VISU::MAXIMUM_METRIC; aGaussMetric++){
1387       TComp2MinMax& aComp2MinMax = myMetric2Comp2MinMax[aGaussMetric];
1388       TComp2MinMax& aComp2AverageMinMax = myMetric2Comp2AverageMinMax[aGaussMetric];
1389       TComp2Group2MinMax& aComp2Group2MinMax = myMetric2Comp2Group2MinMax[aGaussMetric];
1390       TComp2Group2MinMax& aComp2Group2AverageMinMax = myMetric2Comp2Group2AverageMinMax[aGaussMetric];
1391
1392       aComp2MinMax.resize(theNbComp + 1);
1393       aComp2AverageMinMax.resize(theNbComp + 1);
1394       aComp2Group2MinMax.resize(theNbComp + 1);
1395       aComp2Group2AverageMinMax.resize(theNbComp + 1);
1396       for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
1397         TMinMax& aMinMax = aComp2MinMax[iComp];
1398         aMinMax.first = VTK_LARGE_FLOAT;
1399         aMinMax.second = -VTK_LARGE_FLOAT;
1400         TMinMax& anAverageMinMax = aComp2AverageMinMax[iComp];
1401         anAverageMinMax.first = VTK_LARGE_FLOAT;
1402         anAverageMinMax.second = -VTK_LARGE_FLOAT;
1403       }
1404     }
1405   }
1406
1407   vtkIdType
1408   TFieldImpl
1409   ::GetDataType() const
1410   {
1411     return myDataType;
1412   }
1413
1414   TMinMax
1415   TFieldImpl
1416   ::GetMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric)
1417   {
1418     TMinMax aMinMax;
1419     bool anIsMinMaxInitialized = false;
1420     if( !theGroupNames.empty() ) {
1421       aMinMax.first = VTK_LARGE_FLOAT;
1422       aMinMax.second = -VTK_LARGE_FLOAT;
1423
1424       const TGroup2MinMax& aGroup2MinMax = myMetric2Comp2Group2MinMax[theGaussMetric][theCompID];
1425       TNames::const_iterator aNameIter = theGroupNames.begin();
1426       for( ; aNameIter != theGroupNames.end(); aNameIter++ ) {
1427         TGroup2MinMax::const_iterator aGroup2MinMaxIter = aGroup2MinMax.find( *aNameIter );
1428         if( aGroup2MinMaxIter != aGroup2MinMax.end() ) {
1429           const TMinMax& aGroupMinMax = aGroup2MinMaxIter->second;
1430           aMinMax.first = std::min( aMinMax.first, aGroupMinMax.first );
1431           aMinMax.second = std::max( aMinMax.second, aGroupMinMax.second );
1432           anIsMinMaxInitialized = true;
1433         }
1434       }
1435     }
1436
1437     if( !anIsMinMaxInitialized )
1438       aMinMax = myMetric2Comp2MinMax[theGaussMetric][theCompID];
1439
1440     return aMinMax;
1441   }
1442
1443
1444   TMinMax
1445   TFieldImpl
1446   ::GetAverageMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric)
1447   {
1448     TMinMax aMinMax;
1449     bool anIsMinMaxInitialized = false;
1450     if( !theGroupNames.empty() ) {
1451       aMinMax.first = VTK_LARGE_FLOAT;
1452       aMinMax.second = -VTK_LARGE_FLOAT;
1453
1454       const TGroup2MinMax& aGroup2MinMax = myMetric2Comp2Group2AverageMinMax[theGaussMetric][theCompID];
1455       TNames::const_iterator aNameIter = theGroupNames.begin();
1456       for( ; aNameIter != theGroupNames.end(); aNameIter++ ) {
1457         TGroup2MinMax::const_iterator aGroup2MinMaxIter = aGroup2MinMax.find( *aNameIter );
1458         if( aGroup2MinMaxIter != aGroup2MinMax.end() ) {
1459           const TMinMax& aGroupMinMax = aGroup2MinMaxIter->second;
1460           aMinMax.first = std::min( aMinMax.first, aGroupMinMax.first );
1461           aMinMax.second = std::max( aMinMax.second, aGroupMinMax.second );
1462           anIsMinMaxInitialized = true;
1463         }
1464       }
1465     }
1466
1467     if( !anIsMinMaxInitialized )
1468       aMinMax = myMetric2Comp2AverageMinMax[theGaussMetric][theCompID];
1469
1470     return aMinMax;
1471   }
1472
1473   //----------------------------------------------------------------------------
1474   const PMeshValue&
1475   TGeom2Value
1476   ::GetMeshValue(EGeometry theGeom) const
1477   {
1478     TGeom2MeshValue::const_iterator anIter = myGeom2MeshValue.find(theGeom);
1479     if(anIter == myGeom2MeshValue.end())
1480       EXCEPTION(std::runtime_error,"TGeom2Value::GetMeshValue - myGeom2MeshValue.find(theGeom) fails");
1481     return anIter->second;
1482   }
1483
1484   PMeshValue&
1485   TGeom2Value
1486   ::GetMeshValue(EGeometry theGeom)
1487   {
1488     return myGeom2MeshValue[theGeom];
1489   }
1490
1491
1492   //----------------------------------------------------------------------------
1493   TGeom2MeshValue&
1494   TGeom2Value
1495   ::GetGeom2MeshValue()
1496   {
1497     return myGeom2MeshValue;
1498   }
1499
1500   const TGeom2MeshValue&
1501   TGeom2Value
1502   ::GetGeom2MeshValue() const
1503   {
1504     return myGeom2MeshValue;
1505   }
1506
1507   PMeshValue
1508   TGeom2Value
1509   ::GetFirstMeshValue() const
1510   {
1511     if(myGeom2MeshValue.size() == 1)
1512       return myGeom2MeshValue.begin()->second;
1513     return PMeshValue();
1514   }
1515
1516
1517   //---------------------------------------------------------------
1518   TValForTimeImpl
1519   ::TValForTimeImpl():
1520     myGaussPtsIDFilter(new TGaussPtsIDFilter()),
1521     myUnstructuredGridIDMapper(new TUnstructuredGridIDMapperImpl()),
1522   myIsFilled(false)
1523   {}
1524
1525   const PMeshValue&
1526   TValForTimeImpl
1527   ::GetMeshValue(EGeometry theGeom) const
1528   {
1529     return myGeom2Value.GetMeshValue(theGeom);
1530   }
1531
1532   PMeshValue&
1533   TValForTimeImpl
1534   ::GetMeshValue(EGeometry theGeom)
1535   {
1536     return myGeom2Value.GetMeshValue(theGeom);
1537   }
1538
1539   TGeom2MeshValue&
1540   TValForTimeImpl
1541   ::GetGeom2MeshValue()
1542   {
1543     return myGeom2Value.GetGeom2MeshValue();
1544   }
1545
1546   const TGeom2MeshValue&
1547   TValForTimeImpl
1548   ::GetGeom2MeshValue() const
1549   {
1550     return myGeom2Value.GetGeom2MeshValue();
1551   }
1552
1553   PMeshValue
1554   TValForTimeImpl
1555   ::GetFirstMeshValue() const
1556   {
1557     return myGeom2Value.GetFirstMeshValue();
1558   }
1559
1560   int
1561   TValForTimeImpl
1562   ::GetNbGauss(EGeometry theGeom) const
1563   {
1564     TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
1565     if(anIter == myGeom2NbGauss.end()){
1566       return 1;
1567     }
1568     return anIter->second;
1569   }
1570
1571   int
1572   TValForTimeImpl
1573   ::GetMaxNbGauss() const
1574   {
1575     int aNbGauss = 1;
1576     TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.begin();
1577     for(; anIter != myGeom2NbGauss.end(); anIter++){
1578       aNbGauss = std::max<int>(aNbGauss, anIter->second);
1579     }
1580     return aNbGauss;
1581   }
1582
1583   unsigned long int
1584   TValForTimeImpl
1585   ::GetMemorySize()
1586   {
1587     size_t aSize = sizeof(TValForTimeImpl);
1588     const TGeom2MeshValue& aGeom2MeshValue = GetGeom2MeshValue();
1589     TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
1590     TGeom2MeshValue::const_iterator anIterEnd = aGeom2MeshValue.end();
1591     for(; anIter != anIterEnd; anIter++){
1592       const PMeshValue& aMeshValue = anIter->second;
1593       aSize += aMeshValue->GetMemorySize();
1594       aSize += sizeof(EGeometry);
1595     }
1596     return aSize;
1597   }
1598
1599   //---------------------------------------------------------------
1600 }