VTK  9.1.0
vtkFileSeriesHelper.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkFileSeriesHelper.h
5
6 Copyright (c) Kitware, Inc.
7 All rights reserved.
8 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
27#ifndef vtkFileSeriesHelper_h
28#define vtkFileSeriesHelper_h
29
30#include "vtkObject.h"
31
32#include "vtkIOCGNSReaderModule.h" // for export macros
33#include "vtkSmartPointer.h" // for vtkSmartPointer.
34#include <string> // for std::string
35#include <utility> // for std::pair
36#include <vector> // for std::vector
37
38class vtkAlgorithm;
40class vtkInformation;
42
43class VTKIOCGNSREADER_EXPORT vtkFileSeriesHelper : public vtkObject
44{
45public:
48 void PrintSelf(ostream& os, vtkIndent indent) override;
49
50 typedef bool (*FileNameFunctorType)(vtkAlgorithm* reader, const std::string& filename);
51
53
57 void AddFileName(const char* fname);
58 void SetFileNames(const std::vector<std::string>& filenames);
60
64 unsigned int GetNumberOfFiles() const;
65
77 virtual bool ReadMetaFile(const char* metafilename);
78
80
85 vtkGetObjectMacro(Controller, vtkMultiProcessController);
87
89
98 vtkSetMacro(IgnoreReaderTime, bool);
99 vtkGetMacro(IgnoreReaderTime, bool);
100 vtkBooleanMacro(IgnoreReaderTime, bool);
102
120 virtual bool UpdateInformation(vtkAlgorithm* reader, const FileNameFunctorType& ftor);
121
126 vtkGetMacro(UpdateInformationTime, vtkMTimeType);
127
132 const std::vector<double>& GetTimeSteps() const { return this->AggregatedTimeSteps; }
133
137 const std::pair<double, double>& GetTimeRange(bool* isvalid = NULL) const
138 {
139 if (isvalid != NULL)
140 {
141 *isvalid = this->AggregatedTimeRangeValid;
142 }
143 return this->AggregatedTimeRange;
144 }
145
150
155 vtkGetMacro(PartitionedFiles, bool);
156
166 std::vector<std::string> GetActiveFiles(vtkInformation* outInfo) const;
167
168protected:
171
173 {
174 public:
178 bool operator==(const vtkTimeInformation& other) const;
179
180 const std::pair<double, double>& GetTimeRange() const { return this->TimeRange; }
181 const std::vector<double>& GetTimeSteps() const { return this->TimeSteps; }
182 bool GetTimeStepsValid() const { return this->TimeStepsValid; }
183 bool GetTimeRangeValid() const { return this->TimeRangeValid; }
184
185 void Save(vtkMultiProcessStream& stream) const;
187
188 private:
189 std::pair<double, double> TimeRange;
190 std::vector<double> TimeSteps;
191 bool TimeRangeValid;
192 bool TimeStepsValid;
193 };
194
196 std::vector<std::string> FileNames;
199 std::vector<vtkTimeInformation> Information;
200
201private:
203 void operator=(const vtkFileSeriesHelper&) = delete;
204
205 std::vector<std::string> SplitFiles(
206 const std::vector<std::string>& files, int piece, int numPieces) const;
207
208 void Broadcast(int srcRank);
209
210 std::vector<double> AggregatedTimeSteps;
211 bool AggregatedTimeRangeValid;
212 std::pair<double, double> AggregatedTimeRange;
213 vtkTimeStamp UpdateInformationTime;
214};
215
216#endif
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:114
const std::vector< double > & GetTimeSteps() const
void Load(vtkMultiProcessStream &stream)
bool operator==(const vtkTimeInformation &other) const
const std::pair< double, double > & GetTimeRange() const
vtkTimeInformation(vtkInformation *outInfo)
void Save(vtkMultiProcessStream &stream) const
Helper class to process file series.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const std::pair< double, double > & GetTimeRange(bool *isvalid=NULL) const
Returns the time range determined.
void SetController(vtkMultiProcessController *)
Get/Set the parallel controller.
virtual bool ReadMetaFile(const char *metafilename)
Setup file names in the series using a meta-file.
const std::vector< double > & GetTimeSteps() const
Returns the timesteps determined.
void FillTimeInformation(vtkInformation *info) const
Fills up info with information about timesteps and timerange.
void AddFileName(const char *fname)
Specify the set of files that comprise the series.
std::vector< std::string > FileNames
void SetFileNames(const std::vector< std::string > &filenames)
Specify the set of files that comprise the series.
virtual bool UpdateInformation(vtkAlgorithm *reader, const FileNameFunctorType &ftor)
vtkFileSeriesHelper needs to collect information about the nature of the fileseries.
~vtkFileSeriesHelper() override
vtkMultiProcessController * Controller
void RemoveAllFileNames()
Specify the set of files that comprise the series.
static vtkFileSeriesHelper * New()
unsigned int GetNumberOfFiles() const
Get the number of files in the series.
std::vector< std::string > GetActiveFiles(vtkInformation *outInfo) const
Returns the list of files to read on current rank to satisfy the request.
std::vector< vtkTimeInformation > Information
a simple class to control print indentation
Definition: vtkIndent.h:113
Store vtkAlgorithm input/output information.
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition: vtkObject.h:73
record modification and/or execution time
Definition: vtkTimeStamp.h:52
@ info
Definition: vtkX3D.h:382
@ time
Definition: vtkX3D.h:503
@ string
Definition: vtkX3D.h:496
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287