boundingshape.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __BOUNDINGSHAPE_H
00025 #define __BOUNDINGSHAPE_H
00026 
00027 #include "primitive.h"
00028 #include "odehandle.h"
00029 
00030 #include <string>
00031 #include <vector>
00032 
00033 
00034 namespace lpzrobots {
00035   
00036   /**
00037      class for reading bounding shape description files (.bbox) and to create appropriate geoms
00038 
00039      File Format: Lines wise, every line stands for one primitive. 
00040 
00041      Possible lines are:
00042      - sphere radius (x,y,z)
00043      - cylinder radius height (x,y,z) (alpha, beta, gamma)
00044      - capsule radius height (x,y,z) (alpha, beta, gamma)
00045      - box length width height (x,y,z) (alpha, beta, gamma)
00046      
00047      (x,y,z) is the position vector and (alpha, beta, gamma) are 
00048      the rotation angles about x,y,z axis respectively        
00049 
00050      Example:
00051      \code
00052 cylinder 6.5 50 (0,0,25) (0,0,0)
00053 cylinder 50 15 (0,0,28) (0,0,0)
00054 cylinder 40 30 (0,0,50) (0,0,0)
00055 cylinder 30 20 (0,0,75) (0,0,0)
00056 cylinder 20 30 (0,0,100) (0,0,0)
00057 cylinder 13 30 (0,0,125) (0,0,0)
00058 cylinder 8 30 (0,0,150) (0,0,0)
00059 cylinder 5 30 (0,0,175) (0,0,0)
00060      \endcode
00061   */
00062 
00063   class BoundingShape{
00064 
00065   public:
00066     /**
00067        @param filename path and name of bbox file. It is located using OsgDB search path
00068        @param parent primitive to which the bbox is assoziated
00069     */
00070     BoundingShape(const std::string& filename, Mesh* parent);
00071 
00072     virtual ~BoundingShape();
00073 
00074     /// tries to open the bbox file and greates all geoms
00075     virtual bool init(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00076                       double scale, char mode);
00077     
00078     virtual bool isActive();
00079 
00080     /**
00081      * updates all Primitives of the BoundingShape if only in geom mode (no Body)
00082      * @param pose
00083      */
00084     virtual void setPose(const osg::Matrix& pose);
00085 
00086   private:
00087     bool readBBoxFile(std::string& filename, const OdeHandle& odeHandle, const OsgHandle& osgHandle, 
00088                       double scale, char mode);
00089 
00090   protected:
00091     std::string filename;
00092     bool active;
00093     Primitive* parent;
00094     bool attachedToParentBody; // true as default, false not yet implemented by BoundingShape
00095     std::vector<Primitive*> boundingPrimitiveList; // used if not attached to a body
00096     std::vector<osg::Matrix> boundingPrimitivePoseList; // stores the relative pose of each primitive
00097     OdeHandle odeHandle;
00098     dSpaceID parentSpace;
00099   };
00100 
00101 }
00102 
00103 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3