boundingshape.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *    frankguettler@gmx.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  *  DESCRIPTION                                                            *
00025  *                                                                         *
00026  *   $Log: boundingshape.h,v $
00027  *   Revision 1.5  2010/03/11 15:17:19  guettler
00028  *   -BoundingShape can now be set from outside (see XMLBoundingShape)
00029  *   -Mesh can be created without Body and Geom.
00030  *
00031  *   Revision 1.4  2010/03/07 22:39:45  guettler
00032  *   variables are now protected instead of private for inheritance issues
00033  *
00034  *   Revision 1.3  2006/08/11 15:41:40  martius
00035  *   osgDB used to find path
00036  *
00037  *   Revision 1.2  2006/07/14 12:23:33  martius
00038  *   selforg becomes HEAD
00039  *
00040  *   Revision 1.1.2.8  2006/06/29 16:35:56  robot3
00041  *   includes cleared up
00042  *
00043  *   Revision 1.1.2.7  2006/06/27 14:14:29  robot3
00044  *   -optimized mesh and boundingshape code
00045  *   -other changes
00046  *
00047  *   Revision 1.1.2.6  2006/06/26 21:52:58  robot3
00048  *   Mesh works now with bbox file
00049  *
00050  *   Revision 1.1.2.5  2006/06/23 08:54:40  robot3
00051  *   made some changes on primitive Mesh (including boundingshape)
00052  *
00053  *   Revision 1.1.2.4  2006/06/22 11:33:43  robot3
00054  *   moved boundingshape implementation to .cpp-file
00055  *
00056  *   Revision 1.1.2.3  2006/05/29 22:22:07  martius
00057  *   added std includes
00058  *
00059  *   Revision 1.1.2.2  2006/03/29 15:03:19  martius
00060  *   format documented
00061  *
00062  *   Revision 1.1.2.1  2006/03/29 14:51:45  martius
00063  *   class for reading bounding shape description files and creates the appropriate geoms
00064  *
00065  *   Revision 1.1.2.1  2005/12/06 17:38:21  martius
00066  *   *** empty log message ***
00067  *
00068  *                                                                         *
00069  ***************************************************************************/
00070 #ifndef __BOUNDINGSHAPE_H
00071 #define __BOUNDINGSHAPE_H
00072 
00073 #include "primitive.h"
00074 #include "odehandle.h"
00075 
00076 #include <string>
00077 #include <vector>
00078 
00079 
00080 namespace lpzrobots {
00081   
00082   /**
00083      class for reading bounding shape description files (.bbox) and to create appropriate geoms
00084 
00085      File Format: Lines wise, every line stands for one primitive. 
00086 
00087      Possible lines are:
00088      - sphere radius (x,y,z)
00089      - cylinder radius height (x,y,z) (alpha, beta, gamma)
00090      - capsule radius height (x,y,z) (alpha, beta, gamma)
00091      - box length width height (x,y,z) (alpha, beta, gamma)
00092      
00093      (x,y,z) is the position vector and (alpha, beta, gamma) are 
00094      the rotation angles about x,y,z axis respectively        
00095 
00096      Example:
00097      \code
00098 cylinder 6.5 50 (0,0,25) (0,0,0)
00099 cylinder 50 15 (0,0,28) (0,0,0)
00100 cylinder 40 30 (0,0,50) (0,0,0)
00101 cylinder 30 20 (0,0,75) (0,0,0)
00102 cylinder 20 30 (0,0,100) (0,0,0)
00103 cylinder 13 30 (0,0,125) (0,0,0)
00104 cylinder 8 30 (0,0,150) (0,0,0)
00105 cylinder 5 30 (0,0,175) (0,0,0)
00106      \endcode
00107   */
00108 
00109   class BoundingShape{
00110 
00111   public:
00112     /**
00113        @param filename path and name of bbox file. It is located using OsgDB search path
00114        @param parent primitive to which the bbox is assoziated
00115     */
00116     BoundingShape(const std::string& filename, Mesh* parent);
00117 
00118     virtual ~BoundingShape();
00119 
00120     /// tries to open the bbox file and greates all geoms
00121     virtual bool init(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00122                       double scale, char mode);
00123     
00124     virtual bool isActive();
00125 
00126     /**
00127      * updates all Primitives of the BoundingShape if only in geom mode (no Body)
00128      * @param pose
00129      */
00130     virtual void setPose(const osg::Matrix& pose);
00131 
00132   private:
00133     bool readBBoxFile(std::string& filename, const OdeHandle& odeHandle, const OsgHandle& osgHandle, 
00134                       double scale, char mode);
00135 
00136   protected:
00137     std::string filename;
00138     bool active;
00139     Primitive* parent;
00140     bool attachedToParentBody; // true as default, false not yet implemented by BoundingShape
00141     std::vector<Primitive*> boundingPrimitiveList; // used if not attached to a body
00142     std::vector<osg::Matrix> boundingPrimitivePoseList; // stores the relative pose of each primitive
00143     OdeHandle odeHandle;
00144     dSpaceID parentSpace;
00145   };
00146 
00147 }
00148 
00149 #endif
Generated on Fri Nov 4 10:59:38 2011 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3