![]() |
|
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 octreeDataFace 00027 00028 Description 00029 Holds data for octree to work on mesh faces. E.g. calculate 00030 (in calcNearest) the correct intersection point with a face. 00031 00032 SourceFiles 00033 octreeDataFace.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef octreeDataFace_H 00038 #define octreeDataFace_H 00039 00040 #include "treeBoundBoxList.H" 00041 #include "faceList.H" 00042 #include "point.H" 00043 #include "className.H" 00044 #include "linePointRef.H" 00045 00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00047 00048 namespace Foam 00049 { 00050 00051 // Class forward declarations 00052 class primitiveMesh; 00053 template<class Type> class octree; 00054 class polyPatch; 00055 00056 /*---------------------------------------------------------------------------*\ 00057 Class octreeDataFace Declaration 00058 \*---------------------------------------------------------------------------*/ 00059 00060 class octreeDataFace 00061 { 00062 // Static data 00063 00064 //- tolerance on linear dimensions 00065 static scalar tol; 00066 00067 00068 // Private data 00069 00070 //- the mesh 00071 const primitiveMesh& mesh_; 00072 00073 //- labels (in mesh indexing) of faces 00074 labelList meshFaces_; 00075 00076 //- bbs for all above faces 00077 treeBoundBoxList allBb_; 00078 00079 00080 // Private Member Functions 00081 00082 //- Set allBb to tight fitting bounding box 00083 void calcBb(); 00084 00085 public: 00086 00087 // Declare name of the class and it's debug switch 00088 ClassName("octreeDataFace"); 00089 00090 // Constructors 00091 00092 //- Construct from selected mesh faces. 00093 octreeDataFace 00094 ( 00095 const primitiveMesh&, 00096 const labelList& meshFaces, 00097 const treeBoundBoxList& 00098 ); 00099 00100 //- Construct from selected mesh faces. Tight fitting bounding boxes 00101 // generated internally. 00102 octreeDataFace 00103 ( 00104 const primitiveMesh&, 00105 const labelList& meshFaces 00106 ); 00107 00108 //- Construct from selected mesh faces. 00109 octreeDataFace 00110 ( 00111 const primitiveMesh&, 00112 const List<const labelList*>&, 00113 const List<const treeBoundBoxList*>& 00114 ); 00115 00116 //- Construct from selected mesh faces. Tight fitting bounding boxes 00117 // generated internally. 00118 octreeDataFace(const primitiveMesh&, const List<const labelList*>&); 00119 00120 //- Construct from alll faces in patch. Tight fitting bounding boxes 00121 // generated internally. 00122 octreeDataFace(const polyPatch& patch); 00123 00124 //- Construct from all boundary faces. Tight fitting bounding boxes 00125 // generated internally. 00126 octreeDataFace(const primitiveMesh&); 00127 00128 //- Construct as copy 00129 octreeDataFace(const octreeDataFace&); 00130 00131 00132 // Destructor 00133 00134 ~octreeDataFace(); 00135 00136 00137 // Member Functions 00138 00139 // Access 00140 00141 const primitiveMesh& mesh() const 00142 { 00143 return mesh_; 00144 } 00145 00146 const labelList& meshFaces() const 00147 { 00148 return meshFaces_; 00149 } 00150 00151 const treeBoundBoxList& allBb() const 00152 { 00153 return allBb_; 00154 } 00155 00156 label size() const 00157 { 00158 return allBb_.size(); 00159 } 00160 00161 00162 // Search 00163 00164 //- Get type of sample 00165 label getSampleType 00166 ( 00167 const octree<octreeDataFace>&, 00168 const point& 00169 ) const; 00170 00171 //- Does (bb of) shape at index overlap bb 00172 bool overlaps 00173 ( 00174 const label index, 00175 const treeBoundBox& sampleBb 00176 ) const; 00177 00178 //- Does shape at index contain sample 00179 bool contains(const label index, const point& sample) const; 00180 00181 //- Segment (from start to end) intersection with shape 00182 // at index. If intersects returns true and sets intersectionPoint 00183 bool intersects 00184 ( 00185 const label index, 00186 const point& start, 00187 const point& end, 00188 point& intersectionPoint 00189 ) const; 00190 00191 //- Sets newTightest to bounding box (and returns true) if 00192 // nearer to sample than tightest bounding box. Otherwise 00193 // returns false. 00194 bool findTightest 00195 ( 00196 const label index, 00197 const point& sample, 00198 treeBoundBox& tightest 00199 ) const; 00200 00201 //- Given index get unit normal and calculate (numerical) sign 00202 // of sample. 00203 // Used to determine accuracy of calcNearest or inside/outside. 00204 scalar calcSign 00205 ( 00206 const label index, 00207 const point& sample, 00208 vector& n 00209 ) const; 00210 00211 //- Calculates nearest (to sample) point in shape. 00212 // Returns point and mag(nearest - sample). Returns GREAT if 00213 // sample does not project onto (triangle decomposition) of face. 00214 scalar calcNearest 00215 ( 00216 const label index, 00217 const point& sample, 00218 point& nearest 00219 ) const; 00220 00221 //- Calculates nearest (to line segment) point in shape. 00222 // Returns distance and both point. 00223 scalar calcNearest 00224 ( 00225 const label index, 00226 const linePointRef& ln, 00227 point& linePt, // nearest point on line 00228 point& shapePt // nearest point on shape 00229 ) const; 00230 00231 00232 // Write 00233 00234 //- Write shape at index 00235 void write(Ostream& os, const label index) const; 00236 }; 00237 00238 00239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00240 00241 } // End namespace Foam 00242 00243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00244 00245 00246 #endif 00247 00248 // ************************************************************************* //