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 std::ostream& operator<<(std::ostream & os, const clitk::RelativePositionInformationType & rp);
113 //--------------------------------------------------------------------
116 //--------------------------------------------------------------------
117 class RelativePositionDataBase {
120 RelativePositionDataBase() {}
121 ~RelativePositionDataBase() {}
123 typedef RelativePositionDataBaseIndexType IndexType;
125 void Read(const std::string & filename);
126 double GetAreaGain(const IndexType & index) const;
127 double GetThreshold(const IndexType & index) const;
128 int GetNumberOfPatient(const IndexType & index) const;
129 std::vector<std::string> & GetListOfPatients(const IndexType & index) const;
130 void GetListOfObjects(const std::string & station, std::vector<std::string> & objects) const;
131 void GetListOfDirections(const std::string & station,
132 const std::string & object,
133 std::vector<RelativePositionDirectionType> & directions) const;
134 bool CheckIndex(const IndexType & index) const;
137 typedef std::map<std::string, RelativePositionInformationType> MapByPatientType;
138 typedef std::map<RelativePositionDirectionType, MapByPatientType> MapByDirectionType;
139 typedef std::map<std::string, MapByDirectionType> MapByObjectType;
140 typedef std::map<std::string, MapByObjectType> MapByStationType;
141 MapByStationType m_DB;
143 void ReadIndex(std::istream & is, IndexType & index);
144 void ReadInformation(std::istream & is, RelativePositionInformationType & v);
146 const MapByDirectionType & GetMapByDirection(const IndexType & index) const;
147 const MapByPatientType & GetMapByPatient(const IndexType & index) const;
148 const RelativePositionInformationType & GetInformation(const IndexType & index) const;
149 const MapByObjectType & GetMapByObject(const std::string & station) const;
152 //--------------------------------------------------------------------
154 } // end namespace clitk
155 //--------------------------------------------------------------------