[Insight-developers] itkImageIOBase parent/child question

Stephen R. Aylward aylward@unc.edu
Wed, 31 Oct 2001 17:34:54 -0500


My 2 cents...

1) Maybe the base IO class needs to be expanded to include access to
info common to medical images.   However, we should only provide such
access for commonly used info, and we should have some way of checking
to see if default values or actual values from the file are being
returned by the call.   So, if a PNG file doesn't include voxel spacing,
should we assume a spacing of 1 and yet throw a flag that it is an
assumed value.

2) Regardless, there will be times that there is info in a fileformat
that isn't directly supported by the base reader - previously, we've
used data tags to get at such info.   That is, each filereader would
have a method that accepts a string and returns a pointer to the
corresponding data item if that data item is defined in the file being
read.   This is how dicom readers work.

So, that would mean having a function in the base class that always
returns a null pointer when a string is passed, and then specific file
readers can provide instances of that function as appropriate.   Perhaps
we should accept the DICOM standard dictionary for the string names?

s

Wilson Chang wrote:
> 
> 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

-- 
===============================================
Dr. Stephen R. Aylward
Assistant Professor of Radiology
Adjunct Assistant Professor of Computer Science
http://caddlab.rad.unc.edu
aylward@unc.edu
(919) 966-9695