File: vtkTemporalDelimitedTextReader.h

package info (click to toggle)
paraview 5.13.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 544,220 kB
  • sloc: cpp: 3,374,605; ansic: 1,332,409; python: 150,381; xml: 122,166; sql: 65,887; sh: 7,317; javascript: 5,262; yacc: 4,417; java: 3,977; perl: 2,363; lex: 1,929; f90: 1,397; makefile: 170; objc: 153; tcl: 59; pascal: 50; fortran: 29
file content (136 lines) | stat: -rw-r--r-- 4,799 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkTemporalDelimitedTextReader
 * @brief   reads a delimited ascii or unicode text files and and output a
 * temporal vtkTable.
 *
 * This reader requires that FieldDelimiterCharacters is set before
 * the pipeline is executed, otherwise it will produce an empty output.
 *
 * A column can be selected as time step indicator using the SetTimeColumnName
 * or SetTimeColumnId functions. If so, for a given time step 's' only the
 * lines where the time step indicator column have the value 's' are present.
 * To control if the time step indicator column should be present in the
 * output, a RemoveTimeStepColumn option is available. If no time step
 * indicator column is given by the user, the whole file it outputted.
 *
 * This reader assume the time step column is numeric. A warning is
 * set otherwise. The DetectNumericColumns field is set to on,
 * do not change this field unless you really know what you are
 * doing.
 *
 * @see vtkDelimitedTextReader
 */

#ifndef vtkTemporalDelimitedTextReader_h
#define vtkTemporalDelimitedTextReader_h

#include "vtkDelimitedTextReader.h"

#include "vtkIOInfovisModule.h" // module export
#include "vtkNew.h"             // For ReadTable field

#include <map>    // To store the TimeMap
#include <vector> // To store the TimeMap

VTK_ABI_NAMESPACE_BEGIN
class VTKIOINFOVIS_EXPORT vtkTemporalDelimitedTextReader : public vtkDelimitedTextReader
{
public:
  static vtkTemporalDelimitedTextReader* New();
  vtkTypeMacro(vtkTemporalDelimitedTextReader, vtkDelimitedTextReader);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  ///@{
  /**
   * Get/Set the name of the column to use as time indicator.
   * Ignored if TimeColumnId is not equal to -1.
   * If no column has been chosen using either the TimeColumnId or the
   * TimeColumnName the whole input file is outputted.
   * Default to empty string.
   */
  vtkGetMacro(TimeColumnName, std::string);
  void SetTimeColumnName(std::string name);
  ///@}

  ///@{
  /**
   * Get/Set the column to use as time indicator.
   * It the TimeColumnId is equal to -1, the TimeColumnName will be used
   * instead.
   * If no column has been chosen using either the TimeColumnId or the
   * TimeColumnName the whole input file is outputted.
   * Default to -1.
   */
  vtkGetMacro(TimeColumnId, int);
  void SetTimeColumnId(int idx);
  ///@}

  ///@{
  /**
   * Set the RemoveTimeStepColumn flag
   * If this boolean is true, the output will not contain the Time step column.
   * Default to true.
   */
  vtkGetMacro(RemoveTimeStepColumn, bool);
  void SetRemoveTimeStepColumn(bool rts);
  ///@}

  /** Internal fields of this reader use a specific MTime (InternalMTime).
   * This mechanism ensures the actual data is only re-read when necessary.
   * Here, we ensure the GetMTime of this reader stay consistent by returning
   * the latest between the MTime of this reader and the internal one.
   *
   * @see InternalModified
   */
  vtkMTimeType GetMTime() override;

protected:
  vtkTemporalDelimitedTextReader();
  ~vtkTemporalDelimitedTextReader() override = default;

  /**
   * In order to fill the TIME_STEPS and TIME_RANGE keys, this method call the
   * ReadData function that actually read the full input file content (may be
   * slow!). Custom MTime management is used to ensure we do not re-read the
   * input file uselessly.
   */
  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
    vtkInformationVector* outputVector) override;
  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
    vtkInformationVector* outputVector) override;

  /**
   * This function checks if a user specified column has been set and check if
   * this input is valid. If an invalid input has been detected, return false.
   * Otherwise, InternalColumnName will be set to the name of the time column
   * or empty if none has been given by the user.
   */
  bool EnforceColumnName();

  /**
   * When parameters specific of this reader are modified, we do not want to
   * re-read the input file. Keep an internal time stamp to track them.
   */
  void InternalModified();

  // Time column fields
  std::string TimeColumnName;
  std::string InternalColumnName;
  vtkIdType TimeColumnId = -1;
  bool RemoveTimeStepColumn = true;
  std::map<double, std::vector<vtkIdType>> TimeMap;

  // Input file content and update
  vtkNew<vtkTable> ReadTable;
  vtkMTimeType LastReadTime = 0;
  vtkTimeStamp InternalMTime;

private:
  vtkTemporalDelimitedTextReader(const vtkTemporalDelimitedTextReader&) = delete;
  void operator=(const vtkTemporalDelimitedTextReader&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif