1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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/>.
28 Holds data for octree to work on mesh faces.
30 For example, calculate (in calcNearest) the correct intersection point
36 \*---------------------------------------------------------------------------*/
38 #ifndef octreeDataFace_H
39 #define octreeDataFace_H
41 #include "treeBoundBoxList.H"
44 #include "className.H"
45 #include "linePointRef.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declaration of classes
54 template<class Type> class octree;
57 /*---------------------------------------------------------------------------*\
58 Class octreeDataFace Declaration
59 \*---------------------------------------------------------------------------*/
65 //- tolerance on linear dimensions
72 const primitiveMesh& mesh_;
74 //- labels (in mesh indexing) of faces
77 //- bbs for all above faces
78 treeBoundBoxList allBb_;
81 // Private Member Functions
83 //- Set allBb to tight fitting bounding box
88 // Declare name of the class and its debug switch
89 ClassName("octreeDataFace");
93 //- Construct from selected mesh faces.
97 const labelList& meshFaces,
98 const treeBoundBoxList&
101 //- Construct from selected mesh faces. Tight fitting bounding boxes
102 // generated internally.
105 const primitiveMesh&,
106 const labelList& meshFaces
109 //- Construct from selected mesh faces.
112 const primitiveMesh&,
113 const UList<const labelList*>&,
114 const UList<const treeBoundBoxList*>&
117 //- Construct from selected mesh faces.
118 // Tight-fitting bounding boxes generated internally.
119 octreeDataFace(const primitiveMesh&, const UList<const labelList*>&);
121 //- Construct from all faces in patch.
122 // Tight-fitting bounding boxes generated internally.
123 octreeDataFace(const polyPatch&);
125 //- Construct from all boundary faces.
126 // Tight-fitting bounding boxes generated internally.
127 octreeDataFace(const primitiveMesh&);
129 //- Construct as copy
130 octreeDataFace(const octreeDataFace&);
141 const primitiveMesh& mesh() const
146 const labelList& meshFaces() const
151 const treeBoundBoxList& allBb() const
158 return allBb_.size();
164 //- Get type of sample
167 const octree<octreeDataFace>&,
171 //- Does (bb of) shape at index overlap bb
175 const treeBoundBox& sampleBb
178 //- Does shape at index contain sample
179 bool contains(const label index, const point& sample) const;
181 //- Segment (from start to end) intersection with shape
182 // at index. If intersects returns true and sets intersectionPoint
188 point& intersectionPoint
191 //- Sets newTightest to bounding box (and returns true) if
192 // nearer to sample than tightest bounding box. Otherwise
198 treeBoundBox& tightest
201 //- Given index get unit normal and calculate (numerical) sign
203 // Used to determine accuracy of calcNearest or inside/outside.
211 //- Calculates nearest (to sample) point in shape.
212 // Returns point and mag(nearest - sample). Returns GREAT if
213 // sample does not project onto (triangle decomposition) of face.
221 //- Calculates nearest (to line segment) point in shape.
222 // Returns distance and both point.
226 const linePointRef& ln,
227 point& linePt, // nearest point on line
228 point& shapePt // nearest point on shape
234 //- Write shape at index
235 void write(Ostream& os, const label index) const;
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 // ************************************************************************* //