00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _BODY_H_
00021 #define _BODY_H_
00022
00023 #include <mbsim/object.h>
00024 #ifdef HAVE_OPENMBVCPPINTERFACE
00025 namespace OpenMBV {
00026 class Body;
00027 }
00028 #endif
00029
00030 namespace MBSim {
00031
00032 class Frame;
00033 class Contour;
00034
00052 class Body : public Object {
00053 public:
00058 Body(const std::string &name);
00059
00063 virtual ~Body();
00064
00065 void setInitialGeneralizedPosition(const fmatvec::Vec &q0_) { q0 = q0_; }
00066 void setInitialGeneralizedVelocity(const fmatvec::Vec &u0_) { u0 = u0_; }
00067 void setInitialGeneralizedPosition(double q0_) { q0 = fmatvec::Vec(1,fmatvec::INIT,q0_); }
00068 void setInitialGeneralizedVelocity(double u0_) { u0 = fmatvec::Vec(1,fmatvec::INIT,u0_); }
00069
00070
00071 void sethSize(int hSize_, int i=0);
00072 void sethInd(int hInd_, int i=0);
00073
00074
00075
00076 virtual void plot(double t, double dt = 1);
00077 virtual void closePlot();
00078 virtual std::string getType() const { return "Body"; }
00079 virtual void setDynamicSystemSolver(DynamicSystemSolver *sys);
00080
00081
00082
00083 virtual void init(InitStage stage);
00084
00085
00086
00087
00093 virtual Contour* getContour(const std::string &name, bool check=true) const;
00094
00100 virtual Frame* getFrame(const std::string &name, bool check=true) const;
00101
00105 virtual Frame *getFrameOfReference() { return R; }
00106
00110 virtual const Frame *getFrameOfReference() const { return R; }
00111
00115 virtual void setFrameOfReference(Frame *frame) { R = frame; }
00116
00117
00118
00119 const std::vector<Frame*>& getFrames() const { return frame; }
00120 const std::vector<Contour*>& getContours() const { return contour; }
00121 #ifdef HAVE_OPENMBVCPPINTERFACE
00122 boost::shared_ptr<OpenMBV::Group> getOpenMBVGrp() { return openMBVGrp; }
00123 boost::shared_ptr<OpenMBV::Body>& getOpenMBVBody() { return openMBVBody; }
00124 #endif
00125
00126
00131 int frameIndex(const Frame *frame_) const;
00132
00137 int contourIndex(const Contour *contour_) const;
00138
00139 virtual void initializeUsingXML(xercesc::DOMElement *element);
00140 virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00141
00142 virtual Element * getChildByContainerAndName(const std::string &container, const std::string &name) const;
00143
00144 fmatvec::Mat3xV& getPJT(int i=0) {return PJT[i];}
00145 fmatvec::Mat3xV& getPJR(int i=0) {return PJR[i];}
00146 int getuRelSize(int i=0) const {return nu[i];}
00147
00148 protected:
00152 virtual void addFrame(Frame * frame);
00153
00157 virtual void addContour(Contour* contour);
00158
00162 std::vector<Frame*> frame;
00163 std::vector<Contour*> contour;
00164
00168 Frame *R;
00169
00173 fmatvec::Mat3xV PJT[2], PJR[2];
00174
00175 int nu[2], nq;
00176
00177 #ifdef HAVE_OPENMBVCPPINTERFACE
00178 boost::shared_ptr<OpenMBV::Body> openMBVBody;
00179 boost::shared_ptr<OpenMBV::Group> openMBVGrp;
00180 #endif
00181
00182 private:
00183 std::string saved_frameOfReference;
00184 };
00185
00186 }
00187
00188 #endif
00189