ParaView
vtkSpyPlotBlockIterator.h
Go to the documentation of this file.
1 #ifndef vtkSpyPlotBlockIterator_h
2 #define vtkSpyPlotBlockIterator_h
3 
4 #include "assert.h"
5 #include "vtkPVVTKExtensionsDefaultModule.h" //needed for exports
6 #include "vtkSpyPlotReaderMap.h"
7 #include "vtkSpyPlotUniReader.h"
8 
9 class vtkSpyBlock;
11 class vtkSpyPlotReader;
12 
13 //-----------------------------------------------------------------------------
14 class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkSpyPlotBlockIterator
15 {
16 public:
17  // Description:
18  // Initialize the iterator with informations about processors,
19  // files and timestep.
20  virtual void Init(int numberOfProcessors, int processorId, vtkSpyPlotReader* parent,
21  vtkSpyPlotReaderMap* fileMap, int currentTimeStep);
22 
23  // Description:
24  // Go to first block if any.
25  virtual void Start() = 0;
26 
27  // Description:
28  // Returns the total number of blocks to be processed by this Processor.
29  // Can be called only after Init().
30  virtual int GetNumberOfBlocksToProcess() = 0;
31 
32  // Description:
33  // Are there still blocks to iterate over?
34  int IsActive() const;
35 
36  // Description:
37  // Go to the next block if any
38  // \pre is_active: IsActive()
39  void Next();
40 
41  // Description:
42  // Return the block at current position.
43  // \pre is_active: IsActive()
44  vtkSpyPlotBlock* GetBlock() const;
45 
46  // Description:
47  // Return the blockID at current position.
48  // \pre is_active: IsActive()
49  int GetBlockID() const;
50 
51  // Description:
52  // Return the number of fields at current position.
53  // \pre is_active: IsActive()
54  int GetNumberOfFields() const;
55 
56  // Description:
57  // Return the SPCTH API handle at current position.
58  // \pre is_active: IsActive()
59  vtkSpyPlotUniReader* GetUniReader() const;
60 
61  // Description:
62  // Return the number of processors being used
63  int GetNumberOfProcessors() const;
64 
65  // Description:
66  // Return the id of this processor
67  int GetProcessorId() const;
68 
70 
71 protected:
73 
74  virtual void FindFirstBlockOfCurrentOrNextFile() = 0;
75 
80 
82 
83  int Active;
84  int Block;
87 
88  vtkSpyPlotReaderMap::MapOfStringToSPCTH::iterator FileIterator;
89  int FileIndex;
90 
91  int BlockEnd;
93 };
94 
95 class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkSpyPlotBlockDistributionBlockIterator
97 {
98 public:
101  virtual void Start();
102  virtual int GetNumberOfBlocksToProcess();
103 
104 protected:
105  virtual void FindFirstBlockOfCurrentOrNextFile();
106 };
107 
108 class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkSpyPlotFileDistributionBlockIterator
109  : public vtkSpyPlotBlockIterator
110 {
111 public:
114  virtual void Init(int numberOfProcessors, int processorId, vtkSpyPlotReader* parent,
115  vtkSpyPlotReaderMap* fileMap, int currentTimeStep);
116  virtual void Start();
117  virtual int GetNumberOfBlocksToProcess();
118 
119 protected:
120  virtual void FindFirstBlockOfCurrentOrNextFile();
122  int FileEnd;
123 };
124 
126 {
127  assert("pre: is_active" && IsActive());
128 
129  ++this->Block;
130  if (this->Block > this->BlockEnd)
131  {
132  ++this->FileIterator;
133  ++this->FileIndex;
135  }
136 }
137 
139 {
140  return this->ProcessorId;
141 }
142 
144 {
145  return this->NumberOfProcessors;
146 }
147 
149 {
150  assert("pre: is_active" && IsActive());
151  return this->UniReader;
152 }
153 
155 {
156  return this->Active;
157 }
158 
160 {
161  assert("pre: is_active" && IsActive());
162  return this->UniReader->GetBlock(Block);
163 }
164 
166 {
167  assert("pre: is_active" && IsActive());
168  return Block;
169 }
170 
172 {
173  assert("pre: is_active" && IsActive());
174  return this->NumberOfFields;
175 }
176 
177 #endif
178 
179 // VTK-HeaderTest-Exclude: vtkSpyPlotBlockIterator.h
Maps strings to vtkSpyPlotUniReaders.
vtkSpyPlotUniReader * UniReader
vtkSpyPlotReaderMap * FileMap
vtkSpyPlotReaderMap::MapOfStringToSPCTH::iterator FileIterator
vtkSpyPlotBlock * GetBlock() const
virtual void Init(int numberOfProcessors, int processorId, vtkSpyPlotReader *parent, vtkSpyPlotReaderMap *fileMap, int currentTimeStep)
Read SPCTH Spy Plot file format.
vtkSpyPlotUniReader * GetUniReader() const
virtual void FindFirstBlockOfCurrentOrNextFile()=0
virtual void Start()=0
Represents a SpyPlot Block Grid.
virtual int GetNumberOfBlocksToProcess()=0
Read SPCTH Spy Plot file format.