BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / meshTools / octree / octreeLine.H
blobcec8fd30d0993159a7f445135724b81aa8b7907d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 Class
25     Foam::octreeLine
27 Description
28     Iterates over intersections of line with octree leaf elements.
30     Used as in
31     \code
32         octree<octreeDataFace> oc( .. );
34         octreeLine<octreeDataFace> lineSearch(oc, pStart, pEnd);
36         while (lineSearch.getIntersection())
37         {
38             const point& pt = lineSearch.hitInfo().hitPoint();
39             ..
40         }
41     \endcode
43 SourceFiles
44     octreeLine.C
46 \*---------------------------------------------------------------------------*/
48 #ifndef octreeLine_H
49 #define octreeLine_H
51 #include "boolList.H"
52 #include "point.H"
53 #include "pointHitSort.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 namespace Foam
61 // Forward declaration of classes
62 template<class Type> class octree;
63 template<class Type> class treeLeaf;
66 /*---------------------------------------------------------------------------*\
67                            Class octreeLine Declaration
68 \*---------------------------------------------------------------------------*/
70 template <class Type>
71 class octreeLine
73     // Private data
75         //- Octree reference
76         const octree<Type>& tree_;
78         //- Start of segment
79         const point startPoint_;
81         //- End of segment
82         const point endPoint_;
84         //- Start moved into bb
85         point realStartPoint_;
87         //- Exit point of intersection with current treeLeaf
88         point leafExitPoint_;
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
98         label lastElem_;
100         //- Current hit: index in sortedIntersections_
101         label sortedI_;
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_
111         bool getNextLeaf();
113 public:
115     // Constructors
117         //- Construct from components
118         octreeLine
119         (
120             const octree<Type>& tree,
121             const point& startPoint,
122             const point& endPoint
123         );
126     //- Destructor
127     ~octreeLine();
130     // Member Functions
132         const octree<Type>& tree() const
133         {
134             return tree_;
135         }
137         const point& leafExitPoint() const
138         {
139             return leafExitPoint_;
140         }
142         const point& endPoint() const
143         {
144             return endPoint_;
145         }
147         const point& startPoint() const
148         {
149             return startPoint_;
150         }
152         const treeLeaf<Type>* currentLeaf() const
153         {
154             return currentLeaf_;
155         }
157         const List<pointHitSort>& sortedIntersections() const
158         {
159             return sortedIntersections_;
160         }
162         label hitIndex() const
163         {
164             return sortedIntersections_[sortedI_].index();
165         }
167         const pointHit& hitInfo() const
168         {
169             return sortedIntersections_[sortedI_].inter();
170         }
173         //- go to next intersection. Return false if no intersections.
174         bool getIntersection();
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 #ifdef NoRepository
186 #   include "octreeLine.C"
187 #endif
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 #endif
193 // ************************************************************************* //