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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::treeDataEdge
29 
30 Description
31  Holds data for octree to work on an edges subset.
32 
33 SourceFiles
34  treeDataEdge.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef treeDataEdge_H
39 #define treeDataEdge_H
40 
41 #include "treeBoundBoxList.H"
42 #include "linePointRef.H"
43 #include "volumeType.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 template<class Type> class indexedOctree;
52 
53 /*---------------------------------------------------------------------------*\
54  Class treeDataEdge Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class treeDataEdge
58 {
59  // Static Data
60 
61  //- Tolerance on linear dimensions
62  static scalar tol;
63 
64 
65  // Private Data
66 
67  //- Reference to edgeList
68  const edgeList& edges_;
69 
70  //- Reference to points
71  const pointField& points_;
72 
73  //- Labels of edges
74  const labelList edgeLabels_;
75 
76  //- Whether to precalculate and store face bounding box
77  const bool cacheBb_;
78 
79  //- Bbs for all above edges (valid only if cacheBb_)
80  treeBoundBoxList bbs_;
81 
82 
83  // Private Member Functions
84 
85  //- Calculate edge bounding box
86  treeBoundBox calcBb(const label edgeI) const;
87 
88  //- Initialise all member data
89  void update();
90 
91 public:
92 
93 
94  class findNearestOp
95  {
96  const indexedOctree<treeDataEdge>& tree_;
97 
98  public:
99 
101 
102  void operator()
103  (
104  const labelUList& indices,
105  const point& sample,
106 
107  scalar& nearestDistSqr,
108  label& minIndex,
109  point& nearestPoint
110  ) const;
111 
112  void operator()
113  (
114  const labelUList& indices,
115  const linePointRef& ln,
116 
117  treeBoundBox& tightest,
118  label& minIndex,
119  point& linePoint,
120  point& nearestPoint
121  ) const;
122  };
123 
124 
125  class findIntersectOp
126  {
127  public:
128 
130 
131  //- Calculate intersection of triangle with ray. Sets result
132  // accordingly
133  bool operator()
134  (
135  const label index,
136  const point& start,
137  const point& end,
138  point& intersectionPoint
139  ) const;
140  };
141 
142 
143  // Declare name of the class and its debug switch
144  ClassName("treeDataEdge");
145 
146 
147  // Constructors
148 
149  //- Construct from selected edges.
150  // \note Holds references to edges and points!
152  (
153  const bool cacheBb,
154  const edgeList& edges,
155  const pointField& points,
156  const labelUList& edgeLabels
157  );
158 
159  //- Construct from selected edges, transferring contents.
160  // \note Holds references to edges and points!
162  (
163  const bool cacheBb,
164  const edgeList& edges,
165  const pointField& points,
167  );
168 
169 
170  // Member Functions
171 
172  // Access
173 
174  const edgeList& edges() const
175  {
176  return edges_;
177  }
178 
179  const pointField& points() const
180  {
181  return points_;
182  }
183 
184  const labelList& edgeLabels() const
185  {
186  return edgeLabels_;
187  }
188 
189  label size() const
190  {
191  return edgeLabels_.size();
192  }
193 
194  //- Representative point cloud for all shapes inside
195  //- (one point per shape)
196  pointField shapePoints() const;
197 
198 
199  // Search
200 
201  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
202  // Only makes sense for closed surfaces.
204  (
206  const point&
207  ) const;
208 
209  //- Does (bb of) shape at index overlap bb
210  bool overlaps
211  (
212  const label index,
213  const treeBoundBox& sampleBb
214  ) const;
215 
216  //- Does (bb of) shape at index overlap bb
217  bool overlaps
218  (
219  const label index,
220  const point& centre,
221  const scalar radiusSqr
222  ) const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 
233 #endif
234 
235 // ************************************************************************* //
Foam::treeDataEdge::findNearestOp::findNearestOp
findNearestOp(const indexedOctree< treeDataEdge > &tree)
Definition: treeDataEdge.C:102
Foam::treeDataEdge::getVolumeType
volumeType getVolumeType(const indexedOctree< treeDataEdge > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataEdge.C:134
Foam::treeDataEdge::treeDataEdge
treeDataEdge(const bool cacheBb, const edgeList &edges, const pointField &points, const labelUList &edgeLabels)
Construct from selected edges.
Definition: treeDataEdge.C:68
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::treeDataEdge::overlaps
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataEdge.C:144
Foam::treeDataEdge::findIntersectOp::findIntersectOp
findIntersectOp(const indexedOctree< treeDataEdge > &tree)
Definition: treeDataEdge.C:111
volumeType.H
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
Foam::treeDataEdge::edges
const edgeList & edges() const
Definition: treeDataEdge.H:173
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:50
Foam::treeDataEdge::size
label size() const
Definition: treeDataEdge.H:188
Foam::treeDataEdge
Holds data for octree to work on an edges subset.
Definition: treeDataEdge.H:56
Foam::treeDataEdge::findNearestOp
Definition: treeDataEdge.H:93
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
treeBoundBoxList.H
Foam::treeDataEdge::points
const pointField & points() const
Definition: treeDataEdge.H:178
Foam::treeDataEdge::shapePoints
pointField shapePoints() const
Definition: treeDataEdge.C:119
Foam::Vector< scalar >
Foam::treeDataEdge::ClassName
ClassName("treeDataEdge")
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList< label >
Foam::treeDataEdge::edgeLabels
const labelList & edgeLabels() const
Definition: treeDataEdge.H:183
Foam::treeDataEdge::findIntersectOp
Definition: treeDataEdge.H:124
Foam::line
A line primitive.
Definition: line.H:53
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:925
sample
Minimal example by using system/controlDict.functions:
linePointRef.H