searchableSurfacesQueries.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-2018 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::searchableSurfacesQueries
26 
27 Description
28  A collection of tools for searchableSurfaces.
29 
30 SourceFiles
31  searchableSurfacesQueries.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef searchableSurfacesQueries_H
36 #define searchableSurfacesQueries_H
37 
38 #include "searchableSurface.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // Forward declaration of classes
46 class plane;
47 class pointConstraint;
48 
49 /*---------------------------------------------------------------------------*\
50  Class searchableSurfacesQueries Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 {
55  // Private Member Functions
56 
57  static void mergeHits
58  (
59  const point& start,
60 
61  const label surfI,
62  const List<pointIndexHit>& surfHits,
63 
64  labelList& allSurfaces,
65  List<pointIndexHit>& allInfo,
66  scalarList& allDistSqr
67  );
68 
69 public:
70 
71  // Declare name of the class and its debug switch
72  ClassName("searchableSurfacesQueries");
73 
74 
75  // Multiple point queries.
76 
77  //- Find any intersection. Return hit point information and
78  // index in surfacesToTest. If multiple surfaces hit the first
79  // surface is returned, not necessarily the nearest (to start).
80  static void findAnyIntersection
81  (
83  const labelList& surfacesToTest,
84  const pointField& start,
85  const pointField& end,
86  labelList& surfaces,
88  );
89 
90  //- Find all intersections in order from start to end. Returns for
91  // every hit the index in surfacesToTest and the hit info.
92  static void findAllIntersections
93  (
95  const labelList& surfacesToTest,
96  const pointField& start,
97  const pointField& end,
98  labelListList& surfaces,
99  List<List<pointIndexHit>>& surfaceHits
100  );
101 
102  //- Find intersections of edge nearest to both endpoints.
103  static void findNearestIntersection
104  (
105  const PtrList<searchableSurface>& allSurfaces,
106  const labelList& surfacesToTest,
107  const pointField& start,
108  const pointField& end,
109  labelList& surface1,
110  List<pointIndexHit>& hit1,
111  labelList& surface2,
112  List<pointIndexHit>& hit2
113  );
114 
115  //- Find nearest. Return -1 (and a miss()) or surface and nearest
116  // point.
117  static void findNearest
118  (
120  const labelList& surfacesToTest,
121  const pointField&,
122  const scalarField& nearestDistSqr,
123  labelList& surfaces,
125  );
126 
127  //- Find nearest points to a specific region of the surface
128  static void findNearest
129  (
130  const PtrList<searchableSurface>& allSurfaces,
131  const labelList& surfacesToTest,
132  const pointField& samples,
133  const scalarField& nearestDistSqr,
134  const labelList& regionIndices,
135  labelList& nearestSurfaces,
136  List<pointIndexHit>& nearestInfo
137  );
138 
139  //- Find nearest points that are on all supplied surfaces
140  // (nearest point if single surface; nearest intersection by
141  // steepst descent if on multiple surfaces). Returns current
142  // best guess). Wip.
143  static void findNearest
144  (
145  const PtrList<searchableSurface>& allSurfaces,
146  const labelList& surfacesToTest,
147  const pointField& start,
148  const scalarField& distSqr,
149  pointField& near,
150  List<pointConstraint>& constraint,
151  const label nIter = 20
152  );
153 
154  //- Find signed distance to nearest surface. Outside is positive.
155  // illegalHandling: how to handle non-inside or outside
156  // OUTSIDE : treat as outside
157  // INSIDE : treat as inside
158  // UNKNOWN : throw fatal error
159  static void signedDistance
160  (
161  const PtrList<searchableSurface>& allSurfaces,
162  const labelList& surfacesToTest,
163  const pointField& samples,
164  const scalarField& nearestDistSqr,
165  const volumeType illegalHandling,
166  labelList& nearestSurfaces,
168  );
169 
170  //- Find the boundBox of the selected surfaces
171  static boundBox bounds
172  (
173  const PtrList<searchableSurface>& allSurfaces,
174  const labelList& surfacesToTest
175  );
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
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
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
A collection of tools for searchableSurfaces.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:58
static void findAllIntersections(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit >> &surfaceHits)
Find all intersections in order from start to end. Returns for.
static void signedDistance(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, const volumeType illegalHandling, labelList &nearestSurfaces, scalarField &distance)
Find signed distance to nearest surface. Outside is positive.
scalarField samples(nIntervals, 0)
static void findNearestIntersection(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2)
Find intersections of edge nearest to both endpoints.
ClassName("searchableSurfacesQueries")
static void findAnyIntersection(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &)
Find any intersection. Return hit point information and.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest)
Find the boundBox of the selected surfaces.
Namespace for OpenFOAM.