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