File: igstkTransformXMLFileWriterBase.h

package info (click to toggle)
igstk 4.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 38,980 kB
  • sloc: cpp: 86,267; xml: 96; makefile: 75; python: 38
file content (128 lines) | stat: -rw-r--r-- 4,105 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*=========================================================================

  Program:   Image Guided Surgery Software Toolkit
  Module:    $RCSfile: igstkTransformXMLFileWriterBase.h,v $
  Language:  C++
  Date:      $Date: 2009-06-04 20:06:54 $
  Version:   $Revision: 1.1 $

  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __igstkTransformXMLFileWriterBase_h
#define __igstkTransformXMLFileWriterBase_h

#include <itkXMLFile.h>
#include "igstkPrecomputedTransformData.h"


namespace igstk
{
/** \class TransformXMLFileWriterBase
 * 
 *  \brief This class is an abstract writer for xml files containing a 
 *         precomputed transformation. The specific type of transformation is
 *         defined by the subclass.
 *
 *  This class is the base class for all the writers that output a precomputed
 *  transformation. 
 *
 *  The xml file format is as follows:
    @verbatim
    <precomputed_transform>
   
    <description>
       Claron bayonet probe calibration
    </description>
   
    <computation_date>
       Thursday July 4 12:00:00 1776
    </computation_date>
   
    <transformation estimation_error="0.5">
       your parameters go here
    </transformation>
     
   </precomputed_transform>
   @endverbatim
 *
 * 
 */
class TransformXMLFileWriterBase :
         public itk::XMLWriterBase<PrecomputedTransformData> 
{
public:
  
  //standard typedefs
  typedef TransformXMLFileWriterBase                              Self;
  typedef itk::XMLWriterBase<PrecomputedTransformData>            Superclass;
  typedef itk::SmartPointer<Self>                                 Pointer;

           //run-time type information (and related methods)
  itkTypeMacro( TransformXMLFileWriterBase<PrecomputedTransformData>, 
                itk::XMLWriterBase );

  //Calling program must check that we have a valid file name, it is not a directory
  virtual int CanWriteFile( const char* name );

  //Calling program can then write, if filename is valid.  
  virtual int WriteFile();

  /**Check that the transformation matches the writer type*/ 
  virtual bool IsCompatible(
     const PrecomputedTransformData::Pointer transformation )=0;

protected:

  TransformXMLFileWriterBase() {}
  virtual ~TransformXMLFileWriterBase() {}

  void WriteDescription( std::ofstream &out );
  void WriteDate( std::ofstream &out ); 
  virtual void WriteTransformation( std::ofstream &out ) = 0;
 
  //observer to get the transformation description using IGSTK's event
  //based approach
  igstkObserverMacro( TransformationDescription, 
                      igstk::StringEvent, 
                      std::string )

  //observer to get the transformation date using IGSTK's event
  //based approach
  igstkObserverMacro( TransformationDate, 
                      igstk::PrecomputedTransformData::TransformDateTypeEvent, 
                      std::string )

  typedef igstk::PrecomputedTransformData::TransformType * 
    TransformTypePointer;

  //observer to get the transformation using IGSTK's event
  //based approach
  igstkObserverMacro( TransformRequest, 
                      igstk::PrecomputedTransformData::TransformTypeEvent, 
                      TransformTypePointer )

  //observer to get the transformation's estimation error using IGSTK's 
  //event based approach
  igstkObserverMacro( TransformError, 
                      igstk::PrecomputedTransformData::TransformErrorTypeEvent, 
                      igstk::PrecomputedTransformData::ErrorType )

private:

  TransformXMLFileWriterBase( 
    const TransformXMLFileWriterBase & other );


  const TransformXMLFileWriterBase & operator=( 
    const TransformXMLFileWriterBase & right );
};


}
#endif //__igstkTransformXMLFileWriterBase_h