MBSim

Project Page
planewithfrustum.h
00001 /* Copyright (C) 2004-2009 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: mschneider@users.berlios.de
00018  */
00019 
00020 #ifndef _PLANEWITHFRUSTUM_H_
00021 #define _PLANEWITHFRUSTUM_H_
00022 
00023 #include "fmatvec/fmatvec.h"
00024 #include "mbsim/contour.h"
00025 
00026 namespace MBSim {
00027 
00035   class PlaneWithFrustum : public RigidContour {
00036     public:
00045       PlaneWithFrustum(const std::string &name="", Frame *R=0) : RigidContour(name,R), rFrustumOnPlane(0), rFrustumOnTop(0), hFrustum(0), rho(0) {
00046       }
00047       
00048       PlaneWithFrustum(const std::string &name, double rFrustumOnPlane_, double rFrustumOnTop_, double hFrustum_, double rho_, Frame *R=0) : RigidContour(name,R), rFrustumOnPlane(rFrustumOnPlane_), rFrustumOnTop(rFrustumOnTop_), hFrustum(hFrustum_), rho(rho_) {
00049         checkInput();
00050       }
00051 
00052       /* INHERITED INTERFACE OF ELEMENT */
00053       std::string getType() const { return "PlaneWithFrustum"; }
00054       /***************************************************/
00055 
00056       /* GETTER / SETTER */
00057       double getFrustumRadiusOnPlane() {return rFrustumOnPlane; }
00058       double getFrustumRadiusOnTop() {return rFrustumOnTop; }
00059       double getFrustumHeight() {return hFrustum; }
00060       double getRoundingRadius() {return rho; }
00061       /***************************************************/
00062 
00063 #ifdef HAVE_OPENMBVCPPINTERFACE
00064       void enableOpenMBV();
00065 #endif
00066 
00067       virtual void initializeUsingXML(xercesc::DOMElement *element);
00068       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00069 
00070     private:
00071       double rFrustumOnPlane;
00072       double rFrustumOnTop;
00073       double hFrustum;
00074       double rho;
00075 
00076       void checkInput() {
00077         assert(rFrustumOnTop<rFrustumOnPlane); //TODO
00078         assert(rFrustumOnTop>1e-6); //TODO
00079         assert(rho>1e-6);
00080         assert(rho<fabs(hFrustum));
00081         assert(rho<rFrustumOnTop);
00082       }
00083   };
00084 }
00085 
00086 #endif /* _PLANEWITHFRUSTUM_H_ */