All Classes Namespaces Functions Variables Typedefs Enumerations Pages
compoundrigidbody.h
1 /*
2  OpenMBV - Open Multi Body Viewer.
3  Copyright (C) 2009 Markus Friedrich
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 #ifndef _OPENMBV_COMPOUNDRIGIDBODY_H_
21 #define _OPENMBV_COMPOUNDRIGIDBODY_H_
22 
23 #include <openmbvcppinterface/rigidbody.h>
24 #include <vector>
25 #include <boost/enable_shared_from_this.hpp>
26 
27 namespace OpenMBV {
28 
31 #ifndef SWIG
32  , public boost::enable_shared_from_this<CompoundRigidBody>
33 #endif
34  {
35  friend class RigidBody;
36  friend class ObjectFactory;
37  protected:
38  std::string expandStr;
39  std::vector<boost::shared_ptr<RigidBody> > rigidBody;
40 
43  public:
44 
46  std::string getClassName() { return "CompoundRigidBody"; }
47 
49  void addRigidBody(boost::shared_ptr<RigidBody> rigidBody_) {
50  if(rigidBody_->name=="") throw std::runtime_error("the object to be added must have a name");
51  for(unsigned int i=0; i<rigidBody.size(); i++)
52  if(rigidBody[i]->name==rigidBody_->name) throw std::runtime_error("a object of the same name already exists");
53  rigidBody.push_back(rigidBody_);
54  rigidBody_->parent.reset();
55  rigidBody_->compound=shared_from_this();
56  }
57 
58  std::vector<boost::shared_ptr<RigidBody> >& getRigidBodies() {
59  return rigidBody;
60  }
61 
63  virtual void initializeUsingXML(xercesc::DOMElement *element);
64 
65  xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent);
66 
68  void setExpand(bool expand) { expandStr=(expand==true)?"true":"false"; }
69 
70  bool getExpand() { return expandStr=="true"?true:false; }
71  };
72 
73 }
74 
75 #endif
Abstract base class for all rigid bodies.
Definition: rigidbody.h:70
Definition: objectfactory.h:40
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: compoundrigidbody.cc:48
void setExpand(bool expand)
Definition: compoundrigidbody.h:68
void addRigidBody(boost::shared_ptr< RigidBody > rigidBody_)
Definition: compoundrigidbody.h:49
std::string getClassName()
Definition: compoundrigidbody.h:46
Definition: compoundrigidbody.h:30

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML