ITK  5.2.0
Insight Toolkit
itkCastSpatialObjectFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef itkCastSpatialObjectFilter_h
20 #define itkCastSpatialObjectFilter_h
21 
22 #include <list>
23 
24 #include <itkSpatialObject.h>
25 
26 #include <itkArrowSpatialObject.h>
27 #include <itkBlobSpatialObject.h>
28 #include <itkBoxSpatialObject.h>
32 #include <itkGroupSpatialObject.h>
34 #include <itkImageSpatialObject.h>
36 #include <itkLineSpatialObject.h>
40 #include <itkTubeSpatialObject.h>
41 
42 namespace itk
43 {
44 
53 template <unsigned int ObjectDimension>
54 class ITK_TEMPLATE_EXPORT CastSpatialObjectFilter : public Object
55 {
56 public:
57  ITK_DISALLOW_COPY_AND_MOVE(CastSpatialObjectFilter);
58 
61  using Superclass = Object;
64 
65  itkNewMacro(Self);
66 
67  itkTypeMacro(CastSpatialObjectFilter, Object);
68 
70 
72 
73  itkSetObjectMacro(Input, InputSpatialObjectType);
74  itkGetConstObjectMacro(Input, InputSpatialObjectType);
75 
76  template <class OutputSpatialObjectT>
77  std::list<typename OutputSpatialObjectT::Pointer> *
78  GetOutput() const
79  {
80  typedef OutputSpatialObjectT OutObjectType;
81  typedef std::list<typename OutObjectType::Pointer> OutListType;
82 
83  auto * outputList = new OutListType;
84 
85  auto * obj = dynamic_cast<OutObjectType *>(m_Input.GetPointer());
86  if (obj != nullptr)
87  {
88  typename OutObjectType::Pointer sObj = OutObjectType::New();
89  sObj = obj;
90  outputList->push_back(sObj);
91  }
92  InputChildrenListType * inputList = m_Input->GetChildren(9999);
93  auto it = inputList->begin();
94  while (it != inputList->end())
95  {
96  obj = dynamic_cast<OutObjectType *>(it->GetPointer());
97  if (obj != nullptr)
98  {
99  typename OutObjectType::Pointer sObj = OutObjectType::New();
100  sObj = obj;
101  outputList->push_back(sObj);
102  }
103  ++it;
104  }
105 
106  delete inputList;
107 
108  return outputList;
109  }
110 
112  std::list<ArrowPointer> *
113  GetArrows() const
114  {
115  return this->GetOutput<itk::ArrowSpatialObject<ObjectDimension>>();
116  }
117 
119  std::list<BlobPointer> *
120  GetBlobs() const
121  {
122  return this->GetOutput<itk::BlobSpatialObject<ObjectDimension>>();
123  }
124 
126  std::list<BoxPointer> *
127  GetBoxes() const
128  {
129  return this->GetOutput<itk::BoxSpatialObject<ObjectDimension>>();
130  }
131 
133  std::list<ContourPointer> *
134  GetContours() const
135  {
136  return this->GetOutput<itk::ContourSpatialObject<ObjectDimension>>();
137  }
138 
140  std::list<EllipsePointer> *
141  GetEllipses() const
142  {
143  return this->GetOutput<itk::EllipseSpatialObject<ObjectDimension>>();
144  }
145 
147  std::list<GaussianPointer> *
148  GetGaussians() const
149  {
150  return this->GetOutput<itk::GaussianSpatialObject<ObjectDimension>>();
151  }
152 
154  std::list<GroupPointer> *
155  GetGroups() const
156  {
157  return this->GetOutput<itk::GroupSpatialObject<ObjectDimension>>();
158  }
159 
161  std::list<ImageMaskPointer> *
163  {
164  return this->GetOutput<itk::ImageMaskSpatialObject<ObjectDimension>>();
165  }
166 
168  std::list<ImagePointer> *
169  GetImages() const
170  {
171  return this->GetOutput<itk::ImageSpatialObject<ObjectDimension>>();
172  }
173 
175  std::list<LandmarkPointer> *
176  GetLandmarks() const
177  {
178  return this->GetOutput<itk::LandmarkSpatialObject<ObjectDimension>>();
179  }
180 
182  std::list<LinePointer> *
183  GetLines() const
184  {
185  return this->GetOutput<itk::LineSpatialObject<ObjectDimension>>();
186  }
187 
189  std::list<PointBasedPointer> *
191  {
192  return this->GetOutput<itk::PointBasedSpatialObject<ObjectDimension>>();
193  }
194 
196  std::list<PolygonPointer> *
197  GetPolygons() const
198  {
199  return this->GetOutput<itk::PolygonSpatialObject<ObjectDimension>>();
200  }
201 
203  std::list<SpatialObjectPointer> *
205  {
206  return this->GetOutput<itk::SpatialObject<ObjectDimension>>();
207  }
208 
210  std::list<SurfacePointer> *
211  GetSurfaces() const
212  {
213  return this->GetOutput<itk::SurfaceSpatialObject<ObjectDimension>>();
214  }
215 
217  std::list<TubePointer> *
218  GetTubes() const
219  {
220  return this->GetOutput<itk::TubeSpatialObject<ObjectDimension>>();
221  }
222 
223 protected:
225  ~CastSpatialObjectFilter() override = default;
226 
227  void
228  PrintSelf(std::ostream & os, Indent indent) const override;
229 
230 
231 private:
233 
234 }; // End class CastSpatialObjectFilter
235 
236 } // End namespace itk
237 
238 #ifndef ITK_MANUAL_INSTANTIATION
239 # include "itkCastSpatialObjectFilter.hxx"
240 #endif
241 
242 #endif // End !defined( itkCastSpatialObjectFilter_h )
itk::CastSpatialObjectFilter::GetImages
std::list< ImagePointer > * GetImages() const
Definition: itkCastSpatialObjectFilter.h:169
itkPolygonSpatialObject.h
itk::CastSpatialObjectFilter::ImagePointer
typename itk::ImageSpatialObject< ObjectDimension >::Pointer ImagePointer
Definition: itkCastSpatialObjectFilter.h:167
itk::CastSpatialObjectFilter::GetLines
std::list< LinePointer > * GetLines() const
Definition: itkCastSpatialObjectFilter.h:183
itkImageSpatialObject.h
itk::CastSpatialObjectFilter::GetOutput
std::list< typename OutputSpatialObjectT::Pointer > * GetOutput() const
Definition: itkCastSpatialObjectFilter.h:78
itk::CastSpatialObjectFilter::SpatialObjectPointer
typename itk::SpatialObject< ObjectDimension >::Pointer SpatialObjectPointer
Definition: itkCastSpatialObjectFilter.h:202
itkSpatialObject.h
itkEllipseSpatialObject.h
itk::CastSpatialObjectFilter::BoxPointer
typename itk::BoxSpatialObject< ObjectDimension >::Pointer BoxPointer
Definition: itkCastSpatialObjectFilter.h:125
itk::CastSpatialObjectFilter::TubePointer
typename itk::TubeSpatialObject< ObjectDimension >::Pointer TubePointer
Definition: itkCastSpatialObjectFilter.h:216
itk::CastSpatialObjectFilter
This filter casts one spatialobject to another, when the class hierarchy supports it (e....
Definition: itkCastSpatialObjectFilter.h:54
itk::SpatialObject::ChildrenListType
std::list< Pointer > ChildrenListType
Definition: itkSpatialObject.h:109
itk::CastSpatialObjectFilter::GetGaussians
std::list< GaussianPointer > * GetGaussians() const
Definition: itkCastSpatialObjectFilter.h:148
itkLandmarkSpatialObject.h
itk::CastSpatialObjectFilter::GetSurfaces
std::list< SurfacePointer > * GetSurfaces() const
Definition: itkCastSpatialObjectFilter.h:211
itk::CastSpatialObjectFilter::GetSpatialObjects
std::list< SpatialObjectPointer > * GetSpatialObjects() const
Definition: itkCastSpatialObjectFilter.h:204
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkGaussianSpatialObject.h
itk::CastSpatialObjectFilter::GetEllipses
std::list< EllipsePointer > * GetEllipses() const
Definition: itkCastSpatialObjectFilter.h:141
itk::CastSpatialObjectFilter::ImageMaskPointer
typename itk::ImageMaskSpatialObject< ObjectDimension >::Pointer ImageMaskPointer
Definition: itkCastSpatialObjectFilter.h:160
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkGroupSpatialObject.h
itk::CastSpatialObjectFilter::BlobPointer
typename itk::BlobSpatialObject< ObjectDimension >::Pointer BlobPointer
Definition: itkCastSpatialObjectFilter.h:118
itk::CastSpatialObjectFilter::GetPointBased
std::list< PointBasedPointer > * GetPointBased() const
Definition: itkCastSpatialObjectFilter.h:190
itk::CastSpatialObjectFilter::GaussianPointer
typename itk::GaussianSpatialObject< ObjectDimension >::Pointer GaussianPointer
Definition: itkCastSpatialObjectFilter.h:146
itk::CastSpatialObjectFilter::InputChildrenListType
typename InputSpatialObjectType::ChildrenListType InputChildrenListType
Definition: itkCastSpatialObjectFilter.h:71
itk::CastSpatialObjectFilter::GroupPointer
typename itk::GroupSpatialObject< ObjectDimension >::Pointer GroupPointer
Definition: itkCastSpatialObjectFilter.h:153
itk::CastSpatialObjectFilter::LinePointer
typename itk::LineSpatialObject< ObjectDimension >::Pointer LinePointer
Definition: itkCastSpatialObjectFilter.h:181
itk::CastSpatialObjectFilter::GetBlobs
std::list< BlobPointer > * GetBlobs() const
Definition: itkCastSpatialObjectFilter.h:120
itk::CastSpatialObjectFilter::SurfacePointer
typename itk::SurfaceSpatialObject< ObjectDimension >::Pointer SurfacePointer
Definition: itkCastSpatialObjectFilter.h:209
itk::CastSpatialObjectFilter::ArrowPointer
typename itk::ArrowSpatialObject< ObjectDimension >::Pointer ArrowPointer
Definition: itkCastSpatialObjectFilter.h:111
itk::CastSpatialObjectFilter::GetBoxes
std::list< BoxPointer > * GetBoxes() const
Definition: itkCastSpatialObjectFilter.h:127
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:57
itk::CastSpatialObjectFilter::GetGroups
std::list< GroupPointer > * GetGroups() const
Definition: itkCastSpatialObjectFilter.h:155
itk::CastSpatialObjectFilter::GetLandmarks
std::list< LandmarkPointer > * GetLandmarks() const
Definition: itkCastSpatialObjectFilter.h:176
itk::CastSpatialObjectFilter::GetContours
std::list< ContourPointer > * GetContours() const
Definition: itkCastSpatialObjectFilter.h:134
itk::CastSpatialObjectFilter::LandmarkPointer
typename itk::LandmarkSpatialObject< ObjectDimension >::Pointer LandmarkPointer
Definition: itkCastSpatialObjectFilter.h:174
itkBoxSpatialObject.h
itkContourSpatialObject.h
itk::CastSpatialObjectFilter::GetPolygons
std::list< PolygonPointer > * GetPolygons() const
Definition: itkCastSpatialObjectFilter.h:197
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkImageMaskSpatialObject.h
itk::CastSpatialObjectFilter::GetArrows
std::list< ArrowPointer > * GetArrows() const
Definition: itkCastSpatialObjectFilter.h:113
itkArrowSpatialObject.h
itk::CastSpatialObjectFilter::PointBasedPointer
typename itk::PointBasedSpatialObject< ObjectDimension >::Pointer PointBasedPointer
Definition: itkCastSpatialObjectFilter.h:188
itk::CastSpatialObjectFilter::ContourPointer
typename itk::ContourSpatialObject< ObjectDimension >::Pointer ContourPointer
Definition: itkCastSpatialObjectFilter.h:132
itk::CastSpatialObjectFilter::PolygonPointer
typename itk::PolygonSpatialObject< ObjectDimension >::Pointer PolygonPointer
Definition: itkCastSpatialObjectFilter.h:195
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itkPointBasedSpatialObject.h
itkSurfaceSpatialObject.h
itk::CastSpatialObjectFilter::m_Input
InputSpatialObjectType::Pointer m_Input
Definition: itkCastSpatialObjectFilter.h:232
itkBlobSpatialObject.h
itk::CastSpatialObjectFilter::GetTubes
std::list< TubePointer > * GetTubes() const
Definition: itkCastSpatialObjectFilter.h:218
itk::CastSpatialObjectFilter::GetImageMasks
std::list< ImageMaskPointer > * GetImageMasks() const
Definition: itkCastSpatialObjectFilter.h:162
itkLineSpatialObject.h
itkTubeSpatialObject.h
itk::CastSpatialObjectFilter::EllipsePointer
typename itk::EllipseSpatialObject< ObjectDimension >::Pointer EllipsePointer
Definition: itkCastSpatialObjectFilter.h:139