![]() |
|
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 octreeDataCell 00027 00028 Description 00029 Encapsulation of data needed to search in/for cells. Used to find the 00030 cell containing a point (e.g. cell-cell mapping). 00031 00032 SourceFiles 00033 octreeDataCell.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef octreeDataCell_H 00038 #define octreeDataCell_H 00039 00040 #include "treeBoundBoxList.H" 00041 #include "labelList.H" 00042 #include "linePointRef.H" 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 // Class forward declarations 00050 class polyMesh; 00051 template<class Type> class octree; 00052 00053 /*---------------------------------------------------------------------------*\ 00054 Class octreeDataCell Declaration 00055 \*---------------------------------------------------------------------------*/ 00056 00057 class octreeDataCell 00058 { 00059 // Private data 00060 00061 const polyMesh& mesh_; 00062 00063 labelList cellLabels_; 00064 00065 treeBoundBoxList bbs_; 00066 00067 00068 public: 00069 00070 // Constructors 00071 00072 //- Construct from components. 00073 octreeDataCell 00074 ( 00075 const polyMesh& mesh, 00076 const labelList& cellLabels, 00077 const treeBoundBoxList& bbs 00078 ); 00079 00080 //- Construct from mesh. Uses all cells in mesh. 00081 octreeDataCell 00082 ( 00083 const polyMesh& mesh 00084 ); 00085 00086 00087 // Member Functions 00088 00089 // Access 00090 00091 const labelList& cellLabels() const 00092 { 00093 return cellLabels_; 00094 } 00095 00096 const polyMesh& mesh() const 00097 { 00098 return mesh_; 00099 } 00100 00101 const treeBoundBoxList& allBb() const 00102 { 00103 return bbs_; 00104 } 00105 00106 label size() const 00107 { 00108 return bbs_.size(); 00109 } 00110 00111 // Search 00112 00113 //- Get type of sample 00114 label getSampleType(octree<octreeDataCell>&, const point&) const; 00115 00116 //- Does (bb of) shape at index overlap bb 00117 bool overlaps 00118 ( 00119 const label index, 00120 const treeBoundBox& sampleBb 00121 ) const; 00122 00123 //- Does shape at index contain sample 00124 bool contains 00125 ( 00126 const label index, 00127 const point& sample 00128 ) const; 00129 00130 //- Segment (from start to end) intersection with shape 00131 // at index. If intersects returns true and sets intersectionPoint 00132 // BUG: not yet done. 00133 bool intersects 00134 ( 00135 const label index, 00136 const point& start, 00137 const point& end, 00138 point& intersectionPoint 00139 ) const; 00140 00141 //- Sets newTightest to bounding box (and returns true) if 00142 // nearer to sample than tightest bounding box. Otherwise 00143 // returns false 00144 bool findTightest 00145 ( 00146 const label index, 00147 const point& sample, 00148 treeBoundBox& tightest 00149 ) const; 00150 00151 //- Given index get unit normal and calculate (numerical) sign 00152 // of sample. 00153 // Used to determine accuracy of calcNearest or inside/outside. 00154 //Note: always returns GREAT since no inside/outside. 00155 scalar calcSign 00156 ( 00157 const label index, 00158 const point& sample, 00159 vector& n 00160 ) const; 00161 00162 //- Calculates nearest (to sample) point in shape. 00163 // Returns point and mag(nearest - sample) 00164 scalar calcNearest 00165 ( 00166 const Foam::label index, 00167 const Foam::point& sample, 00168 point& nearest 00169 ) const; 00170 00171 //- Calculates nearest (to line segment) point in shape. 00172 // Returns distance and both point. 00173 scalar calcNearest 00174 ( 00175 const label index, 00176 const linePointRef& ln, 00177 point& linePt, // nearest point on line 00178 point& shapePt // nearest point on shape 00179 ) const; 00180 00181 00182 00183 // Write 00184 00185 // Write shape at index 00186 void write(Ostream& os, const label index) const; 00187 }; 00188 00189 00190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00191 00192 } // End namespace Foam 00193 00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00195 00196 00197 #endif 00198 00199 // ************************************************************************* //