Panda3D
 All Classes Functions Variables Enumerations
unionBoundingVolume.h
00001 // Filename: unionBoundingVolume.h
00002 // Created by:  drose (08Feb12)
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 UNIONBOUNDINGVOLUME_H
00016 #define UNIONBOUNDINGVOLUME_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "geometricBoundingVolume.h"
00021 #include "pvector.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : UnionBoundingVolume
00025 // Description : This special bounding volume is the union of all of
00026 //               its constituent bounding volumes.
00027 //
00028 //               A point is defined to be within a UnionBoundingVolume
00029 //               if it is within any one or more of its component
00030 //               bounding volumes.
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_PANDA_MATHUTIL UnionBoundingVolume : public GeometricBoundingVolume {
00033 PUBLISHED:
00034   INLINE_MATHUTIL UnionBoundingVolume();
00035   ALLOC_DELETED_CHAIN(UnionBoundingVolume);
00036 
00037 public:
00038   UnionBoundingVolume(const UnionBoundingVolume &copy);
00039 
00040   virtual BoundingVolume *make_copy() const;
00041 
00042   virtual LPoint3 get_approx_center() const;
00043   virtual void xform(const LMatrix4 &mat);
00044 
00045   virtual void output(ostream &out) const;
00046   virtual void write(ostream &out, int indent_level) const;
00047 
00048 PUBLISHED:
00049   INLINE_MATHUTIL int get_num_components() const;
00050   INLINE_MATHUTIL const GeometricBoundingVolume *get_component(int n) const;
00051   MAKE_SEQ(get_components, get_num_components, get_component);
00052 
00053   void clear_components();
00054   void add_component(const GeometricBoundingVolume *component);
00055 
00056   void filter_intersection(const BoundingVolume *volume);
00057 
00058 protected:
00059   virtual bool extend_other(BoundingVolume *other) const;
00060   virtual bool around_other(BoundingVolume *other,
00061                             const BoundingVolume **first,
00062                             const BoundingVolume **last) const;
00063   virtual int contains_other(const BoundingVolume *other) const;
00064 
00065   virtual bool extend_by_geometric(const GeometricBoundingVolume *volume);
00066   virtual bool around_geometric(const BoundingVolume **first,
00067                                 const BoundingVolume **last);
00068 
00069   virtual int contains_point(const LPoint3 &point) const;
00070   virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
00071   virtual int contains_sphere(const BoundingSphere *sphere) const;
00072   virtual int contains_box(const BoundingBox *box) const;
00073   virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
00074   virtual int contains_line(const BoundingLine *line) const;
00075   virtual int contains_plane(const BoundingPlane *plane) const;
00076   virtual int contains_union(const UnionBoundingVolume *unionv) const;
00077   virtual int contains_intersection(const IntersectionBoundingVolume *intersection) const;
00078   virtual int contains_finite(const FiniteBoundingVolume *volume) const;
00079   virtual int contains_geometric(const GeometricBoundingVolume *volume) const;
00080   int other_contains_union(const BoundingVolume *other) const;
00081 
00082 private:
00083   typedef pvector<CPT(GeometricBoundingVolume) > Components;
00084   Components _components;
00085 
00086 public:
00087   static TypeHandle get_class_type() {
00088     return _type_handle;
00089   }
00090   static void init_type() {
00091     GeometricBoundingVolume::init_type();
00092     register_type(_type_handle, "UnionBoundingVolume",
00093                   GeometricBoundingVolume::get_class_type());
00094   }
00095   virtual TypeHandle get_type() const {
00096     return get_class_type();
00097   }
00098   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00099 
00100 private:
00101   static TypeHandle _type_handle;
00102 
00103   friend class BoundingVolume;
00104 };
00105 
00106 #include "unionBoundingVolume.I"
00107 
00108 #endif
 All Classes Functions Variables Enumerations