initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / indexedOctree / treeDataEdge.H
blob5dad366b3b624121c54dad883bc4c4259ef1ddb0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "treeBoundBoxList.H"
40 #include "linePointRef.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // Forward declaration of classes
48 template<class Type> class indexedOctree;
50 /*---------------------------------------------------------------------------*\
51                            Class treeDataEdge Declaration
52 \*---------------------------------------------------------------------------*/
54 class treeDataEdge
56     // Static data
58         //- tolerance on linear dimensions
59         static scalar tol;
62     // Private data
64         //- Reference to edgeList
65         const edgeList& edges_;
67         //- Reference to points
68         const pointField& points_;
70         //- labels of edges
71         const labelList edgeLabels_;
73         //- Whether to precalculate and store face bounding box
74         const bool cacheBb_;
76         //- bbs for all above edges (valid only if cacheBb_)
77         treeBoundBoxList bbs_;
80     // Private Member Functions
82         //- Calculate edge bounding box
83         treeBoundBox calcBb(const label edgeI) const;
85 public:
87     // Declare name of the class and its debug switch
88     ClassName("treeDataEdge");
91     // Constructors
93         //- Construct from selected edges. !Holds references to edges and points
94         treeDataEdge
95         (
96             const bool cacheBb,
97             const edgeList& edges,
98             const pointField& points,
99             const labelList& edgeLabels
100         );
103     // Member Functions
105         // Access
107             label size() const
108             {
109                 return edgeLabels_.size();
110             }
112             //- Get representative point cloud for all shapes inside
113             //  (one point per shape)
114             pointField points() const;
117         // Search
119             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
120             //  Only makes sense for closed surfaces.
121             label getVolumeType
122             (
123                 const indexedOctree<treeDataEdge>&,
124                 const point&
125             ) const;
127             //- Does (bb of) shape at index overlap bb
128             bool overlaps
129             (
130                 const label index,
131                 const treeBoundBox& sampleBb
132             ) const;
134             //- Calculates nearest (to sample) point in shape.
135             //  Returns actual point and distance (squared)
136             void findNearest
137             (
138                 const labelList& indices,
139                 const point& sample,
141                 scalar& nearestDistSqr,
142                 label& nearestIndex,
143                 point& nearestPoint
144             ) const;
146             //- Calculates nearest (to line) point in shape.
147             //  Returns point and distance (squared)
148             void findNearest
149             (
150                 const labelList& indices,
151                 const linePointRef& ln,
153                 treeBoundBox& tightest,
154                 label& minIndex,
155                 point& linePoint,
156                 point& nearestPoint
157             ) const;
159             //- Calculate intersection of shape with ray. Sets result
160             //  accordingly
161             bool intersects
162             (
163                 const label index,
164                 const point& start,
165                 const point& end,
166                 point& result
167             ) const
168             {
169                 notImplemented
170                 (
171                     "treeDataEdge::intersects(const label, const point&,"
172                     "const point&, point&)"
173                 );
174                 return false;
175             }
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 } // End namespace Foam
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 #endif
189 // ************************************************************************* //