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 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_FLEXIBLEBODY_H
21 #define _OPENMBV_FLEXIBLEBODY_H
22 
23 #include <openmbvcppinterface/dynamiccoloredbody.h>
24 #include <vector>
25 #include <hdf5serie/vectorserie.h>
26 
27 namespace 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 setNumberOfVertexPositions(int num)
Definition: flexiblebody.h:47
void getRow(int row, size_t size, T data[])
int getNumberOfVertexPositions() const
Definition: flexiblebody.h:43
Definition: dynamiccoloredbody.h:28
int getRows() override
Definition: flexiblebody.h:56
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: flexiblebody.cc:63
void append(const T data[], size_t size)
std::vector< double > getRow(int i) override
Definition: flexiblebody.h:57
void append(const T &row)
Definition: flexiblebody.h:51
Abstract base class for all flexible bodies.
Definition: flexiblebody.h:31