Hosted by: BerliOS Developer Logo

OpenMBV C++ Interface

BerliOS Project Page
/home/user/MBSimWindows/openmbv/openmbvcppinterface/openmbvcppinterface/spineextrusion.h
00001 /*
00002     OpenMBV - Open Multi Body Viewer.
00003     Copyright (C) 2009 Markus Friedrich
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _OPENMBV_SPINEEXTRUSION_H_
00021 #define _OPENMBV_SPINEEXTRUSION_H_
00022 
00023 #include <openmbvcppinterface/dynamiccoloredbody.h>
00024 #include <openmbvcppinterface/polygonpoint.h>
00025 #include <vector>
00026 #include <assert.h>
00027 #include <hdf5serie/vectorserie.h>
00028 #include <stdexcept>
00029 
00030 namespace OpenMBV {
00031 
00044   class SpineExtrusion : public DynamicColoredBody {
00045     public:
00047       SpineExtrusion();
00048 
00050       std::string getClassName() { return "SpineExtrusion"; }
00051 
00054       void setNumberOfSpinePoints(const int num) {
00055         numberOfSpinePoints=num;
00056       }
00057 
00060       int getNumberOfSpinePoints() {
00061         return numberOfSpinePoints;
00062       }
00063 
00066       void setContour(std::vector<PolygonPoint*> *contour_) { contour = contour_; }
00067 
00068       std::vector<PolygonPoint*>* getContour() { return contour; }
00069 
00071       void setScaleFactor(const double scale) {
00072         scaleFactor=scale;
00073       }
00074 
00075       double getScaleFactor() { return scaleFactor; }
00076 
00078       void setInitialRotation(const std::vector<double>& initRot) {
00079         if(initRot.size()!=3) throw std::runtime_error("the dimension does not match");
00080         initialRotation=initRot;
00081       }
00082 
00084       void setInitialRotation(double a, double b, double g) {
00085         std::vector<double> initRot;
00086         initRot.push_back(a);
00087         initRot.push_back(b);
00088         initRot.push_back(g);
00089         initialRotation=initRot;
00090       }
00091 
00093       std::vector<double> getInitialRotation() { return initialRotation; }
00094 
00096       void append(const std::vector<double>& row) { 
00097         if(data==0) throw std::runtime_error("can not append data to an environment object"); 
00098         data->append(row);
00099       }
00100 
00101       int getRows() { return data?data->getRows():-1; }
00102       std::vector<double> getRow(int i) { return data?data->getRow(i):std::vector<double>(1+4*numberOfSpinePoints); }
00103 
00105       virtual void initializeUsingXML(xercesc::DOMElement *element);
00106 
00108       xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent);
00109 
00110     protected:
00112       virtual ~SpineExtrusion();
00113 
00115       int numberOfSpinePoints;
00116 
00118       std::vector<PolygonPoint*> *contour;
00119 
00121       H5::VectorSerie<double>* data;
00122 
00124       double scaleFactor;
00125       
00127       std::vector<double> initialRotation;
00128       
00130       void createHDF5File();
00131       void openHDF5File();
00132   };
00133 
00134 }
00135 
00136 #endif /* _OPENMBV_SPINEEXTRUSION_H_ */
00137