FEBio  1.5.0
FEBio/LoadCurve.h
00001 // LoadCurve.h: interface for the LoadCurve class.
00002 //
00004 
00005 #if !defined(AFX_LOADCURVE_H__E2D23AD8_1961_49E7_BE3A_3FC885CED53D__INCLUDED_)
00006 #define AFX_LOADCURVE_H__E2D23AD8_1961_49E7_BE3A_3FC885CED53D__INCLUDED_
00007 
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011 
00012 #include "DumpFile.h"
00013 #include <vector>
00014 
00015 //-----------------------------------------------------------------------------
00017 
00024 
00025 class FELoadCurve
00026 {
00027 public:
00029         struct LOADPOINT
00030         {
00031                 double time;
00032                 double value;
00033         };
00034 
00035 public:
00037         enum INTFUNC { STEP=0, LINEAR=1, SMOOTH=2 };
00038 
00040         enum EXTMODE { CONSTANT, EXTRAPOLATE, REPEAT, REPEAT_OFFSET };
00041 
00042 public:
00044         FELoadCurve() : m_fnc(LINEAR), m_ext(CONSTANT) {}
00045 
00047         FELoadCurve(const FELoadCurve& LC);
00048 
00050         FELoadCurve& operator = (const FELoadCurve& LC);
00051 
00053         virtual ~FELoadCurve() {}
00054 
00056         void Create(int n);
00057 
00059         void Add(double time, double value);
00060 
00062         void Clear() { m_lp.clear(); }
00063 
00065         void SetPoint(int i, double time, double val);
00066 
00068         double Value(double time) const;
00069         double Value() const { return m_value; }
00070 
00072         double Deriv(double time) const;
00073 
00075         void Evaluate(double time)
00076         {
00077                 m_value = Value(time);
00078         }
00079 
00081         void SetInterpolation(INTFUNC fnc) { m_fnc = fnc; }
00082 
00084         void SetExtendMode(EXTMODE mode) { m_ext = mode; }
00085 
00087         LOADPOINT& LoadPoint(int i) { return m_lp[i]; }
00088 
00090         int FindPoint(double t);
00091 
00093         int Points() const { return m_lp.size(); }
00094 
00096         bool HasPoint(double t) const;
00097 
00099         void Serialize(DumpFile& ar);
00100 
00101 protected:
00102         double ExtendValue(double t) const;
00103 
00104 protected:
00105         std::vector<LOADPOINT>  m_lp;   
00106 
00107         double                  m_value;        
00108 
00109         INTFUNC         m_fnc;  
00110         EXTMODE         m_ext;  
00111 };
00112 
00113 typedef FELoadCurve::LOADPOINT LOADPOINT;
00114 
00115 #endif // !defined(AFX_LOADCURVE_H__E2D23AD8_1961_49E7_BE3A_3FC885CED53D__INCLUDED_)