]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_VtkFieldDriver.hxx
Salome HOME
update from the MedMemory V1.0.1
[modules/med.git] / src / MEDMEM / MEDMEM_VtkFieldDriver.hxx
1 #ifndef VTK_FIELD_DRIVER_HXX
2 #define VTK_FIELD_DRIVER_HXX
3
4 #include <string>
5
6 #include "MEDMEM_define.hxx"
7
8 #include "MEDMEM_GenDriver.hxx"
9 #include "utilities.h"
10
11 #include "MEDMEM_STRING.hxx"
12 #include "MEDMEM_Exception.hxx"
13 #include "MEDMEM_Unit.hxx"
14 #include "MEDMEM_Array.hxx"
15 #include "MEDMEM_Support.hxx"
16 //#include "MEDMEM_Field.hxx"
17 #include "MEDMEM_Mesh.hxx"
18 #include "MEDMEM_CellModel.hxx"
19
20 //using namespace MED_FR ;
21
22 template <class T> class FIELD;
23
24 /*!
25
26   Driver Med for FIELD.
27
28   Generic part : implement open and close methods.
29
30 */
31
32 template <class T> class VTK_FIELD_DRIVER : public GENDRIVER
33 {
34 protected:
35   
36   FIELD<T> *     _ptrField;
37   mutable ofstream *        _vtkFile ;
38   string         _fieldName;
39   int            _fieldNum;
40
41 public :
42
43   // all MED cell type ?? Classe de Définition ??
44   //   static const medGeometryElement all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
45   
46   //   static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
47   
48   /*!
49     Constructor.
50   */
51   VTK_FIELD_DRIVER():GENDRIVER(),
52                      _ptrField((FIELD<T> *)MED_NULL), _fieldName(""),
53                      _fieldNum(MED_INVALID)
54   {
55     const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER() ";
56     BEGIN_OF(LOC);
57
58     _vtkFile = new ofstream();
59
60     END_OF(LOC);
61   }
62   /*!
63     Constructor.
64   */
65   VTK_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField)
66     : GENDRIVER(fileName,MED_WRONLY),
67       _ptrField((FIELD<T> *) ptrField),
68       _fieldName(fileName),_fieldNum(MED_INVALID) 
69   {
70     const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField) ";
71     BEGIN_OF(LOC);
72
73     _vtkFile = new ofstream();
74
75     END_OF(LOC);
76   }
77
78   /*!
79     Copy constructor.
80   */
81   VTK_FIELD_DRIVER(const VTK_FIELD_DRIVER & fieldDriver):
82     GENDRIVER(fieldDriver),
83     _ptrField(fieldDriver._ptrField),
84     _fieldName(fieldDriver._fieldName),
85     _fieldNum(fieldDriver._fieldNum) 
86   {
87     _ptrField->addDriver(*this);
88     _vtkFile = new ofstream();
89   }
90
91   /*!
92     Destructor.
93   */
94   ~VTK_FIELD_DRIVER()
95   {
96   const char * LOC ="VTK_FIELD_DRIVER::~VTK_FIELD_DRIVER()";
97   BEGIN_OF(LOC);
98
99   close();
100
101   SCRUTE(_vtkFile);
102
103   delete _vtkFile ;
104
105   SCRUTE(_vtkFile);
106
107   END_OF(LOC);
108   }
109
110   void openConst() const throw (MEDEXCEPTION)
111   {
112     const char * LOC = "VTK_FIELD_DRIVER::openConst()" ;
113     BEGIN_OF(LOC);
114
115     MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
116
117     if ( _fileName == "" )
118       throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
119                                        << "_fileName is |\"\"|, please set a correct fileName before calling open()"
120                                        )
121                             );
122
123     if (!(*_vtkFile).is_open())
124       (*_vtkFile).open(_fileName.c_str()) ; 
125 //    if (*_vtkFile)
126 //      _status = MED_OPENED ;
127 //    else
128
129
130     SCRUTE((*_vtkFile).is_open());
131     SCRUTE(_vtkFile);
132
133
134
135     if (!(*_vtkFile))
136       throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "
137                                        << _fileName)
138                             );
139     END_OF(LOC);
140   }
141
142   void openConstAppend() const throw (MEDEXCEPTION)
143   {
144     const char * LOC = "VTK_FIELD_DRIVER::openConstAppend()" ;
145     BEGIN_OF(LOC);
146
147     MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
148
149     if ( _fileName == "" )
150       throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
151                                        << "_fileName is |\"\"|, please set a correct fileName before calling open()"
152                                        )
153                             );
154
155     SCRUTE((*_vtkFile).is_open());
156
157     if (!(*_vtkFile).is_open())
158       {
159         MESSAGE(LOC<<"The file is already close and it is opened with the right option");
160         (*_vtkFile).open(_fileName.c_str(), ofstream::out | ofstream::app) ; 
161       }
162     else
163       {
164         MESSAGE(LOC<<"The file is still open, it is closed to make sure that it will be opened with the right option");
165         //      closeConst();
166
167
168         (*_vtkFile).close() ;
169
170         _vtkFile->open(_fileName.c_str(), ofstream::out | ofstream::app) ; 
171       }
172 //    if (*_vtkFile)
173 //      _status = MED_OPENED ;
174 //    else
175
176
177     SCRUTE((*_vtkFile).is_open());
178     SCRUTE(_vtkFile);
179
180
181
182     if (!(*_vtkFile))
183       throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "
184                                        << _fileName)
185                             );
186     END_OF(LOC);
187   }
188
189   void open() throw (MEDEXCEPTION)
190   {
191     openConst() ;
192   }
193
194   void openAppend() throw (MEDEXCEPTION)
195   {
196     openConstAppend() ;
197   }
198
199   void closeConst() const throw (MEDEXCEPTION)
200   {
201     const char * LOC = "VTK_FIELD_DRIVER::closeConst() " ;
202     BEGIN_OF(LOC);
203
204     SCRUTE(_vtkFile);
205     SCRUTE(*_vtkFile);
206
207
208     if ((*_vtkFile).is_open())
209       (*_vtkFile).close();
210   
211 //    if (*_vtkFile)
212 //      _status = MED_CLOSED ;
213 //    else
214
215     SCRUTE(_vtkFile);
216     SCRUTE(*_vtkFile);
217
218     if (!(*_vtkFile))
219       throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not close file "
220                                        << _fileName)
221                             );
222
223     END_OF(LOC);
224   }
225
226   void close() {
227     closeConst() ;
228   }
229
230   /*!
231     Set the name of the FIELD asked in file.
232
233     It could be different than the name of the FIELD object.
234   */
235   void   setFieldName(const string & fieldName) ;
236
237   /*!
238     Get the name of the FIELD asked in file.
239   */
240   string getFieldName() const ;
241
242   /*!
243     Return a MEDEXCEPTION : it is the write-only driver.
244   */
245   void read ( void ) throw (MEDEXCEPTION) ;
246
247   /*!
248     Write FIELD in the specified file, with its mesh through its support
249     which has to be on all entities (excluding the faces in 3d and edges
250     in 2d).
251   */
252   void write( void ) const throw (MEDEXCEPTION) ;
253
254   /*!
255     Write FIELD in the specified file, the mesh is supposed to be
256     written in this file. The field support has to be on all entities
257     (excluding the faces in 3d and edges in 2d).
258   */
259   void writeAppend( void ) const throw (MEDEXCEPTION);
260
261 private:
262   GENDRIVER * copy ( void ) const ;
263
264 };
265
266 /*-------------------------*/
267 /* template implementation */
268 /*-------------------------*/
269
270 /*--------------------- DRIVER PART -------------------------------*/
271
272 template <class T> void VTK_FIELD_DRIVER<T>::setFieldName(const string & fieldName)
273 {
274   _fieldName = fieldName; 
275 }
276
277 template <class T> string  VTK_FIELD_DRIVER<T>::getFieldName() const
278 {
279   return _fieldName;
280 }
281
282 template <class T> GENDRIVER * VTK_FIELD_DRIVER<T>::copy(void) const
283 {
284   VTK_FIELD_DRIVER<T> * myDriver = new VTK_FIELD_DRIVER<T>(*this);
285
286   return myDriver ;
287 }
288
289 template <class T> void VTK_FIELD_DRIVER<T>::read (void)
290   throw (MEDEXCEPTION)
291 {
292   throw MEDEXCEPTION("VTK_FIELD_DRIVER::read : Can't read with a VTK driver because it is write only driver !");
293 }
294
295 template <class T> void VTK_FIELD_DRIVER<T>::write(void) const
296   throw (MEDEXCEPTION)
297 {
298   const char * LOC = "VTK_FIELD_DRIVER::write(void) const " ;
299   BEGIN_OF(LOC);
300
301   // we get the Support and its associated Mesh
302
303   const SUPPORT * supportField = _ptrField->getSupport();
304   MESH * meshField = supportField->getMesh();
305
306   // Well we must open vtk file first, because there are
307   // no other driver than MED for VTK that do it !
308   openConst() ;
309
310   // could we put more than one Mesh ?????
311   (*_vtkFile) << "# vtk DataFile Version 2.0" << endl 
312            << "maillage from MedMemory"  << endl ;
313   // only ASCII for the moment (binary came later :-)
314   (*_vtkFile) << "ASCII" << endl ;
315
316   (*_vtkFile) << "DATASET UNSTRUCTURED_GRID" << endl ;
317   // put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero !
318   int SpaceDimension = meshField->getSpaceDimension() ;
319   int NumberOfNodes = meshField->getNumberOfNodes() ;
320   (*_vtkFile) << "POINTS " << NumberOfNodes << " float" << endl ;
321   const double *coordinate = meshField->getCoordinates(MED_FULL_INTERLACE) ;
322   for (int i=0;i<NumberOfNodes;i++) {
323     for (int j=0;j<SpaceDimension;j++)
324       (*_vtkFile) << coordinate[i*SpaceDimension+j] << " " ;
325     if (SpaceDimension==1) 
326       (*_vtkFile) << "0 0" ;
327     if (SpaceDimension==2) 
328       (*_vtkFile) << "0" ;
329     (*_vtkFile) << endl ;
330   }
331
332   // we put connectivity
333   // how many cells and how many value in connectivity :
334   int cells_types_count = meshField->getNumberOfTypes(MED_CELL) ;
335   //  int * cells_count = meshField->get_cells_count() ;
336   //  int cells_sum = cells_count[cells_types_count] ;
337   int cells_sum = meshField->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ;
338   const CELLMODEL * cells_type = meshField->getCellsTypes(MED_CELL) ;
339   //  int connectivity_sum = 0 ;
340
341   //const int * connectivity = meshField->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ; !! UNUSED VARIABLE !!
342   const int * connectivityIndex = meshField->getConnectivityIndex(MED_NODAL,MED_CELL) ;
343
344   int connectivity_sum =  connectivityIndex[cells_sum]-1 ;
345
346   (*_vtkFile) << "CELLS " << cells_sum << " " << connectivity_sum+cells_sum << endl ;
347   // we put connectivity
348   for (int i=0;i<cells_types_count;i++) {
349     int *filter = (int*) NULL ; // index in vtk connectivity
350     switch (cells_type[i].getType())
351       {
352       case MED_POINT1  : {
353         filter = new int[1] ;
354         filter[0] = 0 ;
355         break ;
356       }
357       case MED_SEG2    : {
358         filter = new int[2] ;
359         filter[0] = 0 ;
360         filter[1] = 1 ;
361         break ;
362       }
363       case MED_SEG3    : {  
364         break ;
365       }
366       case MED_TRIA3   : {
367         filter = new int[3] ;
368         filter[0] = 0 ;
369         filter[1] = 1 ;
370         filter[2] = 2 ;
371         break ;
372       }
373       case MED_QUAD4   : {
374         filter = new int[4] ;
375         filter[0] = 0 ;
376         filter[1] = 1 ;
377         filter[2] = 2 ;
378         filter[3] = 3 ;
379         break ;
380       }
381       case MED_TRIA6   : {
382         break ;
383       }
384       case MED_QUAD8   : {
385         break ;
386       }
387       case MED_TETRA4  : {
388         filter = new int[4] ;
389         filter[0] = 0 ;
390         filter[1] = 1 ;
391         filter[2] = 3 ;  // 3td element in med are 4th in vtk (array begin at 0 !)
392         filter[3] = 2 ;  // 4th element in med are 3rd in vtk (array begin at 0 !)
393         break ;
394       }
395       case MED_PYRA5   : {
396         filter = new int[5] ;
397         filter[0] = 0 ;
398         filter[1] = 3 ;  // 2nd element in med are 4th in vtk (array begin at 0 !)
399         filter[2] = 2 ;
400         filter[3] = 1 ;  // 4th element in med are 2nd in vtk (array begin at 0 !)
401         filter[4] = 4 ;
402         break ;
403       }
404       case MED_PENTA6  : {
405         filter = new int[6] ;
406         filter[0] = 0 ;
407         filter[1] = 1 ;
408         filter[2] = 2 ;
409         filter[3] = 3 ;
410         filter[4] = 4 ;
411         filter[5] = 5 ;
412         break ;
413       }
414       case MED_HEXA8   : {
415         filter = new int[8] ;
416         filter[0] = 0 ;
417         filter[1] = 3 ;
418         filter[2] = 2 ;
419         filter[3] = 1 ;
420         filter[4] = 4 ;
421         filter[5] = 7 ;
422         filter[6] = 6 ;
423         filter[7] = 5 ;
424         break ;
425       }
426       case MED_TETRA10 : {
427         break ;
428       }
429       case MED_PYRA13  : {
430         break ;
431       }
432       case MED_PENTA15 : {
433         break ;
434       }
435       case MED_HEXA20  : {
436         break ;
437       }
438       default : { 
439         break ;
440       }
441       }
442     if (filter==NULL) 
443       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getName() ) ) ;
444     int nodes_cell = cells_type[i].getNumberOfNodes();
445     int numberOfCell = meshField->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
446     const int * connectivityArray = meshField->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,cells_type[i].getType());
447     for (int j=0;j<numberOfCell;j++) {
448       (*_vtkFile) << nodes_cell << " " ;
449       for (int k=0;k<nodes_cell;k++)
450         (*_vtkFile) << connectivityArray[j*nodes_cell+filter[k]] - 1 << " " ;
451       (*_vtkFile) << endl ;
452     }
453     if (filter != NULL)
454       delete[] filter ;
455   }
456   (*_vtkFile) << endl ;
457   // we put cells type
458   (*_vtkFile) << "CELL_TYPES " << cells_sum << endl ;
459   for (int i=0;i<cells_types_count;i++) {
460     int vtkType = 0 ;
461     switch (cells_type[i].getType())
462       {
463       case MED_POINT1  : {
464         vtkType = 1 ;
465         break ;
466       }
467       case MED_SEG2    : {
468         vtkType = 3 ;
469         break ;
470       }
471       case MED_SEG3    : {  
472         vtkType = 0 ;
473         break ;
474       }
475       case MED_TRIA3   : {
476         vtkType = 5 ;
477         break ;
478       }
479       case MED_QUAD4   : {
480         vtkType = 9 ;
481         break ;
482       }
483       case MED_TRIA6   : {
484         vtkType = 0 ;
485         break ;
486       }
487       case MED_QUAD8   : {
488         vtkType = 0 ;
489         break ;
490       }
491       case MED_TETRA4  : {
492         vtkType = 10 ;
493         break ;
494       }
495       case MED_PYRA5   : {
496         vtkType = 14 ;
497         break ;
498       }
499       case MED_PENTA6  : {
500         vtkType = 13 ;
501         break ;
502       }
503       case MED_HEXA8   : {
504         vtkType = 12 ;
505         break ;
506       }
507       case MED_TETRA10 : {
508         vtkType = 0 ;
509         break ;
510       }
511       case MED_PYRA13  : {
512         vtkType = 0 ;
513         break ;
514       }
515       case MED_PENTA15 : {
516         vtkType = 0 ;
517         break ;
518       }
519       case MED_HEXA20  : {
520         vtkType = 0 ;
521         break ;
522       }
523       default : { 
524         vtkType = 0 ;
525         break ;
526       }
527       }
528     if (vtkType == 0)
529       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getType() ) ) ;
530     int numberOfCell = meshField->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
531     for (int j=0;j<numberOfCell;j++)
532       (*_vtkFile) << vtkType << endl ;
533   }
534
535   // first : field on node
536   // fields is on all node !
537
538   // second : field on cell
539   // fields is on all cell !
540
541   int dt = _ptrField->getIterationNumber();
542   int it = _ptrField->getOrderNumber();
543
544   ostringstream name ;
545   string nameField = _ptrField->getName();
546   medEntityMesh entitySupport = supportField->getEntity();
547   name << nameField << "_" << dt << "_" << it ;
548
549   if (!(supportField->isOnAllElements()))
550     throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport));
551
552   if (entitySupport == MED_NODE)
553     (*_vtkFile) << "POINT_DATA " << meshField->getNumberOfNodes() << endl ;
554   else if (entitySupport == MED_CELL)
555     (*_vtkFile) << "CELL_DATA " << meshField->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl ;
556   else
557     throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all nodes or cells but it's on !" << entitySupport));
558
559   int NomberOfValue = supportField->getNumberOfElements(MED_ALL_ELEMENTS) ;
560   int NomberOfComponents =  _ptrField->getNumberOfComponents() ;
561
562   med_type_champ fieldType = _ptrField->getValueType() ;
563
564   SCRUTE(name.str());
565   SCRUTE(fieldType);
566
567   switch (fieldType)
568     {
569     case MED_INT32 : {
570       MESSAGE("MED_INT32");
571       if (NomberOfComponents==3)
572         (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
573       else if (NomberOfComponents<=4)
574         {
575           (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
576           (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
577         }
578       else
579         throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
580  
581       //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
582       const int * value = ((FIELD<int>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
583       for (int i=0; i<NomberOfValue; i++)
584         {
585           for(int j=0; j<NomberOfComponents; j++)
586             (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
587           (*_vtkFile) << endl ;
588         }
589       break ;
590     }
591     case MED_REEL64 : {
592       MESSAGE("MED_REEL64");
593       if (NomberOfComponents==3)
594         (*_vtkFile) << "VECTORS " << name.str() << " float" << endl ;
595       else if (NomberOfComponents<=4)
596         {
597           (*_vtkFile) << "SCALARS " << name.str() << " float " << NomberOfComponents << endl ;
598           (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
599         }
600       else
601         throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
602
603       const double * value = ((FIELD<double>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
604       for (int i=0; i<NomberOfValue; i++)
605         {
606           for(int j=0; j<NomberOfComponents; j++)
607             (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
608           (*_vtkFile) << endl ;
609         }
610       break ;
611     }
612     default : { 
613         throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<< name.str() <<" the type is not int or double !"));
614     }
615     }
616
617   END_OF(LOC);
618 }
619
620 template <class T> void VTK_FIELD_DRIVER<T>::writeAppend(void) const
621   throw (MEDEXCEPTION)
622 {
623   const char * LOC = "VTK_FIELD_DRIVER::writeAppend(void) const " ;
624   BEGIN_OF(LOC);
625
626   // we get the Support and its associated Mesh
627
628   const SUPPORT * supportField = _ptrField->getSupport();
629   MESH * meshField = supportField->getMesh();
630
631   // Well we must open vtk file first, because there are
632   // no other driver than MED for VTK that do it !
633   openConstAppend() ;
634
635   // first : field on node
636   // fields is on all node !
637
638   // second : field on cell
639   // fields is on all cell !
640
641   int dt = _ptrField->getIterationNumber();
642   int it = _ptrField->getOrderNumber();
643
644   ostringstream name ;
645   string nameField = _ptrField->getName();
646   medEntityMesh entitySupport = supportField->getEntity();
647   name << nameField << "_" << dt << "_" << it ;
648
649   if (!(supportField->isOnAllElements()))
650     throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport));
651
652   if (entitySupport == MED_NODE)
653     (*_vtkFile) << "POINT_DATA " << meshField->getNumberOfNodes() << endl ;
654   else if (entitySupport == MED_CELL)
655     (*_vtkFile) << "CELL_DATA " << meshField->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl ;
656   else
657     throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all nodes or cells but it's on !" << entitySupport));
658
659   int NomberOfValue = supportField->getNumberOfElements(MED_ALL_ELEMENTS) ;
660   int NomberOfComponents =  _ptrField->getNumberOfComponents() ;
661
662   med_type_champ fieldType = _ptrField->getValueType() ;
663
664   SCRUTE(name.str());
665   SCRUTE(fieldType);
666
667   switch (fieldType)
668     {
669     case MED_INT32 : {
670       MESSAGE("MED_INT32");
671       if (NomberOfComponents==3)
672         (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
673       else if (NomberOfComponents<=4)
674         {
675           (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
676           (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
677         }
678       else
679         throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
680  
681       //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
682       const int * value = ((FIELD<int>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
683       for (int i=0; i<NomberOfValue; i++)
684         {
685           for(int j=0; j<NomberOfComponents; j++)
686             (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
687           (*_vtkFile) << endl ;
688         }
689       break ;
690     }
691     case MED_REEL64 : {
692       MESSAGE("MED_REEL64");
693       if (NomberOfComponents==3)
694         (*_vtkFile) << "VECTORS " << name.str() << " float" << endl ;
695       else if (NomberOfComponents<=4)
696         {
697           (*_vtkFile) << "SCALARS " << name.str() << " float " << NomberOfComponents << endl ;
698           (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
699         }
700       else
701         throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
702
703       const double * value = ((FIELD<double>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
704       for (int i=0; i<NomberOfValue; i++)
705         {
706           for(int j=0; j<NomberOfComponents; j++)
707             (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
708           (*_vtkFile) << endl ;
709         }
710       break ;
711     }
712     default : { 
713         throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<< name.str() <<" the type is not int or double !"));
714     }
715     }
716
717   END_OF(LOC);
718 }
719
720 #endif /* VTK_FIELD_DRIVER_HXX */