All Classes Namespaces Functions Variables Typedefs Enumerations Pages
rigidbody.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_RIGIDBODY_H_
21 #define _OPENMBV_RIGIDBODY_H_
22 
23 #include <openmbvcppinterface/dynamiccoloredbody.h>
24 #include <vector>
25 #include <assert.h>
26 #include <hdf5serie/vectorserie.h>
27 #include <stdexcept>
28 
29 namespace OpenMBV {
30 
31  class CompoundRigidBody;
32 
69  class RigidBody : public DynamicColoredBody {
70  friend class CompoundRigidBody;
71  protected:
72  std::string localFrameStr, referenceFrameStr, pathStr, draggerStr;
73  std::vector<double> initialTranslation;
74  std::vector<double> initialRotation;
75  double scaleFactor;
76  void createHDF5File();
77  void openHDF5File();
79  std::weak_ptr<CompoundRigidBody> compound;
80 
81  RigidBody();
82  ~RigidBody();
83  public:
85  void setLocalFrame(bool f) { localFrameStr=(f==true)?"true":"false"; }
86 
87  bool getLocalFrame() { return localFrameStr=="true"?true:false; }
88 
90  void setReferenceFrame(bool f) { referenceFrameStr=(f==true)?"true":"false"; }
91 
92  bool getReferenceFrame() { return referenceFrameStr=="true"?true:false; }
93 
95  void setPath(bool p) { pathStr=(p==true)?"true":"false"; }
96 
97  bool getPath() { return pathStr=="true"?true:false; }
98 
100  void setDragger(bool p) { draggerStr=(p==true)?"true":"false"; }
101 
102  bool getDragger() { return draggerStr=="true"?true:false; }
103 
105  void setInitialTranslation(const std::vector<double> &initTrans) {
106  if(initTrans.size()!=3) std::runtime_error("the dimension does not match");
107  initialTranslation=initTrans;
108  }
109 
110  std::vector<double> getInitialTranslation() { return initialTranslation; }
111 
113  void setInitialTranslation(double x, double y, double z) {
114  std::vector<double> initTrans;
115  initTrans.push_back(x);
116  initTrans.push_back(y);
117  initTrans.push_back(z);
118  initialTranslation=initTrans;
119  }
120 
124  void setInitialRotation(const std::vector<double>& initRot) {
125  if(initRot.size()!=3) throw std::runtime_error("the dimension does not match");
126  initialRotation=initRot;
127  }
128 
129  std::vector<double> getInitialRotation() { return initialRotation; }
130 
134  void setInitialRotation(double a, double b, double g) {
135  std::vector<double> initRot;
136  initRot.push_back(a);
137  initRot.push_back(b);
138  initRot.push_back(g);
139  initialRotation=initRot;
140  }
141 
143  void setScaleFactor(double scale) {
144  scaleFactor=scale;
145  }
146 
147  double getScaleFactor() { return scaleFactor; }
148 
150  template<typename T>
151  void append(const T& row) {
152  if(data==0) throw std::runtime_error("can not append data to an environment object");
153  if(row.size()!=8) throw std::runtime_error("the dimension does not match");
154  if(!std::isnan(dynamicColor))
155  {
156  std::vector<double> tmprow(8);
157  std::copy(&row[0], &row[8], tmprow.begin());
158  tmprow[7]=dynamicColor;
159  data->append(tmprow);
160  }
161  else
162  data->append(row);
163  }
164 
165  int getRows() { return data?data->getRows():-1; }
166  std::vector<double> getRow(int i) { return data?data->getRow(i):std::vector<double>(8); }
167 
169  virtual void initializeUsingXML(xercesc::DOMElement *element);
170 
171  xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent);
172 
173  virtual std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false);
174 
175  std::shared_ptr<Group> getSeparateGroup();
176  std::shared_ptr<Group> getTopLevelGroup();
177  };
178 
179 }
180 
181 #endif /* _OPENMBV_RIGIDBODY_H_ */
182 
void setInitialTranslation(double x, double y, double z)
Definition: rigidbody.h:113
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: rigidbody.cc:86
void append(const T &row)
Definition: rigidbody.h:151
void setInitialRotation(double a, double b, double g)
Definition: rigidbody.h:134
Abstract base class for all rigid bodies.
Definition: rigidbody.h:69
int getRows()
Definition: rigidbody.h:165
void setReferenceFrame(bool f)
Definition: rigidbody.h:90
void setScaleFactor(double scale)
Definition: rigidbody.h:143
void setInitialTranslation(const std::vector< double > &initTrans)
Definition: rigidbody.h:105
Definition: dynamiccoloredbody.h:28
std::vector< double > getRow(int i)
Definition: rigidbody.h:166
void setLocalFrame(bool f)
Definition: rigidbody.h:85
void getRow(const int row, size_t size, T data[])
void append(const T data[], size_t size)
virtual std::string getFullName(bool includingFileName=false, bool stopAtSeparateFile=false)
Definition: rigidbody.cc:119
void setDragger(bool p)
Definition: rigidbody.h:100
void setInitialRotation(const std::vector< double > &initRot)
Definition: rigidbody.h:124
void setPath(bool p)
Definition: rigidbody.h:95
Definition: compoundrigidbody.h:29

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML