ENH: indexedOctree : renamed find to findInside, changed findIndices to return reference.

This commit is contained in:
mattijs
2010-07-21 11:18:50 +01:00
parent 4e1e1c9c73
commit c7bc9216d4
5 changed files with 26 additions and 9 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,6 +25,12 @@ License
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::labelList Foam::emptyLabelList = Foam::labelList(0);
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
Foam::labelList Foam::invert Foam::labelList Foam::invert

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,6 +43,16 @@ SourceFiles
namespace Foam namespace Foam
{ {
extern const labelList emptyLabelList;
//- Return reference to zero-sized list. Compare to List::null() which returns
// null pointer cast as list reference.
template<class Type>
static const List<Type>& emptyList()
{
return *reinterpret_cast<const List<Type>* >(&emptyLabelList);
}
//- Renumber the values (not the indices) of a list. //- Renumber the values (not the indices) of a list.
// Negative ListType elements are left as is. // Negative ListType elements are left as is.
template<class ListType> template<class ListType>

View File

@ -2497,7 +2497,7 @@ Foam::labelBits Foam::indexedOctree<Type>::findNode
template <class Type> template <class Type>
Foam::label Foam::indexedOctree<Type>::find(const point& sample) const Foam::label Foam::indexedOctree<Type>::findInside(const point& sample) const
{ {
labelBits index = findNode(0, sample); labelBits index = findNode(0, sample);
@ -2526,7 +2526,7 @@ Foam::label Foam::indexedOctree<Type>::find(const point& sample) const
template <class Type> template <class Type>
Foam::labelList Foam::indexedOctree<Type>::findIndices const Foam::labelList& Foam::indexedOctree<Type>::findIndices
( (
const point& sample const point& sample
) const ) const
@ -2544,7 +2544,7 @@ Foam::labelList Foam::indexedOctree<Type>::findIndices
} }
else else
{ {
return labelList(0); return emptyList<label>();
} }
} }

View File

@ -552,11 +552,12 @@ public:
// Use getNode and getOctant to extract info, or call findIndices. // Use getNode and getOctant to extract info, or call findIndices.
labelBits findNode(const label nodeI, const point&) const; labelBits findNode(const label nodeI, const point&) const;
//- Find shape containing point in tree //- Find shape containing point. Only implemented for certain
label find(const point&) const; // shapes.
label findInside(const point&) const;
//- Find the shape indices that occupy the result of findNode //- Find the shape indices that occupy the result of findNode
labelList findIndices(const point&) const; const labelList& findIndices(const point&) const;
//- Determine type (inside/outside/mixed) for point. unknown if //- Determine type (inside/outside/mixed) for point. unknown if
// cannot be determined (e.g. non-manifold surface) // cannot be determined (e.g. non-manifold surface)

View File

@ -745,7 +745,7 @@ Foam::label Foam::meshSearch::findCell
{ {
if (useTreeSearch) if (useTreeSearch)
{ {
return cellTree().find(location); return cellTree().findInside(location);
} }
else else
{ {