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 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;
54
55/*---------------------------------------------------------------------------*\
56 Class triSurfaceSearch Declaration
57\*---------------------------------------------------------------------------*/
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.
106
107 //- Construct from components.
108 // A invalid (negative) tolerance uses the default tolerance.
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 //- Return reference to the surface.
130 const triSurface& surface() const
131 {
132 return surface_;
133 }
134
135 //- Return tolerance to use in searches
136 scalar tolerance() const
137 {
138 return tolerance_;
139 }
140
141 //- Return max tree depth of octree
142 label maxTreeDepth() const
143 {
144 return maxTreeDepth_;
145 }
146
147 //- Calculate for each searchPoint inside/outside status.
148 boolList calcInside(const pointField& searchPoints) const;
149
150 void findNearest
151 (
152 const pointField& samples,
153 const scalarField& nearestDistSqr,
155 ) const;
156
157 //- Calculate nearest point on surface for single searchPoint. Returns
158 // in pointIndexHit:
159 // - hit() : whether nearest point found within bounding box
160 // - hitPoint() : coordinate of nearest point
161 // - index() : surface triangle label
162 pointIndexHit nearest(const point& pt, const vector& span) const;
163
164 void findLine
165 (
166 const pointField& start,
167 const pointField& end,
169 ) const;
170
171 void findLineAny
172 (
173 const pointField& start,
174 const pointField& end,
176 ) const;
177
178 //- Calculate all intersections from start to end
179 void findLineAll
180 (
181 const pointField& start,
182 const pointField& end,
184 ) const;
185};
186
187
188// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189
190} // End namespace Foam
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
194#endif
195
196// ************************************************************************* //
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:66
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:94
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:74
Helper class to search on triSurface.
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.
~triSurfaceSearch()
Destructor.
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:79
Namespace for OpenFOAM.
dictionary dict
scalarField samples(nIntervals, Zero)