MBSim

Project Page
contour_pairing.h
00001 /*
00002  * ContourPairing.h
00003  *
00004  *  Created on: 25.09.2011
00005  *      Author: grundl
00006  */
00007 
00008 #ifndef CONTOURPAIRING_H_
00009 #define CONTOURPAIRING_H_
00010 
00011 //#include <mbsim/link_mechanics.h>
00012 
00013 #include <mbsim/object.h>
00014 #include <mbsim/link.h>
00015 #include <mbsim/contour_pdata.h>
00016 #include <mbsim/constitutive_laws.h>
00017 #include <mbsim/contact_kinematics/contact_kinematics.h>
00018 
00019 #ifdef HAVE_OPENMBVCPPINTERFACE
00020 #include <openmbvcppinterface/group.h>
00021 #include <openmbvcppinterface/frame.h>
00022 #include <openmbvcppinterface/arrow.h>
00023 #endif
00024 
00025 namespace MBSim {
00026   class ContourPairing : public Object {
00027     public:
00028       ContourPairing(const std::string & name_, Contour* contour1, Contour* contour2, bool plotContact = true, ContactKinematics * contactKinematics_ = 0);
00029 
00030       virtual ~ContourPairing();
00031 
00032       /*INHERITED INTERFACE OF Object*/
00033       void updateStateDependentVariables(double t) {
00034         throw MBSimError("ContourPairing::updateStateDependentVariables(double t): Not implemented!");
00035       }
00036       void updateJacobians(double t, int j = 0);
00037       void updateInverseKineticsJacobians(double t) {
00038         throw MBSimError("ContourPairing::updateInverseKineticsJacobians(double t): Not implemented!");
00039       }
00040       void closePlot();
00041       /*******************************/
00042 
00043       void setContactKinematics(ContactKinematics* ck) {
00044         contactKinematics = ck;
00045       }
00046       ContactKinematics* getContactKinematics() const {
00047         return contactKinematics;
00048       }
00049       ContourPointData* getContourPointData() {
00050         return cpData[0];
00051       }
00052       Contour* getContour(const int & index) {
00053         if (index == 0)
00054           return contour1;
00055         return contour2;
00056       }
00057 #ifdef HAVE_OPENMBVCPPINTERFACE
00058       OpenMBV::Group* getOpenMBVGrp() {return openMBVGroup;}
00059 #endif
00060 
00061       bool isActive() {
00062         return gActive;
00063       }
00064       bool wasActive() {
00065         return gActive0;
00066       }
00067       fmatvec::Vec& getRelativeDistance() {
00068         return gk;
00069       }
00070 
00071       fmatvec::Vec& getRelativeVelocity() {
00072         return gdk;
00073       }
00074 
00075       fmatvec::Vec& getContactForce() {
00076         return lak;
00077       }
00078 
00079       fmatvec::Vec& getForce(int index) {
00080         return *(WF[index]);
00081       }
00082 
00083       void setFrictionForceLaw(FrictionForceLaw* frictionForceLaw_) {
00084         fdf = frictionForceLaw_;
00085       }
00086 
00087 #ifdef HAVE_OPENMBVCPPINTERFACE
00088       void enableOpenMBVContactPoints(double size = 1., bool enable = true) {
00089         openMBVContactFrameSize = size;
00090         openMBVContactFrameEnabled = enable;
00091       }
00092       std::vector<OpenMBV::Frame*> getOpenMBVContactFrame() const {
00093         return openMBVContactFrames;
00094       }
00095       OpenMBV::Arrow* getOpenMBVNormalForceArrow() const {
00096         return openMBVNormalForceArrow;
00097       }
00098       void enableOpenMBVNormalForceArrow(OpenMBV::Arrow* NormalForceArrow_) {
00099         openMBVNormalForceArrow = NormalForceArrow_;
00100       }
00101       OpenMBV::Arrow* getOpenMBVFrictionForceArrow() const {
00102         return openMBVFrictionForceArrow;
00103       }
00104       void enableOpenMBVFrictionForceArrow(OpenMBV::Arrow* FrictionForceArrow_) {
00105         openMBVFrictionForceArrow = FrictionForceArrow_;
00106       }
00107 #endif
00108       /******************/
00109 
00110       void init(InitStage stage);
00111 
00112       void plot(double t, double dt);
00113 
00114       void updateg(double t) {
00115         contactKinematics->updateg(gk, cpData[0]);
00116       }
00117 
00118       void updategd(double t);
00119 
00120       void checkActiveg();
00121 
00122       int getFrictionDirections();
00123 
00124       FrictionForceLaw* getFrictionForceLaw() {
00125         return fdf;
00126       }
00127     protected:
00128 
00134       Contour* contour1;
00135 
00139       Contour* contour2;
00140 
00144       ContactKinematics* contactKinematics;
00145 
00149       FrictionForceLaw* fdf;
00150 
00157       std::vector<ContourPointData*> cpData;
00158 
00162       double gTol;
00163 
00167       bool gActive;
00168 
00172       bool gActive0;
00173 
00177       fmatvec::Vec gk;
00178 
00182       fmatvec::Vec gdk;
00183 
00187       fmatvec::Vec lak;
00188 
00192       std::vector<fmatvec::Vec*> WF;
00193 
00194 #ifdef HAVE_OPENMBVCPPINTERFACE
00195 
00199       OpenMBV::Group* openMBVGroup;
00200 
00204       bool openMBVContactFrameEnabled;
00205 
00209       std::vector<OpenMBV::Frame*> openMBVContactFrames;
00210 
00214       double openMBVContactFrameSize;
00215 
00219       OpenMBV::Arrow* openMBVNormalForceArrow;
00220 
00224       OpenMBV::Arrow* openMBVFrictionForceArrow;
00225 #endif
00226   };
00227 }
00228 
00229 #endif /* CONTOURPAIRING_H_ */