00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _KINETICEXCITATION_H_
00021 #define _KINETICEXCITATION_H_
00022
00023 #include <mbsim/link_mechanics.h>
00024 #include <mbsim/frame.h>
00025 #include <fmatvec/function.h>
00026
00027 #ifdef HAVE_OPENMBVCPPINTERFACE
00028 #include "mbsim/utils/boost_parameters.h"
00029 #include "mbsim/utils/openmbv_utils.h"
00030 #endif
00031
00032 namespace MBSim {
00033
00040 class KineticExcitation : public LinkMechanics {
00041 public:
00046 KineticExcitation(const std::string &name="");
00047
00051 virtual ~KineticExcitation();
00052
00053
00054 virtual void updateh(double t, int i=0);
00055 virtual void updateg(double) {}
00056 virtual void updategd(double) {}
00057
00058
00059
00060 virtual void init(InitStage stage);
00061
00062
00063
00064 void calclaSize(int j);
00065 bool isActive() const { return true; }
00066 bool isSingleValued() const { return true; }
00067 bool gActiveChanged() { return false; }
00068
00069
00070
00071 virtual void plot(double t, double dt = 1);
00072
00073
00077 void setForceDirection(const fmatvec::Mat3xV& fd);
00078
00082 void setMomentDirection(const fmatvec::Mat3xV& md);
00083
00088 void setForceFunction(fmatvec::Function<fmatvec::VecV(double)> *func);
00089
00091 void setMomentFunction(fmatvec::Function<fmatvec::VecV(double)> *func);
00092
00096 void setFrameOfReferenceID(int ID) { refFrameID=ID; }
00097
00098 using LinkMechanics::connect;
00099
00104 void connect(MBSim::Frame *frame1, MBSim::Frame *frame2);
00105
00106 #ifdef HAVE_OPENMBVCPPINTERFACE
00107
00108 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVForce, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
00109 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
00110 std::vector<bool> which; which.resize(2, false);
00111 which[1]=true;
00112 LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
00113 }
00114
00116 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMoment, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
00117 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
00118 std::vector<bool> which; which.resize(2, false);
00119 which[1]=true;
00120 LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which);
00121 }
00122 #endif
00123
00124 void initializeUsingXML(xercesc::DOMElement *element);
00125 virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00126
00127 virtual std::string getType() const { return "KineticExcitation"; }
00128
00129 protected:
00133 Frame *refFrame;
00134 int refFrameID;
00135
00139 fmatvec::Mat3xV forceDir, momentDir;
00140
00144 fmatvec::Function<fmatvec::VecV(double)> *F, *M;
00145
00149 Frame C;
00150
00151 private:
00152 std::string saved_ref, saved_ref1, saved_ref2;
00153 };
00154
00155 }
00156
00157 #endif
00158