Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CBoundingBox3D.h

Go to the documentation of this file.
00001 /*
00002  * CBoundingBox3D.h
00003  * $Id: CBoundingBox3D.h,v 1.5 2003/06/24 14:50:02 anxo Exp $
00004  *
00005  * Copyright (C) 1999, 2000 Rainer Jaeger, Michael Meissner
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * As a special exception to the GPL, the QGLViewer authors (Markus
00022  * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas
00023  * Woerner) give permission to link this program with Qt (non-)commercial
00024  * edition, and distribute the resulting executable, without including
00025  * the source code for the Qt (non-)commercial edition in the source
00026  * distribution.
00027  *
00028  */
00029 
00030 //  Description : Class CBoundingBox3D
00031 //  Purpose     : Provides  funcionality
00032 
00033 
00034 #ifndef __CBOUNDING_BOX3D_H
00035 #define __CBOUNDING_BOX3D_H
00036 
00037 
00038 // Qt
00040 
00041 // System
00043 
00044 // Own
00046 #include "CP3D.h"
00047 #include "CP4D.h"
00048 
00049 
00055 class CBoundingBox3D {
00056  public:
00057 
00059   // CONSTRUCTORS //
00061 
00063   CBoundingBox3D(void) { m_LowerLeft = CP3D(0.0, 0.0, 0.0);
00064                        m_UpperRight = CP3D(0.0, 0.0, 0.0); };
00065 
00069   CBoundingBox3D(double, double, double, double, double, double);
00070 
00074   CBoundingBox3D(const CP3D &minVec, const CP3D &maxVec);
00075 
00079   CBoundingBox3D(const CP4D &minVec, const CP4D &maxVec);
00080 
00082   CBoundingBox3D(const CBoundingBox3D &bbox);
00083 
00085   void CommonConstructor(CP3D, CP3D); 
00086 
00088   ~CBoundingBox3D();
00089 
00090 
00091   static double epsilon;
00092 
00094   // MEMBER FUNCTIONS //
00096 
00098    void setBBox(CBoundingBox3D &bbox);
00099 
00101    const CBoundingBox3D& operator=(const CBoundingBox3D& bbox);
00102 
00104    CBoundingBox3D operator+(const CBoundingBox3D& bbox) const;
00105 
00107    CBoundingBox3D& operator+=(const CBoundingBox3D& bbox);
00108 
00111    void addPoint(const CP3D&);
00112 
00115    void addPoint(const CP4D&);
00116 
00118    void move(const CV3D&);
00119 
00123    void scale(const CV3D&);
00124 
00126   CP3D getLowerLeft() const  { return m_LowerLeft; }
00127 
00129   CP3D getUpperRight() const { return m_UpperRight; }
00130 
00133   CP3D getCornerVertex(int) const;
00134 
00136   double getSize(int) const;
00137 
00139   double getMinSize(void) const;
00140 
00142   double getMaxSize(void) const;
00143 
00145   const CP3D getCenter(void) const;
00146 
00148   double getCenter(int nDimension) { return 0.5 * (m_UpperRight[nDimension] 
00149                                                    + m_LowerLeft[nDimension]); };
00150 
00152   double getOuterRadius(void) const { return 0.5 * sqrt(3*getMaxSize()*getMaxSize()); };  
00153 
00155   double getInnerRadius(void) const { return 0.5 * sqrt(3*getMinSize()*getMinSize()); };
00156 
00158   double getDiagonal(void) const;
00159 
00161   double getVolume(void) const;
00162 
00164   bool isInside(const CP3D&) const;
00165 
00167   bool isInside(const CP4D&) const;
00168 
00170   bool operator==(const CBoundingBox3D &cSource) const {
00171     return (m_LowerLeft == cSource.m_LowerLeft) &&
00172            (m_UpperRight == cSource.m_UpperRight);
00173   };
00174 
00175 
00177   // HELPER FUNCTIONS //
00179 
00181   void print(void) const;
00182 
00184   friend ::ostream& operator<<(::ostream&, const CBoundingBox3D&);
00185 
00187   friend ::istream& operator>>(::istream&, CBoundingBox3D&);
00188 
00189 protected:
00190   CP3D m_LowerLeft;
00191   CP3D m_UpperRight;
00192 
00193 }; // class CBoundingBox3D
00194 
00195 #endif // __CBOUNDING_BOX_H

Generated on Wed Sep 21 12:30:31 2005 for QGLViewer by  doxygen 1.4.4