1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Iterates over intersections of line with octree leaf elements.
33 octree<octreeDataFace> oc( .. );
35 octreeLine<octreeDataFace> lineSearch(oc, pStart, pEnd);
37 while (lineSearch.getIntersection())
39 const point& pt = lineSearch.hitInfo().hitPoint();
47 \*---------------------------------------------------------------------------*/
52 #include <OpenFOAM/boolList.H>
53 #include <OpenFOAM/point.H>
54 #include "pointHitSort.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 // Forward declaration of classes
63 template<class Type> class octree;
64 template<class Type> class treeLeaf;
67 /*---------------------------------------------------------------------------*\
68 Class octreeLine Declaration
69 \*---------------------------------------------------------------------------*/
77 const octree<Type>& tree_;
80 const point startPoint_;
83 const point endPoint_;
85 //- Start moved into bb
86 point realStartPoint_;
88 //- Exit point of intersection with current treeLeaf
91 //- Current treeLeaf to be searched in.
92 const treeLeaf<Type>* currentLeaf_;
94 //- Sorted list of intersections
95 List<pointHitSort> sortedIntersections_;
97 //- index of last hit in previous treeLeaf. Used so if shape double
98 // it does not get counted twice. Note is not ok for concave shapes
101 //- Current hit: index in sortedIntersections_
104 // Private Member Functions
106 //- Calculate sorted list of intersections
107 void calcSortedIntersections();
109 //- Searches for leaf with intersected elements.
110 // Return true if found; false otherwise.
111 // Sets currentLeaf_ and sortedIntersections_
118 //- Construct from components
121 const octree<Type>& tree,
122 const point& startPoint,
123 const point& endPoint
134 const octree<Type>& tree() const
139 const point& leafExitPoint() const
141 return leafExitPoint_;
144 const point& endPoint() const
149 const point& startPoint() const
154 const treeLeaf<Type>* currentLeaf() const
159 const List<pointHitSort>& sortedIntersections() const
161 return sortedIntersections_;
164 label hitIndex() const
166 return sortedIntersections_[sortedI_].index();
169 const pointHit& hitInfo() const
171 return sortedIntersections_[sortedI_].inter();
175 //- go to next intersection. Return false if no intersections.
176 bool getIntersection();
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 } // End namespace Foam
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 # include "octreeLine.C"
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 // ************************ vim: set sw=4 sts=4 et: ************************ //