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