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-2025 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  // Private Data
68 
69  //- Reference to the mesh
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  class findNearestOp
96  {
97  const indexedOctree<treeDataFace>& tree_;
98 
99  public:
100 
102 
103  void operator()
104  (
105  const labelUList& indices,
106  const point& sample,
107 
108  scalar& nearestDistSqr,
109  label& minIndex,
110  point& nearestPoint
111  ) const;
112 
113  void operator()
114  (
115  const labelUList& indices,
116  const linePointRef& ln,
117 
118  treeBoundBox& tightest,
119  label& minIndex,
120  point& linePoint,
121  point& nearestPoint
122  ) const;
123  };
124 
125 
126  class findIntersectOp
127  {
128  const indexedOctree<treeDataFace>& tree_;
129 
130  public:
131 
133 
134  //- Calculate intersection of triangle with ray. Sets result
135  // accordingly
136  bool operator()
137  (
138  const label index,
139  const point& start,
140  const point& end,
141  point& intersectionPoint
142  ) const;
143  };
144 
145 
146  // Declare name of the class and its debug switch
147  ClassName("treeDataFace");
148 
149 
150  // Constructors
151 
152  //- Construct from mesh and subset of faces.
154  (
155  const bool cacheBb,
156  const primitiveMesh&,
157  const labelUList&
158  );
159 
160  //- Construct from mesh and subset of faces, transferring contents
162  (
163  const bool cacheBb,
164  const primitiveMesh&,
165  labelList&&
166  );
167 
168  //- Construct from mesh. Uses all faces in mesh.
169  treeDataFace(const bool cacheBb, const primitiveMesh&);
170 
171  //- Construct from mesh. Uses all faces in patch.
172  treeDataFace(const bool cacheBb, const polyPatch&);
173 
174 
175  // Member Functions
176 
177  // Access
178 
179  inline const labelList& faceLabels() const
180  {
181  return faceLabels_;
182  }
183 
184  inline const primitiveMesh& mesh() const
185  {
186  return mesh_;
187  }
188 
189  inline label size() const
190  {
191  return faceLabels_.size();
192  }
193 
194  //- Get representative point cloud for all shapes inside
195  // (one point per shape)
196  pointField shapePoints() const;
197 
198 
199  // Search
200 
201  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
202  // Only makes sense for closed surfaces.
204  (
206  const point&
207  ) const;
208 
209  //- Does (bb of) shape at index overlap bb
210  bool overlaps
211  (
212  const label index,
213  const treeBoundBox& sampleBb
214  ) const;
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 
225 #endif
226 
227 // ************************************************************************* //
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A bit-packed bool list.
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:72
A line primitive.
Definition: line.H:71
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:90
findIntersectOp(const indexedOctree< treeDataFace > &tree)
Definition: treeDataFace.C:154
findNearestOp(const indexedOctree< treeDataFace > &tree)
Definition: treeDataFace.C:145
Encapsulation of data needed to search for faces.
Definition: treeDataFace.H:59
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataFace.C:433
treeDataFace(const bool cacheBb, const primitiveMesh &, const labelUList &)
Construct from mesh and subset of faces.
Definition: treeDataFace.C:83
const labelList & faceLabels() const
Definition: treeDataFace.H:178
const primitiveMesh & mesh() const
Definition: treeDataFace.H:183
label size() const
Definition: treeDataFace.H:188
ClassName("treeDataFace")
volumeType getVolumeType(const indexedOctree< treeDataFace > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataFace.C:178
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataFace.C:164
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:908