ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMetaSceneConverter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 "itkGroupSpatialObject.h"
27 #include "itkMetaConverterBase.h"
28 
29 #include <string>
30 #include <map>
31 
32 namespace itk
33 {
44 template< unsigned int NDimensions = 3,
45  typename PixelType = unsigned char,
46  typename TMeshTraits =
47  DefaultStaticMeshTraits< PixelType, NDimensions, NDimensions >
48  >
49 class ITK_TEMPLATE_EXPORT MetaSceneConverter
50 : public Object
51 {
52 public:
53 
56  using Superclass = Object;
59 
60  itkNewMacro(Self);
61 
63  itkTypeMacro(MetaSceneConverter, Object);
64 
67  using ScenePointer = typename SceneType::Pointer;
68 
72  using ConverterMapType = std::map< std::string, MetaConverterPointer >;
73 
75  ScenePointer ReadMeta(const std::string & name);
76 
78  bool WriteMeta(SceneType *scene, const std::string & fileName,
79  unsigned int depth = SceneType::MaximumDepth,
80  const std::string & spatialObjectTypeName = "");
81 
82  itkGetMacro( Event, MetaEvent * );
83  itkSetObjectMacro( Event, MetaEvent );
84 
86  itkSetMacro( BinaryPoints, bool );
87  itkGetMacro( BinaryPoints, bool );
89 
91  itkSetMacro( TransformPrecision, unsigned int );
92  itkGetMacro( TransformPrecision, unsigned int );
94 
96  itkSetMacro( WriteImagesInSeparateFile, bool );
97  itkGetConstMacro( WriteImagesInSeparateFile, bool );
99 
106  void RegisterMetaConverter(const std::string & metaTypeName,
107  const std::string & spatialObjectTypeName,
108  MetaConverterBaseType *converter);
109 
110  MetaScene * CreateMetaScene(SceneType *scene,
111  unsigned int depth = SceneType::MaximumDepth,
112  const std::string & name = "");
113 
114  ScenePointer CreateSpatialObjectScene(MetaScene *scene);
115 
116 protected:
117 
119  ~MetaSceneConverter() = default;
120 
121 private:
122 
126 
127  using MetaObjectListType = std::list< MetaObject * >;
128 
129  template <typename TConverter>
131  {
132  typename TConverter::Pointer converter = TConverter::New();
133  // needed just for Image & ImageMask
134  converter->SetWriteImagesInSeparateFile(this->m_WriteImagesInSeparateFile);
135  return converter->SpatialObjectToMetaObject(so);
136  }
137  template <typename TConverter>
139  {
140  typename TConverter::Pointer converter = TConverter::New();
141  return converter->MetaObjectToSpatialObject(mo);
142  }
143  void SetTransform(MetaObject *obj, const TransformType * transform);
144 
145  void SetTransform(SpatialObjectType *so, const MetaObject * meta);
146 
147  double m_Orientation[100];
148  double m_Position[10];
149  double m_CenterOfRotation[10];
150 
154  unsigned int m_TransformPrecision;
156 };
157 } // end namespace itk
158 
159 #ifndef ITK_MANUAL_INSTANTIATION
160 #include "itkMetaSceneConverter.hxx"
161 #endif
162 
163 #endif
Event abstract class.
Definition: itkMetaEvent.h:37
Light weight base class for most itk classes.
typename SceneType::Pointer ScenePointer
std::map< std::string, MetaConverterPointer > ConverterMapType
Implementation of the composite pattern.
Converts between MetaObject and SpaitalObject scenes.
std::list< MetaObject * > MetaObjectListType
Representation of a group based on the spatial object classes.
typename SpatialObjectType::TransformType TransformType
typename SpatialObjectType::Pointer SpatialObjectPointer
MetaObject * SpatialObjectToMetaObject(SpatialObjectPointer &so)
Base class for most ITK classes.
Definition: itkObject.h:60
typename MetaConverterBaseType::Pointer MetaConverterPointer
SpatialObjectPointer MetaObjectToSpatialObject(const MetaObject *mo)