MBSim

Project Page
contour_pairing.h
1 /*
2  * ContourPairing.h
3  *
4  * Created on: 25.09.2011
5  * Author: grundl
6  */
7 
8 #ifndef CONTOURPAIRING_H_
9 #define CONTOURPAIRING_H_
10 
11 //#include <mbsim/link_mechanics.h>
12 
13 #include <mbsim/object.h>
14 #include <mbsim/link.h>
15 #include <mbsim/contour_pdata.h>
16 #include <mbsim/constitutive_laws.h>
17 #include <mbsim/contact_kinematics/contact_kinematics.h>
18 
19 #ifdef HAVE_OPENMBVCPPINTERFACE
20 #include <openmbvcppinterface/group.h>
21 #include <openmbvcppinterface/frame.h>
22 #include <openmbvcppinterface/arrow.h>
23 #endif
24 
25 namespace MBSim {
26  class ContourPairing : public Object {
27  public:
28  ContourPairing(const std::string & name_, Contour* contour1, Contour* contour2, bool plotContact = true, ContactKinematics * contactKinematics_ = 0);
29 
30  virtual ~ContourPairing();
31 
32  /*INHERITED INTERFACE OF Object*/
33  void updateStateDependentVariables(double t) {
34  throw MBSimError("ContourPairing::updateStateDependentVariables(double t): Not implemented!");
35  }
36  void updateJacobians(double t, int j = 0);
37  void updateInverseKineticsJacobians(double t) {
38  throw MBSimError("ContourPairing::updateInverseKineticsJacobians(double t): Not implemented!");
39  }
40  void closePlot();
41  /*******************************/
42 
43  void setContactKinematics(ContactKinematics* ck) {
44  contactKinematics = ck;
45  }
46  ContactKinematics* getContactKinematics() const {
47  return contactKinematics;
48  }
49  ContourPointData* getContourPointData() {
50  return cpData[0];
51  }
52  Contour* getContour(const int & index) {
53  if (index == 0)
54  return contour1;
55  return contour2;
56  }
57 #ifdef HAVE_OPENMBVCPPINTERFACE
58  OpenMBV::Group* getOpenMBVGrp() {return openMBVGroup;}
59 #endif
60 
61  bool isActive() {
62  return gActive;
63  }
64  bool wasActive() {
65  return gActive0;
66  }
67  fmatvec::Vec& getRelativeDistance() {
68  return gk;
69  }
70 
71  fmatvec::Vec& getRelativeVelocity() {
72  return gdk;
73  }
74 
75  fmatvec::Vec& getContactForce() {
76  return lak;
77  }
78 
79  fmatvec::Vec& getForce(int index) {
80  return *(WF[index]);
81  }
82 
83  void setFrictionForceLaw(FrictionForceLaw* frictionForceLaw_) {
84  fdf = frictionForceLaw_;
85  }
86 
87 #ifdef HAVE_OPENMBVCPPINTERFACE
88  void enableOpenMBVContactPoints(double size = 1., bool enable = true) {
89  openMBVContactFrameSize = size;
90  openMBVContactFrameEnabled = enable;
91  }
92  std::vector<OpenMBV::Frame*> getOpenMBVContactFrame() const {
93  return openMBVContactFrames;
94  }
95  OpenMBV::Arrow* getOpenMBVNormalForceArrow() const {
96  return openMBVNormalForceArrow;
97  }
98  void enableOpenMBVNormalForceArrow(OpenMBV::Arrow* NormalForceArrow_) {
99  openMBVNormalForceArrow = NormalForceArrow_;
100  }
101  OpenMBV::Arrow* getOpenMBVFrictionForceArrow() const {
102  return openMBVFrictionForceArrow;
103  }
104  void enableOpenMBVFrictionForceArrow(OpenMBV::Arrow* FrictionForceArrow_) {
105  openMBVFrictionForceArrow = FrictionForceArrow_;
106  }
107 #endif
108  /******************/
109 
110  void init(InitStage stage);
111 
112  void plot(double t, double dt);
113 
114  void updateg(double t) {
116  }
117 
118  void updategd(double t);
119 
120  void checkActiveg();
121 
122  int getFrictionDirections();
123 
124  FrictionForceLaw* getFrictionForceLaw() {
125  return fdf;
126  }
127  protected:
128 
135 
140 
145 
150 
157  std::vector<ContourPointData*> cpData;
158 
162  double gTol;
163 
167  bool gActive;
168 
172  bool gActive0;
173 
177  fmatvec::Vec gk;
178 
182  fmatvec::Vec gdk;
183 
187  fmatvec::Vec lak;
188 
192  std::vector<fmatvec::Vec*> WF;
193 
194 #ifdef HAVE_OPENMBVCPPINTERFACE
195 
199  OpenMBV::Group* openMBVGroup;
200 
204  bool openMBVContactFrameEnabled;
205 
209  std::vector<OpenMBV::Frame*> openMBVContactFrames;
210 
214  double openMBVContactFrameSize;
215 
219  OpenMBV::Arrow* openMBVNormalForceArrow;
220 
224  OpenMBV::Arrow* openMBVFrictionForceArrow;
225 #endif
226  };
227 }
228 
229 #endif /* CONTOURPAIRING_H_ */