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

SCM Repository

[diderot] Diff of /branches/vis15/src/lib/common/world.cxx
ViewVC logotype

Diff of /branches/vis15/src/lib/common/world.cxx

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

branches/vis15/src/lib/common/util.cxx revision 3984, Thu Jun 16 18:14:31 2016 UTC branches/vis15/src/lib/common/world.cxx revision 3987, Fri Jun 17 03:08:25 2016 UTC
# Line 1  Line 1 
1  /*! \file util.cxx  /*! \file world.cxx
2   *   *
3   * \author John Reppy   * \author John Reppy
4   */   */
# Line 11  Line 11 
11   */   */
12    
13  #include <cstdlib>  #include <cstdlib>
 #include "diderot/image.hxx"  
14  #include "diderot/world.hxx"  #include "diderot/world.hxx"
15  #include <teem/biff.h>  #include "diderot/nrrd-inst.hxx"
16    
17  namespace diderot {  namespace diderot {
18    
19        //! Check that a nrrd has the expected structure for loading into a dynamic sequence
20        //! \param nin the nrrd to check
21        //! \param nDims the number of dimensions in the sequence elements
22        //! \param dims the array of sequence element dimensions
23        //! \return the number of values per element, or zero on error
24        uint32_t world_base::check_nrrd (Nrrd *nin, uint32_t nDims, uint32_t *dims)
25        {
26          // compute the expected number of values per sequence element
27            uint32_t nValuesPerElem = 1;
28            for (uint32_t i = 0;  i < nDims;  i++) {
29                nValuesPerElem *= dims[i];
30            }
31    
32          // check the structure of the nrrd file
33            if (nin->spaceDim != 0) {
34                this->error ("unexpected number of axes in nrrd; expected 0, found %d\n",
35                    nin->spaceDim);
36                return 0;
37            }
38            if (nin->dim - 1 != nDims) {
39                this->error ("unexpected nrrd dimension; expected %d, found %d\n",
40                    nDims, nin->dim-1);
41                return 0;
42            }
43            for (unsigned int i = 0;  i < nDims;  i++) {
44                if (dims[i] != nin->axis[i].size) {
45                    this->error ("nrrd axis %d does not match expected dimension: %d != %d\n",
46                        i+1, dims[i], nin->axis[i].size);
47                    return 0;
48                }
49            }
50            if (__details::nrrd_type_info[nin->type].sizeb == 0) {
51                this->error ("bogus element type %d in nrrd\n", nin->type);
52                return 0;
53            }
54    
55            return nValuesPerElem;
56        }
57    
58  Nrrd *world_base::load_nrrd_file (std::string const &filename)  Nrrd *world_base::load_nrrd_file (std::string const &filename)
59  {  {
60    /* create a nrrd; at this point it is just an empty container */    /* create a nrrd; at this point it is just an empty container */
# Line 48  Line 86 
86      biffMsgAdd (this->_errors, buf);      biffMsgAdd (this->_errors, buf);
87  }  }
88    
   
89  } // namespace Diderot  } // namespace Diderot

Legend:
Removed from v.3984  
changed lines
  Added in v.3987

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