File: metaArray.h

package info (click to toggle)
paraview 5.13.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, 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 (218 lines) | stat: -rw-r--r-- 5,684 bytes parent folder | download | duplicates (7)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*============================================================================
  MetaIO
  Copyright 2000-2010 Insight Software Consortium

  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
#include "metaTypes.h"

#ifndef ITKMetaIO_METAVECTOR_H
#  define ITKMetaIO_METAVECTOR_H

#  include "metaUtils.h"
#  include "metaForm.h"

/*!    MetaArray (.h and .cpp)
 *
 * Description:
 *    Reads and Writes MetaArray Files.
 *    MetaArray Files can be in one of two possible formats:
 *       a combined header/data format, typically designated .mva files
 *       or as separate header and data files, typically designated
 *       .mvh and .mvd files
 *
 * Features:
 *    Header information is in ascii format - for easy creation, editing,
 *      and review.
 *    Has required and optional header data (provides rapid formation
 *      or extensive documentation).
 *    Handles byte ordering (MSB/LSB)
 *    REQUIRED: NDims, ByteOrderMSB, ElementDataType, DataFileName
 *
 * \author Stephen R. Aylward
 *
 * \date August 29, 1999
 *
 * Depends on:
 *    MetaUtils.h
 *    MetaForm.h
 */

#  if (METAIO_USE_NAMESPACE)
namespace METAIO_NAMESPACE
{
#  endif

class METAIO_EXPORT MetaArray : public MetaForm
{
  // PUBLIC
public:
  // Constructors & Destructor
  MetaArray();

  explicit MetaArray(const char * _headerName);

  explicit MetaArray(MetaArray * _vector, bool _allocateElementData = false, bool _autoFreeElementData = false);

  MetaArray(int               _length,
            MET_ValueEnumType _elementType,
            int               _elementNumberOfChannels = 1,
            void *            _elementData = nullptr,
            bool              _allocateElementData = false,
            bool              _autoFreeElementData = false);

  ~MetaArray() override;

  void
  PrintInfo() const override;

  void
  CopyInfo(const MetaForm * _form) override;

  void
  Clear() override;

  bool
  InitializeEssential(int               _length,
                      MET_ValueEnumType _elementType,
                      int               _elementNumberOfChannels = 1,
                      void *            _elementData = nullptr,
                      bool              _allocateElementData = false,
                      bool              _autoFreeElementData = true);

  bool
  AllocateElementData(bool _autoFreeElementData = true);

  int
  Length() const;
  void
  Length(int _length);

  int
  NDims() const;
  void
  NDims(int _length);

  MET_ValueEnumType
  ElementType() const;
  void
  ElementType(MET_ValueEnumType _elementType);

  int
  ElementNumberOfChannels() const;
  void
  ElementNumberOfChannels(int _elementNumberOfChannels);

  void
  ElementByteOrderSwap();
  bool
  ElementByteOrderFix();

  //    ConverTo(...)
  //       Converts to a new data type
  bool
  ConvertElementDataTo(MET_ValueEnumType _toElementType,
                       double            _fromMin = 0,
                       double            _fromMax = 0,
                       double            _toMin = 0,
                       double            _toMax = 0);

  bool
  ImportBufferToElementData(const void *      _fromBuffer,
                            MET_ValueEnumType _fromElementType,
                            double            _fromMin = 0,
                            double            _fromMax = 0,
                            double            _toMin = 0,
                            double            _toMax = 0);

  bool
  AutoFreeElementData() const;
  void
  AutoFreeElementData(bool _autoFreeElementData);

  const char *
  ElementDataFileName() const;
  void
  ElementDataFileName(const char * _elementDataFileName);

  void *
  ElementData();
  double
  ElementData(int _i) const;
  void
  ElementData(void * _elementData, bool _arrayControlsElementData = false);
  bool
  ElementData(int _i, double _v);

  virtual bool
  CanRead(const char * _headerName = nullptr) const;

  virtual bool
  Read(const char * _headerName = nullptr,
       bool         _readElements = true,
       void *       _elementDataBuffer = nullptr,
       bool         _autoFreeElementData = false);

  virtual bool
  CanReadStream(std::ifstream * _stream) const;

  virtual bool
  ReadStream(std::ifstream * _stream,
             bool            _readElements = true,
             void *          _elementDataBuffer = nullptr,
             bool            _autoFreeElementData = false);

  virtual bool
  Write(const char * _headName = nullptr,
        const char * _dataName = nullptr,
        bool         _writeElements = true,
        const void * _constElementData = nullptr);

  virtual bool
  WriteStream(std::ofstream * _stream, bool _writeElements = true, const void * _constElementData = nullptr);

  // PROTECTED
protected:
  int m_Length{};

  MET_ValueEnumType m_ElementType;

  int m_ElementNumberOfChannels{};

  bool m_AutoFreeElementData;

  std::streamoff m_CompressedElementDataSize;

  std::string m_ElementDataFileName;

  void * m_ElementData;

  void
  M_ResetValues();

  void
  M_SetupReadFields() override;

  void
  M_SetupWriteFields() override;

  bool
  M_Read() override;

  bool
  M_ReadElements(std::ifstream * _fstream, void * _data, int _dataQuantity);

  bool
  M_WriteElements(std::ofstream * _fstream, const void * _data, std::streamoff _dataQuantity);
};

#  if (METAIO_USE_NAMESPACE)
};
#  endif

#endif