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