ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / indexedOctree / treeDataTriSurface.H
blob9184294c0be0e211f5f5cd799727848ebaa959c9
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::treeDataTriSurface
27 Description
28     Encapsulates data for (indexedOc)tree searches on triSurface.
30 SourceFiles
31     treeDataTriSurface.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef treeDataTriSurface_H
36 #define treeDataTriSurface_H
38 #include "triSurface.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 // Forward declaration of classes
46 class treeBoundBox;
47 class treeDataTriSurface;
48 template<class Type> class indexedOctree;
50 /*---------------------------------------------------------------------------*\
51                            Class treeDataTriSurface Declaration
52 \*---------------------------------------------------------------------------*/
54 class treeDataTriSurface
56     // Private data
58         //- Reference to triSurface
59         const triSurface& surface_;
61         //- Tolerance to use for intersection tests
62         const scalar planarTol_;
64     // Private Member Functions
66         // //- fast triangle nearest point calculation. Returns point in E0, E1
67         // //  coordinate system:  base + s*E0 + t*E1
68         // static scalar nearestCoords
69         // (
70         //     const point& base,
71         //     const point& E0,
72         //     const point& E1,
73         //     const scalar a,
74         //     const scalar b,
75         //     const scalar c,
76         //     const point& P,
77         //     scalar& s,
78         //     scalar& t
79         // );
81 public:
83     // Declare name of the class and its debug switch
84     ClassName("treeDataTriSurface");
87     // Constructors
89         //- Construct from triSurface and tolerance for intersection
90         //  tests. Holds reference.
91         treeDataTriSurface(const triSurface&, const scalar planarTol);
94     // Member Functions
96         // Access
98             inline const triSurface& surface() const
99             {
100                 return surface_;
101             }
103             inline label size() const
104             {
105                 return surface_.size();
106             }
108             //- Get representative point cloud for all shapes inside
109             //  (one point per shape)
110             pointField shapePoints() const;
113         // Search
115             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
116             //  Only makes sense for closed surfaces.
117             label getVolumeType
118             (
119                 const indexedOctree<treeDataTriSurface>&,
120                 const point&
121             ) const;
123             //- Does (bb of) shape at index overlap bb
124             bool overlaps
125             (
126                 const label index,
127                 const treeBoundBox& sampleBb
128             ) const;
130             //- Calculates nearest (to sample) point in shape.
131             //  Returns actual point and distance (squared)
132             void findNearest
133             (
134                 const labelUList& indices,
135                 const point& sample,
137                 scalar& nearestDistSqr,
138                 label& nearestIndex,
139                 point& nearestPoint
140             ) const;
142             //- Calculates nearest (to line) point in shape.
143             //  Returns point and distance (squared)
144             void findNearest
145             (
146                 const labelUList& indices,
147                 const linePointRef& ln,
149                 treeBoundBox& tightest,
150                 label& minIndex,
151                 point& linePoint,
152                 point& nearestPoint
153             ) const;
155             //- Calculate intersection of triangle with ray. Sets result
156             //  accordingly
157             bool intersects
158             (
159                 const label index,
160                 const point& start,
161                 const point& end,
162                 point& result
163             ) const;
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 } // End namespace Foam
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 #endif
177 // ************************************************************************* //