vtkEnSight6BinaryReader.cxx 80 KB
Newer Older
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkEnSight6BinaryReader.cxx

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
13 14 15

=========================================================================*/
#include "vtkEnSight6BinaryReader.h"
16 17 18

#include "vtkByteSwap.h"
#include "vtkCellData.h"
19
#include "vtkCharArray.h"
20 21 22
#include "vtkFloatArray.h"
#include "vtkIdList.h"
#include "vtkIdTypeArray.h"
23
#include "vtkMultiBlockDataSet.h"
24
#include "vtkObjectFactory.h"
25 26
#include "vtkPointData.h"
#include "vtkPolyData.h"
27
#include "vtkRectilinearGrid.h"
28
#include "vtkStructuredGrid.h"
29
#include "vtkStructuredPoints.h"
30 31
#include "vtkUnstructuredGrid.h"

32
#include <sys/stat.h>
Sean McBride's avatar
Sean McBride committed
33
#include <cctype>
34
#include <string>
35

36 37 38
#if defined(_WIN32)
# define VTK_STAT_STRUCT struct _stat64
# define VTK_STAT_FUNC _stat64
39 40
#elif defined _DARWIN_FEATURE_64_BIT_INODE || defined __FreeBSD__
// FreeBSD and OSX use stat
41 42
# define VTK_STAT_STRUCT struct stat
# define VTK_STAT_FUNC stat
43 44 45 46 47 48 49
#else
// here, we're relying on _FILE_OFFSET_BITS defined in vtkWin32Header.h to help
// us on POSIX without resorting to using stat64.
# define VTK_STAT_STRUCT struct stat64
# define VTK_STAT_FUNC stat64
#endif

Brad King's avatar
Brad King committed
50
vtkStandardNewMacro(vtkEnSight6BinaryReader);
51 52 53 54 55 56

//----------------------------------------------------------------------------
vtkEnSight6BinaryReader::vtkEnSight6BinaryReader()
{
  this->NumberOfUnstructuredPoints = 0;
  this->UnstructuredPoints = vtkPoints::New();
57
  this->UnstructuredNodeIds = nullptr;
58

59
  this->BinaryIFile = nullptr;
60 61

  this->FileSize = 0;
62 63

  this->ElementIdsListed = 0;
64 65 66 67 68 69
}

//----------------------------------------------------------------------------
vtkEnSight6BinaryReader::~vtkEnSight6BinaryReader()
{
  if (this->UnstructuredNodeIds)
70
  {
71
    this->UnstructuredNodeIds->Delete();
72
    this->UnstructuredNodeIds = nullptr;
73
  }
74
  this->UnstructuredPoints->Delete();
75
  this->UnstructuredPoints = nullptr;
76

77
  if (this->BinaryIFile)
78
  {
79 80 81
    this->BinaryIFile->close();
    delete this->BinaryIFile;
    this->BinaryIFile = nullptr;
82
  }
83 84 85 86 87 88
}

//----------------------------------------------------------------------------
int vtkEnSight6BinaryReader::OpenFile(const char* filename)
{
  if (!filename)
89
  {
90 91
    vtkErrorMacro(<<"Missing filename.");
    return 0;
92
  }
93 94

  // Close file from any previous image
95
  if (this->BinaryIFile)
96
  {
97 98 99
    this->BinaryIFile->close();
    delete this->BinaryIFile;
    this->BinaryIFile = nullptr;
100
  }
101

102 103
  // Open the new file
  vtkDebugMacro(<< "Opening file " << filename);
104 105
  VTK_STAT_STRUCT fs;
  if ( !VTK_STAT_FUNC( filename, &fs) )
106
  {
107
    // Find out how big the file is.
108
    this->FileSize = static_cast<vtkTypeUInt64>(fs.st_size);
109 110

#ifdef _WIN32
111
    this->BinaryIFile = new ifstream(filename, ios::in | ios::binary);
112
#else
113
    this->BinaryIFile = new ifstream(filename, ios::in);
114
#endif
115
  }
116
  else
117
  {
118 119
    vtkErrorMacro("stat failed.");
    return 0;
120
  }
121
  if (! this->BinaryIFile || this->BinaryIFile->fail())
122
  {
123
    vtkErrorMacro(<< "Could not open file " << filename);
124
    return 0;
125
  }
126
  return 1;
127 128 129
}

//----------------------------------------------------------------------------
130 131
int vtkEnSight6BinaryReader::ReadGeometryFile(const char* fileName,
                                              int timeStep,
132
                                              vtkMultiBlockDataSet *output)
133 134
{
  char line[80], subLine[80];
135
  int partId, realId;
136 137 138 139 140
  int lineRead;
  float *coordinateArray;
  int i;
  int pointIdsListed;
  int *pointIds;
141

142 143
  // Initialize
  //
144
  if (!fileName)
145
  {
146 147
    vtkErrorMacro("A GeometryFileName must be specified in the case file.");
    return 0;
148
  }
149
  std::string sfilename;
150
  if (this->FilePath)
151
  {
152
    sfilename = this->FilePath;
153
    if (sfilename.at(sfilename.length()-1) != '/')
154
    {
155
      sfilename += "/";
156
    }
157 158
    sfilename += fileName;
    vtkDebugMacro("full path to geometry file: " << sfilename.c_str());
159
  }
160
  else
161
  {
162
    sfilename = fileName;
163
  }
164

165
  if (this->OpenFile(sfilename.c_str()) == 0)
166
  {
167
    vtkErrorMacro("Unable to open file: " << sfilename.c_str());
168
    return 0;
169
  }
170

171
  lineRead = this->ReadLine(line);
172
  sscanf(line, " %*s %s", subLine);
173 174
  if (strcmp(subLine, "Binary") != 0 &&
      strcmp(subLine, "binary") != 0)
175
  {
176 177
    vtkErrorMacro("This is not an EnSight6 binary file. Try "
                  << "vtkEnSight6Reader.");
178
    return 0;
179
  }
180

181
  if (this->UseFileSets)
182
  {
183
    for (i = 0; i < timeStep - 1; i++)
184
    {
Amy Squillacote's avatar
Amy Squillacote committed
185
      if (!this->SkipTimeStep())
186
      {
Amy Squillacote's avatar
Amy Squillacote committed
187
        return 0;
188
      }
189
    }
190
    while (strncmp(line, "BEGIN TIME STEP", 15) != 0 && lineRead)
191
    {
192
      lineRead = this->ReadLine(line);
193
    }
194
  }
195

196 197 198 199
  // Skip the 2 description lines.  Using ReadLine instead of ReadLine
  // because the description line could be blank.
  this->ReadLine(line);
  this->ReadLine(line);
200

201 202 203 204
  // Read the node id and element id lines.
  this->ReadLine(line); // node id *
  sscanf(line, " %*s %*s %s", subLine);
  if (strcmp(subLine, "given") == 0)
205
  {
206
    this->UnstructuredNodeIds = vtkIdTypeArray::New();
207
    pointIdsListed = 1;
208
  }
209
  else if (strcmp(subLine, "ignore") == 0)
210
  {
211
    pointIdsListed = 1;
212
  }
213
  else
214
  {
215
    pointIdsListed = 0;
216
  }
217

218 219 220
  this->ReadLine(line); // element id *
  sscanf(line, " %*s %*s %s", subLine);
  if (strcmp(subLine, "given") == 0 || strcmp(subLine, "ignore") == 0)
221
  {
222
    this->ElementIdsListed = 1;
223
  }
224
  else
225
  {
226
    this->ElementIdsListed = 0;
227
  }
228

229
  this->ReadLine(line); // "coordinates"
Amy Squillacote's avatar
Amy Squillacote committed
230 231
  this->ReadIntNumber(&this->NumberOfUnstructuredPoints); // number of points
  if (this->NumberOfUnstructuredPoints < 0 ||
Mathieu Westphal's avatar
Mathieu Westphal committed
232
    static_cast<unsigned int>(this->NumberOfUnstructuredPoints) * sizeof(int) > this->FileSize)
233
  {
Amy Squillacote's avatar
Amy Squillacote committed
234 235
    vtkErrorMacro("Invalid number of unstructured points; check that ByteOrder is set correctly.");
    return 0;
236
  }
237

238 239
  this->UnstructuredPoints->SetNumberOfPoints(
                               this->NumberOfUnstructuredPoints);
240

241
  if (pointIdsListed)
242
  {
243 244
    pointIds = new int[this->NumberOfUnstructuredPoints];
    this->ReadIntArray(pointIds, this->NumberOfUnstructuredPoints);
245

246
    if (this->UnstructuredNodeIds)
247
    {
248 249
      int maxId = 0;
      for (i = 0; i < this->NumberOfUnstructuredPoints; i++)
250
      {
251
        if (pointIds[i] > maxId)
252
        {
253 254
          maxId = pointIds[i];
        }
255
      }
256

257 258 259
      this->UnstructuredNodeIds->Allocate(maxId);
      this->UnstructuredNodeIds->FillComponent(0, -1);

260
      for (i = 0; i < this->NumberOfUnstructuredPoints; i++)
261
      {
262
        this->UnstructuredNodeIds->InsertValue(pointIds[i]-1, i);
263 264
      }
    }
265 266
    delete [] pointIds;
  }
267

268
  coordinateArray = (float*)(this->UnstructuredPoints->GetVoidPointer(0));
269
  this->ReadFloatArray(coordinateArray, this->NumberOfUnstructuredPoints * 3);
270

271
  lineRead = this->ReadLine(line); // "part"
272

273
  while (lineRead && strncmp(line, "part", 4) == 0)
274
  {
275
    this->NumberOfGeometryParts++;
276 277
    sscanf(line, " part %d", &partId);
    partId--; // EnSight starts #ing at 1.
278 279
    realId = this->InsertNewPartId(partId);

280
    this->ReadLine(line); // part description line
281
    char *name = strdup(line);
282
    this->ReadLine(line);
283

284
    if (strncmp(line, "block", 5) == 0)
285
    {
286
      lineRead = this->CreateStructuredGridOutput(realId, line, name, output);
287
    }
288
    else
289
    {
290
      lineRead = this->CreateUnstructuredGridOutput(realId, line, name, output);
291
    }
292 293
    free(name);
  }
294

295
  if (this->UnstructuredNodeIds)
296
  {
297
      this->UnstructuredNodeIds->Delete();
298
      this->UnstructuredNodeIds = nullptr;
299
  }
300
  // Close file from any previous image
301
  if (this->BinaryIFile)
302
  {
303 304 305
    this->BinaryIFile->close();
    delete this->BinaryIFile;
    this->BinaryIFile = nullptr;
306
  }
Amy Squillacote's avatar
Amy Squillacote committed
307
  if (lineRead < 0)
308
  {
Amy Squillacote's avatar
Amy Squillacote committed
309
    return 0;
310
  }
311 312 313
  return 1;
}

314
//----------------------------------------------------------------------------
Amy Squillacote's avatar
Amy Squillacote committed
315
int vtkEnSight6BinaryReader::SkipTimeStep()
316 317 318 319 320 321 322
{
  char line[80], subLine[80];
  int lineRead;
  int pointIdsListed;

  this->ReadLine(line);
  while (strncmp(line, "BEGIN TIME STEP", 15) != 0)
323
  {
324
    this->ReadLine(line);
325
  }
326

327 328 329
  // Skip the 2 description lines.
  this->ReadLine(line);
  this->ReadLine(line);
330

331 332 333 334 335
  // Read the node id and element id lines.
  this->ReadLine(line); // node id *
  sscanf(line, " %*s %*s %s", subLine);
  if (strcmp(subLine, "given") == 0 ||
      strcmp(subLine, "ignore") == 0)
336
  {
337
    pointIdsListed = 1;
338
  }
339
  else
340
  {
341
    pointIdsListed = 0;
342
  }
343

344 345 346
  this->ReadLine(line); // element id *
  sscanf(line, " %*s %*s %s", subLine);
  if (strcmp(subLine, "given") == 0 || strcmp(subLine, "ignore") == 0)
347
  {
348
    this->ElementIdsListed = 1;
349
  }
350
  else
351
  {
352
    this->ElementIdsListed = 0;
353
  }
354

355
  this->ReadLine(line); // "coordinates"
Amy Squillacote's avatar
Amy Squillacote committed
356 357
  this->ReadIntNumber(&this->NumberOfUnstructuredPoints); // number of points
  if (this->NumberOfUnstructuredPoints < 0 ||
Mathieu Westphal's avatar
Mathieu Westphal committed
358
    static_cast<unsigned int>(this->NumberOfUnstructuredPoints * sizeof(int)) > this->FileSize)
359
  {
Amy Squillacote's avatar
Amy Squillacote committed
360 361
    vtkErrorMacro("Invalid number of unstructured points; check that ByteOrder is set correctly.");
    return 0;
362
  }
363

364
  if (pointIdsListed)
365
  { // skip point ids.
366
    this->BinaryIFile->seekg((sizeof(int)*this->NumberOfUnstructuredPoints), ios::cur);
367
  }
368

369
  this->BinaryIFile->seekg((sizeof(float)*3*this->NumberOfUnstructuredPoints), ios::cur);
370

371
  lineRead = this->ReadLine(line); // "part"
372

373
  while (lineRead && strncmp(line, "part", 4) == 0)
374
  {
375
    this->ReadLine(line); // part description line
376
    this->ReadLine(line);
377

378
    if (strncmp(line, "block", 5) == 0)
379
    {
Amy Squillacote's avatar
Amy Squillacote committed
380
      lineRead = this->SkipStructuredGrid(line);
381
    }
382
    else
383
    {
Amy Squillacote's avatar
Amy Squillacote committed
384
      lineRead = this->SkipUnstructuredGrid(line);
385
    }
386
  }
Amy Squillacote's avatar
Amy Squillacote committed
387
  if (lineRead < 0)
388
  {
Amy Squillacote's avatar
Amy Squillacote committed
389
    return 0;
390
  }
391

Amy Squillacote's avatar
Amy Squillacote committed
392
  return 1;
393 394 395
}

//----------------------------------------------------------------------------
Amy Squillacote's avatar
Amy Squillacote committed
396
int vtkEnSight6BinaryReader::SkipStructuredGrid(char line[256])
397 398
{
  char subLine[80];
399
  int lineRead;
400 401 402
  int iblanked = 0;
  int dimensions[3];
  int numPts;
403

404
  if (sscanf(line, " %*s %s", subLine) == 1)
405
  {
406
    if (strcmp(subLine, "iblanked") == 0)
407
    {
408 409
      iblanked = 1;
    }
410
  }
411

412 413 414 415
  // Read these separately to get byte order set.
  this->ReadIntNumber(dimensions);
  this->ReadIntNumber(dimensions+1);
  this->ReadIntNumber(dimensions+2);
416
  numPts = dimensions[0] * dimensions[1] * dimensions[2];
Mathieu Westphal's avatar
Mathieu Westphal committed
417 418 419 420 421 422 423 424
  if (dimensions[0] < 0 ||
    static_cast<unsigned int>(dimensions[0] * sizeof(int)) > this->FileSize ||
    dimensions[1] < 0 ||
    static_cast<unsigned int>(dimensions[1] * sizeof(int)) > this->FileSize ||
    dimensions[2] < 0 ||
    static_cast<unsigned int>(dimensions[2] * sizeof(int)) > this->FileSize ||
    numPts < 0 ||
    static_cast<unsigned int>(numPts * sizeof(int)) > this->FileSize)
425
  {
Amy Squillacote's avatar
Amy Squillacote committed
426 427
    vtkErrorMacro("Invalid dimensions read; check that ByteOrder is set correctly.");
    return -1;
428
  }
429

430
  // Skip coordinates.
431
  this->BinaryIFile->seekg((sizeof(float)*3*numPts), ios::cur);
432

433
  if (iblanked)
434
  { // skip blanking array.
435
    this->BinaryIFile->seekg((sizeof(int)*numPts), ios::cur);
436
  }
437

438
  // reading next line to check for EOF
Amy Squillacote's avatar
Amy Squillacote committed
439 440
  lineRead = this->ReadLine(line);
  return lineRead;
441 442 443
}

//----------------------------------------------------------------------------
Amy Squillacote's avatar
Amy Squillacote committed
444
int vtkEnSight6BinaryReader::SkipUnstructuredGrid(char line[256])
445 446 447
{
  int lineRead = 1;
  int numElements;
448
  int cellType;
449

450
  while(lineRead && strncmp(line, "part", 4) != 0)
451
  {
452
    if (strncmp(line, "point", 5) == 0)
453
    {
454
      vtkDebugMacro("point");
455

456
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
457 458
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
459
      {
Amy Squillacote's avatar
Amy Squillacote committed
460 461
        vtkErrorMacro("Invalid number of point cells; check that ByteOrder is set correctly.");
        return -1;
462
      }
463
      if (this->ElementIdsListed)
464
      { // skip element ids.
465
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
466
      }
467

468
      // nodeIdList
469
      this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
470
    }
471
    else if (strncmp(line, "bar2", 4) == 0)
472
    {
473
      vtkDebugMacro("bar2");
474

475
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
476 477
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
478
      {
Amy Squillacote's avatar
Amy Squillacote committed
479 480
        vtkErrorMacro("Invalid number of bar2 cells; check that ByteOrder is set correctly.");
        return -1;
481
      }
482
      if (this->ElementIdsListed)
483
      { // skip element ids.
484
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
485
      }
486

487
      // Skip node ids.
488
      this->BinaryIFile->seekg((sizeof(int)*2*numElements), ios::cur);
489
    }
490
    else if (strncmp(line, "bar3", 4) == 0)
491
    {
492 493
      vtkDebugMacro("bar3");
      vtkWarningMacro("Only vertex nodes of this element will be read.");
494

495
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
496 497
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
498
      {
Amy Squillacote's avatar
Amy Squillacote committed
499 500
        vtkErrorMacro("Invalid number of bar3 cells; check that ByteOrder is set correctly.");
        return -1;
501
      }
502
      if (this->ElementIdsListed)
503
      {
504
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
505
      }
506 507

      // Skip node ids.
508
      this->BinaryIFile->seekg((sizeof(int)*3*numElements), ios::cur);
509
    }
510 511
    else if (strncmp(line, "tria3", 5) == 0 ||
             strncmp(line, "tria6", 5) == 0)
512
    {
513
      if (strncmp(line, "tria3", 5) == 0)
514
      {
515
        vtkDebugMacro("tria3");
516
        cellType = vtkEnSightReader::TRIA3;
517
      }
518
      else
519
      {
520
        vtkDebugMacro("tria6");
521
        vtkWarningMacro("Only vertex nodes of this element will be read.");
522
        cellType = vtkEnSightReader::TRIA6;
523
      }
524

525
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
526 527
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
528
      {
Amy Squillacote's avatar
Amy Squillacote committed
529 530
        vtkErrorMacro("Invalid number of triangle cells; check that ByteOrder is set correctly.");
        return -1;
531
      }
532
      if (this->ElementIdsListed)
533
      {
534
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
535
      }
536

537
      if (cellType == vtkEnSightReader::TRIA3)
538
      {
539
        this->BinaryIFile->seekg((sizeof(int)*3*numElements), ios::cur);
540
      }
541
      else
542
      {
543
        this->BinaryIFile->seekg((sizeof(int)*6*numElements), ios::cur);
544
      }
545
    }
546 547
    else if (strncmp(line, "quad4", 5) == 0 ||
             strncmp(line, "quad8", 5) == 0)
548
    {
549
      if (strncmp(line, "quad8", 5) == 0)
550
      {
551 552
        vtkDebugMacro("quad8");
        vtkWarningMacro("Only vertex nodes of this element will be read.");
553
        cellType = vtkEnSightReader::QUAD8;
554
      }
555
      else
556
      {
557
        vtkDebugMacro("quad4");
558
        cellType = vtkEnSightReader::QUAD4;
559
      }
560

561
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
562 563
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
564
      {
Amy Squillacote's avatar
Amy Squillacote committed
565 566
        vtkErrorMacro("Invalid number of quad cells; check that ByteOrder is set correctly.");
        return -1;
567
      }
568
      if (this->ElementIdsListed)
569
      {
570
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
571
      }
572

573
      if (cellType == vtkEnSightReader::QUAD4)
574
      {
575
        this->BinaryIFile->seekg((sizeof(int)*4*numElements), ios::cur);
576
      }
577
      else
578
      {
579
        this->BinaryIFile->seekg((sizeof(int)*8*numElements), ios::cur);
580
      }
581
    }
582 583
    else if (strncmp(line, "tetra4", 6) == 0 ||
             strncmp(line, "tetra10", 7) == 0)
584
    {
585
      if (strncmp(line, "tetra10", 7) == 0)
586
      {
587 588
        vtkDebugMacro("tetra10");
        vtkWarningMacro("Only vertex nodes of this element will be read.");
589
        cellType = vtkEnSightReader::TETRA10;
590
      }
591
      else
592
      {
593
        vtkDebugMacro("tetra4");
594
        cellType = vtkEnSightReader::TETRA4;
595
      }
596

597
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
598 599
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
600
      {
Amy Squillacote's avatar
Amy Squillacote committed
601 602
        vtkErrorMacro("Invalid number of tetrahedral cells; check that ByteOrder is set correctly.");
        return -1;
603
      }
604
      if (this->ElementIdsListed)
605
      {
606
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
607
      }
608

609
      if (cellType == vtkEnSightReader::TETRA4)
610
      {
611
        this->BinaryIFile->seekg((sizeof(int)*4*numElements), ios::cur);
612
      }
613
      else
614
      {
615
        this->BinaryIFile->seekg((sizeof(int)*10*numElements), ios::cur);
616
      }
617
    }
618 619
    else if (strncmp(line, "pyramid5", 8) == 0 ||
             strncmp(line, "pyramid13", 9) == 0)
620
    {
621
      if (strncmp(line, "pyramid13", 9) == 0)
622
      {
623 624
        vtkDebugMacro("pyramid13");
        vtkWarningMacro("Only vertex nodes of this element will be read.");
625
        cellType = vtkEnSightReader::PYRAMID13;
626
      }
627
      else
628
      {
629
        vtkDebugMacro("pyramid5");
630
        cellType = vtkEnSightReader::PYRAMID5;
631
      }
632

633
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
634 635
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
636
      {
Amy Squillacote's avatar
Amy Squillacote committed
637 638
        vtkErrorMacro("Invalid number of pyramid cells; check that ByteOrder is set correctly.");
        return -1;
639
      }
640
      if (this->ElementIdsListed)
641
      {
642
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
643
      }
644

645
      if (cellType == vtkEnSightReader::PYRAMID5)
646
      {
647
        this->BinaryIFile->seekg((sizeof(int)*5*numElements), ios::cur);
648
      }
649
      else
650
      {
651
        this->BinaryIFile->seekg((sizeof(int)*13*numElements), ios::cur);
652
      }
653
    }
654 655
    else if (strncmp(line, "hexa8", 5) == 0 ||
             strncmp(line, "hexa20", 6) == 0)
656
    {
657
      if (strncmp(line, "hexa20", 6) == 0)
658
      {
659 660
        vtkDebugMacro("hexa20");
        vtkWarningMacro("Only vertex nodes of this element will be read.");
661
        cellType = vtkEnSightReader::HEXA20;
662
      }
663
      else
664
      {
665
        vtkDebugMacro("hexa8");
666
        cellType = vtkEnSightReader::HEXA8;
667
      }
668

669
      this->ReadIntNumber(&numElements);
Mathieu Westphal's avatar
Mathieu Westphal committed
670 671
      if (numElements < 0 ||
        static_cast<unsigned int>(numElements * sizeof(int)) > this->FileSize)
672
      {
Amy Squillacote's avatar
Amy Squillacote committed
673 674
        vtkErrorMacro("Invalid number of hexahedral cells; check that ByteOrder is set correctly.");
        return -1;
675
      }
676
      if (this->ElementIdsListed)
677
      {
678
        this->BinaryIFile->seekg((sizeof(int)*numElements), ios::cur);
679
      }
680

681
      if (cellType == vtkEnSightReader::HEXA8)
682
      {
683
        this->BinaryIFile->seekg((sizeof(int)*8*numElements), ios::cur);
684
      }
685
      else
686
      {
687
        this->BinaryIFile->seekg((sizeof(int)*20*