ITK  5.4.0
Insight Toolkit
itkMetaSceneConverter.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 itkMetaSceneConverter_h
19 #define itkMetaSceneConverter_h
20 
21 #include "itkObject.h"
23 
24 #include "metaScene.h"
25 #include "itkMetaEvent.h"
26 #include "itkSpatialObject.h"
27 #include "itkMetaConverterBase.h"
28 
29 #include <string>
30 #include <map>
31 
32 namespace itk
33 {
45 template <unsigned int VDimension = 3,
46  typename PixelType = unsigned char,
47  typename TMeshTraits = DefaultStaticMeshTraits<PixelType, VDimension, VDimension>>
48 class ITK_TEMPLATE_EXPORT MetaSceneConverter : public Object
49 {
50 public:
51 
54  using Superclass = Object;
57 
58  itkNewMacro(Self);
59 
61  itkOverrideGetNameOfClassMacro(MetaSceneConverter);
62 
67 
71  using ConverterMapType = std::map<std::string, MetaConverterPointer>;
72 
75  ReadMeta(const std::string & name);
76 
78  bool
79  WriteMeta(const SpatialObjectType * soScene,
80  const std::string & fileName,
81  unsigned int depth = SpatialObjectType::MaximumDepth,
82  const std::string & soName = "");
83 
84  itkGetMacro(Event, MetaEvent *);
85  itkSetObjectMacro(Event, MetaEvent);
86 
88  itkSetMacro(BinaryPoints, bool);
89  itkGetConstMacro(BinaryPoints, bool);
90  itkBooleanMacro(BinaryPoints);
94  itkSetMacro(TransformPrecision, unsigned int);
95  itkGetMacro(TransformPrecision, unsigned int);
99  itkSetMacro(WriteImagesInSeparateFile, bool);
100  itkGetConstMacro(WriteImagesInSeparateFile, bool);
101  itkBooleanMacro(WriteImagesInSeparateFile);
110  void
111  RegisterMetaConverter(const std::string & metaTypeName,
112  const std::string & spatialObjectTypeName,
113  MetaConverterBaseType * converter);
114 
119  MetaScene *
120  CreateMetaScene(const SpatialObjectType * soScene,
121  unsigned int depth = SpatialObjectType::MaximumDepth,
122  const std::string & name = "");
123 
125  CreateSpatialObjectScene(MetaScene * mScene);
126 
127 protected:
129  ~MetaSceneConverter() override = default;
130 
131 private:
133 
134  using MetaObjectListType = std::list<MetaObject *>;
135 
136  template <typename TConverter>
137  MetaObject *
139  {
140  auto converter = TConverter::New();
141  // needed just for Image & ImageMask
142  converter->SetWriteImagesInSeparateFile(this->m_WriteImagesInSeparateFile);
143  return converter->SpatialObjectToMetaObject(so);
144  }
145  template <typename TConverter>
146  SpatialObjectPointer
147  MetaObjectToSpatialObject(const MetaObject * mo)
148  {
149  auto converter = TConverter::New();
150  return converter->MetaObjectToSpatialObject(mo);
151  }
152  void
153  SetTransform(MetaObject * obj, const TransformType * transform);
154 
155  void
156  SetTransform(SpatialObjectType * so, const MetaObject * meta);
157 
158  double m_Orientation[100]{};
159  double m_Position[10]{};
160  double m_CenterOfRotation[10]{};
161 
162  MetaEvent * m_Event{};
163  bool m_BinaryPoints{};
164  bool m_WriteImagesInSeparateFile{};
165  unsigned int m_TransformPrecision{};
166  ConverterMapType m_ConverterMap{};
167 };
168 } // end namespace itk
169 
170 #ifndef ITK_MANUAL_INSTANTIATION
171 # include "itkMetaSceneConverter.hxx"
172 #endif
173 
174 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::MetaSceneConverter::TransformType
typename SpatialObjectType::TransformType TransformType
Definition: itkMetaSceneConverter.h:132
itkSpatialObject.h
itk::MetaSceneConverter::SpatialObjectConstPointer
typename SpatialObjectType::ConstPointer SpatialObjectConstPointer
Definition: itkMetaSceneConverter.h:66
itkMetaEvent.h
itk::SmartPointer< Self >
itk::MetaSceneConverter::MetaObjectToSpatialObject
SpatialObjectPointer MetaObjectToSpatialObject(const MetaObject *mo)
Definition: itkMetaSceneConverter.h:147
itk::AffineTransform
Definition: itkAffineTransform.h:101
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::MetaSceneConverter::MetaObjectListType
std::list< MetaObject * > MetaObjectListType
Definition: itkMetaSceneConverter.h:134
itk::MetaSceneConverter::SpatialObjectToMetaObject
MetaObject * SpatialObjectToMetaObject(SpatialObjectConstPointer &so)
Definition: itkMetaSceneConverter.h:138
itk::MetaEvent
Event abstract class.
Definition: itkMetaEvent.h:40
itk::MetaSceneConverter::ConverterMapType
std::map< std::string, MetaConverterPointer > ConverterMapType
Definition: itkMetaSceneConverter.h:71
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:58
itkObject.h
itk::MetaConverterBase
Base class for MetaObject<->SpatialObject converters.
Definition: itkMetaConverterBase.h:42
itk::MetaSceneConverter::SpatialObjectPointer
typename SpatialObjectType::Pointer SpatialObjectPointer
Definition: itkMetaSceneConverter.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::MetaSceneConverter::MetaConverterPointer
typename MetaConverterBaseType::Pointer MetaConverterPointer
Definition: itkMetaSceneConverter.h:70
itkDefaultStaticMeshTraits.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
New
static Pointer New()
itk::MetaSceneConverter
Converts between MetaObject and SpatialObject group.
Definition: itkMetaSceneConverter.h:48
itkMetaConverterBase.h