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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::treeDataFace
29
30Description
31 Encapsulation of data needed to search for faces.
32
33SourceFiles
34 treeDataFace.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef treeDataFace_H
39#define treeDataFace_H
40
41#include "face.H"
42#include "indexedOctree.H"
43#include "treeBoundBoxList.H"
44#include "bitSet.H"
45#include "primitiveMesh.H"
46#include "volumeType.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// Forward declaration of classes
54class polyPatch;
55
56/*---------------------------------------------------------------------------*\
57 Class treeDataFace Declaration
58\*---------------------------------------------------------------------------*/
60class treeDataFace
61{
62 // Static Data
63
64 //- Tolerance on linear dimensions
65 static scalar tolSqr;
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 bitSet isTreeFace_;
77
78 //- Whether to precalculate and store face bounding box
79 const bool cacheBb_;
80
81 //- Face bounding boxes (valid only if cacheBb_)
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
93public:
94
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.
136 // Sets result 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, copying subset of faces
155 (
156 const bool cacheBb,
157 const primitiveMesh& mesh,
159 );
160
161 //- Construct from mesh, moving subset of faces
163 (
164 const bool cacheBb,
165 const primitiveMesh& mesh,
167 );
168
169 //- Construct from mesh. Uses all faces in mesh.
170 treeDataFace(const bool cacheBb, const primitiveMesh& mesh);
171
172 //- Construct from mesh. Uses all faces in patch.
173 treeDataFace(const bool cacheBb, const polyPatch& patch);
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 //- 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// ************************************************************************* //
Minimal example by using system/controlDict.functions:
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:74
A line primitive.
Definition: line.H:68
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:89
Encapsulation of data needed to search for faces.
Definition: treeDataFace.H:60
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataFace.C:411
const labelList & faceLabels() const
Definition: treeDataFace.H:179
label size() const
Definition: treeDataFace.H:189
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:165
const primitiveMesh & mesh() const
Definition: treeDataFace.H:184
pointField shapePoints() const
Definition: treeDataFace.C:151
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
Namespace for OpenFOAM.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:933