ITK  5.3.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  * 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 #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 NDimensions = 3,
46  typename PixelType = unsigned char,
47  typename TMeshTraits = DefaultStaticMeshTraits<PixelType, NDimensions, NDimensions>>
48 class ITK_TEMPLATE_EXPORT MetaSceneConverter : public Object
49 {
50 public:
51 
54  using Superclass = Object;
57 
58  itkNewMacro(Self);
59 
61  itkTypeMacro(MetaSceneConverter, Object);
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);
92 
94  itkSetMacro(TransformPrecision, unsigned int);
95  itkGetMacro(TransformPrecision, unsigned int);
97 
99  itkSetMacro(WriteImagesInSeparateFile, bool);
100  itkGetConstMacro(WriteImagesInSeparateFile, bool);
101  itkBooleanMacro(WriteImagesInSeparateFile);
103 
110  void
111  RegisterMetaConverter(const std::string & metaTypeName,
112  const std::string & spatialObjectTypeName,
113  MetaConverterBaseType * converter);
114 
115  MetaScene *
116  CreateMetaScene(const SpatialObjectType * soScene,
117  unsigned int depth = SpatialObjectType::MaximumDepth,
118  const std::string & name = "");
119 
121  CreateSpatialObjectScene(MetaScene * mScene);
122 
123 protected:
125  ~MetaSceneConverter() override = default;
126 
127 private:
129 
130  using MetaObjectListType = std::list<MetaObject *>;
131 
132  template <typename TConverter>
133  MetaObject *
135  {
136  typename TConverter::Pointer converter = TConverter::New();
137  // needed just for Image & ImageMask
138  converter->SetWriteImagesInSeparateFile(this->m_WriteImagesInSeparateFile);
139  return converter->SpatialObjectToMetaObject(so);
140  }
141  template <typename TConverter>
142  SpatialObjectPointer
143  MetaObjectToSpatialObject(const MetaObject * mo)
144  {
145  typename TConverter::Pointer converter = TConverter::New();
146  return converter->MetaObjectToSpatialObject(mo);
147  }
148  void
149  SetTransform(MetaObject * obj, const TransformType * transform);
150 
151  void
152  SetTransform(SpatialObjectType * so, const MetaObject * meta);
153 
154  double m_Orientation[100];
155  double m_Position[10];
156  double m_CenterOfRotation[10];
157 
161  unsigned int m_TransformPrecision;
163 };
164 } // end namespace itk
165 
166 #ifndef ITK_MANUAL_INSTANTIATION
167 # include "itkMetaSceneConverter.hxx"
168 #endif
169 
170 #endif
itk::MetaSceneConverter::MetaObjectToSpatialObject
SpatialObjectPointer MetaObjectToSpatialObject(const MetaObject *mo)
Definition: itkMetaSceneConverter.h:143
itk::MetaSceneConverter::SpatialObjectPointer
typename SpatialObjectType::Pointer SpatialObjectPointer
Definition: itkMetaSceneConverter.h:65
itk::MetaSceneConverter::ConverterMapType
std::map< std::string, MetaConverterPointer > ConverterMapType
Definition: itkMetaSceneConverter.h:71
itkSpatialObject.h
itk::MetaSceneConverter::m_ConverterMap
ConverterMapType m_ConverterMap
Definition: itkMetaSceneConverter.h:162
itkMetaEvent.h
itk::SmartPointer< Self >
itk::AffineTransform
Definition: itkAffineTransform.h:101
itk::MetaSceneConverter::m_BinaryPoints
bool m_BinaryPoints
Definition: itkMetaSceneConverter.h:159
itk::MetaSceneConverter::m_Event
MetaEvent * m_Event
Definition: itkMetaSceneConverter.h:158
itk::MetaSceneConverter::MetaConverterPointer
typename MetaConverterBaseType::Pointer MetaConverterPointer
Definition: itkMetaSceneConverter.h:70
itk::MetaSceneConverter::SpatialObjectToMetaObject
MetaObject * SpatialObjectToMetaObject(SpatialObjectConstPointer &so)
Definition: itkMetaSceneConverter.h:134
itk::MetaSceneConverter::MetaObjectListType
std::list< MetaObject * > MetaObjectListType
Definition: itkMetaSceneConverter.h:130
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::MetaEvent
Event abstract class.
Definition: itkMetaEvent.h:40
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:57
itk::MetaSceneConverter::m_WriteImagesInSeparateFile
bool m_WriteImagesInSeparateFile
Definition: itkMetaSceneConverter.h:160
itk::MetaSceneConverter::SpatialObjectConstPointer
typename SpatialObjectType::ConstPointer SpatialObjectConstPointer
Definition: itkMetaSceneConverter.h:66
itk::MetaSceneConverter::m_TransformPrecision
unsigned int m_TransformPrecision
Definition: itkMetaSceneConverter.h:161
itkObject.h
itk::MetaConverterBase< NDimensions >
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkDefaultStaticMeshTraits.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::MetaSceneConverter::TransformType
typename SpatialObjectType::TransformType TransformType
Definition: itkMetaSceneConverter.h:128
itk::MetaSceneConverter
Converts between MetaObject and SpaitalObject group.
Definition: itkMetaSceneConverter.h:48
itkMetaConverterBase.h
fileName
std::string fileName
Definition: itkTestDriverInclude.h:118