ITK  5.4.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  itkSetStringMacro(FileName);
69 
71  itkGetStringMacro(FileName);
72 
76  {
77  return m_SpatialObject;
78  }
79 
83  GroupPointer
85  {
86  if (m_Group == nullptr)
87  {
88  if (m_SpatialObject->GetTypeName() == "GroupSpatialObject")
89  {
90  m_Group = static_cast<GroupType *>(m_SpatialObject.GetPointer());
91  }
92  else
93  {
94  m_Group = GroupType::New();
95  m_Group->AddChild(m_SpatialObject);
96  }
97  }
98  return m_Group;
99  }
103  const MetaEvent *
105  {
106  return m_MetaToSpatialConverter->GetEvent();
107  }
108 
109  void
111  {
112  m_MetaToSpatialConverter->SetEvent(event);
113  }
114 
116  void
117  RegisterMetaConverter(const char * metaTypeName,
118  const char * spatialObjectTypeName,
119  MetaConverterBaseType * converter);
120 
121 protected:
122  std::string m_FileName{};
123 
125  ~SpatialObjectReader() override = default;
126 
127 private:
128  GroupPointer m_Group{};
129 
130  SpatialObjectPointer m_SpatialObject{};
131 
132  typename MetaSceneConverterType::Pointer m_MetaToSpatialConverter{};
133 };
134 } // namespace itk
135 
136 #ifndef ITK_MANUAL_INSTANTIATION
137 # include "itkSpatialObjectReader.hxx"
138 #endif
139 
140 #endif // itkSpatialObjectReader_h
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkSpatialObject.h
itk::SpatialObjectReader::GetOutput
SpatialObjectPointer GetOutput()
Definition: itkSpatialObjectReader.h:75
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:110
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:104
itk::SpatialObjectReader::GetGroup
GroupPointer GetGroup()
Definition: itkSpatialObjectReader.h:84
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: itkAnnulusOperator.h:24
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