]> Creatis software - clitk.git/blob - segmentation/clitkAnatomicalFeatureDatabase.h
Debug RTStruct conversion with empty struc
[clitk.git] / segmentation / clitkAnatomicalFeatureDatabase.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ===========================================================================**/
18
19 #ifndef CLITKANATOMICALFEATUREDATABASE_H
20 #define CLITKANATOMICALFEATUREDATABASE_H
21
22 // clitk
23 #include "clitkCommon.h"
24 #include "clitkImageCommon.h"
25
26 namespace clitk {
27   
28
29   //--------------------------------------------------------------------
30   /*
31     Class to store and retreive anatomical feature such as 3D
32     named landmarks points. 
33   */
34   class AnatomicalFeatureDatabase: public itk::Object
35   {
36   public:
37     // typedef
38     typedef std::string TagType;
39
40     // New macro
41     typedef itk::Object                    Superclass;
42     typedef AnatomicalFeatureDatabase      Self;
43     typedef itk::SmartPointer<Self>        Pointer;
44     typedef itk::SmartPointer<const Self>  ConstPointer;
45     itkNewMacro(Self);
46     static Pointer New(std::string filename);
47
48     // Set/Get filename 
49     itkSetMacro(Filename, std::string);
50     itkGetConstMacro(Filename, std::string);
51
52     // Read and write DB
53     void Write();
54     void Load();
55     itkGetConstMacro(Path, std::string);
56     itkSetMacro(Path, std::string);
57     
58     // Set Get landmarks
59     typedef itk::Point<double,3> PointType3D;
60     void SetPoint3D(TagType tag, PointType3D & p);
61     void GetPoint3D(TagType tag, PointType3D & p);
62     double GetPoint3D(std::string tag, int dim);
63     bool TagExist(std::string tag);
64     std::string GetTagValue(std::string tag);
65
66     // Set Get image
67     void SetImageFilename(TagType tag, std::string f);
68     
69     template<class ImageType> 
70     typename ImageType::Pointer GetImage(TagType tag, bool reload=false);
71     
72     template<class ImageType> 
73     bool CheckImage(TagType tag); 
74     
75     template<class ImageType> 
76     void  SetImage(TagType tag, std::string f, typename ImageType::Pointer image, bool write=false);
77     
78     template<class ImageType> 
79     void ReleaseImage(TagType tag);
80     
81     // Set Get Double
82     void SetDouble(TagType tag, double d);
83     double GetDouble(TagType tag);
84     
85     // Remove Tag
86     void RemoveTag(TagType tag);
87
88   protected:
89     AnatomicalFeatureDatabase();
90     ~AnatomicalFeatureDatabase() {}
91
92     std::string m_Filename;
93     std::string m_Path;
94     typedef itk::ImageBase<3> ImageBaseType;
95     typedef std::map<TagType, std::string> MapTagType;
96     typedef std::map<TagType, ImageBaseType*> MapTagImageType; 
97     MapTagType m_MapOfTag;
98     MapTagImageType m_MapOfImage;
99
100   }; // end class
101   //--------------------------------------------------------------------
102
103 #define NewAFDB(NAME, FILE)                                             \
104   clitk::AnatomicalFeatureDatabase::Pointer NAME = clitk::AnatomicalFeatureDatabase::New(FILE);
105
106   #include "clitkAnatomicalFeatureDatabase.txx" 
107
108 } // end namespace clitk
109 //--------------------------------------------------------------------
110
111 #endif // CLITKANATOMICALFEATUREDATABASE_H