Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis12/src/lib/common/image.c
ViewVC logotype

Diff of /branches/vis12/src/lib/common/image.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2708, Sat Sep 20 18:46:49 2014 UTC revision 2709, Sat Sep 20 19:31:47 2014 UTC
# Line 292  Line 292 
292      return (nin->axis[i].kind != nrrdKindSpace);      return (nin->axis[i].kind != nrrdKindSpace);
293  }  }
294    
295  Status_t Diderot_SetImage1D (WorldPrefix_t *wrld, const Nrrd *nin, Diderot_image1D_t **imgOut)  bool Diderot_SetImage1D (WorldPrefix_t *wrld, const Nrrd *nin, Diderot_image1D_t **imgOut)
296  {  {
297      Diderot_image1D_t *img = (Diderot_image1D_t *)malloc(sizeof(Diderot_image1D_t));      Diderot_image1D_t *img = (Diderot_image1D_t *)malloc(sizeof(Diderot_image1D_t));
298    
# Line 303  Line 303 
303    // check that the image format is what we expect    // check that the image format is what we expect
304      if (nin->spaceDim != 1) {      if (nin->spaceDim != 1) {
305          Diderot_Error (wrld, "nrrd has unexpected dimension %d, expected 1\n", nin->spaceDim);          Diderot_Error (wrld, "nrrd has unexpected dimension %d, expected 1\n", nin->spaceDim);
306          return DIDEROT_FAIL;          return true;
307      }      }
308      else if (CheckAxis(nin, base)) {      else if (CheckAxis(nin, base)) {
309          Diderot_Error (wrld, "nrrd has unexpected axis structure: %s\n",          Diderot_Error (wrld, "nrrd has unexpected axis structure: %s\n",
310              airEnumStr(nrrdKind, nin->axis[base].kind));              airEnumStr(nrrdKind, nin->axis[base].kind));
311          return DIDEROT_FAIL;          return true;
312      }      }
313    
314      img->dim = 1;      img->dim = 1;
# Line 328  Line 328 
328    
329      *imgOut = img;      *imgOut = img;
330    
331      return DIDEROT_OK;      return false;
332  }  }
333    
334  /* load image data from Nrrd files */  /* load image data from Nrrd files */
335  Status_t Diderot_LoadImage1D (WorldPrefix_t *wrld, const char *name, Diderot_image1D_t **imgOut)  bool Diderot_LoadImage1D (WorldPrefix_t *wrld, const char *name, Diderot_image1D_t **imgOut)
336  {  {
337      Nrrd *nin = Diderot_LoadNrrdFile (wrld, name);      Nrrd *nin = Diderot_LoadNrrdFile (wrld, name);
338      if (nin == 0)      if (nin == 0)
339          return DIDEROT_FAIL;          return true;
340      else {      else {
341          Status_t sts = Diderot_SetImage1D (wrld, nin, imgOut);          bool sts = Diderot_SetImage1D (wrld, nin, imgOut);
342          nrrdNix (nin);          nrrdNix (nin);
343          return sts;          return sts;
344      }      }
345  }  }
346    
347  /* free image */  /* free image */
348  Status_t Diderot_FreeImage1D (WorldPrefix_t *wrld, Diderot_image1D_t **imgOut)  bool Diderot_FreeImage1D (WorldPrefix_t *wrld, Diderot_image1D_t **imgOut)
349  {  {
350      FREE ((*imgOut)->data);      FREE ((*imgOut)->data);
351      FREE (*imgOut);      FREE (*imgOut);
352      return DIDEROT_OK;      return false;
353  }  }
354    
355  Status_t Diderot_SetImage2D (WorldPrefix_t *wrld, const Nrrd *nin, Diderot_image2D_t **imgOut)  bool Diderot_SetImage2D (WorldPrefix_t *wrld, const Nrrd *nin, Diderot_image2D_t **imgOut)
356  {  {
357      Diderot_image2D_t *img = (Diderot_image2D_t *)malloc(sizeof(Diderot_image2D_t));      Diderot_image2D_t *img = (Diderot_image2D_t *)malloc(sizeof(Diderot_image2D_t));
358    
# Line 362  Line 362 
362    // check that the image format is what we expect    // check that the image format is what we expect
363      if (nin->spaceDim != 2) {      if (nin->spaceDim != 2) {
364          Diderot_Error (wrld, "nrrd has unexpected dimension %d, expected 2\n", nin->spaceDim);          Diderot_Error (wrld, "nrrd has unexpected dimension %d, expected 2\n", nin->spaceDim);
365          return DIDEROT_FAIL;          return true;
366      }      }
367      else if (CheckAxis(nin, base) || CheckAxis(nin, base+1)) {      else if (CheckAxis(nin, base) || CheckAxis(nin, base+1)) {
368          Diderot_Error (wrld, "nrrd has unexpected axis structure: %s %s\n",          Diderot_Error (wrld, "nrrd has unexpected axis structure: %s %s\n",
369              airEnumStr(nrrdKind, nin->axis[base].kind),              airEnumStr(nrrdKind, nin->axis[base].kind),
370              airEnumStr(nrrdKind, nin->axis[base+1].kind));              airEnumStr(nrrdKind, nin->axis[base+1].kind));
371          return DIDEROT_FAIL;          return true;
372      }      }
373    
374      img->dim = 2;      img->dim = 2;
# Line 406  Line 406 
406    
407      *imgOut = img;      *imgOut = img;
408    
409      return DIDEROT_OK;      return false;
410  }  }
411    
412  /* load image data from Nrrd files */  /* load image data from Nrrd files */
413  Status_t Diderot_LoadImage2D (WorldPrefix_t *wrld, const char *name, Diderot_image2D_t **imgOut)  bool Diderot_LoadImage2D (WorldPrefix_t *wrld, const char *name, Diderot_image2D_t **imgOut)
414  {  {
415      Nrrd *nin = Diderot_LoadNrrdFile (wrld, name);      Nrrd *nin = Diderot_LoadNrrdFile (wrld, name);
416      if (nin == 0)      if (nin == 0)
417          return DIDEROT_FAIL;          return true;
418      else {      else {
419          Status_t sts = Diderot_SetImage2D (wrld, nin, imgOut);          bool sts = Diderot_SetImage2D (wrld, nin, imgOut);
420          nrrdNix (nin);          nrrdNix (nin);
421          return sts;          return sts;
422      }      }
423  }  }
424    
425  /* free image */  /* free image */
426  Status_t Diderot_FreeImage2D (WorldPrefix_t *wrld, Diderot_image2D_t **imgOut)  bool Diderot_FreeImage2D (WorldPrefix_t *wrld, Diderot_image2D_t **imgOut)
427  {  {
428      FREE ((*imgOut)->data);      FREE ((*imgOut)->data);
429      FREE (*imgOut);      FREE (*imgOut);
430      return DIDEROT_OK;      return false;
431  }  }
432    
433  Status_t Diderot_SetImage3D (WorldPrefix_t *wrld, const Nrrd *nin, Diderot_image3D_t **imgOut)  bool Diderot_SetImage3D (WorldPrefix_t *wrld, const Nrrd *nin, Diderot_image3D_t **imgOut)
434  {  {
435    // compute the offset to the first space axis    // compute the offset to the first space axis
436      int base = nin->dim - nin->spaceDim;      int base = nin->dim - nin->spaceDim;
# Line 438  Line 438 
438    // check that the image format is what we expect    // check that the image format is what we expect
439      if (nin->spaceDim != 3) {      if (nin->spaceDim != 3) {
440          Diderot_Error (wrld, "nrrd has unexpected dimension %d, expected 3\n", nin->spaceDim);          Diderot_Error (wrld, "nrrd has unexpected dimension %d, expected 3\n", nin->spaceDim);
441          return DIDEROT_FAIL;          return true;
442      }      }
443      else if (CheckAxis(nin, base) || CheckAxis(nin, base+1) || CheckAxis(nin, base+2)) {      else if (CheckAxis(nin, base) || CheckAxis(nin, base+1) || CheckAxis(nin, base+2)) {
444          Diderot_Error (wrld, "nrrd has unexpected axis structure: %s %s %s\n",          Diderot_Error (wrld, "nrrd has unexpected axis structure: %s %s %s\n",
445              airEnumStr(nrrdKind, nin->axis[base].kind),              airEnumStr(nrrdKind, nin->axis[base].kind),
446              airEnumStr(nrrdKind, nin->axis[base+1].kind),              airEnumStr(nrrdKind, nin->axis[base+1].kind),
447              airEnumStr(nrrdKind, nin->axis[base+2].kind));              airEnumStr(nrrdKind, nin->axis[base+2].kind));
448          return DIDEROT_FAIL;          return true;
449      }      }
450    
451      Diderot_image3D_t *img = (Diderot_image3D_t *)malloc(sizeof(Diderot_image3D_t));      Diderot_image3D_t *img = (Diderot_image3D_t *)malloc(sizeof(Diderot_image3D_t));
# Line 486  Line 486 
486    
487      *imgOut = img;      *imgOut = img;
488    
489      return DIDEROT_OK;      return false;
490  }  }
491    
492  /* load image data from Nrrd files */  /* load image data from Nrrd files */
493  Status_t Diderot_LoadImage3D (WorldPrefix_t *wrld, const char *name, Diderot_image3D_t **imgOut)  bool Diderot_LoadImage3D (WorldPrefix_t *wrld, const char *name, Diderot_image3D_t **imgOut)
494  {  {
495      Nrrd *nin = Diderot_LoadNrrdFile (wrld, name);      Nrrd *nin = Diderot_LoadNrrdFile (wrld, name);
496      if (nin == 0)      if (nin == 0)
497          return DIDEROT_FAIL;          return true;
498      else {      else {
499          Status_t sts = Diderot_SetImage3D (wrld, nin, imgOut);          bool sts = Diderot_SetImage3D (wrld, nin, imgOut);
500          nrrdNix (nin);          nrrdNix (nin);
501          return sts;          return sts;
502      }      }
503  }  }
504    
505  /* free image */  /* free image */
506  Status_t Diderot_FreeImage3D (WorldPrefix_t *wrld, Diderot_image3D_t **imgOut)  bool Diderot_FreeImage3D (WorldPrefix_t *wrld, Diderot_image3D_t **imgOut)
507  {  {
508      FREE ((*imgOut)->data);      FREE ((*imgOut)->data);
509      FREE (*imgOut);      FREE (*imgOut);
510      return DIDEROT_OK;      return false;
511  }  }

Legend:
Removed from v.2708  
changed lines
  Added in v.2709

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0