FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/pointField.H>
39 #include <OpenFOAM/boolList.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class triSurface;
51 class treeDataTriSurface;
52 template<class Type> class indexedOctree;
53 
54 /*---------------------------------------------------------------------------*\
55  Class triSurfaceSearch Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 {
60  // Private data
61 
62  //- Reference to surface to work on
63  const triSurface& surface_;
64 
65  //- Octree for searches
67 
68 
69  // Private Member Functions
70 
71 
72  //- Disallow default bitwise copy construct
74 
75  //- Disallow default bitwise assignment
76  void operator=(const triSurfaceSearch&);
77 
78 public:
79 
80  // Static data members
81 
82  //- Point far away; used for illegal finds
83  static const point greatPoint;
84 
85 
86  // Constructors
87 
88  //- Construct from surface. Holds reference to surface!
90 
91 
92 
93  // Member Functions
94 
96  {
97  return treePtr_();
98  }
99 
100  const triSurface& surface() const
101  {
102  return surface_;
103  }
104 
105  //- Calculate for each searchPoint inside/outside status.
106  boolList calcInside(const pointField& searchPoints) const;
107 
108  //- Calculate index of nearest triangle (or -1) for each sample.
109  // Looks only in box of size 2*span around sample.
111  (
112  const pointField& samples,
113  const vector& span
114  ) const;
115 
116  //- Calculate nearest points (to searchPoints) on surface.
117  // Looks only in box of size 2*span around sample. Returns greatPoint
118  // if not found.
120  (
121  const pointField& samples,
122  const vector& span
123  ) const;
124 
125  //- Calculate nearest point on surface for single searchPoint. Returns
126  // in pointIndexHit:
127  // - hit() : whether nearest point found within bounding box
128  // - hitPoint() : coordinate of nearest point
129  // - index() : surface triangle label
130  pointIndexHit nearest(const point&, const vector& span) const;
131 };
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 } // End namespace Foam
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 #endif
141 
142 // ************************ vim: set sw=4 sts=4 et: ************************ //