initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / meshTools / octree / octreeDataEdges.H
blob3607d499b539299593462c27dc76e586dd16e182
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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 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
19     for more details.
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
25 Class
26     Foam::octreeDataEdges
28 Description
29     Holds data for octree to work on an edges subset.
31 SourceFiles
32     octreeDataEdges.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef octreeDataEdges_H
37 #define octreeDataEdges_H
39 #include "line.H"
40 #include "linePointRef.H"
41 #include "treeBoundBoxList.H"
42 #include "labelList.H"
43 #include "className.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Forward declaration of classes
51 template<class Type> class octree;
53 /*---------------------------------------------------------------------------*\
54                            Class octreeDataEdges Declaration
55 \*---------------------------------------------------------------------------*/
57 class octreeDataEdges
59     // Static data
61         //- tolerance on linear dimensions
62         static scalar tol;
65     // Private data
67         //- Reference to edgeList
68         const edgeList& edges_;
70         //- Reference to points
71         const pointField& points_;
73         //- labels of edges
74         labelList edgeLabels_;
76         //- bbs for all above edges
77         treeBoundBoxList allBb_;
80 public:
82     // Declare name of the class and its debug switch
83     ClassName("octreeDataEdges");
85     // Constructors
87         //- Construct from selected edges. !Holds references to edges and points
88         octreeDataEdges
89         (
90             const edgeList& edges,
91             const pointField& points,
92             const labelList& edgeLabels
93         );
95         //- Construct as copy
96         octreeDataEdges(const octreeDataEdges&);
99     // Destructor
101         ~octreeDataEdges();
104     // Member Functions
106         // Access
108             const edgeList& edges() const
109             {
110                 return edges_;
111             }
113             const pointField& points() const
114             {
115                 return points_;
116             }
118             const labelList& edgeLabels() const
119             {
120                 return edgeLabels_;
121             }
123             const treeBoundBoxList& allBb() const
124             {
125                 return allBb_;
126             }
128             label size() const
129             {
130                 return allBb_.size();
131             }
134         // Search
136             //- Get type of sample
137             label getSampleType
138             (
139                 const octree<octreeDataEdges>&,
140                 const point&
141             ) const;
143             //- Does (bb of) shape at index overlap bb
144             bool overlaps
145             (
146                 const label index,
147                 const treeBoundBox& sampleBb
148             ) const;
150             //- Does shape at index contain sample
151             bool contains
152             (
153                 const label index,
154                 const point& sample
155             ) const;
157             //- Segment (from start to end) intersection with shape
158             //  at index. If intersects returns true and sets intersectionPoint
159             bool intersects
160             (
161                 const label index,
162                 const point& start,
163                 const point& end,
164                 point& intersectionPoint
165             ) const;
167             //- Sets newTightest to bounding box (and returns true) if
168             //  nearer to sample than tightest bounding box. Otherwise
169             //  returns false.
170             bool findTightest
171             (
172                 const label index,
173                 const point& sample,
174                 treeBoundBox& tightest
175             ) const;
177             //- Given index get unit normal and calculate (numerical) sign 
178             //  of sample.
179             //  Used to determine accuracy of calcNearest or inside/outside.
180             scalar calcSign
181             (
182                 const label index,
183                 const point& sample,
184                 vector& n
185             ) const;
187             //- Calculates nearest (to sample) point in shape.
188             //  Returns point and mag(nearest - sample).
189             scalar calcNearest
190             (
191                 const label index,
192                 const point& sample,
193                 point& nearest
194             ) const;
196             //- Calculates nearest (to line segment) point in shape.
197             //  Returns distance and both point.
198             scalar calcNearest
199             (
200                 const label index,
201                 const linePointRef& ln,
202                 point& linePt,          // nearest point on line
203                 point& shapePt          // nearest point on shape
204             ) const;
207         // Write
209             //- Write shape at index
210             void write(Ostream& os, const label index) const;
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 } // End namespace Foam
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 #endif
223 // ************************************************************************* //