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 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_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 
31  friend class ObjectFactory;
32  protected:
33  std::vector<std::vector<double> > cp;
34  int num{0};
35  std::vector<double> knot;
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
void append(const T &row)
Definition: dynamicnurbscurve.h:58
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: dynamicnurbscurve.cc:71
Definition: objectfactory.h:36
void getRow(int row, size_t size, T data[])
std::vector< double > getRow(int i) override
Definition: dynamicnurbscurve.h:64
void createHDF5File() override
Definition: dynamicnurbscurve.cc:40
Definition: dynamicnurbscurve.h:30
void setControlPoints(const std::vector< std::vector< double > > &cp_)
Definition: dynamicnurbscurve.h:52
int getRows() override
Definition: dynamicnurbscurve.h:63
const std::vector< std::vector< double > > & getControlPoints()
Definition: dynamicnurbscurve.h:46
Definition: dynamiccoloredbody.h:28
void append(const T data[], size_t size)