treeDataEdge.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-2020 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::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 
38 #include "treeBoundBoxList.H"
39 #include "linePointRef.H"
40 #include "volumeType.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of classes
48 template<class Type> class indexedOctree;
49 
50 /*---------------------------------------------------------------------------*\
51  Class treeDataEdge Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class treeDataEdge
55 {
56  // Static data
57 
58  //- Tolerance on linear dimensions
59  static scalar tol;
60 
61 
62  // Private Data
63 
64  //- Reference to edgeList
65  const edgeList& edges_;
66 
67  //- Reference to points
68  const pointField& points_;
69 
70  //- Labels of edges
71  const labelList edgeLabels_;
72 
73  //- Whether to precalculate and store face bounding box
74  const bool cacheBb_;
75 
76  //- Bbs for all above edges (valid only if cacheBb_)
77  treeBoundBoxList bbs_;
78 
79 
80  // Private Member Functions
81 
82  //- Calculate edge bounding box
83  treeBoundBox calcBb(const label edgeI) const;
84 
85  //- Initialise all member data
86  void update();
87 
88 public:
89 
90 
91  class findNearestOp
92  {
93  const indexedOctree<treeDataEdge>& tree_;
94 
95  public:
96 
98 
99  void operator()
100  (
101  const labelUList& indices,
102  const point& sample,
103 
104  scalar& nearestDistSqr,
105  label& minIndex,
106  point& nearestPoint
107  ) const;
108 
109  void operator()
110  (
111  const labelUList& indices,
112  const linePointRef& ln,
113 
114  treeBoundBox& tightest,
115  label& minIndex,
116  point& linePoint,
117  point& nearestPoint
118  ) const;
119  };
120 
122  class findIntersectOp
123  {
124  public:
125 
127 
128  //- Calculate intersection of triangle with ray. Sets result
129  // accordingly
130  bool operator()
131  (
132  const label index,
133  const point& start,
134  const point& end,
135  point& intersectionPoint
136  ) const;
137  };
138 
139 
140  // Declare name of the class and its debug switch
141  ClassName("treeDataEdge");
142 
143 
144  // Constructors
145 
146  //- Construct from selected edges. !Holds references to edges and points
148  (
149  const bool cacheBb,
150  const edgeList& edges,
151  const pointField& points,
152  const labelUList& edgeLabels
153  );
154 
155  //- Construct from selected edges, transferring contents.
156  // !Holds references to edges and points
158  (
159  const bool cacheBb,
160  const edgeList& edges,
161  const pointField& points,
162  labelList&& edgeLabels
163  );
164 
165 
166  // Member Functions
167 
168  // Access
170  const edgeList& edges() const
171  {
172  return edges_;
173  }
175  const pointField& points() const
176  {
177  return points_;
178  }
180  const labelList& edgeLabels() const
181  {
182  return edgeLabels_;
183  }
185  label size() const
186  {
187  return edgeLabels_.size();
188  }
189 
190  //- Get representative point cloud for all shapes inside
191  // (one point per shape)
192  pointField shapePoints() const;
193 
194 
195  // Search
196 
197  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
198  // Only makes sense for closed surfaces.
200  (
202  const point&
203  ) const;
204 
205  //- Does (bb of) shape at index overlap bb
206  bool overlaps
207  (
208  const label index,
209  const treeBoundBox& sampleBb
210  ) const;
211 
212  //- Does (bb of) shape at index overlap bb
213  bool overlaps
214  (
215  const label index,
216  const point& centre,
217  const scalar radiusSqr
218  ) const;
219 };
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 
229 #endif
230 
231 // ************************************************************************* //
A line primitive.
Definition: line.H:56
const pointField & points() const
Definition: treeDataEdge.H:174
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Holds data for octree to work on an edges subset.
Definition: treeDataEdge.H:53
findNearestOp(const indexedOctree< treeDataEdge > &tree)
Definition: treeDataEdge.C:100
ClassName("treeDataEdge")
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataEdge.C:142
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:908
treeDataEdge(const bool cacheBb, const edgeList &edges, const pointField &points, const labelUList &edgeLabels)
Construct from selected edges. !Holds references to edges and points.
Definition: treeDataEdge.C:66
const edgeList & edges() const
Definition: treeDataEdge.H:169
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataEdge.C:117
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
label size() const
Definition: treeDataEdge.H:184
const labelList & edgeLabels() const
Definition: treeDataEdge.H:179
Namespace for OpenFOAM.
volumeType getVolumeType(const indexedOctree< treeDataEdge > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataEdge.C:132