ITK  6.0.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
79 itkSetMacro(MetaIOVersion, unsigned int);
80 itkGetConstMacro(MetaIOVersion, unsigned int);
85 ReadMeta(const std::string & name);
86
88 bool
90 const std::string & fileName,
91 unsigned int depth = SpatialObjectType::MaximumDepth,
92 const std::string & soName = "");
93
94 itkGetMacro(Event, MetaEvent *);
95 itkSetObjectMacro(Event, MetaEvent);
96
98 itkSetMacro(BinaryPoints, bool);
99 itkGetConstMacro(BinaryPoints, bool);
100 itkBooleanMacro(BinaryPoints);
104 itkSetMacro(TransformPrecision, unsigned int);
105 itkGetMacro(TransformPrecision, unsigned int);
109 itkSetMacro(WriteImagesInSeparateFile, bool);
110 itkGetConstMacro(WriteImagesInSeparateFile, bool);
111 itkBooleanMacro(WriteImagesInSeparateFile);
120 void
121 RegisterMetaConverter(const std::string & metaTypeName,
122 const std::string & spatialObjectTypeName,
123 MetaConverterBaseType * converter);
124
129 MetaScene *
131 unsigned int depth = SpatialObjectType::MaximumDepth,
132 const std::string & name = "");
133
135 CreateSpatialObjectScene(MetaScene * mScene);
136
137protected:
139 ~MetaSceneConverter() override = default;
140
141private:
143
144 using MetaObjectListType = std::list<MetaObject *>;
145
146 template <typename TConverter>
147 MetaObject *
149 {
150 auto converter = TConverter::New();
151 // needed just for Image & ImageMask
152 converter->SetMetaIOVersion(m_MetaIOVersion);
153 converter->SetWriteImagesInSeparateFile(this->m_WriteImagesInSeparateFile);
154 return converter->SpatialObjectToMetaObject(so);
155 }
156 template <typename TConverter>
157 SpatialObjectPointer
158 MetaObjectToSpatialObject(const MetaObject * mo)
159 {
160 auto converter = TConverter::New();
161 converter->SetMetaIOVersion(m_MetaIOVersion);
162 return converter->MetaObjectToSpatialObject(mo);
163 }
164 void
165 SetTransform(MetaObject * obj, const TransformType * transform);
166
167 void
168 SetTransform(SpatialObjectType * so, const MetaObject * meta);
169
170 MetaEvent * m_Event{};
171 bool m_BinaryPoints{};
172 bool m_WriteImagesInSeparateFile{};
173 unsigned int m_TransformPrecision{};
174 ConverterMapType m_ConverterMap{};
175 unsigned int m_MetaIOVersion{ 0 };
176};
177} // end namespace itk
178
179#ifndef ITK_MANUAL_INSTANTIATION
180# include "itkMetaSceneConverter.hxx"
181#endif
182
183#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....