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