VTK  9.4.20241118
vtkFileSeriesHelper.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
3// SPDX-License-Identifier: BSD-3-Clause
16#ifndef vtkFileSeriesHelper_h
17#define vtkFileSeriesHelper_h
18
19#include "vtkObject.h"
20
21#include "vtkIOCGNSReaderModule.h" // for export macros
22#include "vtkSmartPointer.h" // for vtkSmartPointer.
23#include <string> // for std::string
24#include <utility> // for std::pair
25#include <vector> // for std::vector
26
27VTK_ABI_NAMESPACE_BEGIN
28class vtkAlgorithm;
30class vtkInformation;
32
33class VTKIOCGNSREADER_EXPORT vtkFileSeriesHelper : public vtkObject
34{
35public:
38 void PrintSelf(ostream& os, vtkIndent indent) override;
39
40 typedef bool (*FileNameFunctorType)(vtkAlgorithm* reader, const std::string& filename);
41
43
47 void AddFileName(const char* fname);
48 void SetFileNames(const std::vector<std::string>& filenames);
50
54 unsigned int GetNumberOfFiles() const;
55
67 virtual bool ReadMetaFile(const char* metafilename);
68
70
75 vtkGetObjectMacro(Controller, vtkMultiProcessController);
77
79
88 vtkSetMacro(IgnoreReaderTime, bool);
89 vtkGetMacro(IgnoreReaderTime, bool);
90 vtkBooleanMacro(IgnoreReaderTime, bool);
92
110 virtual bool UpdateInformation(vtkAlgorithm* reader, const FileNameFunctorType& ftor);
111
116 vtkGetMacro(UpdateInformationTime, vtkMTimeType);
117
122 const std::vector<double>& GetTimeSteps() const { return this->AggregatedTimeSteps; }
123
127 const std::pair<double, double>& GetTimeRange(bool* isvalid = nullptr) const
128 {
129 if (isvalid != nullptr)
130 {
131 *isvalid = this->AggregatedTimeRangeValid;
132 }
133 return this->AggregatedTimeRange;
134 }
135
140
145 vtkGetMacro(PartitionedFiles, bool);
146
156 std::vector<std::string> GetActiveFiles(vtkInformation* outInfo) const;
157
158protected:
161
163 {
164 public:
166 vtkTimeInformation(double time);
168 bool operator==(const vtkTimeInformation& other) const;
169
170 const std::pair<double, double>& GetTimeRange() const { return this->TimeRange; }
171 const std::vector<double>& GetTimeSteps() const { return this->TimeSteps; }
172 bool GetTimeStepsValid() const { return this->TimeStepsValid; }
173 bool GetTimeRangeValid() const { return this->TimeRangeValid; }
174
175 void Save(vtkMultiProcessStream& stream) const;
177
178 private:
179 std::pair<double, double> TimeRange;
180 std::vector<double> TimeSteps;
181 bool TimeRangeValid;
182 bool TimeStepsValid;
183 };
184
186 std::vector<std::string> FileNames;
189 std::vector<vtkTimeInformation> Information;
190
191private:
193 void operator=(const vtkFileSeriesHelper&) = delete;
194
195 std::vector<std::string> SplitFiles(
196 const std::vector<std::string>& files, int piece, int numPieces) const;
197
198 void Broadcast(int srcRank);
199
200 std::vector<double> AggregatedTimeSteps;
201 bool AggregatedTimeRangeValid;
202 std::pair<double, double> AggregatedTimeRange;
203 vtkTimeStamp UpdateInformationTime;
204};
205
206VTK_ABI_NAMESPACE_END
207#endif
Superclass for all sources, filters, and sinks in VTK.
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.
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
const std::pair< double, double > & GetTimeRange(bool *isvalid=nullptr) const
Returns the time range determined.
a simple class to control print indentation
Definition vtkIndent.h:108
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:162
record modification and/or execution time
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270