ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / octree / octreeDataEdges.H
blob3f89b94ca0691f0d9eb61c61255ec09d46f5e4e5
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::octreeDataEdges
27 Description
28     Holds data for octree to work on an edges subset.
30 SourceFiles
31     octreeDataEdges.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef octreeDataEdges_H
36 #define octreeDataEdges_H
38 #include "line.H"
39 #include "linePointRef.H"
40 #include "treeBoundBoxList.H"
41 #include "labelList.H"
42 #include "className.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // Forward declaration of classes
50 template<class Type> class octree;
52 /*---------------------------------------------------------------------------*\
53                        Class octreeDataEdges Declaration
54 \*---------------------------------------------------------------------------*/
56 class octreeDataEdges
58     // Static data
60         //- tolerance on linear dimensions
61         static scalar tol;
64     // Private data
66         //- Reference to edgeList
67         const edgeList& edges_;
69         //- Reference to points
70         const pointField& points_;
72         //- labels of edges
73         labelList edgeLabels_;
75         //- bbs for all above edges
76         treeBoundBoxList allBb_;
79 public:
81     // Declare name of the class and its debug switch
82     ClassName("octreeDataEdges");
84     // Constructors
86         //- Construct from selected edges. !Holds references to edges and points
87         octreeDataEdges
88         (
89             const edgeList& edges,
90             const pointField& points,
91             const labelList& edgeLabels
92         );
94         //- Construct as copy
95         octreeDataEdges(const octreeDataEdges&);
98     //- Destructor
99     ~octreeDataEdges();
102     // Member Functions
104         // Access
106             const edgeList& edges() const
107             {
108                 return edges_;
109             }
111             const pointField& points() const
112             {
113                 return points_;
114             }
116             const labelList& edgeLabels() const
117             {
118                 return edgeLabels_;
119             }
121             const treeBoundBoxList& allBb() const
122             {
123                 return allBb_;
124             }
126             label size() const
127             {
128                 return allBb_.size();
129             }
132         // Search
134             //- Get type of sample
135             label getSampleType
136             (
137                 const octree<octreeDataEdges>&,
138                 const point&
139             ) const;
141             //- Does (bb of) shape at index overlap bb
142             bool overlaps
143             (
144                 const label index,
145                 const treeBoundBox& sampleBb
146             ) const;
148             //- Does shape at index contain sample
149             bool contains
150             (
151                 const label index,
152                 const point& sample
153             ) const;
155             //- Segment (from start to end) intersection with shape at index.
156             //  If intersects returns true and sets intersectionPoint
157             bool intersects
158             (
159                 const label index,
160                 const point& start,
161                 const point& end,
162                 point& intersectionPoint
163             ) const;
165             //- Sets newTightest to bounding box (and returns true) if
166             //  nearer to sample than tightest bounding box. Otherwise
167             //  returns false.
168             bool findTightest
169             (
170                 const label index,
171                 const point& sample,
172                 treeBoundBox& tightest
173             ) const;
175             //- Given index get unit normal and calculate (numerical) sign
176             //  of sample.
177             //  Used to determine accuracy of calcNearest or inside/outside.
178             scalar calcSign
179             (
180                 const label index,
181                 const point& sample,
182                 vector& n
183             ) const;
185             //- Calculates nearest (to sample) point in shape.
186             //  Returns point and mag(nearest - sample).
187             scalar calcNearest
188             (
189                 const label index,
190                 const point& sample,
191                 point& nearest
192             ) const;
194             //- Calculates nearest (to line segment) point in shape.
195             //  Returns distance and both point.
196             scalar calcNearest
197             (
198                 const label index,
199                 const linePointRef& ln,
200                 point& linePt,          // nearest point on line
201                 point& shapePt          // nearest point on shape
202             ) const;
205         // Write
207             //- Write shape at index
208             void write(Ostream& os, const label index) const;
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 } // End namespace Foam
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 #endif
221 // ************************************************************************* //