ITK  4.6.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 
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 TInternalComputationValueType >
79 class HDF5TransformIOTemplate:public TransformIOBaseTemplate< TInternalComputationValueType >,
80 private HDF5CommonPathNames
81 {
82 public:
89  typedef typename TransformType::ParametersType ParametersType;
90 
91  typedef typename TransformIOBaseTemplate
92  <TInternalComputationValueType>::ConstTransformListType
94 
97  itkNewMacro( Self );
99 
102  virtual bool CanReadFile(const char *);
103 
106  virtual bool CanWriteFile(const char *);
107 
109  virtual void Read();
110 
114  virtual void Write();
115 
116 protected:
118  virtual ~HDF5TransformIOTemplate();
119 
120 private:
122  ParametersType ReadParameters(const std::string &DataSetName);
123 
125  void WriteParameters(const std::string &name,
126  const ParametersType &parameters);
127 
129  void WriteString(const std::string &path, const std::string &value);
130  void WriteString(const std::string &path, const char *value);
131  void WriteOneTransform(const int transformIndex,
132  const TransformType *transform);
134 
135  H5::H5File *m_H5File;
136 };
137 extern const std::string GetTransformName(int);
138 
141 
142 } // end namespace itk
143 
144 #ifndef ITK_MANUAL_INSTANTIATION
145 #include "itkHDF5TransformIO.hxx"
146 #endif
147 
148 #endif // __itkHDF5TransformIO_h
virtual bool CanWriteFile(const char *)
void WriteOneTransform(const int transformIndex, const TransformType *transform)
Light weight base class for most itk classes.
void WriteString(const std::string &path, const std::string &value)
static const std::string transformFixedName
Superclass::TransformType TransformType
TransformIOBaseTemplate< TInternalComputationValueType > Superclass
void WriteParameters(const std::string &name, const ParametersType &parameters)
static const std::string transformParamsName
Read&amp;Write transforms in HDF5 Format.
static const std::string HDFVersion
Superclass::TransformListType TransformListType
TransformType::ParametersType ParametersType
Abstract superclass defining the Transform IO interface.
static const std::string transformTypeName
static const std::string OSVersion
const std::string GetTransformName(int)
Secondary bass class of HDF5CommonPathNames common between templates.
static const std::string ItkVersion
Superclass::TransformPointer TransformPointer
static const std::string OSName
virtual bool CanReadFile(const char *)
ParametersType ReadParameters(const std::string &DataSetName)
HDF5TransformIOTemplate< double > HDF5TransformIO
static const std::string transformGroupName
SmartPointer< Self > Pointer
HDF5TransformIOTemplate Self
TransformIOBaseTemplate< TInternalComputationValueType >::ConstTransformListType ConstTransformListType