VAPoR  0.1
WaveletBlock3DRegionWriter.h
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 
5 
6 #ifndef _WavletBlock3DRegionWriter_h_
7 #define _WavletBlock3DRegionWriter_h_
8 
9 #include <vapor/MyBase.h>
10 #include "WaveletBlockIOBase.h"
11 
12 namespace VAPoR {
13 
14 //
23 //
25 
26 public:
27 
36  //
38  const MetadataVDC &metadata
39  );
40 
49  //
51  const string &metafile
52  );
53 
54  virtual ~WaveletBlock3DRegionWriter();
55 
56 
80  virtual int OpenVariableWrite(
81  size_t timestep,
82  const char *varname,
83  int reflevel = -1,
84  int lod = -1
85  );
86  virtual int OpenVariableRead(
87  size_t timestep,
88  const char *varname,
89  int reflevel = 0,
90  int lod = 0
91  ) {SetErrMsg("Operation not supported"); return(-1);};
92 
93 
94 
100  virtual int CloseVariable();
101 
117  //
118  int WriteRegion(
119  const float *region,
120  const size_t min[3], const size_t max[3]
121  );
122 
123  int WriteRegion(
124  const float *region
125  );
126 
127 
143  //
144  int BlockWriteRegion(
145  const float *region,
146  const size_t bmin[3], const size_t bmax[3],
147  int block = 1
148  );
149 
150 protected:
151 
152  void _GetDataRange(float range[2]) const;
153  void _GetValidRegion(size_t minreg[3], size_t maxreg[3]) const;
154 
155 private:
156 
157  float *_lambda_blks[MAX_LEVELS];
158  float *_lambda_tiles[MAX_LEVELS];
159  float *_padblock3d;
160  float *_padblock2d;
161  size_t _block_size;
162 
163  const float *_regionData; // Pointer to data passed to WriteRegion()
164  size_t _regMin[3];
165  size_t _regMax[3]; // coordinates (in voxels) of region relative to
166  // a super-block aligned enclosing region
167 
168  size_t _validRegMin[3];
169  size_t _validRegMax[3]; // Bounds (in voxels) of valid region relative
170  // to the finest level
171 
172 
173  size_t _volBMin[3];
174  size_t _volBMax[3]; // Bounds (in blocks) of subregion relative to
175  // the global volume
176  int _is_open; // open for writing
177 
178  float _dataRange[2]; // min and max range of data;
179 
180  bool _firstWrite; // True first time Write() is called for an open var
181 
182 
183  // Process a region that requies no transforms
184  //
185  int _WriteUntransformedRegion3D(
186  const size_t min[3],
187  const size_t max[3],
188  const float *region,
189  int block
190  );
191  int _WriteUntransformedRegion2D(
192  const size_t bs[2],
193  const size_t min[2],
194  const size_t max[2],
195  const float *region,
196  int block
197  );
198 
199 
200  // Copy a block-sized subvolume to a brick (block)
201  //
202  void brickit3d(
203  const float *srcptr, // ptr to start of volume containing subvolume
204  size_t nx, size_t ny, size_t nz, // dimensions of volume
205  size_t x, size_t y, size_t z, // voxel coordinates of subvolume
206  float *brickptr // brick destination
207  );
208 
209  // Copy a partial block-sized subvolume to a brick (block)
210  //
211  void brickit3d(
212  const float *srcptr, // ptr to start of volume containing subvolume
213  size_t nx, size_t ny, size_t nz, // dimensions of volume
214  size_t srcx,
215  size_t srcy,
216  size_t srcz, // voxel coordinates of subvolume
217  size_t dstx,
218  size_t dsty,
219  size_t dstz, // coordinates within brick (in voxles) for copy
220  float *brickptr // brick destination
221  );
222 
223  // Copy a tile-sized subvolume to a brick (tile)
224  //
225  void brickit2d(
226  const float *srcptr, // ptr to start of volume containing subvolume
227  const size_t bs[2],
228  size_t nx, size_t ny, // dimensions of volume
229  size_t x, size_t y, // voxel coordinates of subvolume
230  float *brickptr // brick destination
231  );
232 
233  // Copy a partial tile-sized subvolume to a brick (tile)
234  //
235  void brickit2d(
236  const float *srcptr, // ptr to start of volume containing subvolume
237  const size_t bs[2],
238  size_t nx, size_t ny, // dimensions of volume
239  size_t srcx,
240  size_t srcy, // voxel coordinates of subvolume
241  size_t dstx,
242  size_t dsty, // coordinates within brick (in voxles) for copy
243  float *brickptr // brick destination
244  );
245 
246 
247  void copy_top_superblock3d(
248  int srcx,
249  int srcy,
250  int srcz, // coordinates (in blocks) of superblock within
251  // superblock-aligned enclosing region.
252  float *dst_super_block // destination super block
253  );
254 
255  void copy_top_superblock2d(
256  const size_t bs[2],
257  int srcx,
258  int srcy, // coordinates (in tiles) of superblock within
259  // superblock-aligned enclosing region.
260  float *dst_super_block // destination super block
261  );
262 
263 
264  // Recursively coarsen a data octant
265  //
266  int process_octant(
267  size_t sz, // dimension of octant in blocks
268  int srcx,
269  int srcy,
270  int srcz, // Coordinates of octant (in blocks) relative to vol
271  int dstx,
272  int dsty,
273  int dstz, // Coordinates (in blocks) of subregion destination
274  int oct // octant indicator (0-7)
275  );
276 
277 
278  // Recursively coarsen a data quadrant
279  //
280  int process_quadrant(
281  size_t sz, // dimension of quadrant in tiles
282  int srcx,
283  int srcy, // Coordinates of quadrant (in tiles) relative to vol
284  int dstx,
285  int dsty, // Coordinates (in tiles) of subregion destination
286  int quad // quadrant indicator (0-3)
287  );
288 
289  // compute the min and max of a block
290  void compute_minmax3d(
291  const float *blkptr,
292  size_t bx, size_t by, size_t bz,
293  int level
294  );
295 
296  // compute the min and max of a tile
297  void compute_minmax2d(
298  const float *tileptr,
299  size_t bx, size_t by,
300  int level
301  );
302 
303  int my_alloc3d();
304  int my_alloc2d();
305  void my_free();
306 
307  int _WriteRegion3D(
308  const float *region,
309  const size_t min[3], const size_t max[3],
310  int block
311  );
312 
313  int _WriteRegion2D(
314  const float *region,
315  const size_t min[2],
316  const size_t max[2],
317  int block
318  );
319 
320  void _CloseVariable3D();
321  void _CloseVariable2D();
322 
323  int _WaveletBlock3DRegionWriter();
324 
325 };
326 
327 };
328 
329 #endif // _WavletBlock3DRegionWriter_h_
#define VDF_API
Definition: common.h:61
A class for managing data set metadata.
Definition: MetadataVDC.h:92
A subregion write for VDC files.
Performs data IO to VDF files.
virtual int OpenVariableRead(size_t timestep, const char *varname, int reflevel=0, int lod=0)