triSurfaceSearch.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::triSurfaceSearch
26 
27 Description
28  Helper class to search on triSurface.
29 
30 SourceFiles
31  triSurfaceSearch.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef triSurfaceSearch_H
36 #define triSurfaceSearch_H
37 
38 #include "pointField.H"
39 #include "boolList.H"
40 #include "pointIndexHit.H"
41 #include "indexedOctree.H"
42 #include "treeDataTriSurface.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class triSurface;
51 
52 /*---------------------------------------------------------------------------*\
53  Class triSurfaceSearch Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class triSurfaceSearch
57 {
58  // Private Data
59 
60  //- Reference to surface to work on
61  const triSurface& surface_;
62 
63  //- Optional tolerance to use in searches
64  scalar tolerance_;
65 
66  //- Optional max tree depth of octree
67  label maxTreeDepth_;
68 
69  //- Octree for searches
71 
72 
73  // Private Member Functions
74 
75  //- Check whether the current hit on the surface which lies on lineVec
76  // is unique.
77  // point : return 1 unique hit
78  // edge : return 1 hit if in the cone of the edge faces
79  // : return 2 hits if outside or on the cone.
80  bool checkUniqueHit
81  (
82  const pointIndexHit& currHit,
84  const vector& lineVec
85  ) const;
86 
87 
88 public:
89 
90  // Constructors
91 
92  //- Construct from surface. Holds reference to surface!
93  explicit triSurfaceSearch(const triSurface&);
94 
95  //- Construct from surface and dictionary.
97 
98  //- Construct from components
100  (
101  const triSurface& surface,
102  const scalar tolerance,
103  const label maxTreeDepth
104  );
105 
106  //- Disallow default bitwise copy construction
107  triSurfaceSearch(const triSurfaceSearch&) = delete;
108 
109 
110  //- Destructor
112 
113 
114  // Member Functions
115 
116  //- Clear storage
117  void clearOut();
118 
119  //- Demand driven construction of the octree
121 
122  //- Return reference to the surface.
123  const triSurface& surface() const
124  {
125  return surface_;
126  }
127 
128  //- Return tolerance to use in searches
129  scalar tolerance() const
130  {
131  return tolerance_;
132  }
133 
134  //- Return max tree depth of octree
135  label maxTreeDepth() const
136  {
137  return maxTreeDepth_;
138  }
139 
140  //- Calculate for each searchPoint inside/outside status.
141  boolList calcInside(const pointField& searchPoints) const;
142 
143  void findNearest
144  (
145  const pointField& samples,
146  const scalarField& nearestDistSqr,
147  List<pointIndexHit>& info
148  ) const;
149 
150  //- Calculate nearest point on surface for single searchPoint. Returns
151  // in pointIndexHit:
152  // - hit() : whether nearest point found within bounding box
153  // - hitPoint() : coordinate of nearest point
154  // - index() : surface triangle label
155  pointIndexHit nearest(const point&, const vector& span) const;
156 
157  void findLine
158  (
159  const pointField& start,
160  const pointField& end,
161  List<pointIndexHit>& info
162  ) const;
163 
164  void findLineAny
165  (
166  const pointField& start,
167  const pointField& end,
168  List<pointIndexHit>& info
169  ) const;
170 
171  //- Calculate all intersections from start to end
172  void findLineAll
173  (
174  const pointField& start,
175  const pointField& end,
177  ) const;
178 
179 
180  // Member Operators
181 
182  //- Disallow default bitwise assignment
183  void operator=(const triSurfaceSearch&) = delete;
184 };
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************************************************************* //
label maxTreeDepth() const
Return max tree depth of octree.
dictionary dict
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Helper class to search on triSurface.
scalarField samples(nIntervals, 0)
~triSurfaceSearch()
Destructor.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
boolList calcInside(const pointField &searchPoints) const
Calculate for each searchPoint inside/outside status.
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &info) const
Calculate all intersections from start to end.
triSurfaceSearch(const triSurface &)
Construct from surface. Holds reference to surface!
void clearOut()
Clear storage.
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
pointIndexHit nearest(const point &, const vector &span) const
Calculate nearest point on surface for single searchPoint. Returns.
const triSurface & surface() const
Return reference to the surface.
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
scalar tolerance() const
Return tolerance to use in searches.
void operator=(const triSurfaceSearch &)=delete
Disallow default bitwise assignment.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Triangulated surface description with patch information.
Definition: triSurface.H:66
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
Namespace for OpenFOAM.