1 #ifndef OPENSIM_FUNCTION_ADAPTER_H_
2 #define OPENSIM_FUNCTION_ADAPTER_H_
3 /* -------------------------------------------------------------------------- *
4  *                        OpenSim:  FunctionAdapter.h                         *
5  * -------------------------------------------------------------------------- *
6  * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
7  * See http://opensim.stanford.edu and the NOTICE file for more information.  *
8  * OpenSim is developed at Stanford University and supported by the US        *
9  * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
10  * through the Warrior Web program.                                           *
11  *                                                                            *
12  * Copyright (c) 2005-2017 Stanford University and the Authors                *
13  * Author(s): Peter Eastman                                                   *
14  *                                                                            *
15  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
16  * not use this file except in compliance with the License. You may obtain a  *
17  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
18  *                                                                            *
19  * Unless required by applicable law or agreed to in writing, software        *
20  * distributed under the License is distributed on an "AS IS" BASIS,          *
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
22  * See the License for the specific language governing permissions and        *
23  * limitations under the License.                                             *
24  * -------------------------------------------------------------------------- */
25 
26 
27 // INCLUDES
28 #include "Function.h"
29 
30 
31 //=============================================================================
32 //=============================================================================
33 namespace OpenSim {
34 
35 // Excluding this from Doxygen until it has better documentation! -Sam Hamner
36 /// @cond
37 /**
38  * This is a SimTK::Function that acts as a wrapper around an OpenMM::Function.
39  *
40  * @author Peter Eastman
41  */
42 class OSIMCOMMON_API FunctionAdapter : public SimTK::Function
43 {
44 //=============================================================================
45 // DATA
46 //=============================================================================
47 protected:
48     // REFERENCES
49     /** The OpenSim::Function used to evaluate this function. */
50     const OpenSim::Function& _function;
51 
52 //=============================================================================
53 // METHODS
54 //=============================================================================
55 public:
56     FunctionAdapter(const OpenSim::Function &aFunction);
57     double calcValue(const SimTK::Vector& x) const override;
58     double calcDerivative(const std::vector<int>& derivComponents, const SimTK::Vector& x) const;
59     double calcDerivative(const SimTK::Array_<int>& derivComponents, const SimTK::Vector& x) const override;
60     int getArgumentSize() const override;
61     int getMaxDerivativeOrder() const override;
62 private:
63     FunctionAdapter();
64     FunctionAdapter& operator=(FunctionAdapter& function);
65 
66 //=============================================================================
67 };  // END class FunctionAdapter
68 
69 /// @endcond
70 
71 }; //namespace
72 //=============================================================================
73 //=============================================================================
74 
75 #endif // OPENSIM_FUNCTION_ADAPTER_H_
76