FreeFOAM The Cross-Platform CFD Toolkit
treeDataPoint.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::treeDataPoint
26 
27 Description
28  Holds (reference to) pointField. Encapsulation of data needed for
29  octree searches.
30  Used for searching for nearest point. No bounding boxes around points.
31  Only overlaps and calcNearest are implemented, rest makes little sense.
32 
33 SourceFiles
34  treeDataPoint.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef treeDataPoint_H
39 #define treeDataPoint_H
40 
41 #include <OpenFOAM/pointField.H>
42 #include <meshTools/treeBoundBox.H>
43 #include <OpenFOAM/linePointRef.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 template<class Type> class indexedOctree;
52 
53 /*---------------------------------------------------------------------------*\
54  Class treeDataPoint Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 {
59  // Private data
60 
61  const pointField& points_;
62 
63 public:
64 
65  // Declare name of the class and its debug switch
66  ClassName("treeDataPoint");
67 
68 
69  // Constructors
70 
71  //- Construct from components. Holds reference to points!
73 
74 
75  // Member Functions
76 
77  // Access
78 
79  label size() const
80  {
81  return points_.size();
82  }
83 
84  //- Get representative point cloud for all shapes inside
85  // (one point per shape)
86  pointField points() const;
87 
88 
89  // Search
90 
91  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
92  // Only makes sense for closed surfaces.
93  label getVolumeType
94  (
96  const point&
97  ) const;
98 
99  //- Does (bb of) shape at index overlap bb
100  bool overlaps
101  (
102  const label index,
103  const treeBoundBox& sampleBb
104  ) const;
105 
106  //- Calculates nearest (to sample) point in shape.
107  // Returns actual point and distance (squared)
108  void findNearest
109  (
110  const labelList& indices,
111  const point& sample,
112 
113  scalar& nearestDistSqr,
114  label& nearestIndex,
115  point& nearestPoint
116  ) const;
117 
118  //- Calculates nearest (to line) point in shape.
119  // Returns point and distance (squared)
120  void findNearest
121  (
122  const labelList& indices,
123  const linePointRef& ln,
124 
125  treeBoundBox& tightest,
126  label& minIndex,
127  point& linePoint,
128  point& nearestPoint
129  ) const;
130 
131  //- Calculate intersection of shape with ray. Sets result
132  // accordingly
133  bool intersects
134  (
135  const label index,
136  const point& start,
137  const point& end,
138  point& result
139  ) const
140  {
142  (
143  "treeDataPoint::intersects(const label, const point&,"
144  "const point&, point&)"
145  );
146  return false;
147  }
148 
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 
159 #endif
160 
161 // ************************ vim: set sw=4 sts=4 et: ************************ //