File: igstkImageReader.h

package info (click to toggle)
igstk 4.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 38,980 kB
  • sloc: cpp: 86,267; xml: 96; makefile: 75; python: 38
file content (126 lines) | stat: -rwxr-xr-x 3,748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*=========================================================================

  Program:   Image Guided Surgery Software Toolkit
  Module:    $RCSfile: igstkImageReader.h,v $
  Language:  C++
  Date:      $Date: 2008-02-11 01:41:50 $
  Version:   $Revision: 1.7 $

  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __igstkImageReader_h
#define __igstkImageReader_h

#include "igstkMacros.h"
#include "igstkStateMachine.h"
#include "igstkObject.h"

#include "itkImageSpatialObject.h"

namespace igstk
{
 
namespace Friends 
{

/** \class ImageReaderToImageSpatialObject
 * 
 * \brief This class is intended to make the connection between the ImageReader
 * and its output, the ImageSpatialObject. 
 *
 * With this class it is possible to enforce encapsulation of the Reader and
 * the ImageSpatialObject, and make their GetImage() and SetImage() methods
 * private, so that developers cannot gain access to the ITK or VTK layers of
 * these two classes.
 *
 */
class ImageReaderToImageSpatialObject
{
public:

  template < class TReader, class TImageSpatialObject >
  static void 
  ConnectImage( const TReader * reader, 
                TImageSpatialObject * imageSpatialObject )
    {
    imageSpatialObject->RequestSetImage( reader->GetITKImage() );  
    }

}; // end of ImageReaderToImageSpatialObject class

} // end of Friend namespace


  
/** \class ImageReader
 * 
 * \brief This class is a base class for all image reader classes.
 * 
 * This class reads image data stored in files and outputs
 * image spatial object. This class is templated over pixeltype and dimension 
 * parameters
 *
 * \ingroup Object
 */
template < class TImageSpatialObject >
class ImageReader : public Object
{

public:

  /** Macro with standard traits declarations. */
  igstkStandardTemplatedAbstractClassTraitsMacro( ImageReader, Object )

public:

  /** Some convenient typedefs for input image */
  typedef TImageSpatialObject                   ImageSpatialObjectType;  

  /** Declare the ImageReaderToImageSpatialObject class to be a friend 
   *  in order to give it access to the private method GetITKImage(). */
  igstkFriendClassMacro( igstk::Friends::ImageReaderToImageSpatialObject );

protected:

  ImageReader();
  ~ImageReader();

  /** Print the object information in a stream. */
  void PrintSelf( std::ostream& os, ::itk::Indent indent ) const;

  /** Connect the ITK image to the output ImageSpatialObject */
  void ConnectImage();

  /** Some convenient typedefs for internal ITK image. 
   *  These types must not be exposed in the API of this class. */
  typedef typename ImageSpatialObjectType::ImageType  ImageType;
  typedef typename ImageType::ConstPointer            ImagePointer;
  typedef typename ImageType::RegionType              ImageRegionType; 

  typename ImageSpatialObjectType::Pointer   m_ImageSpatialObject;

private:
  
  /** These two methods must be declared and note be implemented
   *  in order to enforce the protocol of smart pointers. */
  ImageReader(const Self&);         //purposely not implemented
  void operator=(const Self&);      //purposely not implemented

  // FIXME : This must be replaced with StateMachine logic
  virtual const ImageType * GetITKImage() const = 0;

};

} // end namespace igstk

#ifndef IGSTK_MANUAL_INSTANTIATION
#include "igstkImageReader.txx"
#endif

#endif // __igstkImageReader_h