vtkXdmfReader.cxx 82.9 KB
Newer Older
1
/*=========================================================================
Jerry Clarke's avatar
Jerry Clarke committed
2

3
4
5
6
7
  Program:   Visualization Toolkit
  Module:    vtkXdmfReader.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$
Jerry Clarke's avatar
Jerry Clarke committed
8
9


Berk Geveci's avatar
Berk Geveci committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen  
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
  of any contributors may be used to endorse or promote products derived
  from this software without specific prior written permission.

  * Modified source versions must be plainly marked as such, and must not be
  misrepresented as being the original software.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

  =========================================================================*/
Andy Cedilnik's avatar
Andy Cedilnik committed
42
#include "vtkXdmfReader.h"
43
44
45
46
47

#include "vtkCallbackCommand.h"
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkDoubleArray.h"
48
49
#include "vtkInformation.h"
#include "vtkInformationVector.h"
50
51
#include "vtkObjectFactory.h"
#include "vtkRectilinearGrid.h"
52
#include "vtkStreamingDemandDrivenPipeline.h"
53
54
55
#include "vtkStructuredGrid.h"
#include "vtkUnstructuredGrid.h"
#include "vtkXdmfDataArray.h"
56
57
58
#include "vtkPointData.h"
#include "vtkCellData.h"
#include "vtkCellArray.h"
59
#include "vtkCharArray.h"
60
#include "vtkXMLParser.h"
61
#include "vtkImageData.h"
62
#include "vtkUniformGrid.h"
63
#include "vtkMultiGroupDataInformation.h"
64
#include "vtkMultiGroupDataSet.h"
65
#include "vtkMultiBlockDataSet.h"
66
67
#include "vtkCompositeDataPipeline.h"
#include "vtkMultiProcessController.h"
68
#include "vtkDataObjectTypes.h"
69

70
#include "XdmfArray.h"
Jerry Clarke's avatar
Jerry Clarke committed
71
#include "XdmfAttribute.h"
72
73
#include "XdmfDOM.h"
#include "XdmfDataDesc.h"
Jerry Clarke's avatar
Jerry Clarke committed
74
#include "XdmfDataItem.h"
75
#include "XdmfGrid.h"
Jerry Clarke's avatar
Jerry Clarke committed
76
#include "XdmfTopology.h"
Andy Cedilnik's avatar
Andy Cedilnik committed
77
#include "XdmfGeometry.h"
Jerry Clarke's avatar
Jerry Clarke committed
78

79
#include <sys/stat.h>
80
81
#include <vtkstd/set>
#include <vtkstd/map>
82
83
#include <vtkstd/string>
#include <vtkstd/vector>
84
85
86
#include <assert.h>

#define USE_IMAGE_DATA // otherwise uniformgrid
Jerry Clarke's avatar
Jerry Clarke committed
87

Andy Cedilnik's avatar
Andy Cedilnik committed
88
vtkStandardNewMacro(vtkXdmfReader);
89
vtkCxxRevisionMacro(vtkXdmfReader, "1.29");
90
91

vtkCxxSetObjectMacro(vtkXdmfReader,Controller,vtkMultiProcessController);
92
93
94
95
96
97
98
99

#if defined(_WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__))
#  include <direct.h>
#  define GETCWD _getcwd
#else
#include <unistd.h>
#  define GETCWD getcwd
#endif
Jerry Clarke's avatar
Jerry Clarke committed
100

101
102
103
#define vtkMAX(x, y) (((x)>(y))?(x):(y))
#define vtkMIN(x, y) (((x)<(y))?(x):(y))

104
105
#define PRINT_EXTENT(x) "[" << (x)[0] << " " << (x)[1] << " " << (x)[2] << " " << (x)[3] << " " << (x)[4] << " " << (x)[5] << "]" 

106
//============================================================================
107
108
109
class vtkXdmfReaderGrid
{
public:
110
111
112
113
114
  vtkXdmfReaderGrid() 
    : XMGrid(0), DataDescription(0), Enabled(0), vtkType(-1)
  {
  }

115
  ~vtkXdmfReaderGrid()
116
117
118
119
120
121
122
123
124
125
126
  {
    delete this->XMGrid;
    vtkstd::map<vtkstd::string, vtkXdmfReaderGrid*>::iterator it;
    for (it = Children.begin(); it != Children.end(); it++)
      {
      delete it->second;
      }
  }

  vtkXdmfReaderGrid* GetChild(const char *childName);
  vtkXdmfReaderGrid* GetChild(int idx);
127
128
129
130

  XdmfGrid       *XMGrid;
  XdmfDataDesc   *DataDescription;
  vtkstd::string Name;
131
132
  int Enabled;
  int vtkType;
133

134
  vtkstd::map<vtkstd::string, vtkXdmfReaderGrid*> Children;
135
136
137
};

//----------------------------------------------------------------------------
138
vtkXdmfReaderGrid* vtkXdmfReaderGrid::GetChild(const char *gridName)
139
{
140
  //find the grid with that name or make one up
141
142
143
  vtkstd::map<vtkstd::string, vtkXdmfReaderGrid*>::iterator it = 
    this->Children.find(gridName);
  if ( it == this->Children.end() || it->second == 0 )
144
    {
145
146
    return NULL;
    //this->Children[gridName] = new vtkXdmfReaderGrid;
147
    }
148
  return this->Children[gridName];
149
150
}

151
//----------------------------------------------------------------------------
152
vtkXdmfReaderGrid* vtkXdmfReaderGrid::GetChild(int idx)
153
{
154
  if ( idx < 0 )
155
    {
156
    return NULL;
157
    }
158
159
160
161
162
  vtkstd::map<vtkstd::string,vtkXdmfReaderGrid*>::iterator it;
  int cnt = 0;
  for ( it = this->Children.begin();
        it != this->Children.end();
        ++ it )
163
    {
164
165
166
167
168
    if ( cnt == idx )
      {
      return it->second;
      }
    cnt ++;
169
    }
170
  return NULL;
171
172
}

173
//============================================================================
174
class vtkXdmfReaderInternal
175
176
{
public:
177
  vtkXdmfReaderInternal()
Dave Demarle's avatar
Dave Demarle committed
178
  {
179
180
181
182
183
184
185
186
187
    this->DataItem = NULL;
    this->ArrayConverter = vtkXdmfDataArray::New();
    this->DomainPtr = NULL;  
    this->Data = NULL;
  }

  ~vtkXdmfReaderInternal()
  {
    if ( this->Data )
Dave Demarle's avatar
Dave Demarle committed
188
      {
189
190
191
192
193
194
195
      delete this->Data;
      this->Data = NULL;
      }    
    if ( this->DataItem )
      {
      delete this->DataItem;
      this->DataItem = 0;
Dave Demarle's avatar
Dave Demarle committed
196
      }
197
198
    this->ArrayConverter->Delete();
    this->ArrayConverter = NULL;
Dave Demarle's avatar
Dave Demarle committed
199
  }
200

201
202
203
204
205
  vtkXdmfReaderGrid* GetGrid(const char* gridName);
  vtkXdmfReaderGrid* GetGrid(int idx);
  vtkXdmfReaderGrid *MakeGrid(
    vtkXdmfReaderGrid *parent,
    const char *gridName);
206

207
208
  int RequestGridInformation(vtkXdmfReaderGrid *grid,
                             vtkInformation *outInfo);
209

210
211
212
213
214
215
  int RequestGridData(/*const char* currentGridName,*/
    vtkXdmfReaderGrid *grid,
    vtkInformation *outInfo,
    vtkDataObject *output,
    int isSubBlock,
    double progressS, double progressE);
216
  
217
218
219
220
221
 
  vtkstd::vector<vtkstd::string> DomainList;
  XdmfXmlNode DomainPtr;
  vtkXdmfReaderGrid *Data;
 
222
  vtkXdmfReader* Reader;
Jerry Clarke's avatar
Jerry Clarke committed
223
  XdmfDataItem *DataItem;
224
225
226

  // For converting arrays from XDMF to VTK format
  vtkXdmfDataArray *ArrayConverter;
227
228
};

229
//----------------------------------------------------------------------------
230
vtkXdmfReaderGrid* vtkXdmfReaderInternal::GetGrid(const char* gridName)
231
{
232
  if (!this->Data)
233
    {
234
    return NULL;
235
    }
236
237
  return this->Data->GetChild(gridName);
}
238

239
240
241
242
//----------------------------------------------------------------------------
vtkXdmfReaderGrid* vtkXdmfReaderInternal::GetGrid(int idx)
{
  if (!this->Data)
243
    {
244
    return NULL;
245
    }
246
  return this->Data->GetChild(idx);
247
248
249
}

//----------------------------------------------------------------------------
250
251
252
253
vtkXdmfReaderGrid* 
  vtkXdmfReaderInternal::MakeGrid(
    vtkXdmfReaderGrid* parent,    
    const char *gridName)
254
{
255
  if ( !parent || !gridName )
256
257
258
259
    {
    return 0;
    }

260
261
262
  //finds or makes up an ActualGrid in the global list
  vtkXdmfReaderGrid* grid = parent->GetChild(gridName);
  if ( !grid )
263
    {
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
    grid = new vtkXdmfReaderGrid; 
    parent->Children[gridName] = grid;
    }
  return grid;
}

//============================================================================
class vtkXdmfReaderTester : public vtkXMLParser
{
public:
  vtkTypeMacro(vtkXdmfReaderTester, vtkXMLParser);
  static vtkXdmfReaderTester* New();
  int TestReadFile()
    {
      this->Valid = 0;
      if(!this->FileName)
280
281
282
        {
        return 0;
        }
283
284
285

      ifstream inFile(this->FileName);
      if(!inFile)
286
        {
287
        return 0;
288
        }
289

290
291
292
293
294
295
296
297
298
299
300
301
      this->SetStream(&inFile);
      this->Done = 0;

      this->Parse();

      if(this->Done && this->Valid )
        {
        return 1;
        }
      return 0;
    }
  void StartElement(const char* name, const char**)
302
    {
303
304
305
306
307
      this->Done = 1;
      if(strcmp(name, "Xdmf") == 0)
        {
        this->Valid = 1;
        }
308
309
    }

310
311
protected:
  vtkXdmfReaderTester()
312
    {
313
314
      this->Valid = 0;
      this->Done = 0;
315
    }
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346

private:
  void ReportStrayAttribute(const char*, const char*, const char*) {}
  void ReportMissingAttribute(const char*, const char*) {}
  void ReportBadAttribute(const char*, const char*, const char*) {}
  void ReportUnknownElement(const char*) {}
  void ReportXmlParseError() {}

  int ParsingComplete() { return this->Done; }
  int Valid;
  int Done;
  vtkXdmfReaderTester(const vtkXdmfReaderTester&); // Not implemented
  void operator=(const vtkXdmfReaderTester&); // Not implemented
};

vtkStandardNewMacro(vtkXdmfReaderTester);

//============================================================================
vtkXdmfReader::vtkXdmfReader()
{  
  this->Internals = new vtkXdmfReaderInternal;
  this->Internals->Reader = this;

  this->DOM = 0;

  this->DomainName = 0;
  this->GridName = 0;
  this->GridsModified = 0;
  this->NumberOfEnabledActualGrids=0;
  
  for (int i = 0; i < 3; i ++ )
347
    {
348
    this->Stride[i] = 1;
349
    }
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367

  this->Controller = 0;
  this->SetController(vtkMultiProcessController::GetGlobalController());

  // Setup the selection callback to modify this object when an array
  // selection is changed.
  this->PointDataArraySelection = vtkDataArraySelection::New();
  this->CellDataArraySelection = vtkDataArraySelection::New();
  this->SelectionObserver = vtkCallbackCommand::New();
  this->SelectionObserver->SetCallback(
    &vtkXdmfReader::SelectionModifiedCallback);
  this->SelectionObserver->SetClientData(this);
  this->PointDataArraySelection->AddObserver(vtkCommand::ModifiedEvent,
                                             this->SelectionObserver);
  this->CellDataArraySelection->AddObserver(vtkCommand::ModifiedEvent,
                                            this->SelectionObserver);

  this->OutputVTKType = -1;
368
369
}

370
//----------------------------------------------------------------------------
371
vtkXdmfReader::~vtkXdmfReader()
372
{
373
374
375
376
377
378
379
  this->CellDataArraySelection->RemoveObserver(this->SelectionObserver);
  this->PointDataArraySelection->RemoveObserver(this->SelectionObserver);
  this->SelectionObserver->Delete();
  this->CellDataArraySelection->Delete();
  this->PointDataArraySelection->Delete();

  this->SetDomainName(0);
380
  
381
  delete this->Internals;
382

383
  if ( this->DOM )
384
    {
385
    delete this->DOM;
Jerry Clarke's avatar
Jerry Clarke committed
386
    }
387

388
389
  H5garbage_collect();  
  this->SetController(0);
Jerry Clarke's avatar
Jerry Clarke committed
390
391
}

392
//----------------------------------------------------------------------------
393
394
void vtkXdmfReader::SelectionModifiedCallback(vtkObject*, unsigned long,
                                              void* clientdata, void*)
395
{
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
  static_cast<vtkXdmfReader*>(clientdata)->Modified();
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetNumberOfPointArrays()
{
  return this->PointDataArraySelection->GetNumberOfArrays();
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetNumberOfCellArrays()
{
  return this->CellDataArraySelection->GetNumberOfArrays();
}

//----------------------------------------------------------------------------
const char* vtkXdmfReader::GetPointArrayName(int index)
{
  return this->PointDataArraySelection->GetArrayName(index);
}

//----------------------------------------------------------------------------
const char* vtkXdmfReader::GetCellArrayName(int index)
{
  return this->CellDataArraySelection->GetArrayName(index);
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetPointArrayStatus(const char* name)
{
  return this->PointDataArraySelection->ArrayIsEnabled(name);
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetCellArrayStatus(const char* name)
{
  return this->CellDataArraySelection->ArrayIsEnabled(name);
}

//----------------------------------------------------------------------------
void vtkXdmfReader::SetPointArrayStatus(const char* name, int status)
{
  vtkDebugMacro("Set point array \"" << name << "\" status to: " << status);
  if(status)
440
    {
441
    this->PointDataArraySelection->EnableArray(name);
442
    }
443
  else
444
    {
445
    this->PointDataArraySelection->DisableArray(name);
446
    }
447
448
449
450
451
452
453
}

//----------------------------------------------------------------------------
void vtkXdmfReader::SetCellArrayStatus(const char* name, int status)
{
  vtkDebugMacro("Set cell array \"" << name << "\" status to: " << status);
  if(status)
454
    {
455
    this->CellDataArraySelection->EnableArray(name);
456
    }
457
458
459
460
461
  else
    {
    this->CellDataArraySelection->DisableArray(name);
    }
}
462

463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
//----------------------------------------------------------------------------
void vtkXdmfReader::EnableAllArrays()
{
  vtkDebugMacro("Enable all point and cell arrays");
  this->PointDataArraySelection->EnableAllArrays();
  this->CellDataArraySelection->EnableAllArrays();
}

//----------------------------------------------------------------------------
void vtkXdmfReader::DisableAllArrays()
{
  vtkDebugMacro("Disable all point and cell arrays");
  this->PointDataArraySelection->DisableAllArrays();
  this->CellDataArraySelection->DisableAllArrays();
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetNumberOfParameters()
{
  if(!this->DOM) 
483
    {
484
    return(-1);
485
    }
486
487
488
489
490
491
492
493
494
495
  // return(this->DOM->FindNumberOfParameters());
  return(0);
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterType(const char *vtkNotUsed(parameterName))
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
496
    {
497
498
499
500
501
502
503
    return(0);
    }
    Param = this->DOM->FindParameter(parameterName);
    if(Param) 
    {
    return(Param->GetParameterType());
    } 
504
    else 
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
    {
    return(0);
    }
  */
  return(0);
}
//----------------------------------------------------------------------------
const char *vtkXdmfReader::GetParameterTypeAsString(const char *vtkNotUsed(parameterName))
{
  /*
    if (this->GetParameterType(parameterName) == XDMF_PARAMETER_RANGE_TYPE) 
    {
    return("RANGE");
    } 
  */
  return("LIST");
}
//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterType(int vtkNotUsed(index))
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
    {
    return(0);
    }
    Param = this->DOM->GetParameter(index);
    if(Param) 
    {
    return(Param->GetParameterType());
    } 
    else 
    {
    return(0);
    }
  */
  return(0);
}
543

544
545
546
547
548
//----------------------------------------------------------------------------
const char *vtkXdmfReader::GetParameterTypeAsString(int vtkNotUsed(index))
{
  /*
    if (this->GetParameterType(index) == XDMF_PARAMETER_RANGE_TYPE) 
549
    {
550
    return("RANGE");
551
    } 
552
553
554
555
556
557
558
559
560
561
562
  */
  return("LIST");
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterRange(int vtkNotUsed(index), int vtkNotUsed(Shape)[3])
{
  /*
    XdmfParameter *Param;
    XdmfArray  *Parray;
    if(!this->DOM) 
563
    {
564
    return(0);
565
    }
566
567
    Param = this->DOM->GetParameter(index);
    if(Param) 
568
    {
569
570
571
572
573
574
575
576
577
578
    if( Param->GetParameterType() == XDMF_PARAMETER_RANGE_TYPE )
    {
    Parray = Param->GetArray();
    Shape[0] = Parray->GetValueAsInt64(0);
    Shape[1] = Parray->GetValueAsInt64(1);
    Shape[2] = Parray->GetValueAsInt64(2);
    } else {
    Shape[0] = 0;
    Shape[1] = 1;
    Shape[2] = Param->GetNumberOfElements();
579
    }
580
581
582
583
584
585
586
587
588
589
590
591
592
    return(Shape[2]);
    }
  */
  return(0);
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterRange(const char *vtkNotUsed(parameterName), int vtkNotUsed(Shape)[3])
{
  /*
    XdmfParameter *Param;
    XdmfArray  *Parray;
    if(!this->DOM) 
593
    {
594
    return(0);
595
    }
596
597
    Param = this->DOM->FindParameter(parameterName);
    if(Param) 
598
    {
599
    if( Param->GetParameterType() == XDMF_PARAMETER_RANGE_TYPE )
600
    {
601
602
603
604
605
606
607
608
609
610
    Parray = Param->GetArray();
    Shape[0] = Parray->GetValueAsInt64(0);
    Shape[1] = Parray->GetValueAsInt64(1);
    Shape[2] = Parray->GetValueAsInt64(2);
    } 
    else 
    {
    Shape[0] = 0;
    Shape[1] = 1;
    Shape[2] = Param->GetNumberOfElements();
611
    }
612
613
614
615
616
617
618
619
620
621
622
623
624
    return(Shape[2]);
    }
  */
  return(0);
}

//----------------------------------------------------------------------------
const char *vtkXdmfReader::GetParameterRangeAsString(int vtkNotUsed(index))
{
  /*
    int Range[3];
    ostrstream StringOutput;
    if(this->GetParameterRange(index, Range) <= 0)
625
    {
626
    return(NULL);
627
    }
628
629
630
631
632
633
    StringOutput << ICE_64BIT_CAST Range[0] << " ";
    StringOutput << ICE_64BIT_CAST Range[1] << " ";
    StringOutput << ICE_64BIT_CAST Range[2] << ends;
    return(StringOutput.str());
  */
  return(0);
634
}
635

636
637
//----------------------------------------------------------------------------
const char *vtkXdmfReader::GetParameterRangeAsString(const char *vtkNotUsed(parameterName))
638
{
639
640
641
642
643
644
645
646
647
648
649
650
651
652
  /*
    int Range[3];
    ostrstream StringOutput;
    if (this->GetParameterRange(parameterName, Range) <= 0) 
    {
    return(NULL);
    }
    StringOutput << ICE_64BIT_CAST Range[0] << " ";
    StringOutput << ICE_64BIT_CAST Range[1] << " ";
    StringOutput << ICE_64BIT_CAST Range[2] << ends;
    return(StringOutput.str());
  */
  return(0);
}
653

654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
//----------------------------------------------------------------------------
const char *vtkXdmfReader::GetParameterName(int vtkNotUsed(index))
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
    {
    return(0);
    }
    Param = this->DOM->GetParameter(index);
    if(Param) 
    {
    return(Param->GetParameterName());
    } 
    else 
    {
    return(0);
    }
  */
  return(0);
}

//----------------------------------------------------------------------------
int vtkXdmfReader::SetParameterIndex(int vtkNotUsed(Index), int vtkNotUsed(CurrentIndex)) 
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
    {
    return(0);
    }
    Param = this->DOM->GetParameter(Index);
    if(!Param) 
    {
    return(-1);
    }
    this->Modified();
    return(Param->SetCurrentIndex(CurrentIndex));
  */
  return(0);
}
695

696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterIndex(int vtkNotUsed(Index)) 
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
    {
    return(0);
    }
    Param = this->DOM->GetParameter(Index);
    if(!Param) 
    {
    return(-1);
    }
    return(Param->GetCurrentIndex());
  */
  return(0);
}
714

715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
//----------------------------------------------------------------------------
int vtkXdmfReader::SetParameterIndex(const char *vtkNotUsed(ParameterName),
                                     int vtkNotUsed(CurrentIndex)) 
{
  /*
    XdmfParameter *Param;
    int Status=-1;
    if(!this->DOM) 
    {
    return(0);
    }
    for(int i=0 ; i < this->DOM->FindNumberOfParameters() ;  i++)
    {
    Param = this->DOM->GetParameter(i);
    if(!Param) 
    {
    return(-1);
    }
    if(XDMF_WORD_CMP(Param->GetParameterName(), ParameterName))
    {
    Status = Param->SetCurrentIndex(CurrentIndex);
    this->Modified();
    if(Status <= 0 ) 
    {
    return(Status);
    }
    }
    }
    return(Status);
  */
  return(0);
}
747

748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterIndex(const char *vtkNotUsed(parameterName)) 
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
    {
    return(0);
    }
    Param = this->DOM->FindParameter(parameterName);
    if(!Param) 
    {
    return(-1);
    }
    return(Param->GetCurrentIndex());
  */
  return(0);
}
766

767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterLength(int vtkNotUsed(index))
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
    {
    return(0);
    }
    Param = this->DOM->GetParameter(index);
    if(Param) 
    {
    return(Param->GetNumberOfElements());
    } 
    else 
    {
    return(0);
    }
  */
  return(0);
}

//----------------------------------------------------------------------------
int vtkXdmfReader::GetParameterLength(const char *vtkNotUsed(parameterName))
{
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
    {
    return(0);
    }
    Param = this->DOM->FindParameter(parameterName);
    if(Param) 
    {
    return(Param->GetNumberOfElements());
    } 
    else 
    {
    return(0);
806
    }
807
  */
Berk Geveci's avatar
Berk Geveci committed
808
  return 0;
809
}
810

811
812
//----------------------------------------------------------------------------
const char *vtkXdmfReader::GetParameterValue(const char *vtkNotUsed(parameterName)) 
813
{
814
815
816
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
817
    {
818
    return(0);
819
    }
820
821
    Param = this->DOM->FindParameter(parameterName);
    if(!Param) 
822
    {
823
    return(0);
824
    }
825
826
827
828
    Param->Update();
    return(Param->GetParameterValue());
  */
  return 0;
Jerry Clarke's avatar
Jerry Clarke committed
829
830
}

831
832
//----------------------------------------------------------------------------
const char *vtkXdmfReader::GetParameterValue(int vtkNotUsed(index)) 
833
{
834
835
836
  /*
    XdmfParameter *Param;
    if(!this->DOM) 
837
    {
838
839
840
841
842
843
844
845
846
847
848
849
    return(0);
    }
    Param = this->DOM->GetParameter(index);
    if(!Param) 
    {
    return(0);
    }
    Param->Update();
    return(Param->GetParameterValue());
  */
  return 0;
}
850

851
852
853
854
855
//----------------------------------------------------------------------------
int vtkXdmfReader::GetNumberOfDomains()
{
  return this->Internals->DomainList.size();
}
856

857
858
859
860
861
862
//----------------------------------------------------------------------------
void vtkXdmfReader::SetDomainName(const char* domain)
{
  if ( this->DomainName == domain )
    {
    return;
863
    }
864
  if ( this->DomainName && domain && strcmp(this->DomainName, domain) == 0 )
865
    {
866
    return;
Jerry Clarke's avatar
Jerry Clarke committed
867
    }
868
  if ( this->DomainName )
869
    {
870
871
    delete [] this->DomainName;
    this->DomainName = 0;
872
    }
873
874
875
876
877
878
879
  if ( domain )
    {
    this->DomainName = new char [ strlen(domain) + 1 ];
    strcpy(this->DomainName, domain);
    }
  this->GridsModified = 1;
}
Jerry Clarke's avatar
Jerry Clarke committed
880

881
882
//----------------------------------------------------------------------------
const char* vtkXdmfReader::GetDomainName(int idx)
883
{
884
885
  return this->Internals->DomainList[idx].c_str();
}
886

887
888
889
890
891
892
//----------------------------------------------------------------------------
void vtkXdmfReader::SetGridName(const char* grid)
{
  this->DisableAllGrids();
  this->EnableGrid(grid);
}
893

894
895
896
897
//----------------------------------------------------------------------------
int vtkXdmfReader::GetNumberOfGrids()
{
  if (this->Internals->Data)
898
    {
899
    return this->Internals->Data->Children.size();
900
    }
901
  return 0;
902
903
904
}

//----------------------------------------------------------------------------
905
const char* vtkXdmfReader::GetGridName(int idx)
906
{
907
  if ( idx < 0 )
908
    {
909
910
911
912
913
914
915
916
917
    return 0;
    }
  vtkstd::map<vtkstd::string,vtkXdmfReaderGrid*>::iterator it;
  int cnt = 0;
  for ( it = this->Internals->Data->Children.begin();
        it != this->Internals->Data->Children.end();
        ++ it )
    {
    if ( cnt == idx )
918
      {
919
      return it->first.c_str();
920
      }
921
    cnt ++;
Jerry Clarke's avatar
Jerry Clarke committed
922
    }
923
924
  return 0;
}
925

926
927
928
929
//----------------------------------------------------------------------------
int vtkXdmfReader::GetGridIndex(const char* name)
{
  if ( !name )
930
    {
931
932
933
934
935
936
937
938
939
940
941
942
943
    return -1;
    }
  vtkstd::map<vtkstd::string,vtkXdmfReaderGrid *>::iterator it;
  int cnt = 0;
  for ( it = this->Internals->Data->Children.begin();
        it != this->Internals->Data->Children.end();
        ++ it )
    {
    if ( it->first == name )
      {
      return cnt;
      }
    cnt ++;
944
    }
945

946
  return -1;
947
948
949
}

//----------------------------------------------------------------------------
950
void vtkXdmfReader::EnableGrid(const char* name)
951
{
952
953
954
955
956
957
958
959
960
961
962
963
964
965
  vtkDebugMacro("Enable grid " << name);
  vtkXdmfReaderGrid* grid = this->Internals->GetGrid(name);
  if ( !grid ) //work around an undo/redo crash
    {
    cerr << "HERE" << endl;
    return;
    }
  if(!grid->Enabled)
    {
    ++this->NumberOfEnabledActualGrids;
    grid->Enabled = 1;
    this->Modified();
    this->UpdateInformation();
    }
966
967
968
}

//----------------------------------------------------------------------------
969
void vtkXdmfReader::EnableGrid(int idx)
970
{
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
  vtkDebugMacro("Enable grid " << idx);
  vtkXdmfReaderGrid* grid = this->Internals->GetGrid(idx);
  if ( !grid )
    {
    return;
    }
  
  if(!grid->Enabled)
    {
    ++this->NumberOfEnabledActualGrids;
    grid->Enabled = 1;
    this->PointDataArraySelection->RemoveAllArrays();
    this->CellDataArraySelection->RemoveAllArrays();
    this->Modified();
    this->UpdateInformation();
    }
987
988
}

989
//----------------------------------------------------------------------------
990
void vtkXdmfReader::EnableAllGrids()
991
{
992
993
994
995
996
997
998
999
1000
  vtkDebugMacro("Enable all grids");
  vtkstd::map<vtkstd::string,vtkXdmfReaderGrid*>::iterator it;
  int changed=0;
  for ( it = this->Internals->Data->Children.begin();
        it != this->Internals->Data->Children.end();
        ++ it )
    {
    if(!it->second->Enabled)
      {
For faster browsing, not all history is shown. View entire blame