1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef CLITKRELATIVEPOSITIONDATABASE_H
20 #define CLITKRELATIVEPOSITIONDATABASE_H
23 #include "clitkCommon.h"
27 //--------------------------------------------------------------------
31 //--------------------------------------------------------------------
34 //--------------------------------------------------------------------
35 class RelativePositionDirectionType {
41 void Print(std::ostream & os = std::cout) const {
42 os << clitk::rad2deg(angle1) << " " << clitk::rad2deg(angle2) << " ";
43 if (notFlag) os << "true";
48 void PrintOptions(std::ostream & os = std::cout) const {
49 os << "angle1 = " << clitk::rad2deg(angle1) << std::endl
50 << "angle2 = " << clitk::rad2deg(angle2) << std::endl;
51 if (notFlag) os << "inverse" << std::endl;
54 void Println(std::ostream & os = std::cout) const {
59 bool operator< (const RelativePositionDirectionType &compare) const
61 if (angle1 < compare.angle1) return true;
62 if (angle1 > compare.angle1) return false;
64 if (angle2 < compare.angle2) return true;
65 if (angle2 > compare.angle2) return false;
67 if (notFlag == true) {
68 if (compare.notFlag == false) return true;
74 //--------------------------------------------------------------------
77 //--------------------------------------------------------------------
78 class RelativePositionDataBaseIndexType {
83 RelativePositionDirectionType direction;
84 void Print(std::ostream & os = std::cout) const {
85 os << patient << " " << station << " " << object << " ";
88 void Println(std::ostream & os = std::cout) const {
93 //--------------------------------------------------------------------
96 //--------------------------------------------------------------------
97 class RelativePositionInformationType {
100 int sizeBeforeThreshold;
101 int sizeAfterThreshold;
103 void Print(std::ostream & os = std::cout) const {
104 os << threshold << " " << sizeBeforeThreshold << " "
105 << sizeAfterThreshold << " " << sizeReference;
107 void Println(std::ostream & os = std::cout) const {
112 //--------------------------------------------------------------------
115 //--------------------------------------------------------------------
116 class RelativePositionDataBase {
119 RelativePositionDataBase() {}
120 ~RelativePositionDataBase() {}
122 typedef RelativePositionDataBaseIndexType IndexType;
124 void Read(const std::string & filename);
125 double GetAreaGain(const IndexType & index) const;
126 double GetThreshold(const IndexType & index) const;
127 int GetNumberOfPatient(const IndexType & index) const;
128 std::vector<std::string> & GetListOfPatients(const IndexType & index) const;
129 void GetListOfObjects(const std::string & station, std::vector<std::string> & objects) const;
130 void GetListOfDirections(const std::string & station,
131 const std::string & object,
132 std::vector<RelativePositionDirectionType> & directions) const;
133 bool CheckIndex(const IndexType & index) const;
136 typedef std::map<std::string, RelativePositionInformationType> MapByPatientType;
137 typedef std::map<RelativePositionDirectionType, MapByPatientType> MapByDirectionType;
138 typedef std::map<std::string, MapByDirectionType> MapByObjectType;
139 typedef std::map<std::string, MapByObjectType> MapByStationType;
140 MapByStationType m_DB;
142 void ReadIndex(std::istream & is, IndexType & index);
143 void ReadInformation(std::istream & is, RelativePositionInformationType & v);
145 const MapByDirectionType & GetMapByDirection(const IndexType & index) const;
146 const MapByPatientType & GetMapByPatient(const IndexType & index) const;
147 const RelativePositionInformationType & GetInformation(const IndexType & index) const;
148 const MapByObjectType & GetMapByObject(const std::string & station) const;
151 //--------------------------------------------------------------------
153 } // end namespace clitk
154 //--------------------------------------------------------------------