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