Panda3D

geometricBoundingVolume.h

00001 // Filename: geometricBoundingVolume.h
00002 // Created by:  drose (07Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef GEOMETRICBOUNDINGVOLUME_H
00016 #define GEOMETRICBOUNDINGVOLUME_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "boundingVolume.h"
00021 
00022 #include "luse.h"
00023 #include "lmatrix.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : GeometricBoundingVolume
00027 // Description : This is another abstract class, for a general class
00028 //               of bounding volumes that actually enclose points in
00029 //               3-d space, such as BSP's and bounding spheres.
00030 ////////////////////////////////////////////////////////////////////
00031 class EXPCL_PANDA_MATHUTIL GeometricBoundingVolume : public BoundingVolume {
00032 public:
00033   INLINE_MATHUTIL GeometricBoundingVolume();
00034 
00035 PUBLISHED:
00036   INLINE_MATHUTIL bool extend_by(const GeometricBoundingVolume *vol);
00037   INLINE_MATHUTIL bool extend_by(const LPoint3 &point);
00038 
00039   // It might be nice to make these template member functions so we
00040   // could have true STL-style first/last iterators, but that's
00041   // impossible for virtual functions.
00042   INLINE_MATHUTIL bool around(const GeometricBoundingVolume **first,
00043                               const GeometricBoundingVolume **last);
00044   INLINE_MATHUTIL bool around(const LPoint3 *first, const LPoint3 *last);
00045 
00046   INLINE_MATHUTIL int contains(const GeometricBoundingVolume *vol) const;
00047   INLINE_MATHUTIL int contains(const LPoint3 &point) const;
00048   INLINE_MATHUTIL int contains(const LPoint3 &a, const LPoint3 &b) const;
00049 
00050   virtual LPoint3 get_approx_center() const=0;
00051   virtual void xform(const LMatrix4 &mat)=0;
00052 
00053 public:
00054   virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const;
00055 
00056 protected:
00057   // Some virtual functions to implement fundamental bounding
00058   // operations on points in 3-d space.
00059 
00060   virtual bool extend_by_point(const LPoint3 &point);
00061   virtual bool around_points(const LPoint3 *first,
00062                              const LPoint3 *last);
00063   virtual int contains_point(const LPoint3 &point) const;
00064   virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
00065 
00066 
00067 public:
00068   static TypeHandle get_class_type() {
00069     return _type_handle;
00070   }
00071   static void init_type() {
00072     BoundingVolume::init_type();
00073     register_type(_type_handle, "GeometricBoundingVolume",
00074                   BoundingVolume::get_class_type());
00075   }
00076   virtual TypeHandle get_type() const {
00077     return get_class_type();
00078   }
00079   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00080 
00081 private:
00082   static TypeHandle _type_handle;
00083 };
00084 
00085 #include "geometricBoundingVolume.I"
00086 
00087 #endif
 All Classes Functions Variables Enumerations