ITK  4.6.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 "metaScene.h"
22 #include "itkMetaEvent.h"
23 #include "itkSceneSpatialObject.h"
25 #include "itkMetaConverterBase.h"
26 #include <string>
27 #include <map>
28 
29 namespace itk
30 {
41 template< unsigned int NDimensions,
42  typename PixelType = unsigned char,
43  typename TMeshTraits =
44  DefaultStaticMeshTraits< PixelType, NDimensions, NDimensions >
45  >
47 {
48 public:
49 
52  typedef typename SceneType::Pointer ScenePointer;
53 
57  typedef std::map< std::string, MetaConverterPointer > ConverterMapType;
58 
61 
62  itkStaticConstMacro(MaximumDepth, unsigned int, 9999999);
63 
65  ScenePointer ReadMeta(const char *name);
66 
68  bool WriteMeta(SceneType *scene, const char *fileName,
69  unsigned int depth = MaximumDepth,
70  char *spatialObjectTypeName = ITK_NULLPTR);
71 
72  const MetaEvent * GetEvent() const { return m_Event; }
73  void SetEvent(MetaEvent *event) { m_Event = event; }
74 
76  void SetBinaryPoints(bool binary) { m_BinaryPoints = binary; }
77 
79  void SetTransformPrecision(unsigned int precision)
80  {
81  m_TransformPrecision = precision;
82  }
83  unsigned int GetTransformPrecision(){ return m_TransformPrecision; }
85 
87  void SetWriteImagesInSeparateFile(bool separate)
88  {
89  m_WriteImagesInSeparateFile = separate;
90  }
91 
98  void RegisterMetaConverter(const char *metaTypeName,
99  const char *spatialObjectTypeName,
100  MetaConverterBaseType *converter);
101 
102  MetaScene * CreateMetaScene(SceneType *scene,
103  unsigned int depth = MaximumDepth,
104  char *name = ITK_NULLPTR);
105 
106  ScenePointer CreateSpatialObjectScene(MetaScene *scene);
107 
108 private:
109 
113 
114  typedef std::list< MetaObject * > MetaObjectListType;
115 
116  template <typename TConverter>
118  {
119  typename TConverter::Pointer converter = TConverter::New();
120  // needed just for Image & ImageMask
121  converter->SetWriteImagesInSeparateFile(this->m_WriteImagesInSeparateFile);
122  return converter->SpatialObjectToMetaObject(so.GetPointer());
123  }
124  template <typename TConverter>
126  {
127  typename TConverter::Pointer converter = TConverter::New();
128  return converter->MetaObjectToSpatialObject(mo);
129  }
130  void SetTransform(MetaObject *obj, TransformType *transform);
131 
132  void SetTransform(SpatialObjectType *so, MetaObject *obj);
133 
134  double m_Orientation[100];
135  double m_Position[10];
136  double m_CenterOfRotation[10];
137 
141  unsigned int m_TransformPrecision;
143 };
144 } // end namespace itk
145 
146 #ifndef ITK_MANUAL_INSTANTIATION
147 #include "itkMetaSceneConverter.hxx"
148 #endif
149 
150 #endif
std::list< MetaObject * > MetaObjectListType
unsigned int GetTransformPrecision()
Event abstract class.
Definition: itkMetaEvent.h:30
MetaConverterBase< NDimensions > MetaConverterBaseType
void SetEvent(MetaEvent *event)
void SetBinaryPoints(bool binary)
MetaConverterBaseType::Pointer MetaConverterPointer
itk::SpatialObject< NDimensions > SpatialObjectType
MetaScene * CreateMetaScene(SceneType *scene, unsigned int depth=MaximumDepth, char *name=ITK_NULLPTR)
itk::SceneSpatialObject< NDimensions > SceneType
void SetTransform(MetaObject *obj, TransformType *transform)
ObjectType * GetPointer() const
bool WriteMeta(SceneType *scene, const char *fileName, unsigned int depth=MaximumDepth, char *spatialObjectTypeName=ITK_NULLPTR)
a SceneSpatialObject has a list of SpatialObjects
void SetTransformPrecision(unsigned int precision)
void RegisterMetaConverter(const char *metaTypeName, const char *spatialObjectTypeName, MetaConverterBaseType *converter)
const MetaEvent * GetEvent() const
SpatialObjectType::TransformType TransformType
Implementation of the composite pattern.
static const unsigned int MaximumDepth
SpatialObjectType::Pointer SpatialObjectPointer
void SetWriteImagesInSeparateFile(bool separate)
Converts between MetaObject and SpaitalObject scenes.
ScenePointer ReadMeta(const char *name)
SceneType::Pointer ScenePointer
std::map< std::string, MetaConverterPointer > ConverterMapType
MetaObject * SpatialObjectToMetaObject(SpatialObjectPointer &so)
Affine transformation with a specified center of rotation.
ScenePointer CreateSpatialObjectScene(MetaScene *scene)
SpatialObjectPointer MetaObjectToSpatialObject(const MetaObject *mo)