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
70 friend class ObjectFactory;
71 public:
74 void setNumberOfSpinePoints(const int num) {
76 }
77
82 }
83
86 void setContour(const std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > &contour_) { contour = contour_; }
87
88 std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > getContour() { return contour; }
89
91 void setScaleFactor(const double scale) {
92 scaleFactor=scale;
93 }
94
95 double getScaleFactor() { return scaleFactor; }
96
100 void setInitialRotation(const std::vector<double>& initRot) {
101 if(initRot.size()!=3) throw std::runtime_error("the dimension does not match");
102 initialRotation=initRot;
103 }
104
105 void setInitialRotation(double a, double b, double g) {
106 std::vector<double> initRot;
107 initRot.push_back(a);
108 initRot.push_back(b);
109 initRot.push_back(g);
110 initialRotation=initRot;
111 }
112
113 void setStateOffSet(const std::vector<double>& stateOff)
114 {
115 stateOffSet = stateOff;
116 }
117
118 std::vector<double> getStateOffSet() { return stateOffSet; }
119
120 enum CrossSectionOrienation { orthogonalWithTwist, cardanWrtWorld, cardanWrtWorldShader };
121 void setCrossSectionOrientation(CrossSectionOrienation o) { csOri = o; }
122 CrossSectionOrienation getCrossSectionOrientation();
123
124 void setCounterClockWise(bool f) { ccw = f; }
125 bool getCounterClockWise() { return ccw; }
126
130 void setUpdateNormals(bool f) { updateNormals = f; }
131 bool getUpdateNormals() { return updateNormals; }
132
134 std::vector<double> getInitialRotation() { return initialRotation; }
135
137 template<typename T>
138 void append(const T& row) {
139 if(data==nullptr) throw std::runtime_error("can not append data to an environment object");
140 data->append(row);
141 }
142
143 int getRows() override { return data?data->getRows():0; }
144 std::vector<Float> getRow(int i) override { return data?data->getRow(i):std::vector<Float>(1+4*numberOfSpinePoints); }
145
147 void initializeUsingXML(xercesc::DOMElement *element) override;
148
150 xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
151 protected:
153 ~SpineExtrusion() override;
154
157
159 std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > contour;
160
163
165 double scaleFactor{1};
166
167 CrossSectionOrienation csOri { orthogonalWithTwist };
168
169 bool ccw { true };
170
171 bool updateNormals { true };
172
174 std::vector<double> initialRotation;
175
177 std::vector<double> stateOffSet;
178
180 void createHDF5File() override;
181 void openHDF5File() override;
182 };
183
184}
185
186#endif /* _OPENMBV_SPINEEXTRUSION_H_ */
187
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:69
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: spineextrusion.cc:105
std::shared_ptr< std::vector< std::shared_ptr< PolygonPoint > > > contour
Definition: spineextrusion.h:159
void createHDF5File() override
Definition: spineextrusion.cc:63
double scaleFactor
Definition: spineextrusion.h:165
void setInitialRotation(const std::vector< double > &initRot)
Definition: spineextrusion.h:100
void setContour(const std::shared_ptr< std::vector< std::shared_ptr< PolygonPoint > > > &contour_)
Definition: spineextrusion.h:86
H5::VectorSerie< Float > * data
Definition: spineextrusion.h:162
void setScaleFactor(const double scale)
Definition: spineextrusion.h:91
void setUpdateNormals(bool f)
Definition: spineextrusion.h:130
int getNumberOfSpinePoints()
Definition: spineextrusion.h:80
std::vector< double > getInitialRotation()
Definition: spineextrusion.h:134
std::vector< double > initialRotation
Definition: spineextrusion.h:174
std::vector< Float > getRow(int i) override
Definition: spineextrusion.h:144
int getRows() override
Definition: spineextrusion.h:143
void setNumberOfSpinePoints(const int num)
Definition: spineextrusion.h:74
xercesc::DOMElement * writeXMLFile(xercesc::DOMNode *parent) override
Definition: spineextrusion.cc:40
void append(const T &row)
Definition: spineextrusion.h:138
int numberOfSpinePoints
Definition: spineextrusion.h:156
std::vector< double > stateOffSet
Definition: spineextrusion.h:177