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
30namespace OpenMBV {
31
62 friend class ObjectFactory;
63 public:
66 void setNumberOfSpinePoints(const int num) {
68 }
69
74 }
75
78 void setContour(const std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > &contour_) { contour = contour_; }
79
80 std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > getContour() { return contour; }
81
83 void setScaleFactor(const double scale) {
84 scaleFactor=scale;
85 }
86
87 double getScaleFactor() { return scaleFactor; }
88
90 void setInitialRotation(const std::vector<double>& initRot) {
91 if(initRot.size()!=3) throw std::runtime_error("the dimension does not match");
92 initialRotation=initRot;
93 }
94
96 void setInitialRotation(double a, double b, double g) {
97 std::vector<double> initRot;
98 initRot.push_back(a);
99 initRot.push_back(b);
100 initRot.push_back(g);
101 initialRotation=initRot;
102 }
103
104 void setStateOffSet(const std::vector<double>& stateOff)
105 {
106 stateOffSet = stateOff;
107 }
108
109 std::vector<double> getStateOffSet() { return stateOffSet; }
110
111 enum CrossSectionOrienation { orthogonalWithTwist, cardanWrtWorld };
112 void setCrossSectionOrientation(CrossSectionOrienation o) { csOri = o; }
113 CrossSectionOrienation getCrossSectionOrientation() { return csOri; }
114
116 std::vector<double> getInitialRotation() { return initialRotation; }
117
119 template<typename T>
120 void append(const T& row) {
121 if(data==nullptr) throw std::runtime_error("can not append data to an environment object");
122 data->append(row);
123 }
124
125 int getRows() override { return data?data->getRows():0; }
126 std::vector<double> getRow(int i) override { return data?data->getRow(i):std::vector<double>(1+4*numberOfSpinePoints); }
127
129 void initializeUsingXML(xercesc::DOMElement *element) override;
130
132 xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
133 protected:
135 ~SpineExtrusion() override;
136
139
141 std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > contour;
142
145
147 double scaleFactor{1};
148
149 CrossSectionOrienation csOri { orthogonalWithTwist };
150
152 std::vector<double> initialRotation;
153
155 std::vector<double> stateOffSet;
156
158 void createHDF5File() override;
159 void openHDF5File() override;
160 };
161
162}
163
164#endif /* _OPENMBV_SPINEEXTRUSION_H_ */
165
void getRow(int row, size_t size, T data[])
void append(const T data[], size_t size)
Definition: dynamiccoloredbody.h:28
Definition: objectfactory.h:38
Class for all bodies extruded along a curve.
Definition: spineextrusion.h:61
H5::VectorSerie< double > * data
Definition: spineextrusion.h:144
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: spineextrusion.cc:99
std::shared_ptr< std::vector< std::shared_ptr< PolygonPoint > > > contour
Definition: spineextrusion.h:141
void setInitialRotation(double a, double b, double g)
Definition: spineextrusion.h:96
void createHDF5File() override
Definition: spineextrusion.cc:58
double scaleFactor
Definition: spineextrusion.h:147
void setInitialRotation(const std::vector< double > &initRot)
Definition: spineextrusion.h:90
void setContour(const std::shared_ptr< std::vector< std::shared_ptr< PolygonPoint > > > &contour_)
Definition: spineextrusion.h:78
void setScaleFactor(const double scale)
Definition: spineextrusion.h:83
std::vector< double > getRow(int i) override
Definition: spineextrusion.h:126
int getNumberOfSpinePoints()
Definition: spineextrusion.h:72
std::vector< double > getInitialRotation()
Definition: spineextrusion.h:116
std::vector< double > initialRotation
Definition: spineextrusion.h:152
int getRows() override
Definition: spineextrusion.h:125
void setNumberOfSpinePoints(const int num)
Definition: spineextrusion.h:66
xercesc::DOMElement * writeXMLFile(xercesc::DOMNode *parent) override
Definition: spineextrusion.cc:40
void append(const T &row)
Definition: spineextrusion.h:120
int numberOfSpinePoints
Definition: spineextrusion.h:138
std::vector< double > stateOffSet
Definition: spineextrusion.h:155