1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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)
34 octreeDataPointTreeLeaf.C
35 octreeDataTriSurfaceTreeLeaf.H (specialization for triSurface)
36 octreeDataTriSurfaceTreeLeaf.C
38 \*---------------------------------------------------------------------------*/
43 #include "labelList.H"
46 #include "linePointRef.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 template<class Type> class octree;
58 template<class Type> class treeLeaf;
60 // Forward declaration of friend functions and operators
62 template<class Type> Istream& operator>>(Istream&, treeLeaf<Type>&);
63 template<class Type> Ostream& operator<<(Ostream&, const treeLeaf<Type>&);
66 /*---------------------------------------------------------------------------*\
67 Class treeLeafName Declaration
68 \*---------------------------------------------------------------------------*/
70 TemplateName(treeLeaf);
73 /*---------------------------------------------------------------------------*\
74 Class treeLeaf Declaration
75 \*---------------------------------------------------------------------------*/
80 public treeElem<Type>,
85 // Keeps real size (at construction time indices_ might be untrimmed)
88 // Indices of 'things' whose bb overlaps leaf bb.
92 // Private Member Functions
94 static void space(Ostream&, const label);
96 //- Disallow default bitwise copy construct
97 treeLeaf(const treeLeaf&);
99 //- Disallow default bitwise assignment
100 void operator=(const treeLeaf&);
107 //- Construct with size
108 treeLeaf(const treeBoundBox& bb, const label size);
110 //- Construct from list
111 treeLeaf(const treeBoundBox& bb, const labelList& indices);
113 //- Construct from Istream
131 const labelList& indices() const
138 void insert(const label index)
140 if (size_ >= indices_.size())
144 "treeLeaf<Type>::insert(index)"
147 << " size_ :" << size_
148 << " size():" << indices_.size()
149 << abort(FatalError);
151 indices_[size_++] = index;
160 "treeLeaf<Type>::trim()"
162 << "Trying to trim empty leaf: " << endl
163 << " size_ :" << size_
164 << " size():" << indices_.size()
165 << abort(FatalError);
167 indices_.setSize(size_);
170 //- Take indices at refineLevel and distribute them to lower levels
171 treeLeaf<Type>* redistribute
187 //- Get type of sample
191 const octree<Type>& top,
196 //- Find index of shape containing sample
203 //- Find tightest fitting bounding box in leaf
208 treeBoundBox& tightest
211 //- Find nearest point.
216 treeBoundBox& tightest,
221 //- Find nearest shape to line
222 // Returns true if found nearer shape and updates nearest and
227 const linePointRef& ln,
228 treeBoundBox& tightest,
229 label& tightestI, // index of nearest shape
230 point& linePoint, // nearest point on line
231 point& shapePoint // nearest point on shape
234 //- Find shapes not outside box. Return true if anything found.
239 labelHashSet& elements
244 //- Debug: print a leaf
245 void printLeaf(Ostream&, const label) const;
247 //- Debug: Write bb in OBJ format
256 label countLeaf(Ostream&, const label) const;
259 // IOstream Operators
261 friend Istream& operator>> <Type>(Istream&, treeLeaf<Type>&);
262 friend Ostream& operator<< <Type>(Ostream&, const treeLeaf<Type>&);
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 } // End namespace Foam
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 # include "treeLeaf.C"
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 #include "octreeDataPointTreeLeaf.H"
279 #include "octreeDataTriSurfaceTreeLeaf.H"
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 // ************************************************************************* //