treeDataTriSurface.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::treeDataTriSurface
26 
27 Description
28  Encapsulates data for (indexedOc)tree searches on triSurface.
29 
30 SourceFiles
31  treeDataTriSurface.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef treeDataTriSurface_H
36 #define treeDataTriSurface_H
37 
38 #include "triSurface.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // Forward declaration of classes
46 class treeBoundBox;
48 template<class Type> class indexedOctree;
49 
50 /*---------------------------------------------------------------------------*\
51  Class treeDataTriSurface Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 {
56  // Private data
57 
58  const triSurface& surface_;
59 
60 
61  // Private Member Functions
62 
63  //- fast triangle nearest point calculation. Returns point in E0, E1
64  // coordinate system: base + s*E0 + t*E1
65  static scalar nearestCoords
66  (
67  const point& base,
68  const point& E0,
69  const point& E1,
70  const scalar a,
71  const scalar b,
72  const scalar c,
73  const point& P,
74  scalar& s,
75  scalar& t
76  );
77 
78 public:
79 
80  // Declare name of the class and its debug switch
81  ClassName("treeDataTriSurface");
82 
83 
84  // Constructors
85 
86  //- Construct from triSurface. Holds reference.
88 
89 
90  // Member Functions
91 
92  // Access
93 
94  const triSurface& surface() const
95  {
96  return surface_;
97  }
98 
99  label size() const
100  {
101  return surface_.size();
102  }
103 
104  //- Get representative point cloud for all shapes inside
105  // (one point per shape)
106  pointField points() const;
107 
108 
109  // Search
110 
111  //- Get type (inside, outside, mixed, unknown) of point
112  // with respect to a surface.
113  // Only makes sense for closed surfaces.
115  (
117  const point&
118  ) const;
119 
120  //- Does (bb of) shape at index overlap bb
121  bool overlaps
122  (
123  const label index,
124  const treeBoundBox& sampleBb
125  ) const;
126 
127  //- Calculates nearest (to sample) point in shape.
128  // Returns actual point and distance (squared)
129  void findNearest
130  (
131  const labelList& indices,
132  const point& sample,
133 
134  scalar& nearestDistSqr,
135  label& nearestIndex,
136  point& nearestPoint
137  ) const;
138 
139  //- Calculates nearest (to line) point in shape.
140  // Returns point and distance (squared)
141  void findNearest
142  (
143  const labelList& indices,
144  const linePointRef& ln,
145 
146  treeBoundBox& tightest,
147  label& minIndex,
148  point& linePoint,
149  point& nearestPoint
150  ) const;
151 
152  //- Calculate intersection of triangle with ray. Sets result
153  // accordingly
154  bool intersects
155  (
156  const label index,
157  const point& start,
158  const point& end,
159  point& result
160  ) const;
161 
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 
172 #endif
173 
174 // ************************************************************************* //
Foam::treeDataTriSurface::ClassName
ClassName("treeDataTriSurface")
Foam::treeDataTriSurface::getVolumeType
label getVolumeType(const indexedOctree< treeDataTriSurface > &, const point &) const
Get type (inside, outside, mixed, unknown) of point.
Definition: treeDataTriSurface.C:206
Foam::treeDataTriSurface::points
pointField points() const
Get representative point cloud for all shapes inside.
Definition: treeDataTriSurface.C:190
Foam::treeDataTriSurface
Encapsulates data for (indexedOc)tree searches on triSurface.
Definition: treeDataTriSurface.H:53
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
Foam::treeDataTriSurface::nearestCoords
static scalar nearestCoords(const point &base, const point &E0, const point &E1, const scalar a, const scalar b, const scalar c, const point &P, scalar &s, scalar &t)
fast triangle nearest point calculation. Returns point in E0, E1
Definition: treeDataTriSurface.C:43
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:57
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataTriSurface.H:47
Foam::treeDataTriSurface::surface
const triSurface & surface() const
Definition: treeDataTriSurface.H:93
Foam::treeDataTriSurface::surface_
const triSurface & surface_
Definition: treeDataTriSurface.H:57
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::treeDataTriSurface::findNearest
void findNearest(const labelList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
Definition: treeDataTriSurface.C:315
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::treeDataTriSurface
treeDataPrimitivePatch< triSurface > treeDataTriSurface
Definition: treeDataTriSurface.H:47
Foam::treeDataTriSurface::treeDataTriSurface
treeDataTriSurface(const triSurface &)
Construct from triSurface. Holds reference.
Definition: treeDataTriSurface.C:182
Foam::Vector< scalar >
Foam::List
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
Foam::treeDataTriSurface::overlaps
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataTriSurface.C:265
Foam::line
A line primitive.
Definition: line.H:56
Foam::treeDataTriSurface::intersects
bool intersects(const label index, const point &start, const point &end, point &result) const
Calculate intersection of triangle with ray. Sets result.
Definition: treeDataTriSurface.C:417
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::treeDataTriSurface::size
label size() const
Definition: treeDataTriSurface.H:98
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:854
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.