openmbvcppinterface  3.1.0
OpenMBV C++ Interface
flexiblebody.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_FLEXIBLEBODY_H
21#define _OPENMBV_FLEXIBLEBODY_H
22
23#include <openmbvcppinterface/dynamiccoloredbody.h>
24#include <vector>
25#include <hdf5serie/vectorserie.h>
26
27namespace OpenMBV {
28
32 protected:
33 int numvp{0};
35 FlexibleBody() = default;
36 ~FlexibleBody() override = default;
37 xercesc::DOMElement *writeXMLFile(xercesc::DOMNode *parent) override;
38 void createHDF5File() override;
39 void openHDF5File() override;
40 public:
43 int getNumberOfVertexPositions() const { return numvp; }
44
47 void setNumberOfVertexPositions(int num) { numvp = num; }
48
50 template<typename T>
51 void append(const T& row) {
52 if(data==nullptr) throw std::runtime_error("can not append data to an environment object");
53 data->append(row);
54 }
55
56 int getRows() override { return data?data->getRows():0; }
57 std::vector<double> getRow(int i) override { return data?data->getRow(i):std::vector<double>(1+3*numvp); }
58
60 void initializeUsingXML(xercesc::DOMElement *element) override;
61 };
62
63}
64
65#endif
void getRow(int row, size_t size, T data[])
void append(const T data[], size_t size)
Definition: dynamiccoloredbody.h:28
Abstract base class for all flexible bodies.
Definition: flexiblebody.h:31
void append(const T &row)
Definition: flexiblebody.h:51
void setNumberOfVertexPositions(int num)
Definition: flexiblebody.h:47
int getNumberOfVertexPositions() const
Definition: flexiblebody.h:43
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: flexiblebody.cc:63
std::vector< double > getRow(int i) override
Definition: flexiblebody.h:57
int getRows() override
Definition: flexiblebody.h:56