openmbvcppinterface  3.1.0
OpenMBV C++ Interface
path.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_PATH_H_
21 #define _OPENMBV_PATH_H_
22 
23 #include <openmbvcppinterface/body.h>
24 #include <hdf5serie/vectorserie.h>
25 #include <vector>
26 #include <stdexcept>
27 
28 namespace OpenMBV {
29 
36  class Path : public Body {
37  friend class ObjectFactory;
38  protected:
39  void createHDF5File() override;
40  void openHDF5File() override;
42  std::vector<double> color;
43 
44  Path();
45  ~Path() override;
46  public:
48  template<typename T>
49  void append(const T& row) {
50  if(data==nullptr) throw std::runtime_error("can not append data to an environment object");
51  if(row.size()!=4) throw std::runtime_error("the dimension does not match");
52  data->append(row);
53  }
54 
55  int getRows() override { return data?data->getRows():0; }
56  std::vector<double> getRow(int i) override { return data?data->getRow(i):std::vector<double>(4); }
57 
59  void setColor(const std::vector<double>& hsv) {
60  if(hsv.size()!=3) throw std::runtime_error("the dimension does not match");
61  color=hsv;
62  }
63 
64  std::vector<double> getColor() { return color; }
65 
67  void setColor(double h, double s, double v) {
68  std::vector<double> hsv;
69  hsv.push_back(h);
70  hsv.push_back(s);
71  hsv.push_back(v);
72  color=hsv;
73  }
74 
76  void initializeUsingXML(xercesc::DOMElement *element) override;
77 
78  xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
79  };
80 
81 }
82 
83 #endif
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: path.cc:67
Definition: objectfactory.h:36
void setColor(const std::vector< double > &hsv)
Definition: path.h:59
void getRow(int row, size_t size, T data[])
Definition: path.h:36
int getRows() override
Definition: path.h:55
void append(const T data[], size_t size)
void setColor(double h, double s, double v)
Definition: path.h:67
void append(const T &row)
Definition: path.h:49
std::vector< double > getRow(int i) override
Definition: path.h:56
Definition: body.h:31