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