ITK  5.2.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 
66 
70  using ConverterMapType = std::map<std::string, MetaConverterPointer>;
71 
74  ReadMeta(const std::string & name);
75 
77  bool
78  WriteMeta(SpatialObjectType * soScene,
79  const std::string & fileName,
80  unsigned int depth = SpatialObjectType::MaximumDepth,
81  const std::string & soName = "");
82 
83  itkGetMacro(Event, MetaEvent *);
84  itkSetObjectMacro(Event, MetaEvent);
85 
87  itkSetMacro(BinaryPoints, bool);
88  itkGetConstMacro(BinaryPoints, bool);
89  itkBooleanMacro(BinaryPoints);
91 
93  itkSetMacro(TransformPrecision, unsigned int);
94  itkGetMacro(TransformPrecision, unsigned int);
96 
98  itkSetMacro(WriteImagesInSeparateFile, bool);
99  itkGetConstMacro(WriteImagesInSeparateFile, bool);
100  itkBooleanMacro(WriteImagesInSeparateFile);
102 
109  void
110  RegisterMetaConverter(const std::string & metaTypeName,
111  const std::string & spatialObjectTypeName,
112  MetaConverterBaseType * converter);
113 
114  MetaScene *
115  CreateMetaScene(SpatialObjectType * soScene,
116  unsigned int depth = SpatialObjectType::MaximumDepth,
117  const std::string & name = "");
118 
120  CreateSpatialObjectScene(MetaScene * mScene);
121 
122 protected:
124  ~MetaSceneConverter() override = default;
125 
126 private:
128 
129  using MetaObjectListType = std::list<MetaObject *>;
130 
131  template <typename TConverter>
132  MetaObject *
134  {
135  typename TConverter::Pointer converter = TConverter::New();
136  // needed just for Image & ImageMask
137  converter->SetWriteImagesInSeparateFile(this->m_WriteImagesInSeparateFile);
138  return converter->SpatialObjectToMetaObject(so);
139  }
140  template <typename TConverter>
141  SpatialObjectPointer
142  MetaObjectToSpatialObject(const MetaObject * mo)
143  {
144  typename TConverter::Pointer converter = TConverter::New();
145  return converter->MetaObjectToSpatialObject(mo);
146  }
147  void
148  SetTransform(MetaObject * obj, const TransformType * transform);
149 
150  void
151  SetTransform(SpatialObjectType * so, const MetaObject * meta);
152 
153  double m_Orientation[100];
154  double m_Position[10];
155  double m_CenterOfRotation[10];
156 
160  unsigned int m_TransformPrecision;
162 };
163 } // end namespace itk
164 
165 #ifndef ITK_MANUAL_INSTANTIATION
166 # include "itkMetaSceneConverter.hxx"
167 #endif
168 
169 #endif
itk::MetaSceneConverter::MetaObjectToSpatialObject
SpatialObjectPointer MetaObjectToSpatialObject(const MetaObject *mo)
Definition: itkMetaSceneConverter.h:142
itk::MetaSceneConverter::SpatialObjectPointer
typename SpatialObjectType::Pointer SpatialObjectPointer
Definition: itkMetaSceneConverter.h:65
itk::MetaSceneConverter::ConverterMapType
std::map< std::string, MetaConverterPointer > ConverterMapType
Definition: itkMetaSceneConverter.h:70
itkSpatialObject.h
itk::MetaSceneConverter::m_ConverterMap
ConverterMapType m_ConverterMap
Definition: itkMetaSceneConverter.h:161
itkMetaEvent.h
itk::SmartPointer< Self >
itk::AffineTransform
Definition: itkAffineTransform.h:101
itk::MetaSceneConverter::m_BinaryPoints
bool m_BinaryPoints
Definition: itkMetaSceneConverter.h:158
itk::MetaSceneConverter::m_Event
MetaEvent * m_Event
Definition: itkMetaSceneConverter.h:157
itk::MetaSceneConverter::MetaConverterPointer
typename MetaConverterBaseType::Pointer MetaConverterPointer
Definition: itkMetaSceneConverter.h:69
itk::MetaSceneConverter::MetaObjectListType
std::list< MetaObject * > MetaObjectListType
Definition: itkMetaSceneConverter.h:129
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:159
itk::MetaSceneConverter::m_TransformPrecision
unsigned int m_TransformPrecision
Definition: itkMetaSceneConverter.h:160
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:127
itk::MetaSceneConverter
Converts between MetaObject and SpaitalObject group.
Definition: itkMetaSceneConverter.h:48
itkMetaConverterBase.h
itk::MetaSceneConverter::SpatialObjectToMetaObject
MetaObject * SpatialObjectToMetaObject(SpatialObjectPointer &so)
Definition: itkMetaSceneConverter.h:133
fileName
std::string fileName
Definition: itkTestDriverInclude.h:118