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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::treeDataEdge
29
30Description
31 Holds data for octree to work on an edges subset.
32
33SourceFiles
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
47namespace Foam
48{
49
50// Forward declaration of classes
51template<class Type> class indexedOctree;
52
53/*---------------------------------------------------------------------------*\
54 Class treeDataEdge Declaration
55\*---------------------------------------------------------------------------*/
57class 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_)
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
91public:
92
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
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,
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
174 const edgeList& edges() const
175 {
176 return edges_;
177 }
179 const pointField& points() const
180 {
181 return points_;
182 }
184 const labelList& edgeLabels() const
185 {
186 return edgeLabels_;
187 }
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// ************************************************************************* //
Minimal example by using system/controlDict.functions:
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:74
A line primitive.
Definition: line.H:68
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:89
Holds data for octree to work on an edges subset.
Definition: treeDataEdge.H:57
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataEdge.C:144
ClassName("treeDataEdge")
const edgeList & edges() const
Definition: treeDataEdge.H:173
label size() const
Definition: treeDataEdge.H:188
const labelList & edgeLabels() const
Definition: treeDataEdge.H:183
volumeType getVolumeType(const indexedOctree< treeDataEdge > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataEdge.C:134
pointField shapePoints() const
Definition: treeDataEdge.C:119
const pointField & points() const
Definition: treeDataEdge.H:178
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
Namespace for OpenFOAM.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:933