All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
treeDataCell.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-2019 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::treeDataCell
26 
27 Description
28  Encapsulation of data needed to search in/for cells. Used to find the
29  cell containing a point (e.g. cell-cell mapping).
30 
31 SourceFiles
32  treeDataCell.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef treeDataCell_H
37 #define treeDataCell_H
38 
39 #include "polyMesh.H"
40 #include "treeBoundBoxList.H"
41 #include "volumeType.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of classes
49 template<class Type> class indexedOctree;
50 
51 /*---------------------------------------------------------------------------*\
52  Class treeDataCell Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class treeDataCell
56 {
57  // Private Data
58 
59  const polyMesh& mesh_;
60 
61  //- Subset of cells to work on
62  const labelList cellLabels_;
63 
64  //- Whether to precalculate and store cell bounding box
65  const bool cacheBb_;
66 
67  //- How to decide if point is inside cell
68  const polyMesh::cellDecomposition decompMode_;
69 
70  //- Cell bounding boxes (valid only if cacheBb_)
71  treeBoundBoxList bbs_;
72 
73 
74  // Private Member Functions
75 
76  //- Calculate cell bounding box
77  treeBoundBox calcCellBb(const label celli) const;
78 
79  //- Initialise all member data
80  void update();
81 
82 public:
83 
84 
85  class findNearestOp
86  {
87  const indexedOctree<treeDataCell>& tree_;
88 
89  public:
90 
92 
93  void operator()
94  (
95  const labelUList& indices,
96  const point& sample,
97 
98  scalar& nearestDistSqr,
99  label& minIndex,
100  point& nearestPoint
101  ) const;
102 
103  void operator()
104  (
105  const labelUList& indices,
106  const linePointRef& ln,
107 
108  treeBoundBox& tightest,
109  label& minIndex,
110  point& linePoint,
111  point& nearestPoint
112  ) const;
113  };
114 
116  class findIntersectOp
117  {
118  const indexedOctree<treeDataCell>& tree_;
119 
120  public:
121 
123 
124  bool operator()
125  (
126  const label index,
127  const point& start,
128  const point& end,
129  point& intersectionPoint
130  ) const;
131  };
132 
133 
134  // Declare name of the class and its debug switch
135  ClassName("treeDataCell");
136 
137 
138  // Constructors
139 
140  //- Construct from mesh and subset of cells.
142  (
143  const bool cacheBb,
144  const polyMesh&,
145  const labelUList&,
147  );
148 
149  //- Move construct from mesh and subset of cells, transferring contents
151  (
152  const bool cacheBb,
153  const polyMesh&,
154  labelList&&,
155  const polyMesh::cellDecomposition decompMode
156  );
157 
158  //- Construct from mesh. Uses all cells in mesh.
160  (
161  const bool cacheBb,
162  const polyMesh&,
163  const polyMesh::cellDecomposition decompMode
164  );
165 
166 
167  // Member Functions
168 
169  // Access
171  inline const labelList& cellLabels() const
172  {
173  return cellLabels_;
174  }
176  inline const polyMesh& mesh() const
177  {
178  return mesh_;
179  }
182  {
183  return decompMode_;
184  }
186  inline label size() const
187  {
188  return cellLabels_.size();
189  }
190 
191  //- Get representative point cloud for all shapes inside
192  // (one point per shape)
193  pointField shapePoints() const;
194 
195 
196  // Search
197 
198  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
199  // Only makes sense for closed surfaces.
201  (
203  const point&
204  ) const
205  {
207  return volumeType::unknown;
208  }
209 
210  //- Does (bb of) shape at index overlap bb
211  bool overlaps
212  (
213  const label index,
214  const treeBoundBox& sampleBb
215  ) const;
216 
217  //- Does shape at index contain sample
218  bool contains
219  (
220  const label index,
221  const point& sample
222  ) const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 
233 #endif
234 
235 // ************************************************************************* //
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataCell.C:170
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
A line primitive.
Definition: line.H:56
polyMesh::cellDecomposition decompMode() const
Definition: treeDataCell.H:180
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:163
cellDecomposition
Enumeration defining the decomposition of the cell for.
Definition: polyMesh.H:98
const polyMesh & mesh() const
Definition: treeDataCell.H:175
volumeType getVolumeType(const indexedOctree< treeDataCell > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataCell.H:200
treeDataCell(const bool cacheBb, const polyMesh &, const labelUList &, const polyMesh::cellDecomposition decompMode)
Construct from mesh and subset of cells.
Definition: treeDataCell.C:87
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:912
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e...
Definition: treeDataCell.H:54
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataCell.C:156
findNearestOp(const indexedOctree< treeDataCell > &tree)
Definition: treeDataCell.C:137
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
ClassName("treeDataCell")
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const labelList & cellLabels() const
Definition: treeDataCell.H:170
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
label size() const
Definition: treeDataCell.H:185
bool contains(const label index, const point &sample) const
Does shape at index contain sample.
Definition: treeDataCell.C:187
Namespace for OpenFOAM.