KWStyle - itkPathSource.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkPathSource.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:43 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17
18 DEF #ifndef _itkPathSource_h
19 DEF #define _itkPathSource_h
20
21 #include "itkProcessObject.h"
22 #include "itkPath.h"
23
24 namespace itk
25 {
26   
27 /** \class PathSource
28  *  \brief Base class for all process objects that output path data.
29  *
30  * PathSource is the base class for all process objects that output
31  * path data. Specifically, this class defines the GetOutput() method
32  * that returns a pointer to the output path. The class also defines
33  * some internal private data members that are used to manage streaming
34  * of data.
35  *
36  * \ingroup DataSources
37  * \ingroup Paths
38  */
39
40 template <class TOutputPath>
41 class ITK_EXPORT PathSource : public ProcessObject
42 {
43 public:
44   /** Standard class typedefs. */
45   typedef PathSource                Self;
46   typedef ProcessObject             Superclass;
47   typedef SmartPointer<Self>        Pointer;
48   typedef SmartPointer<const Self>  ConstPointer;
49   
50   /** Smart Pointer type to a DataObject. */
51   typedef DataObject::Pointer DataObjectPointer;
52   
53   /** Method for creation through the object factory. */
54   itkNewMacro(Self);
55   
56   /** Run-time type information (and related methods). */
57   itkTypeMacro(PathSource,ProcessObject);
58   
59   /** Some convenient typedefs. */
60   typedef TOutputPath                         OutputPathType;
61   typedef typename OutputPathType::Pointer    OutputPathPointer;
62   typedef typename OutputPathType::InputType  OutputPathInputType;
63   typedef typename OutputPathType::OutputType OutputPathOutputType;
64   typedef typename OutputPathType::IndexType  OutputPathIndexType;
65   typedef typename OutputPathType::OffsetType OutputPathOffsetType;
66   
67   /** Get the output data of this process object.  The output of this
68    * function is not valid until an appropriate Update() method has
69    * been called, either explicitly or implicitly.  Both the filter
70    * itself and the data object have Update() methods, and both
71    * methods update the data.  Here are three ways to use
72    * GetOutput() and make sure the data is valid.  In these
73    * examples, \a image is a pointer to some Image object, and the
74    * particular ProcessObjects involved are filters.  The same
75    * examples apply to non-image (e.g. Mesh) data as well.
76    *
77    * \code
78    *   anotherFilter->SetInput( someFilter->GetOutput() );
79    *   anotherFilter->Update();
80    * \endcode
81    *
82    * In this situation, \a someFilter and \a anotherFilter are said
83    * to constitute a \b pipeline.  
84    *
85    * \code
86    *   image = someFilter->GetOutput();
87    *   image->Update();
88    * \endcode
89    *
90    * \code
91    *   someFilter->Update();
92    *   image = someFilter->GetOutput();
93    * \endcode
94    * (In the above example, the two lines of code can be in
95    * either order.)
96    *
97    * Note that Update() is not called automatically except within a
98    * pipeline as in the first example.  When \b streaming (using a 
99    * StreamingImageFilter) is activated, it may be more efficient to
100    * use a pipeline than to call Update() once for each filter in
101    * turn.
102    *
103    * For an image, the data generated is for the requested
104    * Region, which can be set using ImageBase::SetRequestedRegion().
105    * By default, the largest possible region is requested.
106    */
107   OutputPathType * GetOutput(void);
108   OutputPathType * GetOutput(unsigned int idx);
109   
110   /** Graft the specified DataObject onto this ProcessObject's output.
111    * This method grabs a handle to the specified DataObject's path
112    * data to use as its output's own path data. It also copies the
113    * region ivars (RequestedRegion, BufferedRegion,
114    * LargestPossibleRegion) and meta-data (Spacing, Origin) from the
115    * specified data object into this filter's output data object. Most
116    * importantly, however, it leaves the Source ivar untouched so the
117    * original pipeline routing is intact. This method is used when a
118    * process object is implemented using a mini-pipeline which is
119    * defined in its GenerateData() method.  The usage is:
120    *
121    * \code
122    *    // setup the mini-pipeline to process the input to this filter
123    *    firstFilterInMiniPipeline->SetInput( this->GetInput() );
124    *
125    *    // setup the mini-pipeline to calculate the correct regions
126    *    // and write to the appropriate bulk data block
127    *    lastFilterInMiniPipeline->GraftOutput( this->GetOutput() );
128    *
129    *    // execute the mini-pipeline
130    *    lastFilterInMiniPipeline->Update();
131    *
132    *    // graft the mini-pipeline output back onto this filter's output.
133    *    // this is needed to get the appropriate regions passed back.
134    *    this->GraftOutput( lastFilterInMiniPipeline->GetOutput() );
135    * \endcode
136    *
137    * For proper pipeline execution, a filter using a mini-pipeline
138    * must implement the GeneratseInputRequestedRegion(),
139    * GenerateOutputRequestedRegion(), GenerateOutputInformation() and
140    * EnlargeOutputRequestedRegion() methods as necessary to reflect
141    * how the mini-pipeline will execute (in other words, the outer
142    * filter's pipeline mechanism must be consistent with what the
143    * mini-pipeline will do). */
144   // just calls GraftNthOutput()
145   virtual void GraftOutput(OutputPathType *output);
146
147   /** Graft the specified data object onto this ProcessObject's idx'th
148    * output. This is the similar to GraftOutput method except is
149    * allows you specify which output is affected. The specified index
150    * must be a valid output number (less than
151    * ProcessObject::GetNumberOfOutputs()). See the GraftOutput for
152    * general usage information. */
153   virtual void GraftNthOutput(unsigned int idx, OutputPathType *output);
154
155   /** Make a DataObject of the correct type to used as the specified
156    * output.  Every ProcessObject subclass must be able to create a
157    * DataObject that can be used as a specified output. This method
158    * is automatically called when DataObject::DisconnectPipeline() is
159    * called.  DataObject::DisconnectPipeline, disconnects a data object
160    * from being an output of its current source.  When the data object
161    * is disconnected, the ProcessObject needs to construct a replacement
162    * output data object so that the ProcessObject is in a valid state.
163    * So DataObject::DisconnectPipeline eventually calls
164    * ProcessObject::MakeOutput. Note that MakeOutput always returns a
165    * SmartPointer to a DataObject. If a subclass of ImageSource has
166    * multiple outputs of different types, then that class must provide
167    * an implementation of MakeOutput(). */
168   virtual DataObjectPointer MakeOutput(unsigned int idx);
169
170 protected:
171   PathSource();
172   virtual ~PathSource() {}
173   void PrintSelf(std::ostream& os, Indent indent) const;
174   
175   // Inherit the empty ProcessObject::GenerateData()
176   
177   // Inherit ProcessObject::PrepareOutputs(), which calls Initialize()
178   // (Image replaces w/ empty function)
179   
180 private:
181   PathSource(const Self&); //purposely not implemented
182   void operator=(const Self&);   //purposely not implemented
183 };
184
185 // end namespace itk
186
187 #ifndef ITK_MANUAL_INSTANTIATION
188 #include "itkPathSource.txx"
189 #endif
190
191 #endif
192

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:38PM
© Kitware Inc.