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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-FileCopyrightText: Copyright (c) GeometryFactory
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkSEPReader
* @brief Stanford Exploration Project files reader.
*
* This reader takes a .H file that points to a .H@ file and contains
* all the information to interpret the raw data in the .H@ file.
*/
#ifndef vtkSEPReader_h
#define vtkSEPReader_h
#include "vtkIOImageModule.h" // For export macro
#include "vtkExtentTranslator.h" // for vtkExtentTranslator
#include "vtkImageAlgorithm.h"
#include "vtkNew.h" // for ivars
#include <array> // for std::array
#include <cstdint> // for std::uint8_t and std::uint32_t
#include <string> // for std::string
namespace details
{
VTK_ABI_NAMESPACE_BEGIN
enum class EndiannessType : std::uint8_t
{
SEP_LITTLE_ENDIAN = 0,
SEP_BIG_ENDIAN = 1
};
static constexpr int SEP_READER_MAX_DIMENSION = 32u;
VTK_ABI_NAMESPACE_END
}
VTK_ABI_NAMESPACE_BEGIN
class vtkStringArray;
class VTKIOIMAGE_EXPORT vtkSEPReader : public vtkImageAlgorithm
{
public:
static vtkSEPReader* New();
vtkTypeMacro(vtkSEPReader, vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* @brief Specify file name for the SEP Header file.
*/
vtkSetStdStringFromCharMacro(FileName);
vtkGetCharFromStdStringMacro(FileName);
/**
* @brief When 2D mode is true, the third dimension is
* ignored and the output is in 2D.
**/
vtkGetMacro(OutputGridDimension, int);
vtkSetMacro(OutputGridDimension, int);
/**
* @brief Specify extent translator split mode.
* Default: vtkExtentTranslator::BLOCK_MODE
**/
vtkSetMacro(ExtentSplitMode, int);
vtkGetMacro(ExtentSplitMode, int);
vtkGetMacro(DataOrigin, VTK_FUTURE_CONST double*);
vtkGetMacro(DataSpacing, VTK_FUTURE_CONST double*);
/**
* Array containing the name of all dimensions.
* Contains ESize elements.
**/
vtkGetObjectMacro(AllDimensions, vtkStringArray);
/**
* Array containing the name and the size of all dimensions.
* The two first entries are the header. Contains 2*ESize elements.
**/
vtkGetObjectMacro(AllRanges, vtkStringArray);
/**
* Specify the name for each spatial / fixed dimension.
* ZDimension is only used for 3D output.
* FixedDimension2 is only used for 2D output.
**/
vtkSetStdStringFromCharMacro(XDimension);
vtkSetStdStringFromCharMacro(YDimension);
vtkSetStdStringFromCharMacro(ZDimension);
vtkSetStdStringFromCharMacro(FixedDimension1);
vtkSetStdStringFromCharMacro(FixedDimension2);
vtkSetMacro(FixedDimensionValue1, int);
vtkSetMacro(FixedDimensionValue2, int);
vtkGetVector2Macro(FixedDimRange, int);
bool CanReadFile(VTK_FILEPATH const char*);
std::array<std::int32_t, 6> ComputeExtent() const;
protected:
vtkSEPReader();
int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
int RequestData(vtkInformation* request, vtkInformationVector**, vtkInformationVector*) override;
bool ReadHeader();
bool ReadData(vtkImageData*, int*);
/**
* Exposed Properties
*/
std::string FileName;
int OutputGridDimension = 3;
int ExtentSplitMode = vtkExtentTranslator::BLOCK_MODE;
double DataOrigin[details::SEP_READER_MAX_DIMENSION];
double DataSpacing[details::SEP_READER_MAX_DIMENSION];
std::string XDimension = "CDP";
std::string YDimension = "LINE";
std::string ZDimension = "DEPTH"; // used only in 3D
std::string FixedDimension1 = "OFFSET";
std::string FixedDimension2 = "DEPTH"; // used only in 2D
int FixedDimensionValue1 = details::SEP_READER_MAX_DIMENSION;
int FixedDimensionValue2 = details::SEP_READER_MAX_DIMENSION;
int FixedDimRange[2] = { 0, 0 };
vtkNew<vtkStringArray> AllDimensions;
vtkNew<vtkStringArray> AllRanges;
private:
enum class DataFormatType : std::uint8_t
{
XDR_FLOAT = 0,
XDR_INT = 1,
XDR_DOUBLE = 2
};
/**
* Internal Variables
*/
DataFormatType DataFormat = DataFormatType::XDR_FLOAT;
details::EndiannessType Endianness;
int Dimensions[details::SEP_READER_MAX_DIMENSION];
double OutputSpacing[3];
double OutputOrigin[3];
std::string Label[details::SEP_READER_MAX_DIMENSION];
std::string DataFileType;
std::string BinaryFilename;
int ESize = 4;
int XArrayId = details::SEP_READER_MAX_DIMENSION;
int YArrayId = details::SEP_READER_MAX_DIMENSION;
int ZArrayId = details::SEP_READER_MAX_DIMENSION;
int FixedDimension1ArrayId = details::SEP_READER_MAX_DIMENSION;
int FixedDimension2ArrayId = details::SEP_READER_MAX_DIMENSION;
void ReadDataPiece(FILE* file, char*& dataOutput, vtkIdType offset, vtkIdType range);
vtkSEPReader(const vtkSEPReader&) = delete;
void operator=(const vtkSEPReader&) = delete;
};
VTK_ABI_NAMESPACE_END
#endif // vtkSEPReader_h
|