mbsimflexiblebody 4.0.0 MBSim Flexible Body Module

flexible_band.h
1 /* Copyright (C) 2004-2015 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: martin.o.foerg@googlemail.com
18 */
19
20 #ifndef _FLEXIBLE_BAND_H_
21 #define _FLEXIBLE_BAND_H_
22
23 #include "mbsimFlexibleBody/contours/contour1s.h"
24 #include "mbsimFlexibleBody/utils/contact_utils.h"
25 #include "mbsim/utils/eps.h"
26
27 #include <openmbvcppinterface/spineextrusion.h>
28 #include "mbsim/utils/boost_parameters.h"
29 #include <mbsim/utils/openmbv_utils.h>
30
31 #include <list>
32
33 namespace MBSim {
34
35 BOOST_PARAMETER_NAME(numberOfSpinePoints)
36
37 }
38
39 namespace MBSimFlexibleBody {
40
41 class FlexibleBand : public Contour1s {
42 public:
47 FlexibleBand(const std::string& name) : Contour1s(name), width(0), ARK(fmatvec::EYE), sOld(-1e12) { }
48
49 /* INHERITED INTERFACE OF ELEMENT */
50 void init(InitStage stage, const MBSim::InitConfigSet &config) override;
51 /***************************************************/
52
53 MBSim::ContourFrame* createContourFrame(const std::string &name="P") override;
54
55 /* GETTER / SETTER */
56 void setWidth(double width_) { width = width_; }
57 double getWidth() const { return width; }
58
59 void setRelativePosition(const fmatvec::Vec2 &r);
60 void setRelativeOrientation(double al);
61
62 const fmatvec::Vec3& getRelativePosition() const { return RrRP; }
63 const fmatvec::SqrMat3& getRelativeOrientation() const { return ARK; }
64
65 fmatvec::Vec3 evalPosition(const fmatvec::Vec2 &zeta) override { return evalPosition(zeta(0)); }
66 fmatvec::Vec3 evalWs(const fmatvec::Vec2 &zeta) override { return evalWs(zeta(0)); }
67 fmatvec::Vec3 evalWt(const fmatvec::Vec2 &zeta) override { return evalWt(zeta(0)); }
68 fmatvec::Vec3 evalWu(const fmatvec::Vec2 &zeta) override { return evalWs(zeta); }
69 fmatvec::Vec3 evalWv(const fmatvec::Vec2 &zeta) override { return evalWt(zeta); }
70
71 bool isZetaOutside(const fmatvec::Vec2 &zeta) override;
72
73 void updatePositions(double s);
74
75 fmatvec::Vec3 evalPosition(double s) { if(fabs(s-sOld)>MBSim::macheps) updatePositions(s); return WrOP; }
76 fmatvec::Vec3 evalWs(double s) { if(fabs(s-sOld)>MBSim::macheps) updatePositions(s); return Ws; }
77 fmatvec::Vec3 evalWt(double s) { if(fabs(s-sOld)>MBSim::macheps) updatePositions(s); return Wt; }
78
79 void plot() override;
80
81 void setContourOfReference(Contour1s *contour_) { contour = contour_; }
82
83 MBSim::ContactKinematics * findContactPairingWith(const std::type_info &type0, const std::type_info &type1) override { return findContactPairingFlexible(type0, type1); }
84
85 void setNodes(const std::vector<double> &nodes_) { etaNodes = nodes_; }
86
87 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, MBSim::tag, (optional (numberOfSpinePoints,(int),10)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
88 openMBVSpineExtrusion = OpenMBV::ObjectFactory::create<OpenMBV::SpineExtrusion>();
89 openMBVSpineExtrusion->setNumberOfSpinePoints(numberOfSpinePoints);
90 }
91
92 void resetUpToDate() override;
93
94 protected:
98 double width;
99
100 fmatvec::Vec3 RrRP, WrOP, Ws, Wt;
101 fmatvec::SqrMat3 ARK;
102
103 Contour1s* contour;
104
105 double sOld;
106
107 std::shared_ptr<OpenMBV::SpineExtrusion> openMBVSpineExtrusion;
108 };
109
110 }
111
112 #endif /* _FLEXIBLE_BAND_H_ */
MBSimFlexibleBody::FlexibleBand::width
double width
width of flexible band
Definition: flexible_band.h:98
MBSimFlexibleBody::FlexibleBand::FlexibleBand
FlexibleBand(const std::string &name)
constructor
Definition: flexible_band.h:47
MBSimFlexibleBody::Contour1s
basic class for contours described by one contour parameter
Definition: contour1s.h:35
MBSim::Element::InitStage
InitStage
MBSim::ContourFrame
MBSimFlexibleBody::Contour1s::Contour1s
Contour1s(const std::string &name)
constructor
Definition: contour1s.h:41
MBSimFlexibleBody::FlexibleBand
Definition: flexible_band.h:41
MBSim::Element::name
std::string name
MBSim::ContactKinematics