ITK  6.0.0
Insight Toolkit
itkSpatialObjectReader.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 #ifndef itkSpatialObjectReader_h
19 #define itkSpatialObjectReader_h
20 
21 #include "itkMetaSceneConverter.h"
22 #include "itkMetaConverterBase.h"
23 #include "itkSpatialObject.h"
24 #include "itkGroupSpatialObject.h"
25 #include "itkProcessObject.h"
26 
27 namespace itk
28 {
33 template <unsigned int VDimension = 3,
34  typename PixelType = unsigned char,
35  typename TMeshTraits = DefaultStaticMeshTraits<PixelType, VDimension, VDimension>>
36 class ITK_TEMPLATE_EXPORT SpatialObjectReader : public Object
37 {
38 public:
39  ITK_DISALLOW_COPY_AND_MOVE(SpatialObjectReader);
40 
47  using GroupPointer = typename GroupType::Pointer;
48 
54 
56  itkNewMacro(Self);
57 
59  using Superclass = Object;
60  itkOverrideGetNameOfClassMacro(SpatialObjectReader);
64  void
65  Update();
66 
68  void
69  SetMetaIOVersion(unsigned int ver);
70  unsigned int
71  GetMetaIOVersion(void) const;
75  itkSetStringMacro(FileName);
76 
78  itkGetStringMacro(FileName);
79 
83  {
84  return m_SpatialObject;
85  }
86 
90  GroupPointer
92  {
93  if (m_Group == nullptr)
94  {
95  if (m_SpatialObject->GetTypeName() == "GroupSpatialObject")
96  {
97  m_Group = static_cast<GroupType *>(m_SpatialObject.GetPointer());
98  }
99  else
100  {
101  m_Group = GroupType::New();
102  m_Group->AddChild(m_SpatialObject);
103  }
104  }
105  return m_Group;
106  }
110  const MetaEvent *
112  {
113  return m_MetaToSpatialConverter->GetEvent();
114  }
115 
116  void
118  {
119  m_MetaToSpatialConverter->SetEvent(event);
120  }
121 
123  void
124  RegisterMetaConverter(const char * metaTypeName,
125  const char * spatialObjectTypeName,
126  MetaConverterBaseType * converter);
127 
128 protected:
129  std::string m_FileName{};
130 
132  ~SpatialObjectReader() override = default;
133 
134 private:
135  GroupPointer m_Group{};
136 
137  SpatialObjectPointer m_SpatialObject{};
138 
139  typename MetaSceneConverterType::Pointer m_MetaToSpatialConverter{};
140 };
141 } // namespace itk
142 
143 #ifndef ITK_MANUAL_INSTANTIATION
144 # include "itkSpatialObjectReader.hxx"
145 #endif
146 
147 #endif // itkSpatialObjectReader_h
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkSpatialObject.h
itk::SpatialObjectReader::GetOutput
SpatialObjectPointer GetOutput()
Definition: itkSpatialObjectReader.h:82
itk::SmartPointer< Self >
itk::SpatialObjectReader::SpatialObjectPointer
typename SpatialObjectType::Pointer SpatialObjectPointer
Definition: itkSpatialObjectReader.h:45
itk::SpatialObjectReader
Definition: itkSpatialObjectReader.h:36
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkGroupSpatialObject.h
itk::SpatialObjectReader::SetEvent
void SetEvent(MetaEvent *event)
Definition: itkSpatialObjectReader.h:117
itkProcessObject.h
itk::SpatialObjectReader::GroupPointer
typename GroupType::Pointer GroupPointer
Definition: itkSpatialObjectReader.h:47
itkMetaSceneConverter.h
itk::MetaEvent
Event abstract class.
Definition: itkMetaEvent.h:40
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:58
itk::SpatialObjectReader::GetEvent
const MetaEvent * GetEvent()
Definition: itkSpatialObjectReader.h:111
itk::SpatialObjectReader::GetGroup
GroupPointer GetGroup()
Definition: itkSpatialObjectReader.h:91
itk::MetaConverterBase
Base class for MetaObject<->SpatialObject converters.
Definition: itkMetaConverterBase.h:42
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
New
static Pointer New()
itk::GroupSpatialObject
Representation of a group based on the spatial object classes.
Definition: itkGroupSpatialObject.h:39
itk::MetaSceneConverter
Converts between MetaObject and SpatialObject group.
Definition: itkMetaSceneConverter.h:48
itkMetaConverterBase.h