![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * R a n g e C l a s s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1994,2002 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXRange.h,v 1.6 2002/01/18 22:42:54 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXRANGE_H 00025 #define FXRANGE_H 00026 00027 00028 /// Range 00029 class FXAPI FXRange { 00030 protected: 00031 FXfloat d[3][2]; 00032 public: 00033 00034 /// Default constructor 00035 FXRange(){} 00036 00037 /// Initialize 00038 FXRange(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi){ 00039 d[0][0]=xlo; d[0][1]=xhi; 00040 d[1][0]=ylo; d[1][1]=yhi; 00041 d[2][0]=zlo; d[2][1]=zhi; 00042 } 00043 00044 /// Length of side i 00045 FXfloat side(FXint i) const { return d[i][1]-d[i][0]; } 00046 00047 /// Width of box 00048 FXfloat width() const { return d[0][1]-d[0][0]; } 00049 00050 /// Height of box 00051 FXfloat height() const { return d[1][1]-d[1][0]; } 00052 00053 /// Depth of box 00054 FXfloat depth() const { return d[2][1]-d[2][0]; } 00055 00056 /// Longest side 00057 FXfloat longest() const; 00058 00059 /// shortest side 00060 FXfloat shortest() const; 00061 00062 /// Test if empty 00063 FXbool empty() const; 00064 00065 /// Test if overlap 00066 FXbool overlap(const FXRange& box) const; 00067 00068 /// Test if box contains point x,y,z 00069 FXbool contains(FXfloat x,FXfloat y,FXfloat z) const; 00070 00071 /// Indexing 00072 FXfloat* operator[](FXint i){ return d[i]; } 00073 00074 /// Indexing 00075 const FXfloat* operator[](FXint i) const { return d[i]; } 00076 00077 /// Include given range into box 00078 FXRange& include(const FXRange& box); 00079 00080 /// Include point 00081 FXRange& include(FXfloat x,FXfloat y,FXfloat z); 00082 00083 /// Include point 00084 FXRange& include(const FXVec& v); 00085 00086 /// Clip domain against another 00087 FXRange& clipTo(const FXRange& box); 00088 00089 /// Get corners of box 00090 friend FXAPI void boxCorners(FXVec* points,const FXRange& box); 00091 00092 /// Ray intersection test 00093 friend FXAPI FXbool boxIntersect(const FXRange& box,const FXVec& u,const FXVec& v); 00094 00095 /// Get center of box 00096 friend FXAPI FXVec boxCenter(const FXRange& box); 00097 00098 /// Compute diagonal 00099 friend FXAPI FXfloat boxDiagonal(const FXRange& box); 00100 00101 /// Save object to a stream 00102 friend FXAPI FXStream& operator<<(FXStream& store,const FXRange& box); 00103 00104 /// Load object from a stream 00105 friend FXAPI FXStream& operator>>(FXStream& store,FXRange& box); 00106 }; 00107 00108 00109 #endif