00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_3D_H
00069 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_3D_H
00070
00071
00072
00073 #include "min_max_policy.h"
00074 #include "point_3dh.h"
00075
00076
00077 namespace lass
00078 {
00079
00080 namespace prim
00081 {
00082
00083 template
00084 <
00085 typename T,
00086 class MinMaxPolicy = StrictMinMax
00087 >
00088 class Aabb3D
00089 {
00090 public:
00091
00092 typedef Aabb3D<T, MinMaxPolicy> TSelf;
00093 typedef MinMaxPolicy TMinMaxPolicy;
00094
00095 typedef Point3D<T> TPoint;
00096 typedef Point3DH<T> TPointH;
00097 typedef typename TPoint::TVector TVector;
00098
00099 typedef typename TPoint::TValue TValue;
00100 typedef typename TPoint::TParam TParam;
00101 typedef typename TPoint::TReference TReference;
00102 typedef typename TPoint::TConstReference TConstReference;
00103 typedef typename TPoint::TNumTraits TNumTraits;
00104
00105 enum { dimension = TPoint::dimension };
00106
00107 template <typename U> struct Rebind
00108 {
00109 typedef Aabb3D<U, MinMaxPolicy> Type;
00110 };
00111
00112 Aabb3D();
00113 Aabb3D(const TPoint& min, const TPoint& max);
00114 explicit Aabb3D(const TPoint& point);
00115 template <class MMP2> Aabb3D(const Aabb3D<T, MMP2>& other);
00116
00117 const TPoint& min() const;
00118 const TPoint& max() const;
00119 void setMin(const TPoint& min);
00120 void setMax(const TPoint& max);
00121
00122 template <class MMP2> TSelf& operator=(const Aabb3D<T, MMP2>& other);
00123
00124 TSelf& operator+=(const TPoint& point);
00125 template<class MMP2> TSelf& operator+=(const Aabb3D<T, MMP2>& other);
00126 void grow(TParam iDistance);
00127 void grow(TVector iDistance);
00128 void scale(TParam iScale);
00129
00130 const TPointH center() const;
00131 const TVector size() const;
00132 const TValue area() const;
00133 const TValue volume() const;
00134
00135 const Side classify(const TPoint& point) const;
00136 const bool contains(const TPoint& point) const;
00137 template <class MMP2> const bool contains(const Aabb3D<T, MMP2>& other) const;
00138 template <class MMP2> const bool intersects(const Aabb3D<T, MMP2>& other) const;
00139 template <class MMP2> const bool collides(const Aabb3D<T, MMP2>& other) const;
00140
00141 template <class RandomGenerator> const TPoint random(RandomGenerator& random) const;
00142
00143 void clear();
00144 const bool isEmpty() const;
00145 const bool isValid() const;
00146
00147 template <typename MMP2> void swap(Aabb3D<T, MMP2>& other);
00148
00149 private:
00150
00151 TPoint min_;
00152 TPoint max_;
00153 };
00154
00155 template <typename T, class MMPa, class MMPb>
00156 const Aabb3D<T, MMPa> operator+(const Aabb3D<T, MMPa>& a, const Aabb3D<T, MMPb>& b);
00157
00158 template <typename T, class MMP>
00159 const Aabb3D<T, MMP> operator+(const Aabb3D<T, MMP>& a, const Point3D<T>& b);
00160
00161 template <typename T, class MMP>
00162 const Aabb3D<T, MMP> operator+(const Point3D<T>& a, const Aabb3D<T, MMP>& b);
00163
00164 template <typename T>
00165 const Aabb3D<T> aabb(const Point3D<T>& point);
00166
00167 template <typename T, class MMP>
00168 T distance(const Aabb3D<T, MMP>& a, const Point3D<T>& b);
00169
00170 template <typename T, class MMPa, class MMPb>
00171 T distance(const Aabb3D<T, MMPa>& a, const Aabb3D<T, MMPb>& b);
00172
00173 template <typename T, class MMPa, class MMPb, class MMPr>
00174 Result intersect(const Aabb3D<T, MMPa>& a, const Aabb3D<T, MMPb>& b, Aabb3D<T, MMPr>& result);
00175
00176 template <typename T, class MMPa, class MMPb>
00177 const bool intersects(const Aabb3D<T, MMPa>& a, const Aabb3D<T, MMPb>& b);
00178
00179 template <typename T, class MMP>
00180 const bool intersects(const Aabb3D<T, MMP>& a, const Point3D<T>& b);
00181
00182 template <typename T, class MMP>
00183 const bool intersects(const Point3D<T>& a, const Aabb3D<T, MMP>& b);
00184
00185 template <typename T, class MMPa, class MMPb>
00186 const bool collides(const Aabb3D<T, MMPa>& a, const Aabb3D<T, MMPb>& b);
00187
00188 template <typename T, class MMP>
00189 const bool collides(const Aabb3D<T, MMP>& a, const Point3D<T>& b);
00190
00191 template <typename T, class MMP>
00192 const bool collides(const Point3D<T>& a, const Aabb3D<T, MMP>& b);
00193
00194 template <typename T, class MMP>
00195 std::ostream& operator<<(std::ostream& stream, const Aabb3D<T, MMP>& aabb);
00196
00197 template <typename T, class MMP>
00198 io::XmlOStream& operator<<(io::XmlOStream& stream, const Aabb3D<T, MMP>& aabb);
00199
00200 }
00201
00202 }
00203
00204 #include "aabb_3d.inl"
00205
00206 #define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_AABB_3D
00207 #ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
00208 # include "pyobject_util.h"
00209 #endif
00210
00211 #define LASS_PRIM_PYOBJECT_UTIL_AABB_3D
00212 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H
00213 # include "pyobject_util.h"
00214 #endif
00215
00216 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_PARALLELOGRAM_3D_H
00217 # include "aabb_3d_parallelogram_3d.h"
00218 #endif
00219
00220 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_3D_H
00221 # include "aabb_3d_ray_3d.h"
00222 #endif
00223
00224 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_SIMPLE_POLYGON_3D_H
00225 # include "aabb_3d_simple_polygon_3d.h"
00226 #endif
00227
00228 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_SPHERE_3D_H
00229 # include "aabb_3d_sphere_3d.h"
00230 #endif
00231
00232 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRIANGLE_3D_H
00233 # include "aabb_3d_triangle_3d.h"
00234 #endif
00235
00236 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRANSFORMATION_3D_H
00237 # include "aabb_3d_transformation_3d.h"
00238 #endif
00239
00240 #endif
00241
00242
00243