FreeFOAM The Cross-Platform CFD Toolkit
treeDataEdge.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::treeDataEdge
26 
27 Description
28  Holds data for octree to work on an edges subset.
29 
30 SourceFiles
31  treeDataEdge.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef treeDataEdge_H
36 #define treeDataEdge_H
37 
39 #include <OpenFOAM/linePointRef.H>
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of classes
47 template<class Type> class indexedOctree;
48 
49 /*---------------------------------------------------------------------------*\
50  Class treeDataEdge Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 {
55  // Static data
56 
57  //- tolerance on linear dimensions
58  static scalar tol;
59 
60 
61  // Private data
62 
63  //- Reference to edgeList
64  const edgeList& edges_;
65 
66  //- Reference to points
67  const pointField& points_;
68 
69  //- labels of edges
70  const labelList edgeLabels_;
71 
72  //- Whether to precalculate and store face bounding box
73  const bool cacheBb_;
74 
75  //- bbs for all above edges (valid only if cacheBb_)
76  treeBoundBoxList bbs_;
77 
78 
79  // Private Member Functions
80 
81  //- Calculate edge bounding box
82  treeBoundBox calcBb(const label edgeI) const;
83 
84 public:
85 
86  // Declare name of the class and its debug switch
87  ClassName("treeDataEdge");
88 
89 
90  // Constructors
91 
92  //- Construct from selected edges. !Holds references to edges and points
94  (
95  const bool cacheBb,
96  const edgeList& edges,
97  const pointField& points,
98  const labelList& edgeLabels
99  );
100 
101 
102  // Member Functions
103 
104  // Access
105 
106  label size() const
107  {
108  return edgeLabels_.size();
109  }
110 
111  //- Get representative point cloud for all shapes inside
112  // (one point per shape)
113  pointField points() const;
114 
115 
116  // Search
117 
118  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
119  // Only makes sense for closed surfaces.
120  label getVolumeType
121  (
123  const point&
124  ) const;
125 
126  //- Does (bb of) shape at index overlap bb
127  bool overlaps
128  (
129  const label index,
130  const treeBoundBox& sampleBb
131  ) const;
132 
133  //- Calculates nearest (to sample) point in shape.
134  // Returns actual point and distance (squared)
135  void findNearest
136  (
137  const labelList& indices,
138  const point& sample,
139 
140  scalar& nearestDistSqr,
141  label& nearestIndex,
142  point& nearestPoint
143  ) const;
144 
145  //- Calculates nearest (to line) point in shape.
146  // Returns point and distance (squared)
147  void findNearest
148  (
149  const labelList& indices,
150  const linePointRef& ln,
151 
152  treeBoundBox& tightest,
153  label& minIndex,
154  point& linePoint,
155  point& nearestPoint
156  ) const;
157 
158  //- Calculate intersection of shape with ray. Sets result
159  // accordingly
160  bool intersects
161  (
162  const label index,
163  const point& start,
164  const point& end,
165  point& result
166  ) const
167  {
169  (
170  "treeDataEdge::intersects(const label, const point&,"
171  "const point&, point&)"
172  );
173  return false;
174  }
175 
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 
186 #endif
187 
188 // ************************ vim: set sw=4 sts=4 et: ************************ //