[Insight-developers] itkImageIOBase parent/child question

Miller, James V (CRD) millerjv@crd.ge.com
Fri, 2 Nov 2001 08:03:44 -0500


When you need the distance to the imaging device, scan rate, etc. You'll have to dynamic_cast<> the
ImageIOBase to the appropriate subclass.  That is the only way you'll be able to get access to
members that only exist in the subclass. 

Of course, this means that you'll need to know the suite of readers that could have the information
that you are requesting.


-----Original Message-----
From: Wilson Chang [mailto:wmcst6+@pitt.edu]
Sent: Wednesday, October 31, 2001 5:09 PM
To: insight-developers@public.kitware.com
Subject: [Insight-developers] itkImageIOBase parent/child question


I was wondering if someone knew of a solution to a problem that I have been
having.  Here is the scenerio:

class Parent
{
}

class Child1 : public Parent
{
private:
  int m_Child1data;
}

class Child2 : public Parent
{
private:
  float m_Child2data;
}


}main()
{
    Parent foo;
//some code that makes the foo of type Child1.
// foo must be of type Parent to be generic across all possible children
type
...
}//main()


    My question is, how can I go about getting access to members of a child,
when all the code really knows about is the parent?  i.e. how would I go
about getting m_Child1data if all the program knew about was the Parent
class?  Putting a "itkGetMacro(Child1Data, int)" in the Child1 class doesn't
work.  Any Ideas?

    The situation that I am running into involves file readers.  All of the
file readers inherit from ImageIOBase.  For example, I am working on the
itkVOLImageIO class.  I have some information loaded from the image file
pertaining to the image (i.e. patient information, distance the image is
away from the imaging device, scan rate...).  This information does not have
a place to be stored in the ImageIOBase class.  However, this information is
important for processing the image later downstream.  When a generic file
reader is created to load up the file:
 itk::ImageFileReader<myImage>::Pointer reader =
itk::ImageFileReader<myImage>::New();
but now I need access to information besides the pixel values, such as the
distance the image is away from the imaging device, scan rate, etc.  How can
I go about getting access to the information?

Wilson Chang

Univ of Pittsburgh MD/PhD program
School of Engineering-Bioengineering
School of Medicine

_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers