Follow this link to skip to the main content

bounding_shape.h

Go to the documentation of this file.
00001 // -*-c++-*-
00002 //---------------------------< /-/ CLARAty /-/ >------------------------------
00003 /**
00004  * @file  bounding_shape.h
00005  *
00006  * The Bounding_Shape class models the collision parameters of a
00007  * three-dimensionsl object. It is to be used in collision detection
00008  * algorithms.
00009  *
00010  * <br>@b Designer(s):  Issa Nesnas
00011  * <br>@b Author(s):    Issa Nesnas
00012  * <br>@b Date:         August 4, 2005
00013  *
00014  * <b>Software License:</b><br>
00015  * <code> http://claraty.jpl.nasa.gov/license/open_src/  or 
00016  *        file: license/open_src.txt </code> 
00017  *
00018  * &copy; 2006, Jet Propulsion Laboratory, California Institute of Technology<br>
00019  *
00020  * $Revision: 1.6 $
00021  */
00022 //-----------------------------------------------------------------------------
00023 
00024 #ifndef  BOUNDING_SHAPE_H
00025 #define  BOUNDING_SHAPE_H
00026 
00027 #include "claraty/share.h"
00028 #include <iostream>
00029 #include "claraty/3d_object.h"
00030 #include "claraty/tree.h"
00031 #include "claraty/transform.h"
00032 
00033 namespace claraty {
00034 
00035 /**
00036  * @ingroup motion_data_structure
00037  */
00038 //@{
00039 //@}
00040 
00041 class Bounding_Shape  {
00042   friend std::ostream& operator<< (std::ostream& os,
00043                                    Bounding_Shape & bounding_shape);  
00044 
00045 public:
00046   
00047   /** @{ @name Constructors/destructors */
00048   Bounding_Shape();
00049   Bounding_Shape(const Bounding_Shape & bounding_shape);
00050   ~Bounding_Shape();
00051   
00052   /** @} */
00053 
00054   /** @{ @name Observers */
00055   std::string get_name();
00056   std::string get_parent_name();
00057   bool get_containment();
00058   bool get_alignment();
00059   bool get_collision();
00060   Transform & get_transform();
00061   N_3D_Object & get_3d_object();
00062   /** @} */
00063 
00064   /** @{ @name Mutators */
00065   void set_name(std::string name);
00066   void set_parent_name(std::string parent_name);
00067   void set_containment(bool containment);
00068   void set_alignment(bool alignment);
00069   void set_collision(bool collision);
00070   void set_tolerance(double tolerance);
00071   double & get_tolerance();
00072   void set(Transform & transform);
00073   void set(N_3D_Object & N_3D_object);
00074 
00075   /** @} */
00076 
00077 protected:
00078 
00079 private:
00080   std::string _name;            /**< Name of shape object */
00081   std::string _parent_name;     /**< Name of parent of shape object */
00082   bool _is_container;           /**< Flag to indicate if shape is a container */
00083   bool _is_aligned;             /**< Flag to indicate if is aligned */
00084   bool _ignore_collisions;      /**< Flag to indicate if ignore collisions */
00085   double _tol;                  /**< Tolerance */
00086   Transform  _transform;        /**< Transform wrt body ref. frame */
00087   N_3D_Object  _three_d_object; /**< Shape object data */
00088 
00089 };
00090 
00091 
00092 //-----------------------------------------------------------------------------
00093 /**
00094  * @ingroup 
00095  */
00096 
00097 class Composite_Bounding_Shape : public Bounding_Shape  {
00098   friend std::ostream& operator<< (std::ostream& os,
00099                                    Composite_Bounding_Shape & composite_bounding_shape);  
00100 
00101 public:
00102   
00103   /** @{ @name Observers */
00104   bool empty();
00105   Tree<Bounding_Shape> & get_shape_tree();
00106   N_3D_Object & get_3d_object() { return _get_top_level_bounding_shape().get_3d_object();}
00107   Composite_Bounding_Shape * get_composite_bounding_shape()
00108   {
00109     return this;
00110   };
00111   /** @} */
00112 
00113   /** @{ @name Mutators */
00114   void insert(Bounding_Shape * bounding_shape);
00115   void insert_at_root(Bounding_Shape * bounding_shape);
00116   void copy(Composite_Bounding_Shape & composite_bounding_shape);
00117   void clear_tree();
00118   /** @} */
00119 
00120 protected:
00121 
00122 private:
00123   Bounding_Shape & _get_top_level_bounding_shape();
00124   Tree<Bounding_Shape> _bounding_shape_tree;
00125 
00126 };
00127 
00128 } // namespace claraty
00129 
00130 #endif // BOUNDING_SHAPE_H