1 /*============================================================================
2   MetaIO
3   Copyright 2000-2010 Insight Software Consortium
4 
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7 
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifdef _MSC_VER
13 #pragma warning(disable:4702)
14 #pragma warning(disable:4284)
15 #endif
16 
17 #include "metaTube.h"
18 
19 #include <stdio.h>
20 #include <ctype.h>
21 #include <string>
22 
23 #if (METAIO_USE_NAMESPACE)
24 namespace METAIO_NAMESPACE {
25 #endif
26 
27 TubePnt::
TubePnt(int dim)28 TubePnt(int dim)
29   {
30   m_Dim = dim;
31   m_X = new float[m_Dim];
32   m_T = new float[m_Dim];
33   m_V1= new float[m_Dim];
34   m_V2= new float[m_Dim];
35   for(unsigned int i=0;i<m_Dim;i++)
36     {
37     m_X[i] = 0;
38     m_V1[i]= 0;
39     m_V2[i]= 0;
40     m_T[i]= 0;
41     }
42   m_R=0;
43   //Color is red by default
44   m_Color[0]=1.0f;
45   m_Color[1]=0.0f;
46   m_Color[2]=0.0f;
47   m_Color[3]=1.0f;
48   m_ID = -1;
49   }
50 
51 TubePnt::
~TubePnt()52 ~TubePnt()
53   {
54   delete []m_X;
55   delete []m_V1;
56   delete []m_V2;
57   delete []m_T;
58   }
59 
60 /** MetaTube Constructors */
61 MetaTube::
MetaTube()62 MetaTube()
63 :MetaObject()
64 {
65   if(META_DEBUG) METAIO_STREAM::cout << "MetaTube()" << METAIO_STREAM::endl;
66   Clear();
67 }
68 
69 
70 MetaTube::
MetaTube(const char * _headerName)71 MetaTube(const char *_headerName)
72 :MetaObject()
73 {
74   if(META_DEBUG)  METAIO_STREAM::cout << "MetaTube()" << METAIO_STREAM::endl;
75   Clear();
76   Read(_headerName);
77 }
78 
79 
80 MetaTube::
MetaTube(const MetaTube * _tube)81 MetaTube(const MetaTube *_tube)
82 :MetaObject()
83 {
84   if(META_DEBUG)  METAIO_STREAM::cout << "MetaTube()" << METAIO_STREAM::endl;
85   Clear();
86   CopyInfo(_tube);
87 }
88 
89 
90 MetaTube::
MetaTube(unsigned int dim)91 MetaTube(unsigned int dim)
92 :MetaObject(dim)
93 {
94   if(META_DEBUG) METAIO_STREAM::cout << "MetaTube()" << METAIO_STREAM::endl;
95   Clear();
96 }
97 
98 /** Destructor */
99 MetaTube::
~MetaTube()100 ~MetaTube()
101 {
102   // Delete the list of pointers to tubes.
103   PointListType::iterator it = m_PointList.begin();
104   while(it != m_PointList.end())
105   {
106     TubePnt* pnt = *it;
107     it++;
108     delete pnt;
109   }
110   m_PointList.clear();
111   M_Destroy();
112 }
113 
114 //
115 void MetaTube::
PrintInfo() const116 PrintInfo() const
117 {
118   MetaObject::PrintInfo();
119   METAIO_STREAM::cout << "ParentPoint = " << m_ParentPoint << METAIO_STREAM::endl;
120   if(m_Root)
121     {
122     METAIO_STREAM::cout << "Root = " << "True" << METAIO_STREAM::endl;
123     }
124   else
125     {
126     METAIO_STREAM::cout << "Root = " << "True" << METAIO_STREAM::endl;
127     }
128   METAIO_STREAM::cout << "PointDim = " << m_PointDim << METAIO_STREAM::endl;
129   METAIO_STREAM::cout << "NPoints = " << m_NPoints << METAIO_STREAM::endl;
130   char str[255];
131   MET_TypeToString(m_ElementType, str);
132   METAIO_STREAM::cout << "ElementType = " << str << METAIO_STREAM::endl;
133 }
134 
135 void MetaTube::
CopyInfo(const MetaObject * _object)136 CopyInfo(const MetaObject * _object)
137 {
138   MetaObject::CopyInfo(_object);
139 }
140 
141 
142 
143 void MetaTube::
PointDim(const char * pointDim)144 PointDim(const char* pointDim)
145 {
146   strcpy(m_PointDim,pointDim);
147 }
148 
149 const char* MetaTube::
PointDim(void) const150 PointDim(void) const
151 {
152   return m_PointDim;
153 }
154 
155 void MetaTube::
NPoints(int npnt)156 NPoints(int npnt)
157 {
158   m_NPoints = npnt;
159 }
160 
161 int MetaTube::
NPoints(void) const162 NPoints(void) const
163 {
164   return m_NPoints;
165 }
166 
167 void MetaTube::
Root(bool root)168 Root(bool root)
169 {
170   m_Root = root;
171 }
172 
173 bool MetaTube::
Root(void) const174 Root(void) const
175 {
176   return m_Root;
177 }
178 
179 
180 void  MetaTube::
ParentPoint(int parentpoint)181 ParentPoint(int parentpoint)
182 {
183   m_ParentPoint = parentpoint;
184 }
185 
186 int MetaTube::
ParentPoint(void) const187 ParentPoint(void) const
188 {
189   return m_ParentPoint;
190 }
191 
192 /** Clear tube information */
193 void MetaTube::
Clear(void)194 Clear(void)
195 {
196   if(META_DEBUG) METAIO_STREAM::cout << "MetaTube: Clear" << METAIO_STREAM::endl;
197   MetaObject::Clear();
198   // Delete the list of pointers to tubes.
199   PointListType::iterator it = m_PointList.begin();
200   while(it != m_PointList.end())
201   {
202     TubePnt* pnt = *it;
203     it++;
204     delete pnt;
205   }
206   m_PointList.clear();
207 
208   m_ParentPoint= -1;
209   m_Root = false;
210   m_NPoints = 0;
211   strcpy(m_PointDim, "x y z r v1x v1y v1z v2x v2y v2z tx ty tz red green blue alpha id");
212   m_ElementType = MET_FLOAT;
213 }
214 
215 /** Destroy tube information */
216 void MetaTube::
M_Destroy(void)217 M_Destroy(void)
218 {
219   MetaObject::M_Destroy();
220 }
221 
222 /** Set Read fields */
223 void MetaTube::
M_SetupReadFields(void)224 M_SetupReadFields(void)
225 {
226   if(META_DEBUG) METAIO_STREAM::cout << "MetaTube: M_SetupReadFields" << METAIO_STREAM::endl;
227 
228   MetaObject::M_SetupReadFields();
229 
230   MET_FieldRecordType * mF;
231 
232   // int nDimsRecNum = MET_GetFieldRecordNumber("NDims", &m_Fields);
233 
234   mF = new MET_FieldRecordType;
235   MET_InitReadField(mF, "ParentPoint", MET_INT, false);
236   m_Fields.push_back(mF);
237 
238   mF = new MET_FieldRecordType;
239   MET_InitReadField(mF, "Root", MET_STRING, false);
240   m_Fields.push_back(mF);
241 
242   mF = new MET_FieldRecordType;
243   MET_InitReadField(mF, "PointDim", MET_STRING, true);
244   m_Fields.push_back(mF);
245 
246   mF = new MET_FieldRecordType;
247   MET_InitReadField(mF, "NPoints", MET_INT, true);
248   m_Fields.push_back(mF);
249 
250   mF = new MET_FieldRecordType;
251   MET_InitReadField(mF, "Points", MET_NONE, true);
252   mF->terminateRead = true;
253   m_Fields.push_back(mF);
254 
255 }
256 
257 void MetaTube::
M_SetupWriteFields(void)258 M_SetupWriteFields(void)
259 {
260   strcpy(m_ObjectTypeName,"Tube");
261   MetaObject::M_SetupWriteFields();
262 
263   MET_FieldRecordType * mF;
264 
265   if(m_ParentPoint>=0 && m_ParentID>=0)
266     {
267     mF = new MET_FieldRecordType;
268     MET_InitWriteField(mF, "ParentPoint", MET_INT,m_ParentPoint);
269     m_Fields.push_back(mF);
270     }
271 
272   if(m_Root)
273     {
274     mF = new MET_FieldRecordType;
275     MET_InitWriteField(mF, "Root", MET_STRING, strlen("True"), "True");
276     m_Fields.push_back(mF);
277     }
278   else
279     {
280     mF = new MET_FieldRecordType;
281     MET_InitWriteField(mF, "Root", MET_STRING, strlen("False"), "False");
282     m_Fields.push_back(mF);
283     }
284 
285   if(strlen(m_PointDim)>0)
286     {
287     mF = new MET_FieldRecordType;
288     MET_InitWriteField(mF, "PointDim", MET_STRING,
289                            strlen(m_PointDim),m_PointDim);
290     m_Fields.push_back(mF);
291     }
292 
293   m_NPoints = (int)m_PointList.size();
294   mF = new MET_FieldRecordType;
295   MET_InitWriteField(mF, "NPoints", MET_INT,m_NPoints);
296   m_Fields.push_back(mF);
297 
298   mF = new MET_FieldRecordType;
299   MET_InitWriteField(mF, "Points", MET_NONE);
300   m_Fields.push_back(mF);
301 
302 }
303 
304 
305 
306 bool MetaTube::
M_Read(void)307 M_Read(void)
308 {
309   if(META_DEBUG)
310     {
311     METAIO_STREAM::cout << "MetaTube: M_Read: Loading Header" << METAIO_STREAM::endl;
312     }
313 
314   if(!MetaObject::M_Read())
315     {
316     METAIO_STREAM::cout << "MetaTube: M_Read: Error parsing file" << METAIO_STREAM::endl;
317     return false;
318     }
319 
320   if(META_DEBUG)
321     {
322     METAIO_STREAM::cout << "MetaTube: M_Read: Parsing Header" << METAIO_STREAM::endl;
323     }
324 
325   MET_FieldRecordType * mF;
326 
327   mF = MET_GetFieldRecord("ParentPoint", &m_Fields);
328   if(mF->defined)
329     {
330     m_ParentPoint= (int)mF->value[0];
331     }
332 
333   m_Root = false;
334   mF = MET_GetFieldRecord("Root", &m_Fields);
335   if(mF->defined)
336     {
337     if(*((char *)(mF->value)) == 'T'
338       || *((char*)(mF->value)) == 't'
339       || *((char*)(mF->value)) == '1')
340       {
341       m_Root = true;
342       }
343     else
344       {
345       m_Root = false;
346       }
347     }
348 
349   mF = MET_GetFieldRecord("NPoints", &m_Fields);
350   if(mF->defined)
351     {
352     m_NPoints= (int)mF->value[0];
353     }
354 
355   mF = MET_GetFieldRecord("PointDim", &m_Fields);
356   if(mF->defined)
357     {
358     strcpy(m_PointDim,(char *)(mF->value));
359     }
360 
361 
362   int* posDim= new int[m_NDims];
363   int i;
364   for(i= 0; i < m_NDims; i++)
365     {
366     posDim[i] = -1;
367     }
368   int posR = -1;
369   int posV1x = -1;
370   int posV1y = -1;
371   int posV1z = -1;
372   int posV2x = -1;
373   int posV2y = -1;
374   int posV2z = -1;
375   int posTx = -1;
376   int posTy = -1;
377   int posTz = -1;
378   int posRed = -1;
379   int posGreen = -1;
380   int posBlue = -1;
381   int posAlpha = -1;
382   int posID = -1;
383 
384   int pntDim;
385   char** pntVal = NULL;
386   MET_StringToWordArray(m_PointDim, &pntDim, &pntVal);
387 
388   if(META_DEBUG)
389     {
390     METAIO_STREAM::cout << "MetaTube: Parsing point dim" << METAIO_STREAM::endl;
391     }
392 
393   int j;
394   for(j = 0; j < pntDim; j++)
395     {
396     if(!strcmp(pntVal[j], "x") || !strcmp(pntVal[j], "X"))
397       {
398       posDim[0] = j;
399       }
400     if(!strcmp(pntVal[j], "y") || !strcmp(pntVal[j], "Y"))
401       {
402       posDim[1] = j;
403       }
404     if(!strcmp(pntVal[j], "z") || !strcmp(pntVal[j], "Z"))
405       {
406       posDim[2] = j;
407       }
408     if(((char *)pntVal[j])[0] == 'w' || ((char *)pntVal[j])[0] == 'W')
409       {
410       posDim[(int)pntVal[j][1]+3] = j;
411       }
412     if(!strcmp(pntVal[j], "s") || !strcmp(pntVal[j], "S") ||
413       !strcmp(pntVal[j], "r") || !strcmp(pntVal[j], "R") ||
414       !strcmp(pntVal[j], "rad") || !strcmp(pntVal[j], "Rad") ||
415       !strcmp(pntVal[j], "radius") || !strcmp(pntVal[j], "Radius"))
416       {
417       posR = j;
418       }
419     if(!strcmp(pntVal[j], "v1x"))
420       {
421       posV1x = j;
422       }
423     if(!strcmp(pntVal[j], "v1y"))
424       {
425       posV1y = j;
426       }
427     if(!strcmp(pntVal[j], "v1z"))
428       {
429       posV1z = j;
430       }
431     if(!strcmp(pntVal[j], "v2x"))
432       {
433       posV2x = j;
434       }
435     if(!strcmp(pntVal[j], "v2y"))
436       {
437       posV2y = j;
438       }
439     if(!strcmp(pntVal[j], "v2z"))
440       {
441       posV2z = j;
442       }
443     if(!strcmp(pntVal[j], "tx"))
444       {
445       posTx = j;
446       }
447     if(!strcmp(pntVal[j], "ty"))
448       {
449       posTy = j;
450       }
451     if(!strcmp(pntVal[j], "tz"))
452       {
453       posTz = j;
454       }
455     if(!strcmp(pntVal[j], "red"))
456       {
457       posRed = j;
458       }
459     if(!strcmp(pntVal[j], "green"))
460       {
461       posGreen = j;
462       }
463 
464     if(!strcmp(pntVal[j], "blue"))
465       {
466       posBlue = j;
467       }
468     if(!strcmp(pntVal[j], "alpha"))
469       {
470       posAlpha = j;
471       }
472     if(!strcmp(pntVal[j], "id") || !strcmp(pntVal[j], "ID"))
473       {
474       posID = j;
475       }
476     }
477 
478   for(i=0;i<pntDim;i++)
479     {
480     delete [] pntVal[i];
481     }
482   delete [] pntVal;
483 
484   float v[30];
485 
486   if(m_Event)
487     {
488     m_Event->StartReading(m_NPoints);
489     }
490 
491   if(m_BinaryData)
492     {
493     int elementSize;
494     MET_SizeOfType(m_ElementType, &elementSize);
495     int readSize = m_NPoints*(m_NDims*(2+m_NDims)+10)*elementSize;
496 
497     char* _data = new char[readSize];
498     m_ReadStream->read((char *)_data, readSize);
499 
500     int gc = m_ReadStream->gcount();
501     if(gc != readSize)
502       {
503       METAIO_STREAM::cout << "MetaLine: m_Read: data not read completely"
504                 << METAIO_STREAM::endl;
505       METAIO_STREAM::cout << "   ideal = " << readSize
506                 << " : actual = " << gc << METAIO_STREAM::endl;
507       delete [] posDim;
508       delete [] _data;
509       return false;
510       }
511 
512     i=0;
513     int d;
514     unsigned int k;
515     for(j=0; j<(int)m_NPoints; j++)
516       {
517       TubePnt* pnt = new TubePnt(m_NDims);
518 
519       for(d=0; d<m_NDims; d++)
520         {
521         float td;
522         char * const num = (char *)(&td);
523         for(k=0;k<sizeof(float);k++)
524           {
525           num[k] = _data[i+k];
526           }
527         MET_SwapByteIfSystemMSB(&td,MET_FLOAT);
528         i+=sizeof(float);
529         pnt->m_X[d] = td;
530         }
531 
532         {
533         float td;
534         char * const num = (char *)(&td);
535         for(k=0;k<sizeof(float);k++)
536           {
537           num[k] = _data[i+k];
538           }
539         MET_SwapByteIfSystemMSB(&td,MET_FLOAT);
540         i+=sizeof(float);
541         pnt->m_R = td;
542         }
543 
544       for(d = 0; d < m_NDims; d++)
545         {
546         float td;
547         char * const num = (char *)(&td);
548         for(k=0;k<sizeof(float);k++)
549           {
550           num[k] = _data[i+k];
551           }
552         MET_SwapByteIfSystemMSB(&td,MET_FLOAT);
553         i+=sizeof(float);
554         pnt->m_V1[d] = (float)td;
555         }
556 
557       if(m_NDims==3)
558         {
559         for(d = 0; d < m_NDims; d++)
560           {
561           float td;
562           char * const num = (char *)(&td);
563           for(k=0;k<sizeof(float);k++)
564             {
565             num[k] = _data[i+k];
566             }
567           MET_SwapByteIfSystemMSB(&td,MET_FLOAT);
568           i+=sizeof(float);
569           pnt->m_V2[d] = (float)td;
570           }
571         }
572 
573       for(d = 0; d < m_NDims; d++)
574         {
575         float td;
576         char * const num = (char *)(&td);
577         for(k=0;k<sizeof(float);k++)
578           {
579           num[k] = _data[i+k];
580           }
581         MET_SwapByteIfSystemMSB(&td,MET_FLOAT);
582         i+=sizeof(float);
583         pnt->m_T[d] = (float)td;
584         }
585 
586       for(d=0; d<4; d++)
587         {
588         float td;
589         char * const num = (char *)(&td);
590         for(k=0;k<sizeof(float);k++)
591           {
592           num[k] = _data[i+k];
593           }
594         MET_SwapByteIfSystemMSB(&td,MET_FLOAT);
595         i+=sizeof(float);
596         pnt->m_Color[d] = (float)td;
597         }
598 
599         {
600         int id;
601         char * const num = (char *)(&id);
602         for(k=0;k<sizeof(int);k++)
603           {
604           num[k] = _data[i+k];
605           }
606         MET_SwapByteIfSystemMSB(&id,MET_INT);
607         i+=sizeof(int);
608         pnt->m_ID = id;
609         }
610 
611       m_PointList.push_back(pnt);
612       }
613     delete [] _data;
614     }
615   else
616     {
617     for(j=0; j<(int)m_NPoints; j++)
618       {
619       if(m_Event)
620         {
621         m_Event->SetCurrentIteration(j+1);
622         }
623 
624       TubePnt* pnt = new TubePnt(m_NDims);
625 
626       for(int k=0; k<pntDim; k++)
627         {
628         *m_ReadStream >> v[k];
629         m_ReadStream->get();
630         }
631 
632       for(int d=0; d<m_NDims; d++)
633         {
634         pnt->m_X[d] = v[posDim[d]];
635         }
636 
637       pnt->m_R = v[posR];
638 
639       if(posV1x>=0 && posV1x<pntDim)
640         {
641         pnt->m_V1[0] = v[posV1x];
642         if(posV1y >= 0 && posV1y<pntDim)
643           {
644           pnt->m_V1[1] = v[posV1y];
645           }
646         if(posV1z >= 0 && m_NDims>2 && posV1z<pntDim)
647           {
648           pnt->m_V1[2] = v[posV1z];
649           }
650         }
651       if(posV2x >= 0 && posV2x<pntDim)
652         {
653         pnt->m_V2[0] = v[posV2x];
654         if(posV2y >= 0 && posV2y<pntDim)
655           {
656           pnt->m_V2[1] = v[posV2y];
657           }
658         if(posV2z >= 0 && m_NDims>2 && posV2z<pntDim)
659           {
660           pnt->m_V2[2] = v[posV2z];
661           }
662         }
663       if(posTx >= 0 && posTx<pntDim)
664         {
665         pnt->m_T[0] = v[posTx];
666         if(posTy >= 0 && posTy<pntDim)
667           {
668           pnt->m_T[1] = v[posTy];
669           }
670         if(posTz >= 0 && m_NDims>2 && posTz<pntDim)
671           {
672           pnt->m_T[2] = v[posTz];
673           }
674         }
675 
676       if(posRed >= 0 && posRed < pntDim)
677         {
678         pnt->m_Color[0] = v[posRed];
679         }
680 
681       if(posGreen >= 0 && posGreen < pntDim)
682         {
683         pnt->m_Color[1] = v[posGreen];
684         }
685 
686       if(posBlue >= 0 && posBlue < pntDim)
687         {
688         pnt->m_Color[2] = v[posBlue];
689         }
690 
691       if(posAlpha >= 0 && posAlpha < pntDim)
692         {
693         pnt->m_Color[3] = v[posAlpha];
694         }
695 
696       if(posID >= 0 && posID < pntDim)
697         {
698         pnt->m_ID = (int)v[posID];
699         }
700 
701       m_PointList.push_back(pnt);
702       }
703 
704 
705     char c = ' ';
706     while( (c!='\n') && (!m_ReadStream->eof()))
707       {
708       c = m_ReadStream->get();// to avoid unrecognize charactere
709       }
710     }
711 
712   if(m_Event)
713     {
714     m_Event->StopReading();
715     }
716 
717   delete [] posDim;
718   return true;
719 }
720 
721 MET_ValueEnumType MetaTube::
ElementType(void) const722 ElementType(void) const
723 {
724   return m_ElementType;
725 }
726 
727 void MetaTube::
ElementType(MET_ValueEnumType _elementType)728 ElementType(MET_ValueEnumType _elementType)
729 {
730   m_ElementType = _elementType;
731 }
732 
733 bool MetaTube::
M_Write(void)734 M_Write(void)
735 {
736 
737   if(!MetaObject::M_Write())
738     {
739     METAIO_STREAM::cout << "MetaTube: M_Read: Error parsing file" << METAIO_STREAM::endl;
740     return false;
741     }
742 
743   /** Then copy all tubes points */
744   if(m_BinaryData)
745     {
746     PointListType::const_iterator it = m_PointList.begin();
747     PointListType::const_iterator itEnd = m_PointList.end();
748     int elementSize;
749     MET_SizeOfType(m_ElementType, &elementSize);
750 
751     const unsigned int writeSize = m_NPoints*(m_NDims*(2+m_NDims)+10)*elementSize;
752 
753     char* data = new char[writeSize];
754 
755     memset( data, '\0', writeSize );
756 
757     int i=0;
758     int d;
759     while(it != itEnd)
760       {
761       for(d = 0; d < m_NDims; d++)
762         {
763         float pntX = (*it)->m_X[d];
764         MET_SwapByteIfSystemMSB(&pntX,MET_FLOAT);
765         MET_DoubleToValue((double)pntX,m_ElementType,data,i++);
766         }
767 
768       float r = (*it)->m_R;
769       MET_SwapByteIfSystemMSB(&r,MET_FLOAT);
770       MET_DoubleToValue((double)r,m_ElementType,data,i++);
771 
772       for(d = 0; d < m_NDims; d++)
773         {
774         float v = (*it)->m_V1[d];
775         MET_SwapByteIfSystemMSB(&v,MET_FLOAT);
776         MET_DoubleToValue((double)v,m_ElementType,data,i++);
777         }
778 
779       if(m_NDims==3)
780         {
781         for(d = 0; d < m_NDims; d++)
782           {
783           float v2 = (*it)->m_V2[d];
784           MET_SwapByteIfSystemMSB(&v2,MET_FLOAT);
785           MET_DoubleToValue((double)v2,m_ElementType,data,i++);
786           }
787         }
788 
789       for(d = 0; d < m_NDims; d++)
790         {
791         float t = (*it)->m_T[d];
792         MET_SwapByteIfSystemMSB(&t,MET_FLOAT);
793         MET_DoubleToValue((double)t,m_ElementType,data,i++);
794         }
795 
796       for(d=0; d<4; d++)
797         {
798         float c = (*it)->m_Color[d];
799         MET_SwapByteIfSystemMSB(&c,MET_FLOAT);
800         MET_DoubleToValue((double)c,m_ElementType,data,i++);
801         }
802 
803       int id = (*it)->m_ID;
804       MET_SwapByteIfSystemMSB(&id,MET_INT);
805       MET_DoubleToValue((double)id,m_ElementType,data,i++);
806       it++;
807       }
808 
809     m_WriteStream->write((char *)data,writeSize);
810     m_WriteStream->write("\n",1);
811     delete [] data;
812     }
813   else
814     {
815     PointListType::const_iterator it = m_PointList.begin();
816     PointListType::const_iterator itEnd = m_PointList.end();
817 
818     int d;
819     while(it != itEnd)
820       {
821       for(d = 0; d < m_NDims; d++)
822         {
823         *m_WriteStream << (*it)->m_X[d] << " ";
824         }
825 
826       *m_WriteStream << (*it)->m_R << " ";
827 
828       for(d = 0; d < m_NDims; d++)
829         {
830         *m_WriteStream << (*it)->m_V1[d] << " ";
831         }
832 
833       if(m_NDims>=3)
834         {
835         for(d = 0; d < m_NDims; d++)
836           {
837           *m_WriteStream << (*it)->m_V2[d] << " ";
838           }
839         }
840 
841       for(d = 0; d < m_NDims; d++)
842         {
843         *m_WriteStream << (*it)->m_T[d] << " ";
844         }
845 
846       for(d=0;d<4;d++)
847         {
848         *m_WriteStream << (*it)->m_Color[d] << " ";
849         }
850 
851       *m_WriteStream << (*it)->m_ID << " ";
852 
853       *m_WriteStream << METAIO_STREAM::endl;
854       it++;
855       }
856     }
857   return true;
858 }
859 
860 #if (METAIO_USE_NAMESPACE)
861 };
862 #endif
863 
864