initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / meshTools / indexedOctree / treeDataEdge.H
blobc4b0ce2788c104162c4e429f6c3293cdb92cee85
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::treeDataEdge
28 Description
29     Holds data for octree to work on an edges subset.
31 SourceFiles
32     treeDataEdge.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef treeDataEdge_H
37 #define treeDataEdge_H
39 #include "treeBoundBox.H"
40 #include "pointField.H"
41 #include "treeBoundBoxList.H"
42 #include "linePointRef.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // Forward declaration of classes
50 template<class Type> class indexedOctree;
52 /*---------------------------------------------------------------------------*\
53                            Class treeDataEdge Declaration
54 \*---------------------------------------------------------------------------*/
56 class treeDataEdge
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         const labelList edgeLabels_;
75         //- Whether to precalculate and store face bounding box
76         const bool cacheBb_;
78         //- bbs for all above edges (valid only if cacheBb_)
79         treeBoundBoxList bbs_;
82     // Private Member Functions
84         //- Calculate edge bounding box
85         treeBoundBox calcBb(const label edgeI) const;
87 public:
89     // Declare name of the class and its debug switch
90     ClassName("treeDataEdge");
93     // Constructors
95         //- Construct from selected edges. !Holds references to edges and points
96         treeDataEdge
97         (
98             const bool cacheBb,
99             const edgeList& edges,
100             const pointField& points,
101             const labelList& edgeLabels
102         );
105     // Member Functions
107         // Access
109             label size() const
110             {
111                 return edgeLabels_.size();
112             }
114             //- Get representative point cloud for all shapes inside
115             //  (one point per shape)
116             pointField points() const;
119         // Search
121             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
122             //  Only makes sense for closed surfaces.
123             label getVolumeType
124             (
125                 const indexedOctree<treeDataEdge>&,
126                 const point&
127             ) const;
129             //- Does (bb of) shape at index overlap bb
130             bool overlaps
131             (
132                 const label index,
133                 const treeBoundBox& sampleBb
134             ) const;
136             //- Calculates nearest (to sample) point in shape.
137             //  Returns actual point and distance (squared)
138             void findNearest
139             (
140                 const labelList& indices,
141                 const point& sample,
143                 scalar& nearestDistSqr,
144                 label& nearestIndex,
145                 point& nearestPoint
146             ) const;
148             //- Calculates nearest (to line) point in shape.
149             //  Returns point and distance (squared)
150             void findNearest
151             (
152                 const labelList& indices,
153                 const linePointRef& ln,
155                 treeBoundBox& tightest,
156                 label& minIndex,
157                 point& linePoint,
158                 point& nearestPoint
159             ) const;
161             //- Calculate intersection of shape with ray. Sets result
162             //  accordingly
163             bool intersects
164             (
165                 const label index,
166                 const point& start,
167                 const point& end,
168                 point& result
169             ) const
170             {
171                 notImplemented
172                 (
173                     "treeDataEdge::intersects(const label, const point&,"
174                     "const point&, point&)"
175                 );
176                 return false;
177             }
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 } // End namespace Foam
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 #endif
191 // ************************************************************************* //