| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkMeshSource.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:42 $ |
| 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 |
|
Portions of this code are covered under the VTK copyright. |
| 13 |
|
See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. |
| 14 |
|
|
| 15 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 16 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 17 |
IND |
*****PURPOSE. See the above copyright notices for more information. |
| 18 |
|
|
| 19 |
|
=========================================================================*/ |
| 20 |
|
#ifndef __itkMeshSource_h |
| 21 |
|
#define __itkMeshSource_h |
| 22 |
|
|
| 23 |
|
#if defined(_MSC_VER) |
| 24 |
|
#pragma warning ( disable : 4786 ) |
| 25 |
|
#endif |
| 26 |
|
#include "itkProcessObject.h" |
| 27 |
|
|
| 28 |
|
namespace itk |
| 29 |
|
{ |
| 30 |
|
|
| 31 |
|
/** \class MeshSource |
| 32 |
|
* \brief Base class for all process objects that output mesh data. |
| 33 |
|
* |
| 34 |
|
* MeshSource is the base class for all process objects that output |
| 35 |
|
* mesh data. Specifically, this class defines the GetOutput() method |
| 36 |
|
* that returns a pointer to the output mesh. The class also defines |
| 37 |
|
* some internal private data members that are used to manage streaming |
| 38 |
|
* of data. |
| 39 |
|
* |
| 40 |
|
* \ingroup DataSources |
| 41 |
|
*/ |
| 42 |
|
template <class TOutputMesh> |
| 43 |
|
class ITK_EXPORT MeshSource : public ProcessObject |
| 44 |
|
{ |
| 45 |
|
public: |
| 46 |
|
/** Standard class typedefs. */ |
| 47 |
|
typedef MeshSource Self; |
| 48 |
TDA |
typedef ProcessObject Superclass; |
| 49 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 50 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 51 |
|
|
| 52 |
|
/** Method for creation through the object factory. */ |
| 53 |
|
itkNewMacro(Self); |
| 54 |
|
|
| 55 |
|
/** Run-time type information (and related methods). */ |
| 56 |
|
itkTypeMacro(MeshSource,ProcessObject); |
| 57 |
|
|
| 58 |
|
/** Some convenient typedefs. */ |
| 59 |
|
typedef DataObject::Pointer DataObjectPointer; |
| 60 |
TDA |
typedef TOutputMesh OutputMeshType; |
| 61 |
TDA |
typedef typename OutputMeshType::Pointer OutputMeshPointer; |
| 62 |
|
|
| 63 |
|
/** Get the mesh output of this process object. */ |
| 64 |
|
OutputMeshType * GetOutput(void); |
| 65 |
|
OutputMeshType * GetOutput(unsigned int idx); |
| 66 |
|
|
| 67 |
|
/** Set the mesh output of this process object. This call is slated |
| 68 |
|
* to be removed from ITK. You should GraftOutput() and possible |
| 69 |
|
* DataObject::DisconnectPipeline() to properly change the output. */ |
| 70 |
|
void SetOutput(TOutputMesh *output); |
| 71 |
|
|
| 72 |
|
/** Graft the specified DataObject onto this ProcessObject's output. |
| 73 |
|
* This method grabs a handle to the specified DataObject's bulk |
| 74 |
|
* data to used as its output's own bulk data. It also copies the |
| 75 |
|
* region ivars (RequestedRegion, BufferedRegion, |
| 76 |
|
* LargestPossibleRegion) and meta-data (Spacing, Origin) from the |
| 77 |
|
* specified data object into this filter's output data object. Most |
| 78 |
|
* importantly, however, it leaves the Source ivar untouched so the |
| 79 |
|
* original pipeline routing is intact. This method is used when a |
| 80 |
|
* process object is implemented using a mini-pipeline which is |
| 81 |
|
* defined in its GenerateData() method. The usage is: |
| 82 |
|
* |
| 83 |
|
* \code |
| 84 |
|
* // setup the mini-pipeline to process the input to this filter |
| 85 |
|
* firstFilterInMiniPipeline->SetInput( this->GetInput() ); |
| 86 |
|
* |
| 87 |
|
* // setup the mini-pipeline to calculate the correct regions |
| 88 |
|
* // and write to the appropriate bulk data block |
| 89 |
|
* lastFilterInMiniPipeline->GraftOutput( this->GetOutput() ); |
| 90 |
|
* |
| 91 |
|
* // execute the mini-pipeline |
| 92 |
|
* lastFilterInMiniPipeline->Update(); |
| 93 |
|
* |
| 94 |
|
* // graft the mini-pipeline output back onto this filter's output. |
| 95 |
|
* // this is needed to get the appropriate regions passed back. |
| 96 |
|
* this->GraftOutput( lastFilterInMiniPipeline->GetOutput() ); |
| 97 |
|
* \endcode |
| 98 |
|
* |
| 99 |
|
* For proper pipeline execution, a filter using a mini-pipeline |
| 100 |
|
* must implement the GenerateInputRequestedRegion(), |
| 101 |
|
* GenerateOutputRequestedRegion(), GenerateOutputInformation() and |
| 102 |
|
* EnlargeOutputRequestedRegion() methods as necessary to reflect |
| 103 |
|
* how the mini-pipeline will execute (in other words, the outer |
| 104 |
|
* filter's pipeline mechanism must be consistent with what the |
| 105 |
|
* mini-pipeline will do). */ |
| 106 |
|
virtual void GraftOutput(DataObject *output); |
| 107 |
|
virtual void GraftNthOutput(unsigned int idx, DataObject *output); |
| 108 |
|
|
| 109 |
|
/** Make a DataObject of the correct type to used as the specified |
| 110 |
|
* output. Every ProcessObject subclass must be able to create a |
| 111 |
|
* DataObject that can be used as a specified output. This method |
| 112 |
|
* is automatically called when DataObject::DisconnectPipeline() is |
| 113 |
|
* called. DataObject::DisconnectPipeline, disconnects a data object |
| 114 |
|
* from being an output of its current source. When the data object |
| 115 |
|
* is disconnected, the ProcessObject needs to construct a replacement |
| 116 |
|
* output data object so that the ProcessObject is in a valid state. |
| 117 |
|
* So DataObject::DisconnectPipeline eventually calls |
| 118 |
|
* ProcessObject::MakeOutput. Note that MakeOutput always returns a |
| 119 |
|
* SmartPointer to a DataObject. If a subclass of MeshSource has |
| 120 |
|
* multiple outputs of different types, then that class must provide |
| 121 |
|
* an implementation of MakeOutput(). */ |
| 122 |
|
virtual DataObjectPointer MakeOutput(unsigned int idx); |
| 123 |
|
|
| 124 |
|
protected: |
| 125 |
|
MeshSource(); |
| 126 |
|
virtual ~MeshSource() {} |
| 127 |
|
void PrintSelf(std::ostream& os, Indent indent) const; |
| 128 |
|
|
| 129 |
|
/** Requested region of Mesh is specified as i of N unstructured regions. |
| 130 |
|
* Since all DataObjects should be able to set the requested region in |
| 131 |
|
* unstructured form, just copy output->RequestedRegion all inputs. */ |
| 132 |
|
void GenerateInputRequestedRegion(); |
| 133 |
|
|
| 134 |
|
private: |
| 135 |
|
MeshSource(const Self&); //purposely not implemented |
| 136 |
|
void operator=(const Self&); //purposely not implemented |
| 137 |
|
|
| 138 |
|
/** Used by streaming: The requested region of the output being processed |
| 139 |
|
* by the execute method. Set in the GenerateInputRequestedRegion method. */ |
| 140 |
|
int m_GenerateDataRegion; |
| 141 |
|
int m_GenerateDataNumberOfRegions; |
| 142 |
IND |
**}; |
| 143 |
|
|
| 144 |
|
} // end namespace itk |
| 145 |
|
|
| 146 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 147 |
|
#include "itkMeshSource.txx" |
| 148 |
|
#endif |
| 149 |
|
|
| 150 |
|
#endif |
| 151 |
|
|
| 152 |
EOF |
|