Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / CONVERTOR / VISU_MeshValue.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
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:
25 //  Module : VISU
26
27 #include "VISU_MeshValue.hxx"
28 #include "VISU_Structures_impl.hxx"
29 #include "VISU_ConvertorUtils.hxx"
30
31 #include "VISU_PointCoords.hxx"
32 #include "VISU_TypeList.hxx"
33
34 #include <vtkUnstructuredGrid.h>
35 #include <vtkPolyData.h>
36
37 #include <vtkPointData.h>
38 #include <vtkCellData.h>
39
40 #include <vtkCharArray.h>
41 #include <vtkUnsignedCharArray.h>
42 #include <vtkShortArray.h>
43 #include <vtkUnsignedShortArray.h>
44 #include <vtkIntArray.h>
45 #include <vtkUnsignedIntArray.h>
46 #include <vtkLongArray.h>
47 #include <vtkUnsignedLongArray.h> 
48 #include <vtkFloatArray.h> 
49 #include <vtkDoubleArray.h> 
50
51 #include <string>
52 #include <algorithm>
53
54 #ifdef _DEBUG_
55 static int MYDEBUG = 0;
56 #else
57 static int MYDEBUG = 0;
58 #endif
59
60 namespace VISU
61 {
62   //---------------------------------------------------------------
63   std::string
64   GenerateFieldName(const PFieldImpl& theField,
65                     const PValForTimeImpl& theValForTime)
66   {
67     const VISU::TTime& aTime = theValForTime->myTime;
68     std::string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + 
69       VISU_Convertor::GenerateName(aTime);
70     return aFieldName;
71   }
72
73
74   //---------------------------------------------------------------
75   void
76   TMeshValueBase
77   ::Init(vtkIdType theNbElem,
78          vtkIdType theNbGauss,
79          vtkIdType theNbComp)
80   {
81     myNbElem = theNbElem;
82     myNbGauss = theNbGauss;
83     myNbComp = theNbComp;
84     myStep = theNbComp*theNbGauss;
85   }
86
87   vtkIdType 
88   TMeshValueBase
89   ::GetNbElem() const
90   {
91     return myNbElem;
92   }
93
94   vtkIdType 
95   TMeshValueBase
96   ::GetNbComp() const
97   {
98     return myNbComp;
99   }
100
101   vtkIdType 
102   TMeshValueBase
103   ::GetNbGauss() const
104   {
105     return myNbGauss;
106   }
107
108   size_t 
109   TMeshValueBase
110   ::size() const
111   {
112     return myNbElem * myStep;
113   }
114
115
116   namespace TL
117   {
118     //----------------------------------------------------------------------------
119     typedef TList<char,
120                   TList<unsigned char,
121                         TList<short,
122                               TList<unsigned short,
123                                     TList<int,
124                                           TList<unsigned int,
125                                                 TList<long,
126                                                       TList<unsigned long, 
127                                                             TList<float, 
128                                                                   TList<double, 
129                                                                         TNullType> > > > > > > > > >
130     TVTKBasicTypeList;
131     
132
133     //----------------------------------------------------------------------------
134     typedef TList<vtkCharArray,
135                   TList<vtkUnsignedCharArray,
136                         TList<vtkShortArray,
137                               TList<vtkUnsignedShortArray,
138                                     TList<vtkIntArray,
139                                           TList<vtkUnsignedIntArray,
140                                                 TList<vtkLongArray,
141                                                       TList<vtkUnsignedLongArray, 
142                                                             TList<vtkFloatArray, 
143                                                                   TList<vtkDoubleArray, 
144                                                                               TNullType> > > > > > > > > >
145     TVTKArrayTypeList;
146     
147
148     typedef TList<TInt2Type<VTK_CHAR>,
149                   TList<TInt2Type<VTK_UNSIGNED_CHAR>,
150                         TList<TInt2Type<VTK_SHORT>,
151                               TList<TInt2Type<VTK_UNSIGNED_SHORT>,
152                                     TList<TInt2Type<VTK_INT>,
153                                           TList<TInt2Type<VTK_UNSIGNED_INT>,
154                                                 TList<TInt2Type<VTK_LONG>,
155                                                       TList<TInt2Type<VTK_UNSIGNED_LONG>,
156                                                             TList<TInt2Type<VTK_FLOAT>, 
157                                                                   TList<TInt2Type<VTK_DOUBLE>, 
158                                                                         TNullType> > > > > > > > > >
159     TVTKBasicEnumList;
160     
161
162     //----------------------------------------------------------------------------
163     template <unsigned int type_enum>
164     struct TEnum2VTKBasicType
165     {
166       typedef typename TTypeAt<TVTKBasicTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
167     };
168     
169     //----------------------------------------------------------------------------
170     template <unsigned int type_enum>
171     struct TEnum2VTKArrayType
172     {
173       typedef typename TTypeAt<TVTKArrayTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
174     };
175     
176     //----------------------------------------------------------------------------
177     template <class T>
178     struct TVTKBasicType2Enum
179     {
180       typedef typename TTypeAt<TVTKBasicEnumList, TIndexOf<TVTKBasicTypeList, T>::value >::TResult TResult;
181     };
182     
183   }
184
185
186   //----------------------------------------------------------------------------
187   template<int EDataType>
188   void 
189   InitTimeStampOnProfile(const PUnstructuredGrid& theSource,
190                          const PFieldImpl& theField, 
191                          const PValForTimeImpl& theValForTime,
192                          const VISU::TEntity& theEntity);
193
194
195   //----------------------------------------------------------------------------
196   void 
197   GetTimeStampOnProfile(const PUnstructuredGrid& theSource,
198                         const PFieldImpl& theField, 
199                         const PValForTimeImpl& theValForTime,
200                         const VISU::TEntity& theEntity)
201   {
202     vtkIdType aDataType = theField->GetDataType();
203     switch(aDataType){
204     case VTK_DOUBLE:
205       InitTimeStampOnProfile<VTK_DOUBLE>(theSource, theField, theValForTime, theEntity);
206       break;
207     case VTK_FLOAT:
208       InitTimeStampOnProfile<VTK_FLOAT>(theSource, theField, theValForTime, theEntity);
209       break;
210     case VTK_INT:
211       InitTimeStampOnProfile<VTK_INT>(theSource, theField, theValForTime, theEntity);
212       break;
213     case VTK_LONG:
214       InitTimeStampOnProfile<VTK_LONG>(theSource, theField, theValForTime, theEntity);
215       break;
216     default:
217       EXCEPTION(std::runtime_error,
218                 "GetTimeStampOnProfile - handling unsupported data type - "<<aDataType);
219     }
220   }
221
222
223   //----------------------------------------------------------------------------
224   template<int EDataType>
225   struct TDataArrayHolder
226   {
227     typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
228     typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
229     TVTKDataArray* myDataArray;
230
231     TDataArrayHolder(TVTKDataArray* theDataArray):
232       myDataArray(theDataArray)
233     {}
234     
235     void
236     WritePointer(TVTKDataArray* theDataArray,
237                  vtkIdType theTupleId,
238                  TVTKBasicType* thePointer)
239     {
240       vtkIdType aNumberOfComponents = theDataArray->GetNumberOfComponents();
241       vtkIdType aPosition = theTupleId * aNumberOfComponents;
242       TVTKBasicType *aPtr = theDataArray->WritePointer(aPosition, aNumberOfComponents);
243       for(vtkIdType anId = 0; anId < aNumberOfComponents; anId++)
244         *aPtr++ = *thePointer++;
245     }
246
247     virtual
248     void
249     SetTuple(vtkIdType theTupleId, 
250              TVTKBasicType* thePointer)
251     {
252       this->WritePointer(myDataArray, theTupleId, thePointer);
253     }
254   };
255
256
257   //----------------------------------------------------------------------------
258   template<int EDataType>
259   struct TDataArrayHolder2: TDataArrayHolder<EDataType>
260   {
261     typedef TDataArrayHolder<EDataType> TSuperClass;
262     typedef typename TSuperClass::TVTKDataArray TVTKDataArray;
263     typedef typename TSuperClass::TVTKBasicType TVTKBasicType;
264     TVTKDataArray* myDataArray2;
265
266     TDataArrayHolder2(TVTKDataArray* theDataArray,
267                       TVTKDataArray* theDataArray2):
268       TSuperClass(theDataArray),
269       myDataArray2(theDataArray2)
270     {}
271     
272     virtual
273     void
274     SetTuple(vtkIdType theTupleId, 
275              TVTKBasicType* thePointer)
276     {
277       this->WritePointer(this->myDataArray, theTupleId, thePointer);
278       this->WritePointer(this->myDataArray2, theTupleId, thePointer);
279     }
280   };
281
282
283   //----------------------------------------------------------------------------
284   template<int EDataType>
285   struct TTimeStampOnProfileInitArray
286   {
287     typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
288     typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
289     typedef TTMeshValue<TVTKBasicType> TMeshValue;
290     typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
291
292     typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
293     typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
294     PDataArrayHolder myDataArrayHolder;
295
296     TTimeStampOnProfileInitArray(const PDataArrayHolder& theDataArrayHolder):
297       myDataArrayHolder(theDataArrayHolder)
298     {}
299     
300     void
301     Execute(const PFieldImpl& theField,
302             const PValForTimeImpl& theValForTime)
303     {
304       vtkIdType aNbComp = theField->myNbComp;
305       vtkIdType aSize = std::max(3, aNbComp);
306       TVector<TVTKBasicType> aDataValues(aSize);
307       
308       const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
309       TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
310       for(int aTupleId = 0; anIter != aGeom2MeshValue.end(); anIter++){
311         EGeometry aEGeom = anIter->first;
312         const TMeshValuePtr aMeshValue = anIter->second;
313         
314         vtkIdType aNbElem = aMeshValue->GetNbElem();
315         vtkIdType aNbGauss = aMeshValue->GetNbGauss();
316         
317         INITMSG(MYDEBUG,
318                 "- aEGeom = "<<aEGeom<<
319                 "; aNbElem = "<<aNbElem<<
320                 "; aNbGauss = "<<aNbGauss<<
321                 std::endl);
322         
323         for(vtkIdType iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
324           typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetCompValueSliceArr(iElem);
325           for(vtkIdType iComp = 0; iComp < aNbComp; iComp++){
326             const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iComp];
327             aDataValues[iComp] = TVTKBasicType();
328             for(vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++){
329               aDataValues[iComp] += aValueSlice[iGauss];
330             }
331             aDataValues[iComp] /= aNbGauss;
332           }
333           this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
334         }
335       }
336     }
337   };
338
339
340   //----------------------------------------------------------------------------
341   template<int EDataType>
342   void 
343   InitTimeStampOnProfile(const PUnstructuredGrid& theSource,
344                          const PFieldImpl& theField, 
345                          const PValForTimeImpl& theValForTime,
346                          const VISU::TEntity& theEntity)
347   {
348     vtkIdType aNbTuples = theField->myDataSize / theField->myNbComp;
349     std::string aFieldName = VISU::GenerateFieldName(theField, theValForTime);
350     
351     vtkDataSetAttributes* aDataSetAttributes;
352     switch(theEntity){
353     case VISU::NODE_ENTITY : 
354       aDataSetAttributes = theSource->GetPointData();
355       break;
356     default: 
357       aDataSetAttributes = theSource->GetCellData();
358     }
359
360     typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
361     TVTKDataArray *aSelectedDataArray = TVTKDataArray::New();
362     vtkIdType aNbComp = theField->myNbComp;
363     switch(aNbComp) {
364     case 1:
365       aSelectedDataArray->SetNumberOfComponents(1);
366       aDataSetAttributes->SetScalars(aSelectedDataArray);
367       break;
368     default:
369       aSelectedDataArray->SetNumberOfComponents(3);
370       aDataSetAttributes->SetVectors(aSelectedDataArray);
371     }
372     aSelectedDataArray->SetNumberOfTuples(aNbTuples);
373     aSelectedDataArray->SetName(aFieldName.c_str());
374
375     TVTKDataArray *aFullDataArray = TVTKDataArray::New();
376     aFullDataArray->SetNumberOfComponents(aNbComp);
377     aFullDataArray->SetNumberOfTuples(aNbTuples);
378     aFullDataArray->SetName("VISU_FIELD");
379     aDataSetAttributes->AddArray(aFullDataArray);
380
381     INITMSG(MYDEBUG,"InitTimeStampOnProfile "<<
382             "- theEntity = "<<theEntity<<
383             "; aNbTuples = "<<aNbTuples<<
384             "; aNbComp = "<<aNbComp<<
385             std::endl);
386     TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnProfile");
387     
388     const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
389     typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
390     typedef TTMeshValue<TVTKBasicType> TMeshValue;
391     typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
392
393     typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
394     typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
395
396     TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
397     if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){
398       aFullDataArray->SetVoidArray(aMeshValue->GetPointer(),
399                                    aMeshValue->size(),
400                                    true);
401       INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<<std::endl);
402       if(aNbComp == 1){
403         aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
404                                          aMeshValue->size(),
405                                          true);
406         INITMSG(MYDEBUG,"InitTimeStampOnProfile - aSelectedDataArray->SetVoidArray()"<<std::endl);
407       }else{
408         PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder(aSelectedDataArray));
409         TTimeStampOnProfileInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
410       }
411     }else{
412       typedef TDataArrayHolder2<EDataType> TTDataArrayHolder2;
413       PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray));
414       TTimeStampOnProfileInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
415     }
416
417     aSelectedDataArray->Delete();
418     aFullDataArray->Delete();
419   }
420
421
422   //----------------------------------------------------------------------------
423   template<int EDataType>
424   void 
425   InitTimeStampOnGaussMesh(const PPolyData& theSource,
426                            const PFieldImpl& theField, 
427                            const PValForTimeImpl& theValForTime);
428
429   void 
430   GetTimeStampOnGaussMesh(const PPolyData& theSource,
431                           const PFieldImpl& theField, 
432                           const PValForTimeImpl& theValForTime)
433   {
434     vtkIdType aDataType = theField->GetDataType();
435     switch(aDataType){
436     case VTK_DOUBLE:
437       InitTimeStampOnGaussMesh<VTK_DOUBLE>(theSource, theField, theValForTime);
438       break;
439     case VTK_FLOAT:
440       InitTimeStampOnGaussMesh<VTK_FLOAT>(theSource, theField, theValForTime);
441       break;
442     case VTK_INT:
443       InitTimeStampOnGaussMesh<VTK_INT>(theSource, theField, theValForTime);
444       break;
445     case VTK_LONG:
446       InitTimeStampOnGaussMesh<VTK_LONG>(theSource, theField, theValForTime);
447       break;
448     default:
449       EXCEPTION(std::runtime_error,
450                 "GetTimeStampOnGaussMesh - handling unsupported data type - "<<aDataType);
451     }
452   }
453
454   //----------------------------------------------------------------------------
455   template<int EDataType>
456   struct TTimeStampOnGaussMeshInitArray
457   {
458     typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
459     typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
460     typedef TTMeshValue<TVTKBasicType> TMeshValue;
461     typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
462
463     typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
464     typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
465     PDataArrayHolder myDataArrayHolder;
466
467     TTimeStampOnGaussMeshInitArray(const PDataArrayHolder& theDataArrayHolder):
468       myDataArrayHolder(theDataArrayHolder)
469     {}
470     
471     void
472     Execute(const PFieldImpl& theField,
473             const PValForTimeImpl& theValForTime)
474     {
475       vtkIdType aNbComp = theField->myNbComp;
476       vtkIdType aSize = std::max(3, aNbComp);
477       TVector<TVTKBasicType> aDataValues(aSize);
478
479       const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
480
481       PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
482       const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
483       TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
484       for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
485         EGeometry aEGeom = anIter->first;
486         
487         PGaussSubMeshImpl aGaussSubMesh = anIter->second;
488         if(!aGaussSubMesh->myIsDone)
489           continue;
490         
491         TGeom2MeshValue::const_iterator anIter2 = aGeom2MeshValue.find(aEGeom);
492         if(anIter2 == aGeom2MeshValue.end()){
493           EXCEPTION(std::runtime_error,
494                     "TTimeStampOnGaussMeshInitArray >> Can't find values for corresponding Gauss Points SubMesh");
495         }
496         TMeshValuePtr aMeshValue = anIter2->second;
497         vtkIdType aNbGauss = aMeshValue->GetNbGauss();
498         vtkIdType aNbElem = aMeshValue->GetNbElem();
499         
500         if(aNbGauss < 1)
501           continue;
502         
503         const TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
504         
505         INITMSG(MYDEBUG,
506                 "- aEGeom = "<<aEGeom<<
507                 "; aNbElem = "<<aNbElem<<
508                 "; aNbGauss = "<<aNbGauss<<
509                 "; aCoords.GetNbPoints() = "<<aCoords.GetNbPoints()<<
510                 std::endl);
511
512         if(aCoords.GetNbPoints() == aNbElem*aNbGauss){
513           for(int iElem = 0; iElem < aNbElem; iElem++){
514             typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetGaussValueSliceArr(iElem);
515             for(int iGauss = 0; iGauss < aNbGauss; iGauss++, aTupleId++){
516               const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
517               for(int iComp = 0; iComp < aNbComp; iComp++){
518                 aDataValues[iComp] = aValueSlice[iComp];
519               }
520               this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
521             }
522           }
523         }else{
524           for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
525             typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetCompValueSliceArr(iElem);
526             for(int iComp = 0; iComp < aNbComp; iComp++){
527               const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iComp];
528               aDataValues[iComp] = TVTKBasicType();
529               for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
530                 aDataValues[iComp] += aValueSlice[iGauss];
531               }
532               aDataValues[iComp] /= aNbGauss;
533             }
534             this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
535           }
536         }
537       }
538     }
539   };
540
541
542   template<int EDataType>
543   void 
544   InitTimeStampOnGaussMesh(const PPolyData& theSource,
545                            const PFieldImpl& theField, 
546                            const PValForTimeImpl& theValForTime)
547   {
548     vtkIdType aNbTuples = theSource->GetNumberOfPoints();
549     std::string aFieldName = VISU::GenerateFieldName(theField, theValForTime);
550
551     vtkDataSetAttributes* aDataSetAttributes = theSource->GetPointData();
552
553     typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
554     TVTKDataArray *aSelectedDataArray = TVTKDataArray::New();
555     vtkIdType aNbComp = theField->myNbComp;
556     switch(aNbComp){
557     case 1:
558       aSelectedDataArray->SetNumberOfComponents(1);
559       aDataSetAttributes->SetScalars(aSelectedDataArray);
560       break;
561     default:
562       aSelectedDataArray->SetNumberOfComponents(3);
563       aDataSetAttributes->SetVectors(aSelectedDataArray);
564     }
565     aSelectedDataArray->SetNumberOfTuples(aNbTuples);
566     aSelectedDataArray->SetName(aFieldName.c_str());
567
568     TVTKDataArray *aFullDataArray = TVTKDataArray::New();
569     aFullDataArray->SetNumberOfComponents(aNbComp);
570     aFullDataArray->SetNumberOfTuples(aNbTuples);
571     aFullDataArray->SetName("VISU_FIELD");
572     aDataSetAttributes->AddArray(aFullDataArray);
573
574     INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh "<<
575             "- aNbTuples = "<<aNbTuples<<
576             "; aNbComp = "<<aNbComp<<
577             std::endl);
578     TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnGaussMesh");
579     
580     const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
581     typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
582     typedef TTMeshValue<TVTKBasicType> TMeshValue;
583     typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
584
585     typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
586     typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
587
588     TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
589     if(aGeom2MeshValue.size() == 1){
590       aFullDataArray->SetVoidArray(aMeshValue->GetPointer(),
591                                    aMeshValue->size(),
592                                    true);
593       INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aFullDataArray->SetVoidArray()"<<std::endl);
594       if(aNbComp == 1 || aNbComp == 3){
595         aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
596                                          aMeshValue->size(),
597                                          true);
598         INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aSelectedDataArray->SetVoidArray()"<<std::endl);
599       }else{
600         PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder(aSelectedDataArray));
601         TTimeStampOnGaussMeshInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
602       }
603     }else{
604       typedef TDataArrayHolder2<EDataType> TTDataArrayHolder2;
605       PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray));
606       TTimeStampOnGaussMeshInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
607     }
608
609     aSelectedDataArray->Delete();
610     aFullDataArray->Delete();
611   }
612
613
614   //---------------------------------------------------------------
615 }