Panda3D
unionBoundingVolume.h
1 // Filename: unionBoundingVolume.h
2 // Created by: drose (08Feb12)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef UNIONBOUNDINGVOLUME_H
16 #define UNIONBOUNDINGVOLUME_H
17 
18 #include "pandabase.h"
19 
20 #include "geometricBoundingVolume.h"
21 #include "pvector.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : UnionBoundingVolume
25 // Description : This special bounding volume is the union of all of
26 // its constituent bounding volumes.
27 //
28 // A point is defined to be within a UnionBoundingVolume
29 // if it is within any one or more of its component
30 // bounding volumes.
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDA_MATHUTIL UnionBoundingVolume : public GeometricBoundingVolume {
33 PUBLISHED:
34  INLINE_MATHUTIL UnionBoundingVolume();
35  ALLOC_DELETED_CHAIN(UnionBoundingVolume);
36 
37 public:
38  UnionBoundingVolume(const UnionBoundingVolume &copy);
39 
40  virtual BoundingVolume *make_copy() const;
41 
42  virtual LPoint3 get_approx_center() const;
43  virtual void xform(const LMatrix4 &mat);
44 
45  virtual void output(ostream &out) const;
46  virtual void write(ostream &out, int indent_level) const;
47 
48 PUBLISHED:
49  INLINE_MATHUTIL int get_num_components() const;
50  INLINE_MATHUTIL const GeometricBoundingVolume *get_component(int n) const;
51  MAKE_SEQ(get_components, get_num_components, get_component);
52 
53  void clear_components();
54  void add_component(const GeometricBoundingVolume *component);
55 
56  void filter_intersection(const BoundingVolume *volume);
57 
58 protected:
59  virtual bool extend_other(BoundingVolume *other) const;
60  virtual bool around_other(BoundingVolume *other,
61  const BoundingVolume **first,
62  const BoundingVolume **last) const;
63  virtual int contains_other(const BoundingVolume *other) const;
64 
65  virtual bool extend_by_geometric(const GeometricBoundingVolume *volume);
66  virtual bool around_geometric(const BoundingVolume **first,
67  const BoundingVolume **last);
68 
69  virtual int contains_point(const LPoint3 &point) const;
70  virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
71  virtual int contains_sphere(const BoundingSphere *sphere) const;
72  virtual int contains_box(const BoundingBox *box) const;
73  virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
74  virtual int contains_line(const BoundingLine *line) const;
75  virtual int contains_plane(const BoundingPlane *plane) const;
76  virtual int contains_union(const UnionBoundingVolume *unionv) const;
77  virtual int contains_intersection(const IntersectionBoundingVolume *intersection) const;
78  virtual int contains_finite(const FiniteBoundingVolume *volume) const;
79  virtual int contains_geometric(const GeometricBoundingVolume *volume) const;
80  int other_contains_union(const BoundingVolume *other) const;
81 
82 private:
84  Components _components;
85 
86 public:
87  static TypeHandle get_class_type() {
88  return _type_handle;
89  }
90  static void init_type() {
91  GeometricBoundingVolume::init_type();
92  register_type(_type_handle, "UnionBoundingVolume",
93  GeometricBoundingVolume::get_class_type());
94  }
95  virtual TypeHandle get_type() const {
96  return get_class_type();
97  }
98  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
99 
100 private:
101  static TypeHandle _type_handle;
102 
103  friend class BoundingVolume;
104 };
105 
106 #include "unionBoundingVolume.I"
107 
108 #endif
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
Definition: boundingBox.h:31
This defines a bounding sphere, consisting of a center and a radius.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This funny bounding volume is an infinite plane that divides space into two regions: the part behind ...
Definition: boundingPlane.h:31
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
This special bounding volume is the intersection of all of its constituent bounding volumes...
This special bounding volume is the union of all of its constituent bounding volumes.
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
A special kind of GeometricBoundingVolume that is known to be finite.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This defines a bounding convex hexahedron.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
Definition: boundingLine.h:33