All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
body.h
1 /* Copyright (C) 2004-2014 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 _BODY_H_
21 #define _BODY_H_
22 
23 #include <mbsim/object.h>
24 #ifdef HAVE_OPENMBVCPPINTERFACE
25 namespace OpenMBV {
26  class Body;
27 }
28 #endif
29 
30 namespace MBSim {
31 
32  class Frame;
33  class Contour;
34 
52  class Body : public Object {
53  public:
58  Body(const std::string &name);
59 
63  virtual ~Body();
64 
65  void setInitialGeneralizedPosition(const fmatvec::Vec &q0_) { q0 = q0_; }
66  void setInitialGeneralizedVelocity(const fmatvec::Vec &u0_) { u0 = u0_; }
67  void setInitialGeneralizedPosition(double q0_) { q0 = fmatvec::Vec(1,fmatvec::INIT,q0_); }
68  void setInitialGeneralizedVelocity(double u0_) { u0 = fmatvec::Vec(1,fmatvec::INIT,u0_); }
69 
70  /* INHERITED INTERFACE OF OBJECTINTERFACE */
71  void sethSize(int hSize_, int i=0);
72  void sethInd(int hInd_, int i=0);
73  /*******************************************************/
74 
75  /* INHERITED INTERFACE OF ELEMENT */
76  virtual void plot(double t, double dt = 1);
77  virtual void closePlot();
78  virtual std::string getType() const { return "Body"; }
80  /*******************************************************/
81 
82  /* INHERITED INTERFACE OF OBJECT */
83  virtual void init(InitStage stage);
84  /*******************************************************/
85 
86  /* INTERFACE FOR DERIVED CLASSES */
87 
93  virtual Contour* getContour(const std::string &name, bool check=true) const;
94 
100  virtual Frame* getFrame(const std::string &name, bool check=true) const;
101 
105  virtual Frame *getFrameOfReference() { return R; }
106 
110  virtual const Frame *getFrameOfReference() const { return R; }
111 
115  virtual void setFrameOfReference(Frame *frame) { R = frame; }
116  /*******************************************************/
117 
118  /* GETTER / SETTER */
119  const std::vector<Frame*>& getFrames() const { return frame; }
120  const std::vector<Contour*>& getContours() const { return contour; }
121 #ifdef HAVE_OPENMBVCPPINTERFACE
122  boost::shared_ptr<OpenMBV::Group> getOpenMBVGrp() { return openMBVGrp; }
123  boost::shared_ptr<OpenMBV::Body>& getOpenMBVBody() { return openMBVBody; }
124 #endif
125  /*******************************************************/
126 
131  int frameIndex(const Frame *frame_) const;
132 
137  int contourIndex(const Contour *contour_) const;
138 
139  virtual void initializeUsingXML(xercesc::DOMElement *element);
140  virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
141 
142  virtual Element * getChildByContainerAndName(const std::string &container, const std::string &name) const;
143 
144  fmatvec::Mat3xV& getPJT(int i=0) {return PJT[i];}
145  fmatvec::Mat3xV& getPJR(int i=0) {return PJR[i];}
146  int getuRelSize(int i=0) const {return nu[i];}
147 
148  protected:
152  virtual void addFrame(Frame * frame);
153 
157  virtual void addContour(Contour* contour);
158 
162  std::vector<Frame*> frame;
163  std::vector<Contour*> contour;
164 
169 
173  fmatvec::Mat3xV PJT[2], PJR[2];
174 
175  int nu[2], nq;
176 
177 #ifdef HAVE_OPENMBVCPPINTERFACE
178  boost::shared_ptr<OpenMBV::Body> openMBVBody;
179  boost::shared_ptr<OpenMBV::Group> openMBVGrp;
180 #endif
181 
182  private:
183  std::string saved_frameOfReference;
184  };
185 
186 }
187 
188 #endif
189 
virtual void setFrameOfReference(Frame *frame)
Definition: body.h:115
virtual ~Body()
destructor
Definition: body.cc:42
virtual void closePlot()
closes plot file
Definition: body.cc:78
int contourIndex(const Contour *contour_) const
Definition: body.cc:194
Vector< Ref, double > Vec
virtual void plot(double t, double dt=1)
plots time dependent data
Definition: body.cc:67
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:49
virtual void init(InitStage stage)
initialize object at start of simulation with respect to contours and frames
Definition: body.cc:98
basic class for contour definition for rigid (which do not know about their shape) and flexible (they...
Definition: contour.h:51
virtual Frame * getFrame(const std::string &name, bool check=true) const
Definition: body.cc:172
fmatvec::Mat3xV PJT[2]
Definition: body.h:173
Frame * R
frame of reference of the object
Definition: body.h:168
virtual Contour * getContour(const std::string &name, bool check=true) const
Definition: body.cc:158
InitStage
The stages of the initialization.
Definition: element.h:97
virtual Element * getChildByContainerAndName(const std::string &container, const std::string &name) const
Get the Element named name in the container named container.
Definition: body.cc:225
std::string name
name of element
Definition: element.h:290
std::vector< Frame * > frame
vector of frames and contours
Definition: body.h:162
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
Body(const std::string &name)
constructor
Definition: body.cc:38
int frameIndex(const Frame *frame_) const
Definition: body.cc:186
virtual void addContour(Contour *contour)
Definition: body.cc:140
virtual void setDynamicSystemSolver(DynamicSystemSolver *sys)
sets the used dynamics system solver to the element
Definition: body.cc:89
virtual std::string getType() const
Definition: body.h:78
virtual const Frame * getFrameOfReference() const
Definition: body.h:110
virtual Frame * getFrameOfReference()
Definition: body.h:105
Element(const std::string &name)
constructor
Definition: element.cc:44
virtual void addFrame(Frame *frame)
Definition: body.cc:149
base class for all mechanical bodies with mass and generalised coordinates
Definition: body.h:52
class for all objects having own dynamics and mass
Definition: object.h:42
fmatvec::Vec q0
initial position, velocity
Definition: object.h:315

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML