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 | Copyright (C) 2011-2016 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  //- Disallow default bitwise copy construct
89 
90  //- Disallow default bitwise assignment
91  void operator=(const triSurfaceSearch&);
92 
93 
94 public:
95 
96  // Constructors
97 
98  //- Construct from surface. Holds reference to surface!
99  explicit triSurfaceSearch(const triSurface&);
100 
101  //- Construct from surface and dictionary.
102  triSurfaceSearch(const triSurface&, const dictionary& dict);
103 
104  //- Construct from components
106  (
107  const triSurface& surface,
108  const scalar tolerance,
109  const label maxTreeDepth
110  );
111 
112 
113  //- Destructor
115 
116  //- Clear storage
117  void clearOut();
118 
119 
120  // Member Functions
121 
122  //- Demand driven construction of the octree
124 
125  //- Return reference to the surface.
126  const triSurface& surface() const
127  {
128  return surface_;
129  }
130 
131  //- Return tolerance to use in searches
132  scalar tolerance() const
133  {
134  return tolerance_;
135  }
136 
137  //- Return max tree depth of octree
138  label maxTreeDepth() const
139  {
140  return maxTreeDepth_;
141  }
142 
143  //- Calculate for each searchPoint inside/outside status.
144  boolList calcInside(const pointField& searchPoints) const;
145 
146  void findNearest
147  (
148  const pointField& samples,
149  const scalarField& nearestDistSqr,
150  List<pointIndexHit>& info
151  ) const;
152 
153  //- Calculate nearest point on surface for single searchPoint. Returns
154  // in pointIndexHit:
155  // - hit() : whether nearest point found within bounding box
156  // - hitPoint() : coordinate of nearest point
157  // - index() : surface triangle label
158  pointIndexHit nearest(const point&, const vector& span) const;
159 
160  void findLine
161  (
162  const pointField& start,
163  const pointField& end,
164  List<pointIndexHit>& info
165  ) const;
166 
167  void findLineAny
168  (
169  const pointField& start,
170  const pointField& end,
171  List<pointIndexHit>& info
172  ) const;
173 
174  //- Calculate all intersections from start to end
175  void findLineAll
176  (
177  const pointField& start,
178  const pointField& end,
180  ) const;
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace Foam
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************************************************************* //
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:137
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.
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.
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:65
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
Namespace for OpenFOAM.