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"
28
29#include <string>
30#include <map>
31
32namespace itk
33{
45template <unsigned int VDimension = 3,
46 typename PixelType = unsigned char,
47 typename TMeshTraits = DefaultStaticMeshTraits<PixelType, VDimension, VDimension>>
48class ITK_TEMPLATE_EXPORT MetaSceneConverter : public Object
49{
50public:
51
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
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 *
121 unsigned int depth = SpatialObjectType::MaximumDepth,
122 const std::string & name = "");
123
125 CreateSpatialObjectScene(MetaScene * mScene);
126
127protected:
129 ~MetaSceneConverter() override = default;
130
131private:
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
Light weight base class for most itk classes.
Event abstract class.
Definition: itkMetaEvent.h:42
Converts between MetaObject and SpatialObject group.
SpatialObjectPointer MetaObjectToSpatialObject(const MetaObject *mo)
SpatialObjectPointer CreateSpatialObjectScene(MetaScene *mScene)
typename MetaConverterBaseType::Pointer MetaConverterPointer
void SetTransform(SpatialObjectType *so, const MetaObject *meta)
std::list< MetaObject * > MetaObjectListType
typename SpatialObjectType::Pointer SpatialObjectPointer
bool WriteMeta(const SpatialObjectType *soScene, const std::string &fileName, unsigned int depth=SpatialObjectType::MaximumDepth, const std::string &soName="")
void RegisterMetaConverter(const std::string &metaTypeName, const std::string &spatialObjectTypeName, MetaConverterBaseType *converter)
std::map< std::string, MetaConverterPointer > ConverterMapType
~MetaSceneConverter() override=default
void SetTransform(MetaObject *obj, const TransformType *transform)
MetaObject * SpatialObjectToMetaObject(SpatialObjectConstPointer &so)
MetaScene * CreateMetaScene(const SpatialObjectType *soScene, unsigned int depth=SpatialObjectType::MaximumDepth, const std::string &name="")
typename SpatialObjectType::TransformType TransformType
SpatialObjectPointer ReadMeta(const std::string &name)
typename SpatialObjectType::ConstPointer SpatialObjectConstPointer
Base class for most ITK classes.
Definition: itkObject.h:62
Implementation of the composite pattern.
SmartPointer< const Self > ConstPointer
static Pointer New()
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....