![]() |
|
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 octreeLine 00027 00028 Description 00029 Iterates over intersections of line with octree leaf elements. 00030 Used as in 00031 00032 octree<octreeDataFace> oc( .. ); 00033 00034 octreeLine<octreeDataFace> lineSearch(oc, pStart, pEnd); 00035 00036 while (lineSearch.getIntersection()) 00037 { 00038 const point& pt = lineSearch.hitInfo().hitPoint(); 00039 .. 00040 } 00041 00042 00043 SourceFiles 00044 octreeLine.C 00045 00046 \*---------------------------------------------------------------------------*/ 00047 00048 #ifndef octreeLine_H 00049 #define octreeLine_H 00050 00051 #include "boolList.H" 00052 #include "point.H" 00053 #include "pointHitSort.H" 00054 00055 00056 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00057 00058 namespace Foam 00059 { 00060 00061 // Class forward declarations 00062 template<class Type> class octree; 00063 template<class Type> class treeLeaf; 00064 00065 // * * * * * * Forward declaration of template friend functions * * * * * * // 00066 00067 //template<class Type> Istream& operator>>(Istream&, octreeLine<Type>&); 00068 00069 00070 /*---------------------------------------------------------------------------*\ 00071 Class octreeLine Declaration 00072 \*---------------------------------------------------------------------------*/ 00073 00074 template <class Type> 00075 class octreeLine 00076 { 00077 // Private data 00078 00079 //- Octree reference 00080 const octree<Type>& tree_; 00081 00082 //- Start of segment 00083 const point startPoint_; 00084 00085 //- End of segment 00086 const point endPoint_; 00087 00088 //- Start moved into bb 00089 point realStartPoint_; 00090 00091 //- Exit point of intersection with current treeLeaf 00092 point leafExitPoint_; 00093 00094 //- Current treeLeaf to be searched in. 00095 const treeLeaf<Type>* currentLeaf_; 00096 00097 //- Sorted list of intersections 00098 List<pointHitSort> sortedIntersections_; 00099 00100 //- index of last hit in previous treeLeaf. Used so if shape double 00101 // it does not get counted twice. Note is not ok for concave shapes 00102 label lastElem_; 00103 00104 //- Current hit: index in sortedIntersections_ 00105 label sortedI_; 00106 00107 // Private Member Functions 00108 00109 //- Calculate sorted list of intersections 00110 void calcSortedIntersections(); 00111 00112 //- Searches for leaf with intersected elements. 00113 // Return true if found; false otherwise. 00114 // Sets currentLeaf_ and sortedIntersections_ 00115 bool getNextLeaf(); 00116 00117 public: 00118 00119 // Constructors 00120 00121 //- Construct from components 00122 octreeLine 00123 ( 00124 const octree<Type>& tree, 00125 const point& startPoint, 00126 const point& endPoint 00127 ); 00128 00129 00130 // Destructor 00131 00132 ~octreeLine(); 00133 00134 00135 // Member Functions 00136 00137 const octree<Type>& tree() const 00138 { 00139 return tree_; 00140 } 00141 00142 const point& leafExitPoint() const 00143 { 00144 return leafExitPoint_; 00145 } 00146 00147 const point& endPoint() const 00148 { 00149 return endPoint_; 00150 } 00151 00152 const point& startPoint() const 00153 { 00154 return startPoint_; 00155 } 00156 00157 const treeLeaf<Type>* currentLeaf() const 00158 { 00159 return currentLeaf_; 00160 } 00161 00162 const List<pointHitSort>& sortedIntersections() const 00163 { 00164 return sortedIntersections_; 00165 } 00166 00167 label hitIndex() const 00168 { 00169 return sortedIntersections_[sortedI_].index(); 00170 } 00171 00172 const pointHit& hitInfo() const 00173 { 00174 return sortedIntersections_[sortedI_].inter(); 00175 } 00176 00177 00178 //- go to next intersection. Return false if no intersections. 00179 bool getIntersection(); 00180 00181 }; 00182 00183 00184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00185 00186 } // End namespace Foam 00187 00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00189 00190 #ifdef NoRepository 00191 # include "octreeLine.C" 00192 #endif 00193 00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00195 00196 #endif 00197 00198 // ************************************************************************* //