openmbvcppinterface  3.1.0
OpenMBV C++ Interface
dynamicivbody.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_DYNAICIVBODY_H_
21#define _OPENMBV_DYNAICIVBODY_H_
22
23#include <openmbvcppinterface/body.h>
24#include <hdf5serie/vectorserie.h>
25#include <string>
26#include <utility>
27
28namespace OpenMBV {
29
31 class DynamicIvBody : public Body {
32 friend class ObjectFactory;
33 public:
35 void setIvFileName(std::string ivFileName_) { ivContent=""; ivFileName=std::move(ivFileName_); }
36 std::string getIvFileName() { return ivFileName; }
37
38 void setIvContent(std::string ivContent_) { ivFileName=""; ivContent=std::move(ivContent_); }
39 const std::string& getIvContent() { return ivContent; }
40
41 void setDataSize(size_t s) { dataSize = s; }
42 size_t getDataSize() { return dataSize; }
43
44 void setScalarData(bool s) { scalarData = s; }
45 bool getScalarData() { return scalarData; }
46
48 void initializeUsingXML(xercesc::DOMElement *element) override;
49
50 xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
51
53 template<typename T>
54 void append(const T& row) {
55 data->append(row);
56 }
57
58 int getRows() override { return data?data->getRows():0; }
59 std::vector<Float> getRow(int i) override { return data?data->getRow(i):std::vector<Float>(dataSize); }
60
61 void setStateOffSet(const std::vector<double>& stateOff)
62 {
63 stateOffSet = stateOff;
64 }
65
66 std::vector<double> getStateOffSet() { return stateOffSet; }
67
68 protected:
69 DynamicIvBody();
70 ~DynamicIvBody() override = default;
71 std::string ivFileName;
72 std::string ivContent;
73
74 size_t dataSize;
75 H5::VectorSerie<Float>* data{nullptr};
76 bool scalarData { false };
77
79 std::vector<double> stateOffSet;
80
81 void createHDF5File() override;
82 void openHDF5File() override;
83 };
84
85}
86
87#endif
void getRow(int row, size_t size, T data[])
void append(const T data[], size_t size)
Definition: body.h:32
Definition: dynamicivbody.h:31
std::vector< double > stateOffSet
Definition: dynamicivbody.h:79
std::vector< Float > getRow(int i) override
Definition: dynamicivbody.h:59
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: dynamicivbody.cc:46
void append(const T &row)
Definition: dynamicivbody.h:54
int getRows() override
Definition: dynamicivbody.h:58
void setIvFileName(std::string ivFileName_)
Definition: dynamicivbody.h:35
Definition: objectfactory.h:38