[Insight-developers] TImage::ImageDimension

Luis Ibanez ibanez at cs.unc.edu
Fri Oct 27 11:06:09 EDT 2000


Hi,

Looking closer into the problem of using ImageDimension,
there are some funny facts:

1) In VC++ 6.0 this produce  a warning, not an error

2) The warning doesn't appears with gcc,  maybe
     because gcc doesn't complain about zero
    size arrays being declared  like:    int m[0];

3)  In spite of the warning,...
      the code runs ok  with gcc and VC++.

------

This is a minimal example of the similar situation.
Here, a short "Image" class is used, just to isolate
the code from the rest of Insight, so the attached
file is self-contained.

The output of the program shows that the dimension
of the image created inside the process object is
really 3 as expected.

I will speculate that this is due to the different aspects
of the code that are checked during the several compiler
passes.  Perhaps enums are initialized after array sizes
are checked....



Luis


==================================

#include <iostream>

//--------------------------------
// Image Class
//--------------------------------
template <class T, unsigned int N>
class Image {
public:
  enum { ImageDimension = N };
  typedef Image * Pointer;
private:
  unsigned int Index[N];
};


//--------------------------------
// Process Class
//--------------------------------
template <class TImage>
class myProcess {
  typedef Image<int, TImage::ImageDimension> TempImage;
  typename TempImage::Pointer temp;
public:
  myProcess() {
    std::cout << "image dimension = ";
    std::cout <<  TempImage::ImageDimension << std::endl;
  }
};

//--------------------------------
// Main
//--------------------------------
int main()
{
  typedef Image<float,3> myImageType;
  myProcess<myImageType> process;
  return 0;
}




--
______________________________________________________________________

Luis Ibanez
Research Assistant Professor - Division of Neurosurgery
University of North Carolina at Chapel Hill
CB# 7060, Chapel Hill, NC 27599
email : ibanez at cs.unc.edu       home  : http://www.cs.unc.edu/~ibanez
phone : (919)-843-9961          fax   : (919)-966-6627
______________________________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reuseImageDimension.cxx.gz
Type: application/x-gzip
Size: 349 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20001027/f8b47d04/attachment.bin>


More information about the Insight-developers mailing list