mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add 'containsAny' and extra 'contains' methods to boundBox
This commit is contained in:
@ -163,6 +163,90 @@ Foam::tmp<Foam::pointField> Foam::boundBox::corners() const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::boundBox::contains(const UList<point>& points) const
|
||||
{
|
||||
if (points.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
if (!contains(points[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::boundBox::contains
|
||||
(
|
||||
const UList<point>& points,
|
||||
const labelUList& indices
|
||||
) const
|
||||
{
|
||||
if (points.empty() || indices.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
if (!contains(points[indices[i]]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::boundBox::containsAny(const UList<point>& points) const
|
||||
{
|
||||
if (points.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
if (contains(points[i]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::boundBox::containsAny
|
||||
(
|
||||
const UList<point>& points,
|
||||
const labelUList& indices
|
||||
) const
|
||||
{
|
||||
if (points.empty() || indices.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
if (contains(points[indices[i]]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
|
||||
|
||||
@ -174,6 +174,43 @@ public:
|
||||
//- Contains point? (inside only)
|
||||
inline bool containsInside(const point&) const;
|
||||
|
||||
//- Contains all of the points? (inside or on edge)
|
||||
bool contains(const UList<point>&) const;
|
||||
|
||||
//- Contains all of the points? (inside or on edge)
|
||||
bool contains
|
||||
(
|
||||
const UList<point>&,
|
||||
const labelUList& indices
|
||||
) const;
|
||||
|
||||
//- Contains all of the points? (inside or on edge)
|
||||
template<unsigned Size>
|
||||
bool contains
|
||||
(
|
||||
const UList<point>&,
|
||||
const FixedList<label, Size>& indices
|
||||
) const;
|
||||
|
||||
|
||||
//- Contains any of the points? (inside or on edge)
|
||||
bool containsAny(const UList<point>&) const;
|
||||
|
||||
//- Contains any of the points? (inside or on edge)
|
||||
bool containsAny
|
||||
(
|
||||
const UList<point>&,
|
||||
const labelUList& indices
|
||||
) const;
|
||||
|
||||
//- Contains any of the points? (inside or on edge)
|
||||
template<unsigned Size>
|
||||
bool containsAny
|
||||
(
|
||||
const UList<point>&,
|
||||
const FixedList<label, Size>& indices
|
||||
) const;
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
|
||||
@ -73,4 +73,57 @@ Foam::boundBox::boundBox
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
template<unsigned Size>
|
||||
bool Foam::boundBox::contains
|
||||
(
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices
|
||||
) const
|
||||
{
|
||||
// a FixedList is never empty
|
||||
if (points.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
if (!contains(points[indices[i]]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Size>
|
||||
bool Foam::boundBox::containsAny
|
||||
(
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices
|
||||
) const
|
||||
{
|
||||
// a FixedList is never empty
|
||||
if (points.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
if (contains(points[indices[i]]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user