ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkHDF5TransformIO.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 itkHDF5TransformIO_h
19 #define itkHDF5TransformIO_h
20 #include "itkTransformIOBase.h"
21 #include "itkAutoPointer.h"
22 #include <string>
23 
24 // Avoids KWStyle error from forward declaration below.
25 namespace itk
26 {
27 }
28 
29 // Forward declaration of class H5::H5File
30 namespace H5
31 {
32 class H5File;
33 }
34 
35 namespace itk
36 {
37 
38 
53  {
54  //
55  // HDF uses hierarchical paths to find particular data
56  // in a file. These strings are used by both reading and
57  // writing.
58  static const std::string transformGroupName;
59  static const std::string transformTypeName;
60  static const std::string transformFixedName;
61  static const std::string transformParamsName;
62  static const std::string ItkVersion;
63  static const std::string HDFVersion;
64  static const std::string OSName;
65  static const std::string OSVersion;
66  };
67 
68 
78 template<typename TParametersValueType>
79 class HDF5TransformIOTemplate:public TransformIOBaseTemplate<TParametersValueType>,
80 private HDF5CommonPathNames
81 {
82 public:
91 
92  typedef typename TransformIOBaseTemplate
93  <TParametersValueType>::ConstTransformListType
95 
98  itkNewMacro( Self );
100 
103  virtual bool CanReadFile(const char *) ITK_OVERRIDE;
104 
107  virtual bool CanWriteFile(const char *) ITK_OVERRIDE;
108 
110  virtual void Read() ITK_OVERRIDE;
111 
115  virtual void Write() ITK_OVERRIDE;
116 
117 protected:
119  virtual ~HDF5TransformIOTemplate();
120 
121 private:
123  ParametersType ReadParameters(const std::string &DataSetName);
124 
126  void WriteParameters(const std::string &name,
127  const ParametersType &parameters);
128  void WriteFixedParameters(const std::string &name,
129  const FixedParametersType &parameters);
131 
133  void WriteString(const std::string &path, const std::string &value);
134  void WriteString(const std::string &path, const char *value);
135  void WriteOneTransform(const int transformIndex,
136  const TransformType *transform);
138 
139  AutoPointer<H5::H5File> m_H5File;
140 };
141 extern const std::string GetTransformName(int);
142 
144 typedef HDF5TransformIOTemplate<double> HDF5TransformIO;
145 
146 } // end namespace itk
147 
148 #ifndef ITK_MANUAL_INSTANTIATION
149 #include "itkHDF5TransformIO.hxx"
150 #endif
151 
152 #endif // itkHDF5TransformIO_h
Light weight base class for most itk classes.
static const std::string transformFixedName
Superclass::TransformType TransformType
TransformIOBaseTemplate< TParametersValueType > Superclass
static const std::string transformParamsName
Read&amp;Write transforms in HDF5 Format.
void WriteString(const std::string &path, const std::string &value)
void WriteParameters(const std::string &name, const ParametersType &parameters)
TransformType::ParametersType ParametersType
static const std::string HDFVersion
virtual void Read() override
virtual bool CanWriteFile(const char *) override
Abstract superclass defining the Transform IO interface.
Superclass::TransformListType TransformListType
static const std::string transformTypeName
TransformType::Pointer TransformPointer
Superclass::TransformPointer TransformPointer
virtual void Write() override
static const std::string OSVersion
const std::string GetTransformName(int)
Class to hold and manage different parameter types used during optimization.
Secondary bass class of HDF5CommonPathNames common between templates.
static const std::string ItkVersion
std::list< TransformPointer > TransformListType
TransformBaseTemplate< ParametersValueType > TransformType
AutoPointer< H5::H5File > m_H5File
void WriteOneTransform(const int transformIndex, const TransformType *transform)
TransformType::FixedParametersType FixedParametersType
SmartPointer< Self > Pointer
std::list< ConstTransformPointer > ConstTransformListType
static const std::string OSName
ParametersType ReadParameters(const std::string &DataSetName)
Implements an Automatic Pointer to an object.
static const std::string transformGroupName
virtual bool CanReadFile(const char *) override
TransformIOBaseTemplate< TParametersValueType >::ConstTransformListType ConstTransformListType
HDF5TransformIOTemplate Self
void WriteFixedParameters(const std::string &name, const FixedParametersType &parameters)