1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
32 octreeDataPointTreaLeaf.H (specialization for points)
33 octreeDataPointTreeLeaf.C
34 octreeDataTriSurfaceTreeLeaf.H (specialization for triSurface)
35 octreeDataTriSurfaceTreeLeaf.C
37 \*---------------------------------------------------------------------------*/
42 #include "labelList.H"
45 #include "linePointRef.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 template<class Type> class octree;
57 template<class Type> class treeLeaf;
59 // Forward declaration of friend functions and operators
61 template<class Type> Istream& operator>>(Istream&, treeLeaf<Type>&);
62 template<class Type> Ostream& operator<<(Ostream&, const treeLeaf<Type>&);
65 /*---------------------------------------------------------------------------*\
66 Class treeLeafName Declaration
67 \*---------------------------------------------------------------------------*/
69 TemplateName(treeLeaf);
72 /*---------------------------------------------------------------------------*\
73 Class treeLeaf Declaration
74 \*---------------------------------------------------------------------------*/
79 public treeElem<Type>,
84 // Keeps real size (at construction time indices_ might be untrimmed)
87 // Indices of 'things' whose bb overlaps leaf bb.
91 // Private Member Functions
93 static void space(Ostream&, const label);
95 //- Disallow default bitwise copy construct
96 treeLeaf(const treeLeaf&);
98 //- Disallow default bitwise assignment
99 void operator=(const treeLeaf&);
106 //- Construct with size
107 treeLeaf(const treeBoundBox& bb, const label size);
109 //- Construct from list
110 treeLeaf(const treeBoundBox& bb, const labelList& indices);
112 //- Construct from Istream
129 const labelList& indices() const
136 void insert(const label index)
138 if (size_ >= indices_.size())
142 "treeLeaf<Type>::insert(index)"
145 << " size_ :" << size_
146 << " size():" << indices_.size()
147 << abort(FatalError);
149 indices_[size_++] = index;
158 "treeLeaf<Type>::trim()"
160 << "Trying to trim empty leaf: " << endl
161 << " size_ :" << size_
162 << " size():" << indices_.size()
163 << abort(FatalError);
165 indices_.setSize(size_);
168 //- Take indices at refineLevel and distribute them to lower levels
169 treeLeaf<Type>* redistribute
185 //- Get type of sample
189 const octree<Type>& top,
194 //- Find index of shape containing sample
201 //- Find tightest fitting bounding box in leaf
206 treeBoundBox& tightest
209 //- Find nearest point.
214 treeBoundBox& tightest,
219 //- Find nearest shape to line
220 // Returns true if found nearer shape and updates nearest and
225 const linePointRef& ln,
226 treeBoundBox& tightest,
227 label& tightestI, // index of nearest shape
228 point& linePoint, // nearest point on line
229 point& shapePoint // nearest point on shape
232 //- Find shapes not outside box. Return true if anything found.
237 labelHashSet& elements
242 //- Debug: print a leaf
243 void printLeaf(Ostream&, const label) const;
245 //- Debug: Write bb in OBJ format
254 label countLeaf(Ostream&, const label) const;
257 // IOstream Operators
259 friend Istream& operator>> <Type>(Istream&, treeLeaf<Type>&);
260 friend Ostream& operator<< <Type>(Ostream&, const treeLeaf<Type>&);
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 } // End namespace Foam
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 # include "treeLeaf.C"
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 #include "octreeDataPointTreeLeaf.H"
277 #include "octreeDataTriSurfaceTreeLeaf.H"
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 // ************************************************************************* //