VTK  9.2.6
vtkSEPReader.h
Go to the documentation of this file.
1 /*=========================================================================
2  Copyright (c) GeometryFactory
3  All rights reserved.
4  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
5 
6  This software is distributed WITHOUT ANY WARRANTY; without even
7  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8  PURPOSE. See the above copyright notice for more information.
9 
10 =========================================================================*/
22 #ifndef vtkSEPReader_h
23 #define vtkSEPReader_h
24 
25 #include "vtkIOImageModule.h" // For export macro
26 
27 #include "vtkExtentTranslator.h" // for vtkExtentTranslator
28 #include "vtkImageAlgorithm.h"
29 #include "vtkNew.h" // for ivars
30 
31 #include <array> // for std::array
32 #include <cstdint> // for std::uint8_t
33 #include <string> // for std::string
34 
35 namespace details
36 {
37 enum class EndiannessType : std::uint8_t
38 {
40  SEP_BIG_ENDIAN = 1
41 };
42 
43 static constexpr int SEP_READER_MAX_DIMENSION = 32u;
44 }
45 
46 class vtkStringArray;
47 
48 class VTKIOIMAGE_EXPORT vtkSEPReader : public vtkImageAlgorithm
49 {
50 public:
51  static vtkSEPReader* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  vtkSetStdStringFromCharMacro(FileName);
59  vtkGetCharFromStdStringMacro(FileName);
60 
65  vtkGetMacro(OutputGridDimension, int);
66  vtkSetMacro(OutputGridDimension, int);
67 
72  vtkSetMacro(ExtentSplitMode, int);
73  vtkGetMacro(ExtentSplitMode, int);
74 
75  vtkGetMacro(DataOrigin, VTK_FUTURE_CONST double*);
76  vtkGetMacro(DataSpacing, VTK_FUTURE_CONST double*);
77 
82  vtkGetObjectMacro(AllDimensions, vtkStringArray);
83 
88  vtkGetObjectMacro(AllRanges, vtkStringArray);
89 
95  vtkSetStdStringFromCharMacro(XDimension);
96  vtkSetStdStringFromCharMacro(YDimension);
97  vtkSetStdStringFromCharMacro(ZDimension);
98  vtkSetStdStringFromCharMacro(FixedDimension1);
99  vtkSetStdStringFromCharMacro(FixedDimension2);
100 
101  vtkSetMacro(FixedDimensionValue1, int);
102  vtkSetMacro(FixedDimensionValue2, int);
103  vtkGetVector2Macro(FixedDimRange, int);
104 
105  bool CanReadFile(VTK_FILEPATH const char*);
106 
107  std::array<std::int32_t, 6> ComputeExtent() const;
108 
109 protected:
110  vtkSEPReader();
111 
114 
115  bool ReadHeader();
116  bool ReadData(vtkImageData*, int*);
117 
121  std::string FileName = "";
122  int OutputGridDimension = 3;
123  int ExtentSplitMode = vtkExtentTranslator::BLOCK_MODE;
126  std::string XDimension = "CDP";
127  std::string YDimension = "LINE";
128  std::string ZDimension = "DEPTH"; // used only in 3D
129  std::string FixedDimension1 = "OFFSET";
130  std::string FixedDimension2 = "DEPTH"; // used only in 2D
131  int FixedDimensionValue1 = details::SEP_READER_MAX_DIMENSION;
132  int FixedDimensionValue2 = details::SEP_READER_MAX_DIMENSION;
133  int FixedDimRange[2] = { 0, 0 };
134 
137 
138 private:
139  enum class DataFormatType : std::uint8_t
140  {
141  XDR_FLOAT = 0,
142  XDR_INT = 1,
143  XDR_DOUBLE = 2
144  };
145 
149  DataFormatType DataFormat = DataFormatType::XDR_FLOAT;
150  details::EndiannessType Endianness;
151  int Dimensions[details::SEP_READER_MAX_DIMENSION];
152  double OutputSpacing[3];
153  double OutputOrigin[3];
155  std::string DataFileType;
156  std::string BinaryFilename;
157  int ESize = 4;
158  int XArrayId = details::SEP_READER_MAX_DIMENSION;
159  int YArrayId = details::SEP_READER_MAX_DIMENSION;
160  int ZArrayId = details::SEP_READER_MAX_DIMENSION;
161  int FixedDimension1ArrayId = details::SEP_READER_MAX_DIMENSION;
162  int FixedDimension2ArrayId = details::SEP_READER_MAX_DIMENSION;
163 
164  void ReadDataPiece(FILE* file, char*& dataOutput, vtkIdType offset, vtkIdType range);
165 
166  vtkSEPReader(const vtkSEPReader&) = delete;
167  void operator=(const vtkSEPReader&) = delete;
168 };
169 
170 #endif // vtkSEPReader_h
Store vtkAlgorithm input/output information.
vtkNew< vtkStringArray > AllRanges
Definition: vtkSEPReader.h:136
a vtkAbstractArray subclass for strings
vtkNew< vtkStringArray > AllDimensions
Definition: vtkSEPReader.h:135
int vtkIdType
Definition: vtkType.h:332
Stanford Exploration Project files reader.
Definition: vtkSEPReader.h:48
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
static constexpr int SEP_READER_MAX_DIMENSION
Definition: vtkSEPReader.h:43
#define VTK_FILEPATH
Generic algorithm superclass for image algs.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.