openmbvcppinterface 3.1.0 OpenMBV C++ Interface

dynamicnurbscurve.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_DYNAMICNURBSCURVE_H
21 #define _OPENMBV_DYNAMICNURBSCURVE_H
22
23 #include <openmbvcppinterface/dynamiccoloredbody.h>
24 #include <vector>
25 #include <hdf5serie/vectorserie.h>
26
27 namespace OpenMBV {
28
30 class DynamicNurbsCurve : public DynamicColoredBody {
31 friend class ObjectFactory;
32 protected:
33 std::vector<std::vector<double> > cp;
34 int num{0};
35 std::vector<double> knot;
36 H5::VectorSerie<double>* data;
37 DynamicNurbsCurve() = default;
38 ~DynamicNurbsCurve() override = default;
39 xercesc::DOMElement *writeXMLFile(xercesc::DOMNode *parent) override;
41 void createHDF5File() override;
42 void openHDF5File() override;
43 public:
46 const std::vector<std::vector<double> >& getControlPoints() { return cp; }
47 int getNumberOfControlPoints() { return num; }
48 const std::vector<double>& getKnotVector() { return knot; }
49
52 void setControlPoints(const std::vector<std::vector<double> > &cp_) { cp = cp_; }
53 void setNumberOfControlPoints(int num_) { num = num_; }
54 void setKnotVector(const std::vector<double>& knot_) { knot = knot_; }
55
57 template<typename T>
58 void append(const T& row) {
59 if(data==nullptr) throw std::runtime_error("can not append data to an environment object");
60 data->append(row);
61 }
62
63 int getRows() override { return data?data->getRows():0; }
64 std::vector<double> getRow(int i) override { return data?data->getRow(i):std::vector<double>(1+4*num); }
65
67 void initializeUsingXML(xercesc::DOMElement *element) override;
68 };
69
70 }
71
72 #endif
OpenMBV::DynamicNurbsCurve::append
void append(const T &row)
Definition: dynamicnurbscurve.h:58
OpenMBV::DynamicNurbsCurve::initializeUsingXML
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: dynamicnurbscurve.cc:67
OpenMBV::ObjectFactory
Definition: objectfactory.h:38
H5::VectorSerie::getRow
void getRow(int row, size_t size, T data[])
OpenMBV::DynamicNurbsCurve::getRow
std::vector< double > getRow(int i) override
Definition: dynamicnurbscurve.h:64
OpenMBV::DynamicNurbsCurve::createHDF5File
void createHDF5File() override
Definition: dynamicnurbscurve.cc:40
OpenMBV::DynamicNurbsCurve
Definition: dynamicnurbscurve.h:30
OpenMBV::DynamicNurbsCurve::setControlPoints
void setControlPoints(const std::vector< std::vector< double > > &cp_)
Definition: dynamicnurbscurve.h:52
OpenMBV::DynamicNurbsCurve::getRows
int getRows() override
Definition: dynamicnurbscurve.h:63
OpenMBV::DynamicNurbsCurve::getControlPoints
const std::vector< std::vector< double > > & getControlPoints()
Definition: dynamicnurbscurve.h:46
OpenMBV::DynamicColoredBody
Definition: dynamiccoloredbody.h:28
H5::VectorSerie< double >
H5::VectorSerie::append
void append(const T data[], size_t size)
H5::VectorSerie::getRows
int getRows()