openmbvcppinterface 3.1.0 OpenMBV C++ Interface

spineextrusion.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_SPINEEXTRUSION_H_
21 #define _OPENMBV_SPINEEXTRUSION_H_
22
23 #include <openmbvcppinterface/dynamiccoloredbody.h>
24 #include <openmbvcppinterface/polygonpoint.h>
25 #include <vector>
26 #include <cassert>
27 #include <hdf5serie/vectorserie.h>
28 #include <stdexcept>
29
30 namespace OpenMBV {
31
44 class SpineExtrusion : public DynamicColoredBody {
45 friend class ObjectFactory;
46 public:
49 void setNumberOfSpinePoints(const int num) {
50 numberOfSpinePoints=num;
51 }
52
55 int getNumberOfSpinePoints() {
56 return numberOfSpinePoints;
57 }
58
61 void setContour(const std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > &contour_) { contour = contour_; }
62
63 std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > getContour() { return contour; }
64
66 void setScaleFactor(const double scale) {
67 scaleFactor=scale;
68 }
69
70 double getScaleFactor() { return scaleFactor; }
71
73 void setInitialRotation(const std::vector<double>& initRot) {
74 if(initRot.size()!=3) throw std::runtime_error("the dimension does not match");
75 initialRotation=initRot;
76 }
77
79 void setInitialRotation(double a, double b, double g) {
80 std::vector<double> initRot;
81 initRot.push_back(a);
82 initRot.push_back(b);
83 initRot.push_back(g);
84 initialRotation=initRot;
85 }
86
87 void setStateOffSet(const std::vector<double>& stateOff)
88 {
89 stateOffSet = stateOff;
90 }
91
92 std::vector<double> getStateOffSet() { return stateOffSet; }
93
95 std::vector<double> getInitialRotation() { return initialRotation; }
96
98 template<typename T>
99 void append(const T& row) {
100 if(data==nullptr) throw std::runtime_error("can not append data to an environment object");
101 data->append(row);
102 }
103
104 int getRows() override { return data?data->getRows():0; }
105 std::vector<double> getRow(int i) override { return data?data->getRow(i):std::vector<double>(1+4*numberOfSpinePoints); }
106
108 void initializeUsingXML(xercesc::DOMElement *element) override;
109
111 xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
112 protected:
113 SpineExtrusion();
114 ~SpineExtrusion() override;
115
117 int numberOfSpinePoints{0};
118
120 std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > contour;
121
123 H5::VectorSerie<double>* data{nullptr};
124
126 double scaleFactor{1};
127
129 std::vector<double> initialRotation;
130
132 std::vector<double> stateOffSet;
133
135 void createHDF5File() override;
136 void openHDF5File() override;
137 };
138
139 }
140
141 #endif /* _OPENMBV_SPINEEXTRUSION_H_ */
142
OpenMBV::SpineExtrusion::scaleFactor
double scaleFactor
Definition: spineextrusion.h:126
OpenMBV::SpineExtrusion::setScaleFactor
void setScaleFactor(const double scale)
Definition: spineextrusion.h:66
OpenMBV::SpineExtrusion::getRow
std::vector< double > getRow(int i) override
Definition: spineextrusion.h:105
OpenMBV::SpineExtrusion
Class for all bodies extruded along a curve.
Definition: spineextrusion.h:44
OpenMBV::SpineExtrusion::createHDF5File
void createHDF5File() override
Definition: spineextrusion.cc:50
OpenMBV::SpineExtrusion::data
H5::VectorSerie< double > * data
Definition: spineextrusion.h:123
OpenMBV::SpineExtrusion::getNumberOfSpinePoints
int getNumberOfSpinePoints()
Definition: spineextrusion.h:55
OpenMBV::SpineExtrusion::setNumberOfSpinePoints
void setNumberOfSpinePoints(const int num)
Definition: spineextrusion.h:49
OpenMBV::ObjectFactory
Definition: objectfactory.h:38
H5::VectorSerie::getRow
void getRow(int row, size_t size, T data[])
OpenMBV::SpineExtrusion::initialRotation
std::vector< double > initialRotation
Definition: spineextrusion.h:129
OpenMBV::SpineExtrusion::setInitialRotation
void setInitialRotation(double a, double b, double g)
Definition: spineextrusion.h:79
OpenMBV::SpineExtrusion::append
void append(const T &row)
Definition: spineextrusion.h:99
OpenMBV::SpineExtrusion::writeXMLFile
xercesc::DOMElement * writeXMLFile(xercesc::DOMNode *parent) override
Definition: spineextrusion.cc:40
OpenMBV::DynamicColoredBody
Definition: dynamiccoloredbody.h:28
OpenMBV::SpineExtrusion::setInitialRotation
void setInitialRotation(const std::vector< double > &initRot)
Definition: spineextrusion.h:73
H5::VectorSerie< double >
OpenMBV::SpineExtrusion::numberOfSpinePoints
int numberOfSpinePoints
Definition: spineextrusion.h:117
H5::VectorSerie::append
void append(const T data[], size_t size)
H5::VectorSerie::getRows
int getRows()
OpenMBV::SpineExtrusion::getInitialRotation
std::vector< double > getInitialRotation()
Definition: spineextrusion.h:95
OpenMBV::SpineExtrusion::contour
std::shared_ptr< std::vector< std::shared_ptr< PolygonPoint > > > contour
Definition: spineextrusion.h:120
OpenMBV::SpineExtrusion::initializeUsingXML
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: spineextrusion.cc:76
OpenMBV::SpineExtrusion::getRows
int getRows() override
Definition: spineextrusion.h:104
OpenMBV::SpineExtrusion::stateOffSet
std::vector< double > stateOffSet
Definition: spineextrusion.h:132
OpenMBV::SpineExtrusion::setContour
void setContour(const std::shared_ptr< std::vector< std::shared_ptr< PolygonPoint > > > &contour_)
Definition: spineextrusion.h:61