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 ScalarParameter scale) {
00072         set(scaleFactor,scale);
00073       }
00074 
00075       double getScaleFactor() { return get(scaleFactor); }
00076 
00078       void append(const std::vector<double>& row) { 
00079         if(data==0) throw std::runtime_error("can not append data to an environment object"); 
00080         data->append(row);
00081       }
00082 
00083       int getRows() { return data?data->getRows():-1; }
00084       std::vector<double> getRow(int i) { return data?data->getRow(i):std::vector<double>(1+4*numberOfSpinePoints); }
00085 
00087       virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00088 
00090       MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *parent);
00091 
00092     protected:
00094       virtual ~SpineExtrusion();
00095 
00097       int numberOfSpinePoints;
00098 
00100       std::vector<PolygonPoint*> *contour;
00101 
00103       H5::VectorSerie<double>* data;
00104 
00106       ScalarParameter scaleFactor;
00107       
00109       void createHDF5File();
00110       void openHDF5File();
00111   };
00112 
00113 }
00114 
00115 #endif /* _OPENMBV_SPINEEXTRUSION_H_ */
00116