initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / boundaryMesh / octreeDataFaceList.H
blobaddd71d79be9948d3ce20ed89ec9c26ea014cbc3
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::octreeDataFaceList
28 Description
29     Holds data for octree to work on list of faces on a bMesh
30     (= PrimitivePatch which holds faces, not references them)
31     Same as octreeDataFace except for that.
33 SourceFiles
34     octreeDataFaceList.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef octreeDataFaceList_H
39 #define octreeDataFaceList_H
41 #include "treeBoundBoxList.H"
42 #include "faceList.H"
43 #include "point.H"
44 #include "className.H"
45 #include "bMesh.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 // Forward declaration of classes
53 template<class Type> class octree;
55 /*---------------------------------------------------------------------------*\
56                            Class octreeDataFaceList Declaration
57 \*---------------------------------------------------------------------------*/
59 class octreeDataFaceList
61     // Static data
63         //- tolerance on linear dimensions
64         static scalar tol;
67     // Static function
69         static inline label nexti(label max, label i)
70         {
71             return (i + 1) % max;
72         }            
75     // Private data
77         //- the mesh
78         const bMesh& mesh_;
80         //- labels (in mesh indexing) of faces
81         labelList faceLabels_;
83         //- bbs for all above faces
84         treeBoundBoxList allBb_;
87     // Private Member Functions
89         //- Set allBb to tight fitting bounding box
90         void calcBb();
92 public:
94     // Declare name of the class and its debug switch
95     ClassName("octreeDataFaceList");
97     // Constructors
99         //- Construct from all faces in bMesh.
100         octreeDataFaceList(const bMesh& mesh);
102         //- Construct from selected faces in bMesh.
103         octreeDataFaceList(const bMesh& mesh, const labelList& faceLabels);
105         //- Construct as copy
106         octreeDataFaceList(const octreeDataFaceList&);
109     // Destructor
111         ~octreeDataFaceList();
114     // Member Functions
116         // Access
118             const bMesh& mesh() const
119             {
120                 return mesh_;
121             }
123             const labelList& faceLabels() const
124             {
125                 return faceLabels_;
126             }
128             const treeBoundBoxList& allBb() const
129             {
130                 return allBb_;
131             }
133             label size() const
134             {
135                 return allBb_.size();
136             }
138         // Search
140             //- Get type of sample
141             label getSampleType
142             (
143                 const octree<octreeDataFaceList>&,
144                 const point&
145             ) const;
147             //- Does (bb of) shape at index overlap bb
148             bool overlaps
149             (
150                 const label index,
151                 const treeBoundBox& sampleBb
152             ) const;
154             //- Does shape at index contain sample
155             bool contains
156             (
157                 const label index,
158                 const point& sample
159             ) const;
161             //- Segment (from start to end) intersection with shape
162             //  at index. If intersects returns true and sets intersectionPoint
163             bool intersects
164             (
165                 const label index,
166                 const point& start,
167                 const point& end,
168                 point& intersectionPoint
169             ) const;
171             //- Sets newTightest to bounding box (and returns true) if
172             //  nearer to sample than tightest bounding box. Otherwise
173             //  returns false.
174             bool findTightest
175             (
176                 const label index,
177                 const point& sample,
178                 treeBoundBox& tightest
179             ) const;
181             //- Given index get unit normal and calculate (numerical) sign 
182             //  of sample.
183             //  Used to determine accuracy of calcNearest or inside/outside.
184             scalar calcSign
185             (
186                 const label index,
187                 const point& sample,
188                 vector& n
189             ) const;
191             //- Calculates nearest (to sample) point in shape.
192             //  Returns point and mag(nearest - sample). Returns GREAT if
193             //  sample does not project onto (triangle decomposition) of face.
194             scalar calcNearest
195             (
196                 const label index,
197                 const point& sample,
198                 point& nearest
199             ) const;
202         // Edit
204         // Write
206             //- Write shape at index
207             void write(Ostream& os, const label index) const;
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 } // End namespace Foam
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 #endif
220 // ************************************************************************* //