1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 octreeDataPointTreaLeaf.H (specialization for points only )
34 octreeDataPointTreeLeaf.C ( ,, )
36 \*---------------------------------------------------------------------------*/
41 #include "labelList.H"
44 #include "linePointRef.H"
45 #include "labelHashSet.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 template<class Type> class octree;
56 template<class Type> class treeLeaf;
58 // Forward declaration of friend functions and operators
60 template<class Type> Istream& operator>>(Istream&, treeLeaf<Type>&);
61 template<class Type> Ostream& operator<<(Ostream&, const treeLeaf<Type>&);
64 /*---------------------------------------------------------------------------*\
65 Class treeLeafName Declaration
66 \*---------------------------------------------------------------------------*/
68 TemplateName(treeLeaf);
71 /*---------------------------------------------------------------------------*\
72 Class treeLeaf Declaration
73 \*---------------------------------------------------------------------------*/
78 public treeElem<Type>,
83 // Keeps real size (at construction time indices_ might be untrimmed)
86 // Indices of 'things' whose bb overlaps leaf bb.
90 // Private Member Functions
92 static void space(Ostream&, const label);
94 //- Disallow default bitwise copy construct
95 treeLeaf(const treeLeaf&);
97 //- Disallow default bitwise assignment
98 void operator=(const treeLeaf&);
105 //- Construct with size
106 treeLeaf(const treeBoundBox& bb, const label size);
108 //- Construct from list
109 treeLeaf(const treeBoundBox& bb, const labelList& indices);
111 //- 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"
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 // ************************************************************************* //