MBSim

Project Page
body.h
1 /* Copyright (C) 2004-2010 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  /* INHERITED INTERFACE OF OBJECTINTERFACE */
66  void sethSize(int hSize_, int i=0);
67  void sethInd(int hInd_, int i=0);
68  /*******************************************************/
69 
70  /* INHERITED INTERFACE OF ELEMENT */
71  virtual void plot(double t, double dt = 1);
72  virtual void closePlot();
73  virtual std::string getType() const { return "Body"; }
75  /*******************************************************/
76 
77  /* INHERITED INTERFACE OF OBJECT */
78  virtual void init(InitStage stage);
79  /*******************************************************/
80 
81  /* INTERFACE FOR DERIVED CLASSES */
85  virtual void addContour(Contour* contour);
86 
90  virtual void addFrame(Frame * frame);
91 
97  virtual Contour* getContour(const std::string &name, bool check=true);
98 
104  virtual Frame* getFrame(const std::string &name, bool check=true);
105 
110 
114  virtual const Frame *getFrameOfReference() const { return frameOfReference; }
115 
120  /*******************************************************/
121 
122  /* GETTER / SETTER */
123  const std::vector<Frame*>& getFrames() const { return frame; }
124  const std::vector<Contour*>& getContours() const { return contour; }
125 #ifdef HAVE_OPENMBVCPPINTERFACE
126  OpenMBV::Group* getOpenMBVGrp() { return openMBVGrp; }
127  OpenMBV::Body* getOpenMBVBody() { return openMBVBody; }
128 #endif
129  /*******************************************************/
130 
135  int frameIndex(const Frame *frame_) const;
136 
141  int contourIndex(const Contour *contour_) const;
142 
143  virtual void initializeUsingXML(TiXmlElement *element);
144 
145  virtual Element * getByPathSearch(std::string path);
146 
147  protected:
151  std::vector<Frame*> frame;
152  std::vector<Contour*> contour;
153 
158 
159 #ifdef HAVE_OPENMBVCPPINTERFACE
160  OpenMBV::Body* openMBVBody;
161  OpenMBV::Group* openMBVGrp;
162 #endif
163 
164  private:
165  std::string saved_frameOfReference;
166  };
167 
168 }
169 
170 #endif
171