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