1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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
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
29 Holds data for octree to work on mesh faces.
31 For example, calculate (in calcNearest) the correct intersection point
37 \*---------------------------------------------------------------------------*/
39 #ifndef octreeDataFace_H
40 #define octreeDataFace_H
42 #include "treeBoundBoxList.H"
45 #include "className.H"
46 #include "linePointRef.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 // Forward declaration of classes
55 template<class Type> class octree;
58 /*---------------------------------------------------------------------------*\
59 Class octreeDataFace Declaration
60 \*---------------------------------------------------------------------------*/
66 //- tolerance on linear dimensions
73 const primitiveMesh& mesh_;
75 //- labels (in mesh indexing) of faces
78 //- bbs for all above faces
79 treeBoundBoxList allBb_;
82 // Private Member Functions
84 //- Set allBb to tight fitting bounding box
89 // Declare name of the class and its debug switch
90 ClassName("octreeDataFace");
94 //- Construct from selected mesh faces.
98 const labelList& meshFaces,
99 const treeBoundBoxList&
102 //- Construct from selected mesh faces. Tight fitting bounding boxes
103 // generated internally.
106 const primitiveMesh&,
107 const labelList& meshFaces
110 //- Construct from selected mesh faces.
113 const primitiveMesh&,
114 const UList<const labelList*>&,
115 const UList<const treeBoundBoxList*>&
118 //- Construct from selected mesh faces.
119 // Tight-fitting bounding boxes generated internally.
120 octreeDataFace(const primitiveMesh&, const UList<const labelList*>&);
122 //- Construct from all faces in patch.
123 // Tight-fitting bounding boxes generated internally.
124 octreeDataFace(const polyPatch&);
126 //- Construct from all boundary faces.
127 // Tight-fitting bounding boxes generated internally.
128 octreeDataFace(const primitiveMesh&);
130 //- Construct as copy
131 octreeDataFace(const octreeDataFace&);
143 const primitiveMesh& mesh() const
148 const labelList& meshFaces() const
153 const treeBoundBoxList& allBb() const
160 return allBb_.size();
166 //- Get type of sample
169 const octree<octreeDataFace>&,
173 //- Does (bb of) shape at index overlap bb
177 const treeBoundBox& sampleBb
180 //- Does shape at index contain sample
181 bool contains(const label index, const point& sample) const;
183 //- Segment (from start to end) intersection with shape
184 // at index. If intersects returns true and sets intersectionPoint
190 point& intersectionPoint
193 //- Sets newTightest to bounding box (and returns true) if
194 // nearer to sample than tightest bounding box. Otherwise
200 treeBoundBox& tightest
203 //- Given index get unit normal and calculate (numerical) sign
205 // Used to determine accuracy of calcNearest or inside/outside.
213 //- Calculates nearest (to sample) point in shape.
214 // Returns point and mag(nearest - sample). Returns GREAT if
215 // sample does not project onto (triangle decomposition) of face.
223 //- Calculates nearest (to line segment) point in shape.
224 // Returns distance and both point.
228 const linePointRef& ln,
229 point& linePt, // nearest point on line
230 point& shapePt // nearest point on shape
236 //- Write shape at index
237 void write(Ostream& os, const label index) const;
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 } // End namespace Foam
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 // ************************************************************************* //