VTK  9.4.20250102
vtkXArrayAccessor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef vtkXArrayAccessor_h
5#define vtkXArrayAccessor_h
6
7#include "vtkNetCDFAccessor.h"
8
9#include "vtkCommand.h" // for vtkBaseTypeMacro
10#include "vtkIONetCDFModule.h" // For export macro
11#include "vtkVariant.h" // for vtkVariant
12
13VTK_ABI_NAMESPACE_BEGIN
14class vtkImageData;
15class vtkTexture;
16class vtkDataArray;
17
18class VTKIONETCDF_EXPORT vtkXArrayAccessor : public vtkNetCDFAccessor
19{
20public:
23
24 int close(int ncid) override;
25 int open(const char* path, int omode, int* ncidp) override;
26 const char* strerror(int ncerr1) override;
27
28 int inq_attlen(int ncid, int varid, const char* name, size_t* lenp) override;
29
30 int inq_dimlen(int ncid, int dimid, size_t* lenp) override;
31 int inq_dimname(int ncid, int dimid, char* name) override;
32
33 int inq_nvars(int ncid, int* nvarsp) override;
34 int inq_ndims(int ncid, int* ndimsp) override;
35
36 int inq_vardimid(int ncid, int varid, int* dimidsp) override;
37 int inq_varid(int ncid, const char* name, int* varidp) override;
38 int inq_varname(int ncid, int varid, char* name) override;
39 int inq_varndims(int ncid, int varid, int* ndimsp) override;
40 int inq_vartype(int ncid, int varid, int* typep) override;
41
42 int get_att_text(int ncid, int varid, const char* name, char* value) override;
43 int get_att_double(int ncid, int varid, const char* name, double* value) override;
44 int get_att_float(int ncid, int varid, const char* name, float* value) override;
45
46 bool GetCoordinates(int ncFD, int varId, std::vector<std::string>& coordName) override;
47 bool NeedsFileName() override;
48
49 // shallow copy
50 int get_vars(int ncid, int varid, const size_t* startp, const size_t* countp,
51 const ptrdiff_t* stridep, int vtkType, vtkIdType numberOfComponents, vtkIdType numberOfTuples,
52 vtkDataArray* dataArray) override;
53 // deep copy
54 int get_vars(int ncid, int varid, const size_t* startp, const size_t* countp,
55 const ptrdiff_t* stridep, void* ip) override;
56 // deep copy
57 int get_vars_double(int ncid, int varid, const size_t* startp, const size_t* countp,
58 const ptrdiff_t* stridep, double* ip) override;
59 int get_var_double(int ncid, int varid, double* ip) override;
60
62
65 void SetDim(const std::vector<std::string>& v);
66 void SetDimLen(const std::vector<size_t>& v);
68
70
73 void SetVar(const std::vector<std::string>& v, const std::vector<int>& is_coord);
74 void SetVarValue(size_t varIndex, void* value);
75 void SetAtt(size_t varIndex, std::string attributeName, const vtkVariant& var);
76 void SetVarType(size_t varIndex, int nctype);
81 bool IsCOARDSCoordinate(std::string);
83
87 void SetVarDims(size_t varIndex, const std::vector<size_t>& dims);
88 void SetVarCoords(size_t varIndex, const std::vector<size_t>& coords);
89
90 void PrintSelf(ostream& os, vtkIndent indent) override;
91
92protected:
93 void PrintVarValue(const char* name, int varid);
94 void PrintVarValue(const char* name, int varid, const size_t* startp, const size_t* countp);
95 bool IsContiguous(int varid, const size_t* startp, const size_t* countp);
97 int varid, const size_t* startp, const size_t* countp, char*& arrayStart, vtkIdType& arraySize);
98 void Copy(int varid, const size_t* startp, const size_t* countp, char* dst);
99 std::vector<size_t> GetDimIncrement(int varid);
100 bool DecrementAndUpdate(size_t varid, std::vector<size_t>& count, const size_t* startp,
101 const size_t* count_p, const std::vector<size_t>& dimIncrement, char*& src);
102
103 vtkXArrayAccessor() = default;
104 ~vtkXArrayAccessor() override = default;
105
106private:
108
113 std::vector<std::string> Var;
114 std::vector<int> IsCoord;
115 std::vector<char*> VarValue;
116 std::map<std::string, size_t> VarIndex;
117 std::vector<std::map<std::string, vtkVariant>> Att;
118 std::vector<int> VarType;
120
122
126 std::vector<std::string> Dim;
127 std::map<std::string, size_t> DimIndex;
128 std::vector<size_t> DimLen;
130
133 std::vector<std::vector<size_t>> VarDims;
134 std::vector<std::vector<size_t>> VarCoords;
135
136 vtkXArrayAccessor(const vtkXArrayAccessor&) = delete;
137 void operator=(const vtkXArrayAccessor&) = delete;
138};
139
140VTK_ABI_NAMESPACE_END
141#endif
abstract superclass for arrays of numeric data
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
handles properties associated with a texture map
Definition vtkTexture.h:168
A type representing the union of many types.
Definition vtkVariant.h:162
void Copy(int varid, const size_t *startp, const size_t *countp, char *dst)
int inq_ndims(int ncid, int *ndimsp) override
int inq_varname(int ncid, int varid, char *name) override
bool NeedsFileName() override
int inq_attlen(int ncid, int varid, const char *name, size_t *lenp) override
void PrintVarValue(const char *name, int varid)
void SetVarDims(size_t varIndex, const std::vector< size_t > &dims)
Set dimensions for a variable.
int get_vars(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, void *ip) override
const char * strerror(int ncerr1) override
void SetVarValue(size_t varIndex, void *value)
Set variables, variable attributes and types for the variable arrays.
void SetDim(const std::vector< std::string > &v)
Set dimensions and their length.
bool DecrementAndUpdate(size_t varid, std::vector< size_t > &count, const size_t *startp, const size_t *count_p, const std::vector< size_t > &dimIncrement, char *&src)
int inq_dimlen(int ncid, int dimid, size_t *lenp) override
void SetVarCoords(size_t varIndex, const std::vector< size_t > &coords)
int inq_dimname(int ncid, int dimid, char *name) override
~vtkXArrayAccessor() override=default
void GetContiguousStartSize(int varid, const size_t *startp, const size_t *countp, char *&arrayStart, vtkIdType &arraySize)
bool IsContiguous(int varid, const size_t *startp, const size_t *countp)
void SetVar(const std::vector< std::string > &v, const std::vector< int > &is_coord)
Set variables, variable attributes and types for the variable arrays.
int close(int ncid) override
int get_att_text(int ncid, int varid, const char *name, char *value) override
int inq_vardimid(int ncid, int varid, int *dimidsp) override
int get_att_double(int ncid, int varid, const char *name, double *value) override
void SetVarType(size_t varIndex, int nctype)
Set variables, variable attributes and types for the variable arrays.
static vtkXArrayAccessor * New()
int get_att_float(int ncid, int varid, const char *name, float *value) override
int get_vars(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, int vtkType, vtkIdType numberOfComponents, vtkIdType numberOfTuples, vtkDataArray *dataArray) override
int get_var_double(int ncid, int varid, double *ip) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int get_vars_double(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, double *ip) override
void SetAtt(size_t varIndex, std::string attributeName, const vtkVariant &var)
Set variables, variable attributes and types for the variable arrays.
vtkXArrayAccessor()=default
bool GetCoordinates(int ncFD, int varId, std::vector< std::string > &coordName) override
bool IsCOARDSCoordinate(std::string)
Check if this coordinate has one dim with the same name as the coordinate.
int inq_varndims(int ncid, int varid, int *ndimsp) override
int inq_nvars(int ncid, int *nvarsp) override
void SetDimLen(const std::vector< size_t > &v)
Set dimensions and their length.
std::vector< size_t > GetDimIncrement(int varid)
int inq_varid(int ncid, const char *name, int *varidp) override
int open(const char *path, int omode, int *ncidp) override
int inq_vartype(int ncid, int varid, int *typep) override
void PrintVarValue(const char *name, int varid, const size_t *startp, const size_t *countp)
int vtkIdType
Definition vtkType.h:315