DGtal  1.5.beta
testImageFactoryFromHDF5.cpp
Go to the documentation of this file.
1 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/images/ImageSelector.h"
35 #include "DGtal/images/ImageFactoryFromHDF5.h"
36 #include "DGtal/images/ImageCache.h"
37 #include "DGtal/images/TiledImage.h"
38 
39 #include "ConfigTest.h"
41 
42 using namespace std;
43 using namespace DGtal;
44 
46 // Functions for testing class ImageFactoryFromHDF5.
48 
49 #define H5FILE_NAME "testImageFactoryFromHDF5.h5"
50 
51 #define DATASETNAME_2D "Int32Array2D"
52 #define NX_2D 6 // dataset dimensions
53 #define NY_2D 5
54 #define RANK_2D 2
55 
57 {
58  hid_t file, dataset; // file and dataset handles
59  hid_t datatype, dataspace; // handles
60  hsize_t dimsf[RANK_2D]; // dataset dimensions
61  herr_t status;
62  DGtal::int32_t data[NY_2D][NX_2D]; // data to write
63  int i, j;
64 
65  // Data and output buffer initialization.
66  for(j = 0; j < NY_2D; j++)
67  for(i = 0; i < NX_2D; i++)
68  data[j][i] = j + i;
69  /*
70  * 0 1 2 3 4 5
71  * 1 2 3 4 5 6
72  * 2 3 4 5 6 7
73  * 3 4 5 6 7 8
74  * 4 5 6 7 8 9
75  */
76 
77  /*
78  * Create a new file using H5F_ACC_TRUNC access,
79  * default file creation properties, and default file
80  * access properties.
81  */
82  file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
83 
84  // Describe the size of the array and create the data space for fixed size dataset.
85  dimsf[0] = NY_2D;
86  dimsf[1] = NX_2D;
87  dataspace = H5Screate_simple(RANK_2D, dimsf, NULL);
88 
89  /*
90  * Define datatype for the data in the file.
91  */
92  datatype = H5Tcopy(H5T_NATIVE_INT32);
93  status = H5Tset_order(datatype, H5T_ORDER_LE);
94 
95  /*
96  * Create a new dataset within the file using defined dataspace and
97  * datatype and default dataset creation properties.
98  */
99  dataset = H5Dcreate2(file, DATASETNAME_2D, datatype, dataspace,
100  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
101 
102  // Write the data to the dataset using default transfer properties.
103  status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
104  if (status)
105  {
106  trace.error() << " H5Dwrite error" << std::endl;
107  return false;
108  }
109 
110  // Close/release resources.
111  H5Sclose(dataspace);
112  H5Tclose(datatype);
113  H5Dclose(dataset);
114  H5Fclose(file);
115 
116  return true;
117 }
118 
119 #define DATASETNAME_2D_TILED "Int64Array2D"
120 #define RANK_2D_TILED 2
121 #define _NX_2D_TILED 16
122 #define _NY_2D_TILED 16
123 
124 bool writeHDF5_2D_TILED(const std::string & _H5FILE_NAME_2D_TILED)
125 {
126  hid_t file, dataset; // file and dataset handles
127  hid_t datatype, dataspace; // handles
128  hsize_t dimsf[RANK_2D_TILED]; // dataset dimensions
129  herr_t status;
130  DGtal::int64_t data[_NY_2D_TILED][_NX_2D_TILED]; // data to write
131  int i, j;
132 
133  int ii=1;
134  // Data and output buffer initialization.
135  for(j = 0; j < _NY_2D_TILED; j++)
136  for(i = 0; i < _NX_2D_TILED; i++)
137  data[j][i] = ii++;
138 
139  /*
140  * Create a new file using H5F_ACC_TRUNC access,
141  * default file creation properties, and default file
142  * access properties.
143  */
144  file = H5Fcreate(_H5FILE_NAME_2D_TILED.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
145 
146  // Describe the size of the array and create the data space for fixed size dataset.
147  dimsf[0] = _NY_2D_TILED;
148  dimsf[1] = _NX_2D_TILED;
149  dataspace = H5Screate_simple(RANK_2D_TILED, dimsf, NULL);
150 
151  /*
152  * Define datatype for the data in the file.
153  */
154  datatype = H5Tcopy(H5T_NATIVE_INT64);
155  status = H5Tset_order(datatype, H5T_ORDER_LE);
156 
157  /*
158  * Create a new dataset within the file using defined dataspace and
159  * datatype and default dataset creation properties.
160  */
161  dataset = H5Dcreate2(file, DATASETNAME_2D_TILED, datatype, dataspace,
162  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
163 
164  // Write the data to the dataset using default transfer properties.
165  status = H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
166  if (status)
167  {
168  trace.error() << " H5Dwrite error" << std::endl;
169  return false;
170  }
171 
172  // Close/release resources.
173  H5Sclose(dataspace);
174  H5Tclose(datatype);
175  H5Dclose(dataset);
176  H5Fclose(file);
177 
178  return true;
179 }
180 
181 #define H5FILE_NAME_3D_TILED_EASY_READING "testImageFactoryFromHDF5_TILED_3D_for_easy_reading.h5"
182 #define H5FILE_NAME_3D_TILED "testImageFactoryFromHDF5_TILED_3D.h5"
183 
184 #define DATASETNAME_3D_TILED "DoubleArray3D"
185 #define NX_3D_TILED 10 // dataset dimensions
186 #define NY_3D_TILED 8
187 #define NZ_3D_TILED 6
188 #define RANK_3D_TILED 3
189 
191 {
192  hid_t file, dataset; // file and dataset handles
193  hid_t datatype, dataspace; // handles
194  hsize_t dimsf[RANK_3D_TILED]; // dataset dimensions
195  herr_t status;
196  double data[NY_3D_TILED][NX_3D_TILED][NZ_3D_TILED]; // data to write
197  int i, j, k;
198 
199  int ii=1;
200  // Data and output buffer initialization.
201  for(k = 0; k < NZ_3D_TILED; k++)
202  for(j = 0; j < NY_3D_TILED; j++)
203  for(i = 0; i < NX_3D_TILED; i++)
204  data[j][i][k] = ii++;
205 
206  /*
207  * Create a new file using H5F_ACC_TRUNC access,
208  * default file creation properties, and default file
209  * access properties.
210  */
211  file = H5Fcreate(H5FILE_NAME_3D_TILED_EASY_READING, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
212 
213  // Describe the size of the array and create the data space for fixed size dataset.
214  dimsf[0] = NY_3D_TILED;
215  dimsf[1] = NX_3D_TILED;
216  dimsf[2] = NZ_3D_TILED;
217  dataspace = H5Screate_simple(RANK_3D_TILED, dimsf, NULL);
218 
219  /*
220  * Define datatype for the data in the file.
221  */
222  datatype = H5Tcopy(H5T_NATIVE_DOUBLE);
223  status = H5Tset_order(datatype, H5T_ORDER_LE);
224 
225  /*
226  * Create a new dataset within the file using defined dataspace and
227  * datatype and default dataset creation properties.
228  */
229  dataset = H5Dcreate2(file, DATASETNAME_3D_TILED, datatype, dataspace,
230  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
231 
232  // Write the data to the dataset using default transfer properties.
233  status = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
234  if (status)
235  {
236  trace.error() << " H5Dwrite error" << std::endl;
237  return false;
238  }
239 
240  // Close/release resources.
241  H5Sclose(dataspace);
242  H5Tclose(datatype);
243  H5Dclose(dataset);
244  H5Fclose(file);
245 
246  return true;
247 }
248 
250 {
251  hid_t file, dataset; // file and dataset handles
252  hid_t datatype, dataspace; // handles
253  hsize_t dimsf[RANK_3D_TILED]; // dataset dimensions
254  herr_t status;
255  double data[NZ_3D_TILED][NY_3D_TILED][NX_3D_TILED]; // data to write
256  int i, j, k;
257 
258  int ii=1;
259  // Data and output buffer initialization.
260  for(k = 0; k < NZ_3D_TILED; k++)
261  for(j = 0; j < NY_3D_TILED; j++)
262  for(i = 0; i < NX_3D_TILED; i++)
263  data[k][j][i] = ii++;
264 
265  /*
266  * Create a new file using H5F_ACC_TRUNC access,
267  * default file creation properties, and default file
268  * access properties.
269  */
270  file = H5Fcreate(H5FILE_NAME_3D_TILED, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
271 
272  // Describe the size of the array and create the data space for fixed size dataset.
273  dimsf[0] = NZ_3D_TILED;
274  dimsf[1] = NY_3D_TILED;
275  dimsf[2] = NX_3D_TILED;
276  dataspace = H5Screate_simple(RANK_3D_TILED, dimsf, NULL);
277 
278  /*
279  * Define datatype for the data in the file.
280  */
281  datatype = H5Tcopy(H5T_NATIVE_DOUBLE);
282  status = H5Tset_order(datatype, H5T_ORDER_LE);
283 
284  /*
285  * Create a new dataset within the file using defined dataspace and
286  * datatype and default dataset creation properties.
287  */
288  dataset = H5Dcreate2(file, DATASETNAME_3D_TILED, datatype, dataspace,
289  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
290 
291  // Write the data to the dataset using default transfer properties.
292  status = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
293  if (status)
294  {
295  trace.error() << " H5Dwrite error" << std::endl;
296  return false;
297  }
298 
299  // Close/release resources.
300  H5Sclose(dataspace);
301  H5Tclose(datatype);
302  H5Dclose(dataset);
303  H5Fclose(file);
304 
305  return true;
306 }
307 
309 {
310  unsigned int nbok = 0;
311  unsigned int nb = 0;
312 
313  trace.beginBlock("Testing ImageFactoryFromHDF5 (2D)");
314 
316 
317  // 1) ImageFactoryFromHDF5
318  typedef ImageFactoryFromHDF5<Image> MyImageFactoryFromHDF5;
319  MyImageFactoryFromHDF5 factImage(H5FILE_NAME, DATASETNAME_2D);
320 
321  typedef MyImageFactoryFromHDF5::OutputImage OutputImage;
322 
323  Z2i::Domain domain1(Z2i::Point(0,0), Z2i::Point(1,1));
324  OutputImage *image1 = factImage.requestImage(domain1);
325  OutputImage::ConstRange r1 = image1->constRange();
326  cout << "image1: "; std::copy( r1.begin(), r1.end(), std::ostream_iterator<int>(cout,", ") ); cout << endl;
327 
328  Z2i::Domain domain1b(Z2i::Point(0,0), Z2i::Point(2,2));
329  OutputImage *image1b = factImage.requestImage(domain1b);
330  OutputImage::ConstRange r1b = image1b->constRange();
331  cout << "image1b: "; std::copy( r1b.begin(), r1b.end(), std::ostream_iterator<int>(cout,", ") ); cout << endl;
332 
333  Z2i::Domain domain2(Z2i::Point(2,0), Z2i::Point(3,1));
334  OutputImage *image2 = factImage.requestImage(domain2);
335  OutputImage::ConstRange r2 = image2->constRange();
336  cout << "image2: "; std::copy( r2.begin(), r2.end(), std::ostream_iterator<int>(cout,", ") ); cout << endl;
337 
338  Z2i::Domain domain3(Z2i::Point(0,2), Z2i::Point(1,3));
339  OutputImage *image3 = factImage.requestImage(domain3);
340  OutputImage::ConstRange r3 = image3->constRange();
341  cout << "image3: "; std::copy( r3.begin(), r3.end(), std::ostream_iterator<int>(cout,", ") ); cout << endl;
342 
343  Z2i::Domain domain4(Z2i::Point(2,2), Z2i::Point(3,3));
344  OutputImage *image4 = factImage.requestImage(domain4);
345  OutputImage::ConstRange r4 = image4->constRange();
346  cout << "image4: "; std::copy( r4.begin(), r4.end(), std::ostream_iterator<int>(cout,", ") ); cout << endl;
347 
348  Z2i::Domain domain5(Z2i::Point(3,2), Z2i::Point(5,4));
349  OutputImage *image5 = factImage.requestImage(domain5);
350  OutputImage::ConstRange r5 = image5->constRange();
351  cout << "image5: "; std::copy( r5.begin(), r5.end(), std::ostream_iterator<int>(cout,", ") ); cout << endl;
352 
353  // 2) ImageCache with DGtal::CACHE_READ_POLICY_LAST, DGtal::CACHE_WRITE_POLICY_WT
354  trace.info() << endl << "ImageCache with DGtal::CACHE_READ_POLICY_LAST, DGtal::CACHE_WRITE_POLICY_WT" << endl;
355 
356  typedef ImageCacheReadPolicyLAST<OutputImage, MyImageFactoryFromHDF5> MyImageCacheReadPolicyLAST;
357  typedef ImageCacheWritePolicyWT<OutputImage, MyImageFactoryFromHDF5> MyImageCacheWritePolicyWT;
358  MyImageCacheReadPolicyLAST imageCacheReadPolicyLAST(factImage);
359  MyImageCacheWritePolicyWT imageCacheWritePolicyWT(factImage);
360 
362  MyImageCache imageCache(factImage, imageCacheReadPolicyLAST, imageCacheWritePolicyWT);
363  OutputImage::Value aValue;
364 
365  trace.info() << "READING from cache (empty cache): " << imageCache << endl;
366  if (imageCache.read(Z2i::Point(2,2), aValue))
367  trace.info() << "READ: Point 2,2 is in an image from cache, value: " << aValue << endl;
368  else
369  trace.info() << "READ: Point 2,2 is not in an image from cache." << endl;
370  nbok += (imageCache.read(Z2i::Point(2,2), aValue) == false) ? 1 : 0;
371  nb++;
372 
373  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
374 
375  imageCache.update(domain1); // image1
376 
377  trace.info() << "READING from cache (not empty but wrong domain): " << imageCache << endl;
378  if (imageCache.read(Z2i::Point(2,2), aValue))
379  trace.info() << "READ: Point 2,2 is in an image from cache, value: " << aValue << endl;
380  else
381  trace.info() << "READ: Point 2,2 is not in an image from cache." << endl;
382  nbok += (imageCache.read(Z2i::Point(2,2), aValue) == false) ? 1 : 0;
383  nb++;
384 
385  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
386 
387  imageCache.update(domain4); // image4
388 
389  trace.info() << "READING from cache (not empty but good domain): " << imageCache << endl;
390  if (imageCache.read(Z2i::Point(2,2), aValue))
391  trace.info() << "READ: Point 2,2 is in an image from cache, value: " << aValue << endl;
392  else
393  trace.info() << "READ: Point 2,2 is not in an image from cache." << endl;
394  nbok += ( (imageCache.read(Z2i::Point(2,2), aValue) && (aValue == 4)) == true ) ? 1 : 0;
395  nb++;
396 
397  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
398 
399  trace.info() << "WRITING from cache (not empty but good domain): " << imageCache << endl;
400  aValue = 22;
401  if (imageCache.write(Z2i::Point(2,2), aValue))
402  trace.info() << "WRITE: Point 2,2 is in an image from cache, value: " << aValue << endl;
403  else
404  trace.info() << "WRITE: Point 2,2 is not in an image from cache." << endl;
405  nbok += ( (imageCache.read(Z2i::Point(2,2), aValue) && (aValue == 22)) == true ) ? 1 : 0;
406  nb++;
407 
408  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
409 
410  imageCache.update(domain3); // image3
411 
412  trace.info() << "WRITING from cache (not empty but wrong domain): " << imageCache << endl;
413  aValue = 22;
414  if (imageCache.write(Z2i::Point(2,2), aValue))
415  trace.info() << "WRITE: Point 2,2 is in an image from cache, value: " << aValue << endl;
416  else
417  trace.info() << "WRITE: Point 2,2 is not in an image from cache." << endl;
418  nbok += (imageCache.read(Z2i::Point(2,2), aValue) == false) ? 1 : 0;
419  nb++;
420 
421  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
422 
423  imageCache.update(domain1); // image1
424 
425  trace.info() << "WRITING from cache (not empty but good domain): " << imageCache << endl;
426  aValue = 7;
427  if (imageCache.write(Z2i::Point(0,0), aValue))
428  trace.info() << "WRITE: Point 0,0 is in an image from cache, value: " << aValue << endl;
429  else
430  trace.info() << "WRITE: Point 0,0 is not in an image from cache." << endl;
431  nbok += ( (imageCache.read(Z2i::Point(0,0), aValue) && (aValue == 7)) == true ) ? 1 : 0;
432  nb++;
433 
434  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
435 
436  trace.endBlock();
437 
438  return nbok == nb;
439 }
440 
442 {
443  unsigned int nbok = 0;
444  unsigned int nb = 0;
445 
446  trace.beginBlock("Testing TiledImage with ImageFactoryFromHDF5 (2D)");
447 
449 
450  typedef ImageFactoryFromHDF5<Image> MyImageFactoryFromHDF5;
451  MyImageFactoryFromHDF5 factImage("testImageFactoryFromHDF5_TILED_2D.h5", DATASETNAME_2D_TILED);
452 
453  typedef MyImageFactoryFromHDF5::OutputImage OutputImage;
454 
455  typedef ImageCacheReadPolicyFIFO<OutputImage, MyImageFactoryFromHDF5> MyImageCacheReadPolicyFIFO;
456  typedef ImageCacheWritePolicyWT<OutputImage, MyImageFactoryFromHDF5> MyImageCacheWritePolicyWT;
457  MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO(factImage, 2);
458  MyImageCacheWritePolicyWT imageCacheWritePolicyWT(factImage);
459 
461  BOOST_CONCEPT_ASSERT(( concepts::CImage< MyTiledImage > ));
462  MyTiledImage tiledImage(factImage, imageCacheReadPolicyFIFO, imageCacheWritePolicyWT, 4);
463 
464  typedef MyTiledImage::OutputImage OutputImage;
465  OutputImage::Value aValue;
466 
467  trace.info() << "Read value for Point 3,1: " << tiledImage(Z2i::Point(3,1)) << endl;
468  nbok += (tiledImage(Z2i::Point(3,1)) == 20) ? 1 : 0;
469  nb++;
470 
471  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
472 
473  trace.info() << "Read value for Point 9,5: " << tiledImage(Z2i::Point(9,5)) << endl;
474  nbok += (tiledImage(Z2i::Point(9,5)) == 90) ? 1 : 0;
475  nb++;
476 
477  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
478 
479  aValue = 1; tiledImage.setValue(Z2i::Point(10,6), aValue);
480  trace.info() << "Write value for Point 10,6: " << aValue << endl;
481  nbok += (tiledImage(Z2i::Point(10,6)) == 1) ? 1 : 0;
482  nb++;
483 
484  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
485 
486  trace.info() << "Read value for Point 1,2: " << tiledImage(Z2i::Point(1,2)) << endl;
487  nbok += (tiledImage(Z2i::Point(1,2)) == 34) ? 1 : 0;
488  nb++;
489 
490  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
491 
492  trace.info() << "Read value for Point 15,0: " << tiledImage(Z2i::Point(15,0)) << endl;
493  nbok += (tiledImage(Z2i::Point(15,0)) == 16) ? 1 : 0;
494  nb++;
495 
496  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
497 
498  aValue = 128; tiledImage.setValue(Z2i::Point(15,0), aValue);
499  trace.info() << "Write value for Point 15,0: " << aValue << endl;
500  nbok += (tiledImage(Z2i::Point(15,0)) == 128) ? 1 : 0;
501  nb++;
502 
503  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
504 
505  trace.endBlock();
506 
507  return nbok == nb;
508 }
509 
511 {
512  unsigned int nbok = 0;
513  unsigned int nb = 0;
514 
515  trace.beginBlock("Testing TiledImage with ImageFactoryFromHDF5 (3D)");
516 
518 
519  typedef ImageFactoryFromHDF5<Image> MyImageFactoryFromHDF5;
520  MyImageFactoryFromHDF5 factImage(H5FILE_NAME_3D_TILED, DATASETNAME_3D_TILED);
521 
522  typedef MyImageFactoryFromHDF5::OutputImage OutputImage;
523 
524  typedef ImageCacheReadPolicyFIFO<OutputImage, MyImageFactoryFromHDF5> MyImageCacheReadPolicyFIFO;
525  typedef ImageCacheWritePolicyWT<OutputImage, MyImageFactoryFromHDF5> MyImageCacheWritePolicyWT;
526  MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO(factImage, 2);
527  MyImageCacheWritePolicyWT imageCacheWritePolicyWT(factImage);
528 
530  BOOST_CONCEPT_ASSERT(( concepts::CImage< MyTiledImage > ));
531  MyTiledImage tiledImage(factImage, imageCacheReadPolicyFIFO, imageCacheWritePolicyWT, 2);
532 
533  typedef MyTiledImage::OutputImage OutputImage;
534  OutputImage::Value aValue;
535 
536  trace.info() << "Read value for Point 0,0,0: " << tiledImage(Z3i::Point(0,0,0)) << endl;
537  nbok += (tiledImage(Z3i::Point(0,0,0)) == 1) ? 1 : 0;
538  nb++;
539 
540  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
541 
542  trace.info() << "Read value for Point 3,1,0: " << tiledImage(Z3i::Point(3,1,0)) << endl;
543  nbok += (tiledImage(Z3i::Point(3,1,0)) == 14) ? 1 : 0;
544  nb++;
545 
546  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
547 
548  trace.info() << "Read value for Point 9,5,2: " << tiledImage(Z3i::Point(9,5,2)) << endl;
549  nbok += (tiledImage(Z3i::Point(9,5,2)) == 220) ? 1 : 0;
550  nb++;
551 
552  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
553 
554  aValue = 1.1; tiledImage.setValue(Z3i::Point(3,6,5), aValue);
555  trace.info() << "Write value for Point 3,6,5: " << aValue << endl;
556  nbok += (tiledImage(Z3i::Point(3,6,5)) == 1.1) ? 1 : 0;
557  nb++;
558 
559  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
560 
561  trace.info() << "Read value for Point 1,2,4: " << tiledImage(Z3i::Point(1,2,4)) << endl;
562  nbok += (tiledImage(Z3i::Point(1,2,4)) == 342) ? 1 : 0;
563  nb++;
564 
565  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
566 
567  trace.info() << "Read value for Point 8,6,3: " << tiledImage(Z3i::Point(8,6,3)) << endl;
568  nbok += (tiledImage(Z3i::Point(8,6,3)) == 309) ? 1 : 0;
569  nb++;
570 
571  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
572 
573  aValue = 125.5; tiledImage.setValue(Z3i::Point(8,6,3), aValue);
574  trace.info() << "Write value for Point 8,6,3: " << aValue << endl;
575  nbok += (tiledImage(Z3i::Point(8,6,3)) == 125.5) ? 1 : 0;
576  nb++;
577 
578  trace.info() << "(" << nbok << "/" << nb << ") " << endl;
579 
580  trace.endBlock();
581 
582  return nbok == nb;
583 }
584 
586 // Standard services - public :
587 
588 int main( int argc, char** argv )
589 {
590  trace.beginBlock ( "Testing class ImageFactoryFromHDF5" );
591  trace.info() << "Args:";
592  for ( int i = 0; i < argc; ++i )
593  trace.info() << " " << argv[ i ];
594  trace.info() << endl;
595 
596  bool res = true;
597  res = res && writeHDF5_2D() && test2D_int32();
598 
599  res = res && writeHDF5_2D_TILED("testImageFactoryFromHDF5_TILED_2D.h5") && testTiledImage2D_int64();
600 
602  res = res && writeHDF5_3D_TILED();
603  res = res && testTiledImage3D_double();
604 
605  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
606  trace.endBlock();
607  return res ? 0 : 1;
608 }
609 // //
Aim: implements a 'FIFO' read policy cache.
Aim: implements a 'LAST' read policy cache.
Aim: implements a 'WT (Write-through)' write policy cache.
Aim: implements an images cache with 'read and write' policies.
Definition: ImageCache.h:78
Aim: implements a factory from an HDF5 file.
Aim: implements a tiled image from a "bigger/original" one from an ImageFactory.
Definition: TiledImage.h:77
std::ostream & error()
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74
Trace trace
Definition: Common.h:153
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:103
#define RANK_2D_TILED
bool writeHDF5_3D_TILED_for_easy_reading()
bool writeHDF5_2D_TILED(const std::string &_H5FILE_NAME_2D_TILED)
#define _NY_2D_TILED
#define DATASETNAME_3D_TILED
#define _NX_2D_TILED
int main(int argc, char **argv)
bool writeHDF5_3D_TILED()
#define NZ_3D_TILED
bool testTiledImage2D_int64()
bool testTiledImage3D_double()
#define H5FILE_NAME_3D_TILED_EASY_READING
#define DATASETNAME_2D
bool writeHDF5_2D()
#define H5FILE_NAME_3D_TILED
#define RANK_2D
#define RANK_3D_TILED
#define NX_2D
#define NY_2D
bool test2D_int32()
#define NX_3D_TILED
#define NY_3D_TILED
#define H5FILE_NAME
#define DATASETNAME_2D_TILED
ImageContainerBySTLVector< Domain, Value > Image
Image::ConstRange ConstRange