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 
26 namespace OpenMBV {
27 
30 #ifndef SWIG
31  , public std::enable_shared_from_this<CompoundRigidBody>
32 #endif
33  {
34  friend class RigidBody;
35  friend class ObjectFactory;
36  protected:
37  std::string expandStr;
38  std::vector<std::shared_ptr<RigidBody> > rigidBody;
39 
42  public:
43 
45  std::string getClassName() { return "CompoundRigidBody"; }
46 
48  void addRigidBody(std::shared_ptr<RigidBody> rigidBody_) {
49  if(rigidBody_->name=="") throw std::runtime_error("the object to be added must have a name");
50  for(unsigned int i=0; i<rigidBody.size(); i++)
51  if(rigidBody[i]->name==rigidBody_->name) throw std::runtime_error("a object of the same name already exists");
52  rigidBody.push_back(rigidBody_);
53  rigidBody_->parent.reset();
54  rigidBody_->compound=shared_from_this();
55  }
56 
57  std::vector<std::shared_ptr<RigidBody> >& getRigidBodies() {
58  return rigidBody;
59  }
60 
62  virtual void initializeUsingXML(xercesc::DOMElement *element);
63 
64  xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent);
65 
67  void setExpand(bool expand) { expandStr=(expand==true)?"true":"false"; }
68 
69  bool getExpand() { return expandStr=="true"?true:false; }
70  };
71 
72 }
73 
74 #endif
void addRigidBody(std::shared_ptr< RigidBody > rigidBody_)
Definition: compoundrigidbody.h:48
Abstract base class for all rigid bodies.
Definition: rigidbody.h:69
Definition: objectfactory.h:36
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: compoundrigidbody.cc:48
void setExpand(bool expand)
Definition: compoundrigidbody.h:67
std::string getClassName()
Definition: compoundrigidbody.h:45
Definition: compoundrigidbody.h:29

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML