1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Iterates over intersections of line with octree leaf elements.
32 octree<octreeDataFace> oc( .. );
34 octreeLine<octreeDataFace> lineSearch(oc, pStart, pEnd);
36 while (lineSearch.getIntersection())
38 const point& pt = lineSearch.hitInfo().hitPoint();
46 \*---------------------------------------------------------------------------*/
53 #include "pointHitSort.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 // Forward declaration of classes
62 template<class Type> class octree;
63 template<class Type> class treeLeaf;
66 /*---------------------------------------------------------------------------*\
67 Class octreeLine Declaration
68 \*---------------------------------------------------------------------------*/
76 const octree<Type>& tree_;
79 const point startPoint_;
82 const point endPoint_;
84 //- Start moved into bb
85 point realStartPoint_;
87 //- Exit point of intersection with current treeLeaf
90 //- Current treeLeaf to be searched in.
91 const treeLeaf<Type>* currentLeaf_;
93 //- Sorted list of intersections
94 List<pointHitSort> sortedIntersections_;
96 //- index of last hit in previous treeLeaf. Used so if shape double
97 // it does not get counted twice. Note is not ok for concave shapes
100 //- Current hit: index in sortedIntersections_
103 // Private Member Functions
105 //- Calculate sorted list of intersections
106 void calcSortedIntersections();
108 //- Searches for leaf with intersected elements.
109 // Return true if found; false otherwise.
110 // Sets currentLeaf_ and sortedIntersections_
117 //- Construct from components
120 const octree<Type>& tree,
121 const point& startPoint,
122 const point& endPoint
132 const octree<Type>& tree() const
137 const point& leafExitPoint() const
139 return leafExitPoint_;
142 const point& endPoint() const
147 const point& startPoint() const
152 const treeLeaf<Type>* currentLeaf() const
157 const List<pointHitSort>& sortedIntersections() const
159 return sortedIntersections_;
162 label hitIndex() const
164 return sortedIntersections_[sortedI_].index();
167 const pointHit& hitInfo() const
169 return sortedIntersections_[sortedI_].inter();
173 //- go to next intersection. Return false if no intersections.
174 bool getIntersection();
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 # include "octreeLine.C"
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 // ************************************************************************* //