VTK  9.3.20240329
vtkSEPReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) GeometryFactory
3 // SPDX-License-Identifier: BSD-3-Clause
15 #ifndef vtkSEPReader_h
16 #define vtkSEPReader_h
17 
18 #include "vtkIOImageModule.h" // For export macro
19 
20 #include "vtkExtentTranslator.h" // for vtkExtentTranslator
21 #include "vtkImageAlgorithm.h"
22 #include "vtkNew.h" // for ivars
23 
24 #include <array> // for std::array
25 #include <cstdint> // for std::uint8_t and std::uint32_t
26 #include <string> // for std::string
27 
28 namespace details
29 {
30 VTK_ABI_NAMESPACE_BEGIN
31 enum class EndiannessType : std::uint8_t
32 {
34  SEP_BIG_ENDIAN = 1
35 };
36 
37 static constexpr int SEP_READER_MAX_DIMENSION = 32u;
38 VTK_ABI_NAMESPACE_END
39 }
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkStringArray;
43 
44 class VTKIOIMAGE_EXPORT vtkSEPReader : public vtkImageAlgorithm
45 {
46 public:
47  static vtkSEPReader* New();
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
56 
61  vtkGetMacro(OutputGridDimension, int);
62  vtkSetMacro(OutputGridDimension, int);
63 
68  vtkSetMacro(ExtentSplitMode, int);
69  vtkGetMacro(ExtentSplitMode, int);
70 
71  vtkGetMacro(DataOrigin, VTK_FUTURE_CONST double*);
72  vtkGetMacro(DataSpacing, VTK_FUTURE_CONST double*);
73 
78  vtkGetObjectMacro(AllDimensions, vtkStringArray);
79 
84  vtkGetObjectMacro(AllRanges, vtkStringArray);
85 
94  vtkSetStdStringFromCharMacro(FixedDimension1);
95  vtkSetStdStringFromCharMacro(FixedDimension2);
96 
97  vtkSetMacro(FixedDimensionValue1, int);
98  vtkSetMacro(FixedDimensionValue2, int);
99  vtkGetVector2Macro(FixedDimRange, int);
100 
101  bool CanReadFile(VTK_FILEPATH const char*);
102 
103  std::array<std::int32_t, 6> ComputeExtent() const;
104 
105 protected:
107 
110 
111  bool ReadHeader();
112  bool ReadData(vtkImageData*, int*);
113 
118  int OutputGridDimension = 3;
119  int ExtentSplitMode = vtkExtentTranslator::BLOCK_MODE;
122  std::string XDimension = "CDP";
123  std::string YDimension = "LINE";
124  std::string ZDimension = "DEPTH"; // used only in 3D
125  std::string FixedDimension1 = "OFFSET";
126  std::string FixedDimension2 = "DEPTH"; // used only in 2D
127  int FixedDimensionValue1 = details::SEP_READER_MAX_DIMENSION;
128  int FixedDimensionValue2 = details::SEP_READER_MAX_DIMENSION;
129  int FixedDimRange[2] = { 0, 0 };
130 
133 
134 private:
135  enum class DataFormatType : std::uint8_t
136  {
137  XDR_FLOAT = 0,
138  XDR_INT = 1,
139  XDR_DOUBLE = 2
140  };
141 
145  DataFormatType DataFormat = DataFormatType::XDR_FLOAT;
146  details::EndiannessType Endianness;
147  int Dimensions[details::SEP_READER_MAX_DIMENSION];
148  double OutputSpacing[3];
149  double OutputOrigin[3];
151  std::string DataFileType;
152  std::string BinaryFilename;
153  int ESize = 4;
154  int XArrayId = details::SEP_READER_MAX_DIMENSION;
155  int YArrayId = details::SEP_READER_MAX_DIMENSION;
156  int ZArrayId = details::SEP_READER_MAX_DIMENSION;
157  int FixedDimension1ArrayId = details::SEP_READER_MAX_DIMENSION;
158  int FixedDimension2ArrayId = details::SEP_READER_MAX_DIMENSION;
159 
160  void ReadDataPiece(FILE* file, char*& dataOutput, vtkIdType offset, vtkIdType range);
161 
162  vtkSEPReader(const vtkSEPReader&) = delete;
163  void operator=(const vtkSEPReader&) = delete;
164 };
165 
166 VTK_ABI_NAMESPACE_END
167 #endif // vtkSEPReader_h
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
a simple class to control print indentation
Definition: vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Stanford Exploration Project files reader.
Definition: vtkSEPReader.h:45
int RequestData(vtkInformation *request, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
vtkGetCharFromStdStringMacro(FileName)
vtkSetStdStringFromCharMacro(ZDimension)
vtkNew< vtkStringArray > AllRanges
Definition: vtkSEPReader.h:132
vtkSetStdStringFromCharMacro(YDimension)
std::string FileName
Exposed Properties.
Definition: vtkSEPReader.h:117
std::array< std::int32_t, 6 > ComputeExtent() const
vtkSetStdStringFromCharMacro(FixedDimension2)
static vtkSEPReader * New()
bool ReadData(vtkImageData *, int *)
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkNew< vtkStringArray > AllDimensions
Definition: vtkSEPReader.h:131
vtkSetStdStringFromCharMacro(XDimension)
Specify the name for each spatial / fixed dimension.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSetStdStringFromCharMacro(FixedDimension1)
bool ReadHeader()
bool CanReadFile(VTK_FILEPATH const char *)
vtkSetStdStringFromCharMacro(FileName)
Specify file name for the SEP Header file.
a vtkAbstractArray subclass for strings
static constexpr int SEP_READER_MAX_DIMENSION
Definition: vtkSEPReader.h:37
@ range
Definition: vtkX3D.h:238
@ offset
Definition: vtkX3D.h:438
@ string
Definition: vtkX3D.h:490
int vtkIdType
Definition: vtkType.h:315
#define VTK_FILEPATH