treeDataFace.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
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 "face.H"
39 #include "indexedOctree.H"
40 #include "treeBoundBoxList.H"
41 #include "PackedBoolList.H"
42 #include "primitiveMesh.H"
43 #include "volumeType.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 //class primitiveMesh;
52 //template<class Type> class indexedOctree;
53 class polyPatch;
54 
55 /*---------------------------------------------------------------------------*\
56  Class treeDataFace Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class treeDataFace
60 {
61  // Static data
62 
63  //- Tolerance on linear dimensions
64  static scalar tolSqr;
65 
66 
67 
68  // Private Data
69 
70  const primitiveMesh& mesh_;
71 
72  //- Subset of faces to work on
73  const labelList faceLabels_;
74 
75  //- Inverse of faceLabels. For every mesh whether face is in faceLabels.
76  PackedBoolList isTreeFace_;
77 
78  //- Whether to precalculate and store face bounding box
79  const bool cacheBb_;
80 
81  //- Face bounding boxes (valid only if cacheBb_)
82  treeBoundBoxList bbs_;
83 
84 
85  // Private Member Functions
86 
87  //- Calculate face bounding box
88  treeBoundBox calcBb(const label celli) const;
89 
90  //- Initialise all member data
91  void update();
92 
93 public:
94 
95 
96  class findNearestOp
97  {
98  const indexedOctree<treeDataFace>& tree_;
99 
100  public:
101 
103 
104  void operator()
105  (
106  const labelUList& indices,
107  const point& sample,
108 
109  scalar& nearestDistSqr,
110  label& minIndex,
111  point& nearestPoint
112  ) const;
113 
114  void operator()
115  (
116  const labelUList& indices,
117  const linePointRef& ln,
118 
119  treeBoundBox& tightest,
120  label& minIndex,
121  point& linePoint,
122  point& nearestPoint
123  ) const;
124  };
125 
127  class findIntersectOp
128  {
129  const indexedOctree<treeDataFace>& tree_;
130 
131  public:
132 
134 
135  //- Calculate intersection of triangle with ray. Sets result
136  // accordingly
137  bool operator()
138  (
139  const label index,
140  const point& start,
141  const point& end,
142  point& intersectionPoint
143  ) const;
144  };
145 
146 
147  // Declare name of the class and its debug switch
148  ClassName("treeDataFace");
149 
150 
151  // Constructors
152 
153  //- Construct from mesh and subset of faces.
155  (
156  const bool cacheBb,
157  const primitiveMesh&,
158  const labelUList&
159  );
160 
161  //- Construct from mesh and subset of faces, transferring contents
163  (
164  const bool cacheBb,
165  const primitiveMesh&,
166  labelList&&
167  );
168 
169  //- Construct from mesh. Uses all faces in mesh.
170  treeDataFace(const bool cacheBb, const primitiveMesh&);
171 
172  //- Construct from mesh. Uses all faces in patch.
173  treeDataFace(const bool cacheBb, const polyPatch&);
174 
175 
176  // Member Functions
177 
178  // Access
180  inline const labelList& faceLabels() const
181  {
182  return faceLabels_;
183  }
185  inline const primitiveMesh& mesh() const
186  {
187  return mesh_;
188  }
190  inline label size() const
191  {
192  return faceLabels_.size();
193  }
194 
195  //- Get representative point cloud for all shapes inside
196  // (one point per shape)
197  pointField shapePoints() const;
198 
199 
200  // Search
201 
202  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
203  // Only makes sense for closed surfaces.
205  (
207  const point&
208  ) const;
209 
210  //- Does (bb of) shape at index overlap bb
211  bool overlaps
212  (
213  const label index,
214  const treeBoundBox& sampleBb
215  ) const;
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 
226 #endif
227 
228 // ************************************************************************* //
const primitiveMesh & mesh() const
Definition: treeDataFace.H:184
A line primitive.
Definition: line.H:56
ClassName("treeDataFace")
Encapsulation of data needed to search for faces.
Definition: treeDataFace.H:58
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataFace.C:168
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataFace.C:437
treeDataFace(const bool cacheBb, const primitiveMesh &, const labelUList &)
Construct from mesh and subset of faces.
Definition: treeDataFace.C:83
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:908
label size() const
Definition: treeDataFace.H:189
A bit-packed bool list.
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
findNearestOp(const indexedOctree< treeDataFace > &tree)
Definition: treeDataFace.C:149
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
volumeType getVolumeType(const indexedOctree< treeDataFace > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataFace.C:182
const labelList & faceLabels() const
Definition: treeDataFace.H:179
Namespace for OpenFOAM.