FreeFOAM The Cross-Platform CFD Toolkit
treeDataFace.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::treeDataFace
26 
27 Description
28  Encapsulation of data needed to search for faces.
29 
30 SourceFiles
31  treeDataFace.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef treeDataFace_H
36 #define treeDataFace_H
37 
38 #include <OpenFOAM/face.H>
39 #include "indexedOctree.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of classes
49 class primitiveMesh;
50 //template<class Type> class indexedOctree;
51 class polyPatch;
52 
53 /*---------------------------------------------------------------------------*\
54  Class treeDataFace Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 {
59  // Static data
60 
61  //- tolerance on linear dimensions
62  static scalar tolSqr;
63 
64 
65 
66  // Private data
67 
68  const primitiveMesh& mesh_;
69 
70  //- Subset of faces to work on
71  const labelList faceLabels_;
72 
73  //- Inverse of faceLabels. For every mesh whether face is in faceLabels.
74  PackedBoolList isTreeFace_;
75 
76  //- Whether to precalculate and store face bounding box
77  const bool cacheBb_;
78 
79  //- face bounding boxes (valid only if cacheBb_)
80  treeBoundBoxList bbs_;
81 
82 
83  // Private Member Functions
84 
85  //- Calculate face bounding box
86  treeBoundBox calcBb(const label cellI) const;
87 
88  //- Initialise all member data
89  void update();
90 
91 public:
92 
93  // Declare name of the class and its debug switch
94  ClassName("treeDataFace");
95 
96 
97  // Constructors
98 
99  //- Construct from mesh and subset of faces.
101  (
102  const bool cacheBb,
103  const primitiveMesh&,
104  const labelList&
105  );
106 
107  //- Construct from mesh. Uses all faces in mesh.
108  treeDataFace(const bool cacheBb, const primitiveMesh&);
109 
110  //- Construct from mesh. Uses all faces in patch.
111  treeDataFace(const bool cacheBb, const polyPatch&);
112 
113 
114  // Member Functions
115 
116  // Access
117 
118  const labelList& faceLabels() const
119  {
120  return faceLabels_;
121  }
122 
123  const primitiveMesh& mesh() const
124  {
125  return mesh_;
126  }
127 
128  label size() const
129  {
130  return faceLabels_.size();
131  }
132 
133  //- Get representative point cloud for all shapes inside
134  // (one point per shape)
135  pointField points() const;
136 
137 
138  // Search
139 
140  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
141  // Only makes sense for closed surfaces.
142  label getVolumeType
143  (
145  const point&
146  ) const;
147 
148  //- Does (bb of) shape at index overlap bb
149  bool overlaps
150  (
151  const label index,
152  const treeBoundBox& sampleBb
153  ) const;
154 
155  //- Calculates nearest (to sample) point in shape.
156  // Returns actual point and distance (squared)
157  void findNearest
158  (
159  const labelList& indices,
160  const point& sample,
161 
162  scalar& nearestDistSqr,
163  label& nearestIndex,
164  point& nearestPoint
165  ) const;
166 
167  //- Calculates nearest (to line) point in shape.
168  // Returns point and distance (squared)
169  void findNearest
170  (
171  const labelList& indices,
172  const linePointRef& ln,
173 
174  treeBoundBox& tightest,
175  label& minIndex,
176  point& linePoint,
177  point& nearestPoint
178  ) const
179  {
181  (
182  "treeDataFace::findNearest"
183  "(const labelList&, const linePointRef&, ..)"
184  );
185  }
186 
187  //- Calculate intersection of shape with ray. Sets result
188  // accordingly
189  bool intersects
190  (
191  const label index,
192  const point& start,
193  const point& end,
194  point& result
195  ) const;
196 
197 };
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 
207 #endif
208 
209 // ************************ vim: set sw=4 sts=4 et: ************************ //