![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 treeBoundBox 00027 00028 Description 00029 Standard boundBox + extra functionality for use in octree. 00030 00031 SourceFiles 00032 treeBoundBoxI.H 00033 treeBoundBox.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef treeBoundBox_H 00038 #define treeBoundBox_H 00039 00040 #include "boundBox.H" 00041 #include "pointField.H" 00042 #include "vectorList.H" 00043 #include "edgeList.H" 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 /*---------------------------------------------------------------------------*\ 00051 Class treeBoundBox Declaration 00052 \*---------------------------------------------------------------------------*/ 00053 00054 class treeBoundBox 00055 : 00056 public boundBox 00057 { 00058 // Private data 00059 00060 //- Static data 00061 00062 // Bits used for octant coding 00063 static const label RIGHTHALF = 0x1 << 0; 00064 static const label TOPHALF = 0x1 << 1; 00065 static const label FRONTHALF = 0x1 << 2; 00066 00067 public: 00068 00069 // Static data members 00070 00071 static treeBoundBox greatBox; 00072 00073 // Bits used for face coding 00074 static const label NOFACE = 0; 00075 static const label LEFTBIT = 0x1 << 0; 00076 static const label RIGHTBIT = 0x1 << 1; 00077 static const label BELOWBIT = 0x1 << 2; 00078 static const label ABOVEBIT = 0x1 << 3; 00079 static const label BEHINDBIT = 0x1 << 4; 00080 static const label INFRONTBIT = 0x1 << 5; 00081 00082 //- Face on which neighbour is 00083 static label neighbourFaceBits(const label&); 00084 00085 00086 // Constructors 00087 00088 //- Construct null setting points to zero 00089 inline treeBoundBox(); 00090 00091 //- Construct from components 00092 inline treeBoundBox(const point& min, const point& max); 00093 00094 //- Construct from components 00095 inline treeBoundBox(const boundBox& bb); 00096 00097 //- Construct as the bounding box of the given pointField. Local 00098 // processor domain only (no reduce as in boundBox) 00099 treeBoundBox(const pointField& points); 00100 00101 //- Construct from Istream 00102 treeBoundBox(Istream&); 00103 00104 00105 // Member functions 00106 00107 // Access 00108 00109 //- Smallest of length,height,width 00110 scalar minDim() const; 00111 00112 //- Largest of length,height,width 00113 scalar maxDim() const; 00114 00115 //- Average of length,height,width 00116 scalar avgDim() const; 00117 00118 //- Typical dimension length,height,width 00119 scalar typDim() const; 00120 00121 //- vertex coordinates 00122 vectorList points() const; 00123 00124 //- edges expressed in terms of points() 00125 edgeList edges() const; 00126 00127 00128 // Check 00129 00130 //- Calculates midpoint 00131 point mid() const; 00132 00133 //- Sub box given by octant number. Midpoint calculated. 00134 treeBoundBox subBbox(const label) const; 00135 00136 //- Sub box given by octant number. Midpoint provided. 00137 treeBoundBox subBbox(const point& mid, const label) const; 00138 00139 //- Returns octant number given point. Midpoint calculated. 00140 label subOctant 00141 ( 00142 const point& sample 00143 ) const; 00144 00145 //- Returns octant number given point. Midpoint calculated. 00146 // onEdge set if sample on edge of subOctant 00147 label subOctant 00148 ( 00149 const point& sample, 00150 bool onEdge 00151 ) const; 00152 00153 //- Returns octant number given point. Midpoint provided. 00154 // onEdge set if sample on edge of subOctant 00155 label subOctant 00156 ( 00157 const point& mid, 00158 const point& sample, 00159 bool onEdge 00160 ) const; 00161 00162 //- Returns octant number given intersection. Midpoint provided. 00163 // onEdge set if sample on edge of subOctant. If onEdge 00164 // the direction vector determines which octant to use 00165 // (acc. to which octant the sample would be if it were moved 00166 // along dir) 00167 label subOctant 00168 ( 00169 const point& mid, 00170 const vector& dir, 00171 const point& sample, 00172 bool onEdge 00173 ) const; 00174 00175 //- Intersects other boundingbox? 00176 inline bool intersects(const treeBoundBox&) const; 00177 00178 //- Intersects segment; set point to intersection position, 00179 // return true if intersection found. 00180 // (intPt argument used during calculation even if not intersecting) 00181 bool intersects(const point&, const point&, point& intPt) const; 00182 00183 //- fully contains bb 00184 bool contains(const treeBoundBox& bb) const; 00185 00186 //- Contains point? (inside or on edge) 00187 bool contains(const point&) const; 00188 00189 //- Contains point? (only inside) 00190 bool containsNarrow(const point&) const; 00191 00192 //- Contains point inside or 00193 // on edge and moving in direction dir would cause it to go 00194 // inside. 00195 bool contains(const vector& dir, const point&) const; 00196 00197 //- Position of point relative to bb 00198 label posBits(const point&) const; 00199 00200 //- Calculate nearest and furthest (to sample) vertex coords of 00201 // bounding box 00202 void calcExtremities 00203 ( 00204 const point& sample, 00205 point& nearest, 00206 point& furthest 00207 ) const; 00208 00209 //- Returns distance sample to furthest away corner. 00210 scalar maxDist(const point& sample) const; 00211 00212 //- Compare distance to point with other bounding box 00213 // return: 00214 // -1 : all vertices of my bounding box are nearer than any of 00215 // other 00216 // +1 : all vertices of my bounding box are further away than 00217 // any of other 00218 // 0 : none of the above. 00219 label distanceCmp(const point&, const treeBoundBox& other) const; 00220 00221 00222 // Friend Operators 00223 00224 friend bool operator==(const treeBoundBox&, const treeBoundBox&); 00225 friend bool operator!=(const treeBoundBox&, const treeBoundBox&); 00226 00227 00228 // IOstream operator 00229 00230 friend Istream& operator>>(Istream&, treeBoundBox&); 00231 }; 00232 00233 00234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00235 00236 } // End namespace Foam 00237 00238 #include "treeBoundBoxI.H" 00239 00240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00241 00242 #endif 00243 00244 // ************************************************************************* //