MBSim

Project Page
body.h
00001 /* Copyright (C) 2004-2010 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: martin.o.foerg@googlemail.com
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       /* INHERITED INTERFACE OF OBJECTINTERFACE */
00071       void sethSize(int hSize_, int i=0);
00072       void sethInd(int hInd_, int i=0); 
00073       /*******************************************************/ 
00074 
00075       /* INHERITED INTERFACE OF ELEMENT */
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       /* INHERITED INTERFACE OF OBJECT */
00083       virtual void init(InitStage stage);
00084       /*******************************************************/ 
00085 
00086       /* INTERFACE FOR DERIVED CLASSES */
00087 
00093       virtual Contour* getContour(const std::string &name, bool check=true);
00094 
00100       virtual Frame* getFrame(const std::string &name, bool check=true);
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       /* GETTER / SETTER */
00119       const std::vector<Frame*>& getFrames() const { return frame; }
00120       const std::vector<Contour*>& getContours() const { return contour; }
00121 #ifdef HAVE_OPENMBVCPPINTERFACE
00122       OpenMBV::Group* getOpenMBVGrp() { return openMBVGrp; }
00123       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 * getByPathSearch(std::string path);
00143 
00144     protected:
00148       virtual void addFrame(Frame * frame);
00149 
00153       virtual void addContour(Contour* contour);
00154 
00158       std::vector<Frame*> frame;
00159       std::vector<Contour*> contour;
00160 
00164       Frame *R;
00165 
00166 #ifdef HAVE_OPENMBVCPPINTERFACE
00167       OpenMBV::Body* openMBVBody;
00168       OpenMBV::Group* openMBVGrp;
00169 #endif
00170 
00171     private:
00172       std::string saved_frameOfReference;
00173   };
00174 
00175 }
00176 
00177 #endif
00178