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 library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
28namespace 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 getRow(int row, size_t size, T data[])
void append(const T data[], size_t size)
Definition: body.h:32
Definition: objectfactory.h:38
Definition: path.h:36
std::vector< double > getRow(int i) override
Definition: path.h:56
void setColor(double h, double s, double v)
Definition: path.h:67
int getRows() override
Definition: path.h:55
void append(const T &row)
Definition: path.h:49
void setColor(const std::vector< double > &hsv)
Definition: path.h:59
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: path.cc:67