Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

BoundingVolumes.h

Go to the documentation of this file.
00001 
00043 #ifndef _AMIRE_COMMON_BOUNDING_VOLUMES_H
00044 #define _AMIRE_COMMON_BOUNDING_VOLUMES_H
00045 
00046 #include <amire/common/Defines.h>
00047 #include <amire/common/Vector.h>
00048 #include <amire/common/Matrix.h>
00049 
00050 namespace amire {
00051   namespace common {
00052     class AMIRE_EXPORT_API BoundingSphere;
00053     class AMIRE_EXPORT_API AABoundingBox;
00054     class AMIRE_EXPORT_API OrientedBoundingBox;
00055 
00059     class AMIRE_EXPORT_API BoundingVolume : public virtual osg::Referenced {
00060     public:
00064       typedef enum {
00065         AA_BOUNDING_BOX = 0,
00066         ORIENTED_BOUNDING_BOX,
00067         BOUNDING_SPHERE
00068       } BaseBoundingType;
00069       
00070       BoundingVolume();
00071       virtual ~BoundingVolume();
00072 
00076       virtual BaseBoundingType getPreferredBaseBoundingType() const = 0;
00077 
00081       virtual void convertTo(BoundingSphere *sphere) const = 0;
00082 
00086       virtual void convertTo(AABoundingBox *box) const = 0;
00087 
00091       virtual void convertTo(OrientedBoundingBox *box) const = 0;
00092 
00096       virtual bool intersectedByVolume(const BoundingVolume *volume) const;
00097 
00101       virtual bool intersectedByLine(const Vector &point, const Vector &direction, double &distance1, double &distance2) const;
00102 
00106       virtual bool intersectedBySegment(const Vector &point1, const Vector &point2,  bool &entryPoint, double &distanceEntryPoint, bool &exitPoint, double &distanceExitPoint) const;
00107 
00111       virtual bool containsPoint(const Vector &point) const;
00112 
00116       virtual bool containsVolume(const BoundingVolume *volume) const;
00117 
00121       virtual bool containsSegment(const Vector &point1, const Vector &point2) const;
00122 
00126       virtual osg::ref_ptr<BoundingVolume> transform(const Matrix &transformation) const = 0;
00127     };
00128 
00132     class AMIRE_EXPORT_API BoundingSphere :public virtual BoundingVolume {
00133     public:
00137       Vector position;
00138 
00142       double radius;
00143 
00147       BoundingSphere();
00148 
00152       BoundingSphere(const Vector &position, double radius);
00153 
00157       BoundingSphere(const AABoundingBox &boundingBox);
00158 
00162       BoundingSphere(const OrientedBoundingBox &boundingBox);
00163 
00167       BoundingSphere(const BoundingSphere &boundingSphere);
00168 
00172       BoundingSphere(const BoundingVolume &boundingVolume);
00173 
00174       virtual ~BoundingSphere();
00175 
00179       virtual BoundingVolume::BaseBoundingType getPreferredBaseBoundingType() const;
00180       virtual void convertTo(BoundingSphere *sphere) const;
00181       virtual void convertTo(AABoundingBox *box) const;
00182       virtual void convertTo(OrientedBoundingBox *box) const;
00183       virtual bool intersectedByVolume(const BoundingVolume *volume) const;
00184       virtual bool intersectedByLine(const Vector &point, const Vector &direction, double &distance1, double &distance2) const;
00185       virtual bool intersectedBySegment(const Vector &point1, const Vector &point2,  bool &entryPoint, double &distanceEntryPoint, bool &exitPoint, double &distanceExitPoint) const;
00186       virtual bool containsPoint(const Vector &point) const;
00187       virtual bool containsVolume(const BoundingVolume *volume) const;
00188       virtual bool containsSegment(const Vector &point1, const Vector &point2) const;
00189       virtual osg::ref_ptr<BoundingVolume> transform(const Matrix &transformation) const;
00190     };
00191 
00195     class AMIRE_EXPORT_API AABoundingBox : public virtual BoundingVolume {
00196     public:
00200       Vector position;
00201 
00205       Vector dimension;
00206 
00210       AABoundingBox();
00211 
00215       AABoundingBox(const Vector &position, const Vector &dimension);
00216 
00220       AABoundingBox(const AABoundingBox &boundingBox);
00221 
00225       AABoundingBox(const OrientedBoundingBox &boundingBox);
00226 
00230       AABoundingBox(const BoundingSphere &boundingSphere);
00231 
00235       AABoundingBox(const BoundingVolume &boundingVolume);
00236 
00237       virtual ~AABoundingBox();
00238 
00242       virtual BoundingVolume::BaseBoundingType getPreferredBaseBoundingType() const;
00243 
00244       virtual void convertTo(BoundingSphere *sphere) const;
00245       virtual void convertTo(AABoundingBox *box) const;
00246       virtual void convertTo(OrientedBoundingBox *box) const;
00247       virtual bool intersectedByVolume(const BoundingVolume *volume) const;
00248       virtual bool intersectedByLine(const Vector &point, const Vector &direction, double &distance1, double &distance2) const;
00249       virtual bool intersectedBySegment(const Vector &point1, const Vector &point2,  bool &entryPoint, double &distanceEntryPoint, bool &exitPoint, double &distanceExitPoint) const;
00250       virtual bool containsPoint(const Vector &point) const;
00251       virtual bool containsVolume(const BoundingVolume *volume) const;
00252       virtual bool containsSegment(const Vector &point1, const Vector &point2) const;
00253       virtual osg::ref_ptr<BoundingVolume> transform(const Matrix &transformation) const;
00254     };
00255 
00259     class AMIRE_EXPORT_API OrientedBoundingBox : public virtual BoundingVolume {
00260     public:
00264       Vector position;
00265 
00269       Vector up;
00270 
00274       Vector direction;
00275 
00279       Vector side;
00280 
00284       OrientedBoundingBox();
00285 
00289       OrientedBoundingBox(const Vector &position, const Vector &up, const Vector &direction, const Vector &side);
00290 
00294       OrientedBoundingBox(const OrientedBoundingBox &boundingBox);
00295 
00299       OrientedBoundingBox(const AABoundingBox &boundingBox);
00300 
00304       OrientedBoundingBox(const BoundingVolume &boundingVolume);
00305 
00306       virtual ~OrientedBoundingBox();
00307 
00311       virtual BoundingVolume::BaseBoundingType getPreferredBaseBoundingType() const;
00312 
00313       virtual void convertTo(BoundingSphere *sphere) const;
00314       virtual void convertTo(AABoundingBox *box) const;
00315       virtual void convertTo(OrientedBoundingBox *box) const;
00316       virtual bool intersectedByVolume(const BoundingVolume *volume) const;
00317       virtual bool intersectedByLine(const Vector &point, const Vector &direction, double &distance1, double &distance2) const;
00318       virtual bool intersectedBySegment(const Vector &point1, const Vector &point2,  bool &entryPoint, double &distanceEntryPoint, bool &exitPoint, double &distanceExitPoint) const;
00319       virtual bool containsPoint(const Vector &point) const;
00320       virtual bool containsVolume(const BoundingVolume *volume) const;
00321       virtual bool containsSegment(const Vector &point1, const Vector &point2) const;
00322       virtual osg::ref_ptr<BoundingVolume> transform(const Matrix &transformation) const;
00323     };
00324 
00325 /*
00326     class AMIRE_EXPORT_API HierarchicalBoundingVolume : public virtual BoundingVolume {
00327     public:
00328       BoundingVolume volume;
00329       std::vector<osg::ref_ptr<BoundingVolume> > subVolumes;
00330 
00331       HierarchicalSphereBoundingVolume();
00332       HierarchicalSphereBoundingVolume(const HierarchicalSphereBoundingVolume &boundingVolume);
00333       virtual ~HierarchicalSphereBoundingVolume();
00334       virtual BoundingVolume::BaseBoundingType getPreferredBaseBoundingType() const;
00335       virtual void convertTo(BoundingSphere *sphere) const;
00336       virtual void convertTo(AABoundingBox *box) const;
00337       virtual bool intersectedByVolume(const BoundingVolume *volume) const;
00338       virtual bool intersectedByLine(const Vector &point, const Vector &direction, double &distance1, double &distance2) const;
00339       virtual bool intersectedBySegment(const Vector &point1, const Vector &point2,  bool &entryPoint, double &distanceEntryPoint, bool &exitPoint, double &distanceExitPoint) const;
00340       virtual bool containsPoint(const Vector &point) const;
00341       virtual bool containsVolume(const BoundingVolume *volume) const;
00342       virtual bool containsSegment(const Vector &point1, const Vector &point2) const;
00343       virtual osg::ref_ptr<BoundingVolume> transform(const Matrix &transformation) const;
00344     };
00345 */
00346   }
00347 }
00348 
00349 #endif

Generated on Tue May 20 17:23:52 2003 for AMIRE-Framework by doxygen1.3