Hosted by: BerliOS Developer Logo

OpenMBV C++ Interface

BerliOS Project Page
/home/user/MBSimWindows/openmbv/openmbvcppinterface/openmbvcppinterface/nurbsdisk.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_NURBSDISK_H_
00021 #define _OPENMBV_NURBSDISK_H_
00022 
00023 #include <openmbvcppinterface/dynamiccoloredbody.h>
00024 #include <hdf5serie/vectorserie.h>
00025 #include <vector>
00026 #include <assert.h>
00027 #include <stdexcept>
00028 
00029 namespace OpenMBV {
00030 
00040   class NurbsDisk : public DynamicColoredBody {
00041     public:
00043       NurbsDisk(); 
00044 
00046       std::string getClassName() { return "NurbsDisk"; }
00047 
00048 
00050       void setLocalFrame(bool f) { localFrameStr=(f==true)?"true":"false"; }
00051 
00052       bool getLocalFrame() { return localFrameStr=="true"?true:false; }
00053 
00055       void setScaleFactor(const ScalarParameter scale) {
00056         set(scaleFactor,scale);
00057       }
00058 
00059       double getScaleFactor() { return get(scaleFactor); }
00060 
00062       void setDrawDegree(int drawDegree_) {
00063         drawDegree=drawDegree_;
00064       }
00065 
00066       int getDrawDegree() { return drawDegree; }
00067 
00069       void setRadii(ScalarParameter Ri_, ScalarParameter Ro_) {
00070         set(Ri,Ri_);
00071         set(Ro,Ro_);
00072       }
00073 
00075       void setRi(ScalarParameter Ri_) {
00076         set(Ri,Ri_);
00077       }
00078 
00080       void setRo(ScalarParameter Ro_) {
00081         set(Ro,Ro_);
00082       }
00083 
00084       double getRi() { return get(Ri); }
00085       double getRo() { return get(Ro); }
00086 
00090       void setKnotVecAzimuthal(const std::vector<double> &KnotVecAzimuthal_) {
00091         set(KnotVecAzimuthal,KnotVecAzimuthal_);
00092       }
00093 
00094       void setKnotVecAzimuthal(const VectorParameter &KnotVecAzimuthal_) {
00095         set(KnotVecAzimuthal,KnotVecAzimuthal_);
00096       }
00097 
00098       std::vector<double> getKnotVecAzimuthal() { return get(KnotVecAzimuthal); }
00099 
00103       void setKnotVecRadial(const std::vector<double> &KnotVecRadial_) {
00104         set(KnotVecRadial,KnotVecRadial_);
00105       }
00106 
00107       void setKnotVecRadial(const VectorParameter &KnotVecRadial_) {
00108         set(KnotVecRadial,KnotVecRadial_);
00109       }
00110 
00111       std::vector<double> getKnotVecRadial() { return get(KnotVecRadial); }
00112 
00114       void setElementNumberAzimuthal(int ElementNumberAzimuthal_) {
00115         ElementNumberAzimuthal=ElementNumberAzimuthal_;
00116       }
00117 
00118       int getElementNumberAzimuthal() { return ElementNumberAzimuthal; }
00119 
00121       void setElementNumberRadial(int ElementNumberRadial_) {
00122         ElementNumberRadial=ElementNumberRadial_;
00123       }
00124 
00125       int getElementNumberRadial() { return ElementNumberRadial; }
00126 
00128       void setInterpolationDegreeRadial(int InterpolationDegreeRadial_) {
00129         InterpolationDegreeRadial=InterpolationDegreeRadial_;
00130       }
00131 
00132       int getInterpolationDegreeRadial() { return InterpolationDegreeRadial; }
00133 
00135       void setInterpolationDegreeAzimuthal(int InterpolationDegreeAzimuthal_) {
00136         InterpolationDegreeAzimuthal=InterpolationDegreeAzimuthal_;
00137       }
00138 
00139       int getInterpolationDegreeAzimuthal() { return InterpolationDegreeAzimuthal; }
00141       void setDiskNormal(float *DiskNormal_) {
00142         DiskNormal=DiskNormal_;
00143       }
00144 
00145       float* getDiskNormal() { return DiskNormal; }
00146 
00148       void setDiskPoint(float *DiskPoint_) {
00149         DiskPoint=DiskPoint_;
00150       }
00151 
00152       float* getDiskPoint() { return DiskPoint; }
00153 
00155       void append(const std::vector<double>& row) { 
00156         if(data==0) throw std::runtime_error("can not append data to an environment object");
00157         data->append(row);
00158       }
00159 
00160       int getRows() { return data?data->getRows():-1; }
00161       std::vector<double> getRow(int i) {
00162         int NodeDofs = (getElementNumberRadial() + 1) * (getElementNumberAzimuthal() + getInterpolationDegreeAzimuthal());
00163         return data?data->getRow(i):std::vector<double>(7+3*NodeDofs+3*getElementNumberAzimuthal()*drawDegree*2);
00164       }
00165 
00167       virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00168 
00170       MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *parent);
00171 
00172     protected:
00174       virtual ~NurbsDisk();
00175 
00177       H5::VectorSerie<double>* data;
00178 
00182       std::string localFrameStr;
00183 
00185       ScalarParameter scaleFactor;
00186 
00188       int drawDegree;
00189 
00191       ScalarParameter Ri, Ro;
00192 
00194       int ElementNumberAzimuthal, ElementNumberRadial;
00195 
00197       int InterpolationDegreeAzimuthal, InterpolationDegreeRadial;
00198 
00200       VectorParameter KnotVecAzimuthal, KnotVecRadial;
00201 
00203       float *DiskNormal;
00204 
00206       float *DiskPoint;
00207 
00209       void createHDF5File();
00210       void openHDF5File();
00211   };
00212 
00213 }
00214 
00215 #endif /* _OPENMBV_NURBSDISK_H_ */
00216