Loading...
Searching...
No Matches
triSurfaceSearch.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) 2017-2022 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::triSurfaceSearch
29
30Description
31 Helper class to search on triSurface.
32
33SourceFiles
34 triSurfaceSearch.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef triSurfaceSearch_H
39#define triSurfaceSearch_H
40
41#include "pointField.H"
42#include "boolList.H"
43#include "pointIndexHit.H"
44#include "indexedOctree.H"
45#include "treeDataTriSurface.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52// Forward declaration of classes
53class triSurface;
55/*---------------------------------------------------------------------------*\
56 Class triSurfaceSearch Declaration
57\*---------------------------------------------------------------------------*/
58
59class triSurfaceSearch
60{
61 // Private data
62
63 //- Reference to surface to work on
64 const triSurface& surface_;
65
66 //- Optional tolerance to use in searches
67 scalar tolerance_;
68
69 //- Optional max tree depth of octree
70 label maxTreeDepth_;
71
72 //- Octree for searches
74
75
76 // Private Member Functions
77
78 //- Check whether the current hit on the surface which lies on lineVec
79 // is unique.
80 // point : return 1 unique hit
81 // edge : return 1 hit if in the cone of the edge faces
82 // : return 2 hits if outside or on the cone.
83 bool checkUniqueHit
84 (
85 const pointIndexHit& currHit,
86 const UList<pointIndexHit>& hits,
87 const vector& lineVec
88 ) const;
89
90 //- No copy construct
91 triSurfaceSearch(const triSurfaceSearch&) = delete;
92
93 //- No copy assignment
94 void operator=(const triSurfaceSearch&) = delete;
95
96
97public:
98
99 // Constructors
100
101 //- Construct from surface. Holds reference to surface!
102 explicit triSurfaceSearch(const triSurface& surface);
103
104 //- Construct from surface and dictionary.
105 triSurfaceSearch(const triSurface& surface, const dictionary& dict);
106
107 //- Construct from components.
108 // A invalid (negative) tolerance uses the default tolerance.
109 triSurfaceSearch
110 (
111 const triSurface& surface,
112 const scalar tolerance,
113 const label maxTreeDepth = 10
114 );
115
116
117 //- Destructor
119
120 //- Clear storage
121 void clearOut();
122
123
124 // Member Functions
125
126 //- Demand driven construction of the octree
128
129 //- Flip orientation (if cached on octree)
130 void flip();
131
132 //- Return reference to the surface.
133 const triSurface& surface() const
134 {
135 return surface_;
136 }
137
138 //- Return tolerance to use in searches
139 scalar tolerance() const
140 {
141 return tolerance_;
142 }
143
144 //- Return max tree depth of octree
145 label maxTreeDepth() const
146 {
147 return maxTreeDepth_;
148 }
149
150 //- Calculate for each searchPoint inside/outside status.
151 boolList calcInside(const pointField& searchPoints) const;
152
153 void findNearest
154 (
155 const pointField& samples,
156 const scalarField& nearestDistSqr,
158 ) const;
159
160 //- Calculate nearest point on surface for single searchPoint. Returns
161 // in pointIndexHit:
162 // - hit() : whether nearest point found within bounding box
163 // - point() : coordinate of nearest point
164 // - index() : surface triangle label
165 pointIndexHit nearest(const point& pt, const vector& span) const;
166
167 void findLine
169 const pointField& start,
170 const pointField& end,
172 ) const;
173
174 void findLineAny
175 (
176 const pointField& start,
177 const pointField& end,
179 ) const;
180
181 //- Calculate all intersections from start to end
182 void findLineAll
183 (
184 const pointField& start,
185 const pointField& end,
187 ) const;
188};
189
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193} // End namespace Foam
194
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197#endif
198
199// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Non-pointer based hierarchical recursive searching.
void flip()
Flip orientation (if cached on octree).
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &info) const
Calculate all intersections from start to end.
boolList calcInside(const pointField &searchPoints) const
Calculate for each searchPoint inside/outside status.
scalar tolerance() const
Return tolerance to use in searches.
const triSurface & surface() const
Return reference to the surface.
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
label maxTreeDepth() const
Return max tree depth of octree.
void clearOut()
Clear storage.
pointIndexHit nearest(const point &pt, const vector &span) const
Calculate nearest point on surface for single searchPoint. Returns.
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Triangulated surface description with patch information.
Definition triSurface.H:74
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
vector point
Point is a vector.
Definition point.H:37
List< bool > boolList
A List of bools.
Definition List.H:60
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
dictionary dict
scalarField samples(nIntervals, Zero)