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 ===========================================================================**/
18 #ifndef CLITKLISTOFPAIR_CXX
19 #define CLITKLISTOFPAIR_CXX
21 ------------------------------------------------=
22 * @file clitkListOfPair.cxx
23 * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
24 * @date 27 Feb 2007 09:55:56
29 ------------------------------------------------=*/
31 #include "clitkListOfPair.h"
33 //--------------------------------------------------------------------
34 double clitk::convertValue(double v,
35 const std::multimap<double, double> & conversionTable,
38 std::multimap<double, double>::const_iterator i;
39 i = conversionTable.lower_bound(v);
40 if (i == conversionTable.end()) {
41 std::cerr << "The value " << v << " is out of the table" << std::endl;
46 double p2 = i->second;
47 if (i != conversionTable.begin()) i--;
49 double p1 = i->second;
53 if ((v-v1) > (v2-v)) return p2;
56 double w = (v-v1)/(v2-v1);
57 return p1*(1.0-w)+w*p2;
60 //--------------------------------------------------------------------
62 #endif /* end #define CLITKLISTOFPAIR_CXX */