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