Cortex  10.0.0-a4
Lookup.h
1 //
3 // Copyright (c) 2009, Image Engine Design Inc. All rights reserved.
4 // Copyright (c) 2013, John Haddon. All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in the
15 // documentation and/or other materials provided with the distribution.
16 //
17 // * Neither the name of Image Engine Design nor the names of any
18 // other contributors to this software may be used to endorse or
19 // promote products derived from this software without specific prior
20 // written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
35 
36 #ifndef IECORE_LOOKUP_H
37 #define IECORE_LOOKUP_H
38 
39 #include <vector>
40 
41 #include "boost/function.hpp"
42 
43 #include "OpenEXR/ImathColor.h"
44 
45 namespace IECore
46 {
47 
52 template<typename X, typename Y>
53 class Lookup
54 {
55 
56  public :
57 
58  typedef X XType;
59  typedef Y YType;
60  typedef boost::function<Y ( X )> Function;
61 
62  Lookup();
63  Lookup( const Function &function, XType xMin, XType xMax, unsigned numSamples );
64 
65  void init( const Function &function, XType xMin, XType xMax, unsigned numSamples );
66 
67  inline Y operator() ( X x ) const;
68 
69  private :
70 
71  std::vector<Y> m_values;
72  XType m_xMin;
73  XType m_xMax;
74  XType m_xMult;
75 
76 };
77 
80 
83 
84 } // namespace IECore
85 
86 #include "IECore/Lookup.inl"
87 
88 #endif // IECORE_LOOKUP_H
Definition: Lookup.h:53
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43