ITK  6.0.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 * https://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
28#include "itkBoxSpatialObject.h"
41
42namespace itk
43{
44
53template <unsigned int ObjectDimension>
54class ITK_TEMPLATE_EXPORT CastSpatialObjectFilter : public Object
55{
56public:
57 ITK_DISALLOW_COPY_AND_MOVE(CastSpatialObjectFilter);
58
64
65 itkNewMacro(Self);
66
67 itkOverrideGetNameOfClassMacro(CastSpatialObjectFilter);
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 auto 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 auto 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> *
135 {
136 return this->GetOutput<itk::ContourSpatialObject<ObjectDimension>>();
137 }
138
140 std::list<EllipsePointer> *
142 {
143 return this->GetOutput<itk::EllipseSpatialObject<ObjectDimension>>();
144 }
145
147 std::list<GaussianPointer> *
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> *
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> *
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> *
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
223protected:
225 ~CastSpatialObjectFilter() override = default;
226
227 void
228 PrintSelf(std::ostream & os, Indent indent) const override;
229
230
231private:
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 )
This filter casts one spatialobject to another, when the class hierarchy supports it (e....
typename itk::TubeSpatialObject< ObjectDimension >::Pointer TubePointer
typename itk::EllipseSpatialObject< ObjectDimension >::Pointer EllipsePointer
std::list< GroupPointer > * GetGroups() const
typename itk::SpatialObject< ObjectDimension >::Pointer SpatialObjectPointer
std::list< SpatialObjectPointer > * GetSpatialObjects() const
std::list< ArrowPointer > * GetArrows() const
std::list< LandmarkPointer > * GetLandmarks() const
std::list< GaussianPointer > * GetGaussians() const
typename itk::ImageSpatialObject< ObjectDimension >::Pointer ImagePointer
std::list< typename OutputSpatialObjectT::Pointer > * GetOutput() const
std::list< LinePointer > * GetLines() const
typename itk::ContourSpatialObject< ObjectDimension >::Pointer ContourPointer
typename itk::SurfaceSpatialObject< ObjectDimension >::Pointer SurfacePointer
typename itk::ImageMaskSpatialObject< ObjectDimension >::Pointer ImageMaskPointer
std::list< SurfacePointer > * GetSurfaces() const
typename itk::PolygonSpatialObject< ObjectDimension >::Pointer PolygonPointer
void PrintSelf(std::ostream &os, Indent indent) const override
~CastSpatialObjectFilter() override=default
std::list< PolygonPointer > * GetPolygons() const
std::list< TubePointer > * GetTubes() const
typename itk::BoxSpatialObject< ObjectDimension >::Pointer BoxPointer
std::list< EllipsePointer > * GetEllipses() const
std::list< BoxPointer > * GetBoxes() const
typename itk::LandmarkSpatialObject< ObjectDimension >::Pointer LandmarkPointer
typename itk::LineSpatialObject< ObjectDimension >::Pointer LinePointer
typename itk::GroupSpatialObject< ObjectDimension >::Pointer GroupPointer
typename itk::BlobSpatialObject< ObjectDimension >::Pointer BlobPointer
std::list< ImagePointer > * GetImages() const
std::list< ImageMaskPointer > * GetImageMasks() const
typename itk::GaussianSpatialObject< ObjectDimension >::Pointer GaussianPointer
std::list< ContourPointer > * GetContours() const
typename itk::PointBasedSpatialObject< ObjectDimension >::Pointer PointBasedPointer
std::list< BlobPointer > * GetBlobs() const
std::list< PointBasedPointer > * GetPointBased() const
typename itk::ArrowSpatialObject< ObjectDimension >::Pointer ArrowPointer
typename InputSpatialObjectType::ChildrenListType InputChildrenListType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Base class for most ITK classes.
Definition: itkObject.h:62
Implementation of the composite pattern.
std::list< Pointer > ChildrenListType
static Pointer New()
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....