mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support construction of pointIndexHit from pointHit
STYLE: combine templated/non-templated headers (reduced clutter) STYLE: use hitPoint(const point&) combined setter - same as setHit() + setPoint(const point&) ENH: expose and use labelOctBits::pack method for addressing
This commit is contained in:
@ -92,9 +92,7 @@ bool Foam::controlMeshRefinement::detectEdge
|
|||||||
magSqr(a - b) < tolSqr
|
magSqr(a - b) < tolSqr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
pointFound.setPoint(midPoint);
|
pointFound.hitPoint(midPoint);
|
||||||
pointFound.setHit();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -365,7 +365,7 @@ Foam::volumeType Foam::dynamicIndexedOctree<Type>::calcVolumeType
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store octant type
|
// Store octant type
|
||||||
nodeTypes_.set((nodeI<<3)+octant, subType);
|
nodeTypes_.set(labelBits::pack(nodeI, octant), subType);
|
||||||
|
|
||||||
// Combine sub node types into type for treeNode. Result is 'mixed' if
|
// Combine sub node types into type for treeNode. Result is 'mixed' if
|
||||||
// types differ among subnodes.
|
// types differ among subnodes.
|
||||||
@ -393,7 +393,11 @@ Foam::volumeType Foam::dynamicIndexedOctree<Type>::getVolumeType
|
|||||||
|
|
||||||
direction octant = nod.bb_.subOctant(sample);
|
direction octant = nod.bb_.subOctant(sample);
|
||||||
|
|
||||||
volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant));
|
volumeType octantType =
|
||||||
|
volumeType::type
|
||||||
|
(
|
||||||
|
nodeTypes_.get(labelBits::pack(nodeI, octant))
|
||||||
|
);
|
||||||
|
|
||||||
if (octantType == volumeType::INSIDE)
|
if (octantType == volumeType::INSIDE)
|
||||||
{
|
{
|
||||||
@ -1418,9 +1422,8 @@ void Foam::dynamicIndexedOctree<Type>::traverseNode
|
|||||||
{
|
{
|
||||||
// Hit so pt is nearer than nearestPoint.
|
// Hit so pt is nearer than nearestPoint.
|
||||||
// Update hit info
|
// Update hit info
|
||||||
hitInfo.setHit();
|
hitInfo.hitPoint(pt);
|
||||||
hitInfo.setIndex(shapeI);
|
hitInfo.setIndex(shapeI);
|
||||||
hitInfo.setPoint(pt);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1456,9 +1459,8 @@ void Foam::dynamicIndexedOctree<Type>::traverseNode
|
|||||||
// Hit so pt is nearer than nearestPoint.
|
// Hit so pt is nearer than nearestPoint.
|
||||||
nearestPoint = pt;
|
nearestPoint = pt;
|
||||||
// Update hit info
|
// Update hit info
|
||||||
hitInfo.setHit();
|
hitInfo.hitPoint(pt);
|
||||||
hitInfo.setIndex(shapeI);
|
hitInfo.setIndex(shapeI);
|
||||||
hitInfo.setPoint(pt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -383,7 +383,7 @@ Foam::volumeType Foam::indexedOctree<Type>::calcVolumeType
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store octant type
|
// Store octant type
|
||||||
nodeTypes_.set((nodeI<<3)+octant, subType);
|
nodeTypes_.set(labelBits::pack(nodeI, octant), subType);
|
||||||
|
|
||||||
// Combine sub node types into type for treeNode. Result is 'mixed' if
|
// Combine sub node types into type for treeNode. Result is 'mixed' if
|
||||||
// types differ among subnodes.
|
// types differ among subnodes.
|
||||||
@ -411,7 +411,10 @@ Foam::volumeType Foam::indexedOctree<Type>::getVolumeType
|
|||||||
|
|
||||||
direction octant = nod.bb_.subOctant(sample);
|
direction octant = nod.bb_.subOctant(sample);
|
||||||
|
|
||||||
volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant));
|
volumeType octantType = volumeType::type
|
||||||
|
(
|
||||||
|
nodeTypes_.get(labelBits::pack(nodeI, octant))
|
||||||
|
);
|
||||||
|
|
||||||
if (octantType == volumeType::INSIDE)
|
if (octantType == volumeType::INSIDE)
|
||||||
{
|
{
|
||||||
@ -1448,9 +1451,8 @@ void Foam::indexedOctree<Type>::traverseNode
|
|||||||
{
|
{
|
||||||
// Hit so pt is nearer than nearestPoint.
|
// Hit so pt is nearer than nearestPoint.
|
||||||
// Update hit info
|
// Update hit info
|
||||||
hitInfo.setHit();
|
hitInfo.hitPoint(pt);
|
||||||
hitInfo.setIndex(shapeI);
|
hitInfo.setIndex(shapeI);
|
||||||
hitInfo.setPoint(pt);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1480,9 +1482,8 @@ void Foam::indexedOctree<Type>::traverseNode
|
|||||||
// Hit so pt is nearer than nearestPoint.
|
// Hit so pt is nearer than nearestPoint.
|
||||||
nearestPoint = pt;
|
nearestPoint = pt;
|
||||||
// Update hit info
|
// Update hit info
|
||||||
hitInfo.setHit();
|
hitInfo.hitPoint(pt);
|
||||||
hitInfo.setIndex(shapeI);
|
hitInfo.setIndex(shapeI);
|
||||||
hitInfo.setPoint(pt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,17 +28,15 @@ Class
|
|||||||
Foam::labelBits
|
Foam::labelBits
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A 29bits label and 3bits direction packed into single label
|
A 29bits (or 61bits) integer label with 3bits direction
|
||||||
|
(eg, octant) packed into single label
|
||||||
SourceFiles
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef labelBits_H
|
#ifndef Foam_labelBits_H
|
||||||
#define labelBits_H
|
#define Foam_labelBits_H
|
||||||
|
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
//#include "uLabel.H"
|
|
||||||
#include "direction.H"
|
#include "direction.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
|
|
||||||
@ -46,20 +45,33 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class labelBits;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class labelBits Declaration
|
Class labelBits Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class labelBits
|
class labelBits
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
|
//- Integer value and (octant) direction
|
||||||
label data_;
|
label data_;
|
||||||
|
|
||||||
inline static label pack(const label val, const direction bits)
|
public:
|
||||||
|
|
||||||
|
// Static Functions
|
||||||
|
|
||||||
|
#ifdef FULLDEBUG
|
||||||
|
|
||||||
|
//- Pack integer value and bits (octant) into a label
|
||||||
|
inline static label pack
|
||||||
|
(
|
||||||
|
const label val,
|
||||||
|
const direction bits
|
||||||
|
)
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
|
||||||
if (bits > 7 || (((val<<3)>>3) != val))
|
if (bits > 7 || (((val<<3)>>3) != val))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -68,51 +80,64 @@ class labelBits
|
|||||||
<< label(8*sizeof(label)-3) << " bit representation"
|
<< label(8*sizeof(label)-3) << " bit representation"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return (val<<3) | bits;
|
return (val<<3) | bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
#else
|
||||||
|
|
||||||
|
//- Pack integer value and bits (octant) into a label
|
||||||
|
static constexpr label pack
|
||||||
|
(
|
||||||
|
const label val,
|
||||||
|
const direction bits
|
||||||
|
) noexcept
|
||||||
|
{
|
||||||
|
return (val<<3) | bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Default construct as zero initialized
|
||||||
inline labelBits()
|
constexpr labelBits() noexcept
|
||||||
|
:
|
||||||
|
data_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
inline labelBits(const label val, const direction bits)
|
labelBits(const label val, const direction bits)
|
||||||
:
|
:
|
||||||
data_(pack(val, bits))
|
data_(pack(val, bits))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Read construct from Istream
|
||||||
inline labelBits(Istream& is)
|
explicit labelBits(Istream& is)
|
||||||
{
|
{
|
||||||
is >> data_;
|
is >> data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
inline label val() const
|
//- The raw data value
|
||||||
{
|
label data() const noexcept { return data_; }
|
||||||
return data_ >> 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline direction bits() const
|
//- Return the integer value
|
||||||
{
|
label val() const noexcept { return (data_ >> 3); }
|
||||||
return data_ & 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void setVal(const label val)
|
//- Return the octant direction
|
||||||
|
direction bits() const noexcept { return (data_ & 7); }
|
||||||
|
|
||||||
|
//- Set the integer value
|
||||||
|
void setVal(const label val)
|
||||||
{
|
{
|
||||||
data_ = pack(val, bits());
|
data_ = pack(val, bits());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setBits(const direction bits)
|
//- Set the octant direction
|
||||||
|
void setBits(const direction bits)
|
||||||
{
|
{
|
||||||
data_ = pack(val(), bits);
|
data_ = pack(val(), bits);
|
||||||
}
|
}
|
||||||
@ -120,26 +145,31 @@ public:
|
|||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
inline friend bool operator==(const labelBits& a, const labelBits& b)
|
inline friend
|
||||||
|
bool operator==(const labelBits& a, const labelBits& b)
|
||||||
{
|
{
|
||||||
return a.data_ == b.data_;
|
return a.data_ == b.data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend bool operator!=(const labelBits& a, const labelBits& b)
|
inline friend
|
||||||
|
bool operator!=(const labelBits& a, const labelBits& b)
|
||||||
{
|
{
|
||||||
return !(a == b);
|
return !(a == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
|
|
||||||
inline friend Istream& operator>>(Istream& is, labelBits& lb)
|
inline friend
|
||||||
|
Istream& operator>>(Istream& is, labelBits& rhs)
|
||||||
{
|
{
|
||||||
return is >> lb.data_;
|
return is >> rhs.data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend Ostream& operator<<(Ostream& os, const labelBits& lb)
|
inline friend
|
||||||
|
Ostream& operator<<(Ostream& os, const labelBits& rhs)
|
||||||
{
|
{
|
||||||
return os << lb.data_;
|
return os << rhs.data_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,7 @@ public:
|
|||||||
//- Construct from integer
|
//- Construct from integer
|
||||||
explicit volumeType(const int t)
|
explicit volumeType(const int t)
|
||||||
:
|
:
|
||||||
t_(static_cast<volumeType::type>(t))
|
t_(static_cast<volumeType::type>(t & 0x3))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
Copyright (C) 2021 OpenCFD Ltd.
|
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -40,10 +40,11 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef LabelledItem_H
|
#ifndef Foam_LabelledItem_H
|
||||||
#define LabelledItem_H
|
#define Foam_LabelledItem_H
|
||||||
|
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -161,9 +162,40 @@ public:
|
|||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::Istream& Foam::operator>>
|
||||||
|
(
|
||||||
|
Istream& is,
|
||||||
|
LabelledItem<T>& item
|
||||||
|
)
|
||||||
|
{
|
||||||
|
is.readBegin("LabelledItem");
|
||||||
|
is >> static_cast<T&>(item) >> item.index();
|
||||||
|
is.readEnd("LabelledItem");
|
||||||
|
|
||||||
|
is.check(FUNCTION_NAME);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const LabelledItem<T>& item
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Output like Tuple2
|
||||||
|
os << token::BEGIN_LIST
|
||||||
|
<< static_cast<const T&>(item) << token::SPACE
|
||||||
|
<< item.index()
|
||||||
|
<< token::END_LIST;
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
#include "LabelledItemI.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -1,66 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | www.openfoam.com
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
|
||||||
Copyright (C) 2021 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "IOstreams.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline Foam::Istream& Foam::operator>>
|
|
||||||
(
|
|
||||||
Istream& is,
|
|
||||||
LabelledItem<T>& item
|
|
||||||
)
|
|
||||||
{
|
|
||||||
is.readBegin("LabelledItem");
|
|
||||||
is >> static_cast<T&>(item) >> item.index();
|
|
||||||
is.readEnd("LabelledItem");
|
|
||||||
|
|
||||||
is.check(FUNCTION_NAME);
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline Foam::Ostream& Foam::operator<<
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const LabelledItem<T>& item
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Output like Tuple2
|
|
||||||
os << token::BEGIN_LIST
|
|
||||||
<< static_cast<const T&>(item) << token::SPACE
|
|
||||||
<< item.index()
|
|
||||||
<< token::END_LIST;
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -94,8 +94,7 @@ Foam::pointHit Foam::face::ray
|
|||||||
if (Foam::mag(curHit.distance()) < Foam::mag(nearestHitDist))
|
if (Foam::mag(curHit.distance()) < Foam::mag(nearestHitDist))
|
||||||
{
|
{
|
||||||
nearestHitDist = curHit.distance();
|
nearestHitDist = curHit.distance();
|
||||||
nearest.setHit();
|
nearest.hitPoint(curHit.hitPoint());
|
||||||
nearest.setPoint(curHit.hitPoint());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!nearest.hit())
|
else if (!nearest.hit())
|
||||||
@ -181,8 +180,7 @@ Foam::pointHit Foam::face::intersection
|
|||||||
if (Foam::mag(curHit.distance()) < Foam::mag(nearestHitDist))
|
if (Foam::mag(curHit.distance()) < Foam::mag(nearestHitDist))
|
||||||
{
|
{
|
||||||
nearestHitDist = curHit.distance();
|
nearestHitDist = curHit.distance();
|
||||||
nearest.setHit();
|
nearest.hitPoint(curHit.hitPoint());
|
||||||
nearest.setPoint(curHit.hitPoint());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,8 +293,7 @@ Foam::pointHit Foam::face::nearestPointClassify
|
|||||||
|
|
||||||
if (curHit.hit())
|
if (curHit.hit())
|
||||||
{
|
{
|
||||||
nearest.setHit();
|
nearest.hitPoint(curHit.hitPoint());
|
||||||
nearest.setPoint(curHit.hitPoint());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -31,7 +31,7 @@ Description
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "boolList.H"
|
#include "boolList.H"
|
||||||
#include "PointHit.H"
|
#include "pointHit.H"
|
||||||
#include "objectHit.H"
|
#include "objectHit.H"
|
||||||
#include "bandCompression.H"
|
#include "bandCompression.H"
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ SourceFiles
|
|||||||
#include "point.H"
|
#include "point.H"
|
||||||
#include "point2D.H"
|
#include "point2D.H"
|
||||||
#include "vector.H"
|
#include "vector.H"
|
||||||
#include "PointHit.H"
|
#include "pointHit.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "UList.H"
|
#include "UList.H"
|
||||||
#include "Pair.H"
|
#include "Pair.H"
|
||||||
|
|||||||
@ -1,241 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | www.openfoam.com
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::PointHit
|
|
||||||
|
|
||||||
Description
|
|
||||||
Describes the interaction of a face and a point.
|
|
||||||
It carries the info of a successful hit and (if successful)
|
|
||||||
the interaction point.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef PointHit_H
|
|
||||||
#define PointHit_H
|
|
||||||
|
|
||||||
#include "bool.H"
|
|
||||||
#include "point.H"
|
|
||||||
#include "token.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class PointHit Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class PointType>
|
|
||||||
class PointHit
|
|
||||||
{
|
|
||||||
// Private Data
|
|
||||||
|
|
||||||
//- Point of hit; for miss holds best estimate outside the object
|
|
||||||
PointType point_;
|
|
||||||
|
|
||||||
//- Distance to hit point
|
|
||||||
scalar distance_;
|
|
||||||
|
|
||||||
//- Hit success
|
|
||||||
bool hit_;
|
|
||||||
|
|
||||||
//- Eligible miss
|
|
||||||
bool eligibleMiss_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Public Typedefs
|
|
||||||
|
|
||||||
//- The point type
|
|
||||||
typedef PointType point_type;
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Default construct. A zero point with a large distance,
|
|
||||||
//- no hit, no eligible misses
|
|
||||||
PointHit()
|
|
||||||
:
|
|
||||||
point_(Zero),
|
|
||||||
distance_(GREAT),
|
|
||||||
hit_(false),
|
|
||||||
eligibleMiss_(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct from point with a large distance,
|
|
||||||
//- no hit, no eligible misses
|
|
||||||
explicit PointHit(const point_type& p)
|
|
||||||
:
|
|
||||||
point_(p),
|
|
||||||
distance_(GREAT),
|
|
||||||
hit_(false),
|
|
||||||
eligibleMiss_(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct from components
|
|
||||||
PointHit
|
|
||||||
(
|
|
||||||
const bool hit,
|
|
||||||
const point_type& p,
|
|
||||||
const scalar dist,
|
|
||||||
const bool eligibleMiss = false
|
|
||||||
)
|
|
||||||
:
|
|
||||||
point_(p),
|
|
||||||
distance_(dist),
|
|
||||||
hit_(hit),
|
|
||||||
eligibleMiss_(eligibleMiss)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Is there a hit
|
|
||||||
bool hit() const noexcept
|
|
||||||
{
|
|
||||||
return hit_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Is this an eligible miss
|
|
||||||
bool eligibleMiss() const noexcept
|
|
||||||
{
|
|
||||||
return eligibleMiss_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the point, no checks
|
|
||||||
const point_type& point() const noexcept
|
|
||||||
{
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return distance to hit
|
|
||||||
scalar distance() const noexcept
|
|
||||||
{
|
|
||||||
return distance_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the hit point. Fatal if not hit.
|
|
||||||
const point_type& hitPoint() const
|
|
||||||
{
|
|
||||||
if (!hit_)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Requested a hit point, but it was not hit"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the miss point. Fatal if hit.
|
|
||||||
const point_type& missPoint() const
|
|
||||||
{
|
|
||||||
if (hit_)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Requested a miss point, but it was hit"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- The point, no checks
|
|
||||||
// \deprecated(2020-10) use point()
|
|
||||||
const point_type& rawPoint() const noexcept
|
|
||||||
{
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
//- Set the hit status \em on
|
|
||||||
void setHit() noexcept
|
|
||||||
{
|
|
||||||
hit_ = true;
|
|
||||||
eligibleMiss_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set the hit status \em off and set the eligible miss status
|
|
||||||
void setMiss(const bool eligible) noexcept
|
|
||||||
{
|
|
||||||
hit_ = false;
|
|
||||||
eligibleMiss_ = eligible;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set the point
|
|
||||||
void setPoint(const point_type& p)
|
|
||||||
{
|
|
||||||
point_ = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set the distance
|
|
||||||
void setDistance(const scalar d) noexcept
|
|
||||||
{
|
|
||||||
distance_ = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
|
||||||
|
|
||||||
//- Distance comparision operator, for sorting
|
|
||||||
template<class AnyPointType>
|
|
||||||
bool operator<(const PointHit<AnyPointType>& rhs) const noexcept
|
|
||||||
{
|
|
||||||
return distance_ < rhs.distance_;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operator
|
|
||||||
|
|
||||||
template<class PointType>
|
|
||||||
inline Ostream& operator<<(Ostream& os, const PointHit<PointType>& pHit)
|
|
||||||
{
|
|
||||||
os << pHit.hit() << token::SPACE
|
|
||||||
<< pHit.point() << token::SPACE
|
|
||||||
<< pHit.distance() << token::SPACE
|
|
||||||
<< pHit.eligibleMiss();
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,312 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | www.openfoam.com
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::PointIndexHit
|
|
||||||
|
|
||||||
Description
|
|
||||||
This class describes the interaction of (usually) a face and a point.
|
|
||||||
It carries the info of a successful hit and (if successful),
|
|
||||||
returns the interaction point.
|
|
||||||
|
|
||||||
like pointHit but carries face (or cell, edge etc.) index
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef PointIndexHit_H
|
|
||||||
#define PointIndexHit_H
|
|
||||||
|
|
||||||
#include "bool.H"
|
|
||||||
#include "point.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward Declarations
|
|
||||||
template<class PointType> class PointIndexHit;
|
|
||||||
|
|
||||||
template<class PointType>
|
|
||||||
inline Istream& operator>>(Istream& is, PointIndexHit<PointType>& pHit);
|
|
||||||
|
|
||||||
template<class PointType>
|
|
||||||
inline Ostream& operator<<(Ostream& os, const PointIndexHit<PointType>& pHit);
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class PointIndexHit Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class PointType>
|
|
||||||
class PointIndexHit
|
|
||||||
{
|
|
||||||
// Private Data
|
|
||||||
|
|
||||||
//- Hit success
|
|
||||||
bool hit_;
|
|
||||||
|
|
||||||
//- Point of hit; invalid for misses
|
|
||||||
PointType point_;
|
|
||||||
|
|
||||||
//- Label of face hit
|
|
||||||
label index_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Public Typedefs
|
|
||||||
|
|
||||||
//- The point type
|
|
||||||
typedef PointType point_type;
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Default construct. A zero point, with no hit and index = -1
|
|
||||||
PointIndexHit()
|
|
||||||
:
|
|
||||||
hit_(false),
|
|
||||||
point_(Zero),
|
|
||||||
index_(-1)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct from a point, with no hit and index = -1
|
|
||||||
explicit PointIndexHit(const point_type& p)
|
|
||||||
:
|
|
||||||
hit_(false),
|
|
||||||
point_(p),
|
|
||||||
index_(-1)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct from components
|
|
||||||
PointIndexHit
|
|
||||||
(
|
|
||||||
const bool success,
|
|
||||||
const point_type& p,
|
|
||||||
const label index
|
|
||||||
)
|
|
||||||
:
|
|
||||||
hit_(success),
|
|
||||||
point_(p),
|
|
||||||
index_(index)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct from Istream
|
|
||||||
explicit PointIndexHit(Istream& is)
|
|
||||||
{
|
|
||||||
is >> *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Is there a hit?
|
|
||||||
bool hit() const noexcept
|
|
||||||
{
|
|
||||||
return hit_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the hit index
|
|
||||||
label index() const noexcept
|
|
||||||
{
|
|
||||||
return index_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return point, no checks
|
|
||||||
const point_type& point() const noexcept
|
|
||||||
{
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Access the point, no checks
|
|
||||||
point_type& point() noexcept
|
|
||||||
{
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return hit point. Fatal if not hit.
|
|
||||||
const point_type& hitPoint() const
|
|
||||||
{
|
|
||||||
if (!hit_)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Requested a hit point, but it was not hit"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return miss point. Fatal if hit.
|
|
||||||
const point_type& missPoint() const
|
|
||||||
{
|
|
||||||
if (hit_)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Requested a miss point, but it was hit"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- The point, no checks. Same as point()
|
|
||||||
const point_type& rawPoint() const noexcept
|
|
||||||
{
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- The point, no checks. Same as point()
|
|
||||||
point_type& rawPoint() noexcept
|
|
||||||
{
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
//- Set the hit status \em on
|
|
||||||
void setHit() noexcept
|
|
||||||
{
|
|
||||||
hit_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set the hit status \em off
|
|
||||||
void setMiss() noexcept
|
|
||||||
{
|
|
||||||
hit_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set the point
|
|
||||||
void setPoint(const point_type& p)
|
|
||||||
{
|
|
||||||
point_ = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set the index
|
|
||||||
void setIndex(const label index) noexcept
|
|
||||||
{
|
|
||||||
index_ = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set the point as \em hit and the hit-index
|
|
||||||
void hitPoint(const point_type& p, const label index)
|
|
||||||
{
|
|
||||||
point_ = p;
|
|
||||||
hit_ = true;
|
|
||||||
index_ = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Write
|
|
||||||
|
|
||||||
void write(Ostream& os)
|
|
||||||
{
|
|
||||||
os << (hit_ ? "hit:" : "miss:")
|
|
||||||
<< point_ << " index:" << index_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
|
||||||
|
|
||||||
//- Test for equality of all components
|
|
||||||
bool operator==(const PointIndexHit& rhs) const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
hit_ == rhs.hit_
|
|
||||||
&& index_ == rhs.index_
|
|
||||||
&& point_ == rhs.point_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Test for inequality of components
|
|
||||||
bool operator!=(const PointIndexHit& rhs) const
|
|
||||||
{
|
|
||||||
return !(*this == rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// IO Operators
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const PointIndexHit& pHit)
|
|
||||||
{
|
|
||||||
if (os.format() == IOstreamOption::ASCII)
|
|
||||||
{
|
|
||||||
os << pHit.hit_ << token::SPACE
|
|
||||||
<< pHit.point_ << token::SPACE
|
|
||||||
<< pHit.index_;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os.write
|
|
||||||
(
|
|
||||||
reinterpret_cast<const char*>(&pHit),
|
|
||||||
sizeof(PointIndexHit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
os.check(FUNCTION_NAME);
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, PointIndexHit& pHit)
|
|
||||||
{
|
|
||||||
if (is.format() == IOstreamOption::ASCII)
|
|
||||||
{
|
|
||||||
is >> pHit.hit_ >> pHit.point_ >> pHit.index_;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO (2019-08-06):
|
|
||||||
// cannot properly handle mixed-precision reading
|
|
||||||
// owing to bool and Point type.
|
|
||||||
|
|
||||||
is.read
|
|
||||||
(
|
|
||||||
reinterpret_cast<char*>(&pHit),
|
|
||||||
sizeof(PointIndexHit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
is.check(FUNCTION_NAME);
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
// Compatibility include.
|
||||||
|
// PointHit template combined into pointHit.H (OCT-2022)
|
||||||
|
|
||||||
|
#ifndef FoamCompat_PointHit_H
|
||||||
|
#define FoamCompat_PointHit_H
|
||||||
|
|
||||||
|
#include "pointHit.H"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
// Compatibility include.
|
||||||
|
// PointIndexHit template combined into pointIndexHit.H (OCT-2022)
|
||||||
|
|
||||||
|
#ifndef FoamCompat_PointIndexHit_H
|
||||||
|
#define FoamCompat_PointIndexHit_H
|
||||||
|
|
||||||
|
#include "pointIndexHit.H"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -33,8 +33,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef objectHit_H
|
#ifndef Foam_objectHit_H
|
||||||
#define objectHit_H
|
#define Foam_objectHit_H
|
||||||
|
|
||||||
#include "bool.H"
|
#include "bool.H"
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
@ -44,6 +44,10 @@ Description
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class objectHit;
|
||||||
|
inline Ostream& operator<<(Ostream& os, const objectHit& obj);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class objectHit Declaration
|
Class objectHit Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -63,7 +67,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Default construct. Nothing hit and object = -1
|
//- Default construct. Nothing hit and object index = -1
|
||||||
constexpr objectHit() noexcept
|
constexpr objectHit() noexcept
|
||||||
:
|
:
|
||||||
hit_(false),
|
hit_(false),
|
||||||
@ -110,7 +114,7 @@ public:
|
|||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Reset to default construct state
|
//- Reset to default construct state (false, -1)
|
||||||
void reset() noexcept
|
void reset() noexcept
|
||||||
{
|
{
|
||||||
hit_ = false;
|
hit_ = false;
|
||||||
@ -129,21 +133,27 @@ public:
|
|||||||
hit_ = false;
|
hit_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Set the hit object index
|
||||||
|
void setIndex(const label index) noexcept
|
||||||
|
{
|
||||||
|
index_ = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operator
|
// Ostream Operator
|
||||||
|
|
||||||
inline friend Ostream& operator<<(Ostream& os, const objectHit& obj)
|
inline friend Ostream& operator<<(Ostream& os, const objectHit& obj)
|
||||||
{
|
{
|
||||||
return os << obj.hit() << token::SPACE << obj.hitObject();
|
return os << obj.hit() << token::SPACE << obj.index();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Global Operators
|
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline bool operator==(const objectHit& a, const objectHit& b)
|
inline bool operator==(const objectHit& a, const objectHit& b)
|
||||||
{
|
{
|
||||||
return a.hit() == b.hit() && a.hitObject() == b.hitObject();
|
return a.hit() == b.hit() && a.index() == b.index();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,8 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -23,27 +24,233 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Typedef
|
Class
|
||||||
Foam::pointHit
|
Foam::PointHit
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A PointIndexHit for 3D points.
|
Describes the interaction of a object and a (templated) point.
|
||||||
|
It carries the info of a successful hit and (if successful)
|
||||||
|
the interaction point.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef pointHit_H
|
#ifndef Foam_pointHit_H
|
||||||
#define pointHit_H
|
#define Foam_pointHit_H
|
||||||
|
|
||||||
|
#include "bool.H"
|
||||||
#include "point.H"
|
#include "point.H"
|
||||||
#include "PointHit.H"
|
#include "token.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef PointHit<point> pointHit;
|
|
||||||
|
// Forward Declarations
|
||||||
|
template<class PointType> class PointHit;
|
||||||
|
|
||||||
|
|
||||||
|
// Standard Types
|
||||||
|
|
||||||
|
//- A PointHit with a 3D point
|
||||||
|
typedef PointHit<point> pointHit;
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class PointHit Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class PointType>
|
||||||
|
class PointHit
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Point of hit; for miss holds best estimate outside the object
|
||||||
|
PointType point_;
|
||||||
|
|
||||||
|
//- Distance to hit point
|
||||||
|
scalar distance_;
|
||||||
|
|
||||||
|
//- Hit success
|
||||||
|
bool hit_;
|
||||||
|
|
||||||
|
//- Eligible miss
|
||||||
|
bool eligibleMiss_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Public Typedefs
|
||||||
|
|
||||||
|
//- The point type
|
||||||
|
typedef PointType point_type;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Default construct. A zero point with a large distance,
|
||||||
|
//- no hit, no eligible misses
|
||||||
|
PointHit()
|
||||||
|
:
|
||||||
|
point_(Zero),
|
||||||
|
distance_(GREAT),
|
||||||
|
hit_(false),
|
||||||
|
eligibleMiss_(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from point with a large distance,
|
||||||
|
//- no hit, no eligible misses
|
||||||
|
explicit PointHit(const point_type& p)
|
||||||
|
:
|
||||||
|
point_(p),
|
||||||
|
distance_(GREAT),
|
||||||
|
hit_(false),
|
||||||
|
eligibleMiss_(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
PointHit
|
||||||
|
(
|
||||||
|
bool hit,
|
||||||
|
const point_type& p,
|
||||||
|
scalar dist,
|
||||||
|
bool eligibleMiss = false
|
||||||
|
)
|
||||||
|
:
|
||||||
|
point_(p),
|
||||||
|
distance_(dist),
|
||||||
|
hit_(hit),
|
||||||
|
eligibleMiss_(eligibleMiss)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Is there a hit
|
||||||
|
bool hit() const noexcept
|
||||||
|
{
|
||||||
|
return hit_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Is this an eligible miss
|
||||||
|
bool eligibleMiss() const noexcept
|
||||||
|
{
|
||||||
|
return eligibleMiss_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the point, no checks
|
||||||
|
const point_type& point() const noexcept
|
||||||
|
{
|
||||||
|
return point_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return distance to hit
|
||||||
|
scalar distance() const noexcept
|
||||||
|
{
|
||||||
|
return distance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the hit point. Fatal if not hit.
|
||||||
|
const point_type& hitPoint() const
|
||||||
|
{
|
||||||
|
if (!hit_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Requested a hit point, but it was not hit"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return point_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the miss point. Fatal if hit.
|
||||||
|
const point_type& missPoint() const
|
||||||
|
{
|
||||||
|
if (hit_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Requested a miss point, but it was hit"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return point_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- The point, no checks
|
||||||
|
// \deprecated(2020-10) use point()
|
||||||
|
const point_type& rawPoint() const noexcept { return point_; }
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Set the hit status \em on
|
||||||
|
void setHit() noexcept
|
||||||
|
{
|
||||||
|
hit_ = true;
|
||||||
|
eligibleMiss_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the hit status \em off and set the eligible miss status
|
||||||
|
void setMiss(const bool eligible) noexcept
|
||||||
|
{
|
||||||
|
hit_ = false;
|
||||||
|
eligibleMiss_ = eligible;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the point
|
||||||
|
void setPoint(const point_type& p)
|
||||||
|
{
|
||||||
|
point_ = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the distance
|
||||||
|
void setDistance(const scalar d) noexcept
|
||||||
|
{
|
||||||
|
distance_ = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the point as \em hit.
|
||||||
|
void hitPoint(const point_type& p)
|
||||||
|
{
|
||||||
|
point_ = p;
|
||||||
|
hit_ = true;
|
||||||
|
eligibleMiss_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Distance comparision operator, for sorting
|
||||||
|
template<class AnyPointType>
|
||||||
|
bool operator<(const PointHit<AnyPointType>& rhs) const noexcept
|
||||||
|
{
|
||||||
|
return distance_ < rhs.distance_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Ostream Operator
|
||||||
|
|
||||||
|
template<class PointType>
|
||||||
|
inline Ostream& operator<<(Ostream& os, const PointHit<PointType>& pHit)
|
||||||
|
{
|
||||||
|
os << pHit.hit() << token::SPACE
|
||||||
|
<< pHit.point() << token::SPACE
|
||||||
|
<< pHit.distance() << token::SPACE
|
||||||
|
<< pHit.eligibleMiss();
|
||||||
|
|
||||||
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,31 +24,304 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Typedef
|
Class
|
||||||
Foam::pointIndexHit
|
Foam::PointIndexHit
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A PointIndexHit for 3D points.
|
This class describes the interaction of an object (often a face)
|
||||||
|
and a point.
|
||||||
|
It carries the info of a successful hit and (if successful),
|
||||||
|
returns the interaction point.
|
||||||
|
|
||||||
|
Like pointHit but carries object (eg, face, cell, edge etc.) index
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef pointIndexHit_H
|
#ifndef Foam_pointIndexHit_H
|
||||||
#define pointIndexHit_H
|
#define Foam_pointIndexHit_H
|
||||||
|
|
||||||
#include "point.H"
|
#include "pointHit.H"
|
||||||
#include "PointIndexHit.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
template<class PointType> class PointIndexHit;
|
||||||
|
|
||||||
|
template<class PointType>
|
||||||
|
inline Istream& operator>>(Istream& is, PointIndexHit<PointType>& pHit);
|
||||||
|
|
||||||
|
template<class PointType>
|
||||||
|
inline Ostream& operator<<(Ostream& os, const PointIndexHit<PointType>& pHit);
|
||||||
|
|
||||||
|
|
||||||
|
// Standard Types
|
||||||
|
|
||||||
|
//- A PointIndexHit with a 3D point
|
||||||
typedef PointIndexHit<point> pointIndexHit;
|
typedef PointIndexHit<point> pointIndexHit;
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class PointIndexHit Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class PointType>
|
||||||
|
class PointIndexHit
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Hit success
|
||||||
|
bool hit_;
|
||||||
|
|
||||||
|
//- Point of hit; invalid for misses
|
||||||
|
PointType point_;
|
||||||
|
|
||||||
|
//- Label of object hit
|
||||||
|
label index_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Public Typedefs
|
||||||
|
|
||||||
|
//- The point type
|
||||||
|
typedef PointType point_type;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Default construct. A zero point, with no hit and index = -1
|
||||||
|
PointIndexHit()
|
||||||
|
:
|
||||||
|
hit_(false),
|
||||||
|
point_(Zero),
|
||||||
|
index_(-1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from a point, with no hit and index = -1
|
||||||
|
explicit PointIndexHit(const point_type& p)
|
||||||
|
:
|
||||||
|
hit_(false),
|
||||||
|
point_(p),
|
||||||
|
index_(-1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from hitPoint with index = -1 or specified
|
||||||
|
explicit PointIndexHit(const PointHit<point_type>& p, label index = -1)
|
||||||
|
:
|
||||||
|
hit_(p.hit()),
|
||||||
|
point_(p.point()),
|
||||||
|
index_(index)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
PointIndexHit(bool success, const point_type& p, label index)
|
||||||
|
:
|
||||||
|
hit_(success),
|
||||||
|
point_(p),
|
||||||
|
index_(index)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
explicit PointIndexHit(Istream& is)
|
||||||
|
{
|
||||||
|
is >> *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Is there a hit?
|
||||||
|
bool hit() const noexcept
|
||||||
|
{
|
||||||
|
return hit_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the hit index
|
||||||
|
label index() const noexcept
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return point, no checks
|
||||||
|
const point_type& point() const noexcept
|
||||||
|
{
|
||||||
|
return point_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Access the point, no checks
|
||||||
|
point_type& point() noexcept
|
||||||
|
{
|
||||||
|
return point_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return hit point. Fatal if not hit.
|
||||||
|
const point_type& hitPoint() const
|
||||||
|
{
|
||||||
|
if (!hit_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Requested a hit point, but it was not hit"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
return point_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return miss point. Fatal if hit.
|
||||||
|
const point_type& missPoint() const
|
||||||
|
{
|
||||||
|
if (hit_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Requested a miss point, but it was hit"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
return point_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- The point, no checks. Same as point()
|
||||||
|
// \deprecated(2020-10) use point()
|
||||||
|
const point_type& rawPoint() const noexcept { return point_; }
|
||||||
|
|
||||||
|
//- The point, no checks. Same as point()
|
||||||
|
// \deprecated(2020-10) use point()
|
||||||
|
point_type& rawPoint() noexcept { return point_; }
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Set the hit status \em on
|
||||||
|
void setHit() noexcept
|
||||||
|
{
|
||||||
|
hit_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the hit status \em off
|
||||||
|
void setMiss() noexcept
|
||||||
|
{
|
||||||
|
hit_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the point
|
||||||
|
void setPoint(const point_type& p)
|
||||||
|
{
|
||||||
|
point_ = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the index
|
||||||
|
void setIndex(const label index) noexcept
|
||||||
|
{
|
||||||
|
index_ = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the point as \em hit without changing the hit-index
|
||||||
|
void hitPoint(const point_type& p)
|
||||||
|
{
|
||||||
|
point_ = p;
|
||||||
|
hit_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Set the point as \em hit and set the hit-index
|
||||||
|
void hitPoint(const point_type& p, const label index)
|
||||||
|
{
|
||||||
|
point_ = p;
|
||||||
|
hit_ = true;
|
||||||
|
index_ = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- Report hit/miss status, point and index
|
||||||
|
void write(Ostream& os)
|
||||||
|
{
|
||||||
|
os << (hit_ ? "hit:" : "miss:")
|
||||||
|
<< point_ << " index:" << index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Test for equality of all components
|
||||||
|
bool operator==(const PointIndexHit& rhs) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
hit_ == rhs.hit_
|
||||||
|
&& index_ == rhs.index_
|
||||||
|
&& point_ == rhs.point_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Test for inequality of components
|
||||||
|
bool operator!=(const PointIndexHit& rhs) const
|
||||||
|
{
|
||||||
|
return !(*this == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IO Operators
|
||||||
|
|
||||||
|
friend Ostream& operator<<(Ostream& os, const PointIndexHit& pHit)
|
||||||
|
{
|
||||||
|
if (os.format() == IOstreamOption::ASCII)
|
||||||
|
{
|
||||||
|
os << pHit.hit_ << token::SPACE
|
||||||
|
<< pHit.point_ << token::SPACE
|
||||||
|
<< pHit.index_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os.write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(&pHit),
|
||||||
|
sizeof(PointIndexHit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
os.check(FUNCTION_NAME);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
friend Istream& operator>>(Istream& is, PointIndexHit& pHit)
|
||||||
|
{
|
||||||
|
if (is.format() == IOstreamOption::ASCII)
|
||||||
|
{
|
||||||
|
is >> pHit.hit_ >> pHit.point_ >> pHit.index_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO (2019-08-06):
|
||||||
|
// cannot properly handle mixed-precision reading
|
||||||
|
// owing to bool and Point type.
|
||||||
|
|
||||||
|
is.read
|
||||||
|
(
|
||||||
|
reinterpret_cast<char*>(&pHit),
|
||||||
|
sizeof(PointIndexHit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
is.check(FUNCTION_NAME);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Contiguous data for pointIndexHit
|
//- Contiguous data for pointIndexHit
|
||||||
template<> struct is_contiguous<pointIndexHit> : is_contiguous<point> {};
|
template<> struct is_contiguous<pointIndexHit> : is_contiguous<point> {};
|
||||||
|
|
||||||
}
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -31,8 +31,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef pointIndexHitIOList_H
|
#ifndef Foam_pointIndexHitIOList_H
|
||||||
#define pointIndexHitIOList_H
|
#define Foam_pointIndexHitIOList_H
|
||||||
|
|
||||||
#include "pointIndexHit.H"
|
#include "pointIndexHit.H"
|
||||||
#include "IOList.H"
|
#include "IOList.H"
|
||||||
|
|||||||
@ -572,8 +572,7 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::ray
|
|||||||
if (hit && eligible)
|
if (hit && eligible)
|
||||||
{
|
{
|
||||||
// Hit. Set distance to intersection.
|
// Hit. Set distance to intersection.
|
||||||
inter.setHit();
|
inter.hitPoint(pInter);
|
||||||
inter.setPoint(pInter);
|
|
||||||
inter.setDistance(dist);
|
inter.setDistance(dist);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -671,8 +670,7 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::intersection
|
|||||||
return intersection;
|
return intersection;
|
||||||
}
|
}
|
||||||
|
|
||||||
intersection.setHit();
|
intersection.hitPoint(a_ + u*edge1 + v*edge2);
|
||||||
intersection.setPoint(a_ + u*edge1 + v*edge2);
|
|
||||||
intersection.setDistance(t);
|
intersection.setDistance(t);
|
||||||
|
|
||||||
return intersection;
|
return intersection;
|
||||||
@ -898,8 +896,7 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::nearestPoint
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Hit on line
|
// Hit on line
|
||||||
lnInfo.setHit();
|
lnInfo.hitPoint(triInfo.hitPoint());
|
||||||
lnInfo.setPoint(triInfo.hitPoint());
|
|
||||||
lnInfo.setDistance(0.0);
|
lnInfo.setDistance(0.0);
|
||||||
triInfo.setDistance(0.0);
|
triInfo.setDistance(0.0);
|
||||||
}
|
}
|
||||||
@ -972,8 +969,7 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::nearestPoint
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lnInfo.setHit();
|
lnInfo.hitPoint(nearestLinePoint);
|
||||||
lnInfo.setPoint(nearestLinePoint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return triInfo;
|
return triInfo;
|
||||||
|
|||||||
@ -277,9 +277,8 @@ Foam::pointIndexHit Foam::turbulentDFSEMInletFvPatchVectorField::setNewPosition
|
|||||||
const face& tf = triFace_[triI];
|
const face& tf = triFace_[triI];
|
||||||
const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]);
|
const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]);
|
||||||
|
|
||||||
pos.setHit();
|
pos.hitPoint(tri.randomPoint(rndGen_));
|
||||||
pos.setIndex(triToFace_[triI]);
|
pos.setIndex(triToFace_[triI]);
|
||||||
pos.rawPoint() = tri.randomPoint(rndGen_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -302,9 +301,8 @@ Foam::pointIndexHit Foam::turbulentDFSEMInletFvPatchVectorField::setNewPosition
|
|||||||
const face& tf = triFace_[triI];
|
const face& tf = triFace_[triI];
|
||||||
const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]);
|
const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]);
|
||||||
|
|
||||||
pos.setHit();
|
pos.hitPoint(tri.randomPoint(rndGen_));
|
||||||
pos.setIndex(triToFace_[triI]);
|
pos.setIndex(triToFace_[triI]);
|
||||||
pos.rawPoint() = tri.randomPoint(rndGen_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
|
|||||||
@ -589,20 +589,17 @@ void Foam::searchableCone::findLineAll
|
|||||||
// Check tNear, tFar
|
// Check tNear, tFar
|
||||||
if (tNear>=0 && tNear <= magV)
|
if (tNear>=0 && tNear <= magV)
|
||||||
{
|
{
|
||||||
near.setPoint(start+tNear*V);
|
near.hitPoint(start+tNear*V);
|
||||||
near.setHit();
|
|
||||||
near.setIndex(0);
|
near.setIndex(0);
|
||||||
if (tFar <= magV)
|
if (tFar <= magV)
|
||||||
{
|
{
|
||||||
far.setPoint(start+tFar*V);
|
far.hitPoint(start+tFar*V);
|
||||||
far.setHit();
|
|
||||||
far.setIndex(0);
|
far.setIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tFar>=0 && tFar <= magV)
|
else if (tFar>=0 && tFar <= magV)
|
||||||
{
|
{
|
||||||
near.setPoint(start+tFar*V);
|
near.hitPoint(start+tFar*V);
|
||||||
near.setHit();
|
|
||||||
near.setIndex(0);
|
near.setIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -417,21 +417,18 @@ void Foam::searchableCylinder::findLineAll
|
|||||||
// Check tNear, tFar
|
// Check tNear, tFar
|
||||||
if (tNear >= 0 && tNear <= magV)
|
if (tNear >= 0 && tNear <= magV)
|
||||||
{
|
{
|
||||||
near.setPoint(start+tNear*V);
|
near.hitPoint(start+tNear*V);
|
||||||
near.setHit();
|
|
||||||
near.setIndex(0);
|
near.setIndex(0);
|
||||||
|
|
||||||
if (tFar <= magV)
|
if (tFar <= magV)
|
||||||
{
|
{
|
||||||
far.setPoint(start+tFar*V);
|
far.hitPoint(start+tFar*V);
|
||||||
far.setHit();
|
|
||||||
far.setIndex(0);
|
far.setIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tFar >= 0 && tFar <= magV)
|
else if (tFar >= 0 && tFar <= magV)
|
||||||
{
|
{
|
||||||
near.setPoint(start+tFar*V);
|
near.hitPoint(start+tFar*V);
|
||||||
near.setHit();
|
|
||||||
near.setIndex(0);
|
near.setIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -577,12 +577,11 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest
|
|||||||
|
|
||||||
if (nearestDistSqr >= sqr(magN - radii_[0]))
|
if (nearestDistSqr >= sqr(magN - radii_[0]))
|
||||||
{
|
{
|
||||||
info.setPoint
|
info.hitPoint
|
||||||
(
|
(
|
||||||
origin_
|
origin_
|
||||||
+ (magN < ROOTVSMALL ? vector(radii_[0],0,0) : (radii_[0]*n/magN))
|
+ (magN < ROOTVSMALL ? vector(radii_[0],0,0) : (radii_[0]*n/magN))
|
||||||
);
|
);
|
||||||
info.setHit();
|
|
||||||
info.setIndex(0);
|
info.setIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -105,8 +105,7 @@ void Foam::searchableSurfaceCollection::findNearest
|
|||||||
if (distSqr < minDistSqr[pointi])
|
if (distSqr < minDistSqr[pointi])
|
||||||
{
|
{
|
||||||
minDistSqr[pointi] = distSqr;
|
minDistSqr[pointi] = distSqr;
|
||||||
nearestInfo[pointi].setPoint(globalPt);
|
nearestInfo[pointi].hitPoint(globalPt);
|
||||||
nearestInfo[pointi].setHit();
|
|
||||||
nearestInfo[pointi].setIndex
|
nearestInfo[pointi].setIndex
|
||||||
(
|
(
|
||||||
hitInfo[pointi].index()
|
hitInfo[pointi].index()
|
||||||
|
|||||||
@ -170,8 +170,7 @@ void Foam::regionToFace::combine(topoSet& set, const bool add) const
|
|||||||
if (!ni.first().hit() || d2 < ni.second().first())
|
if (!ni.first().hit() || d2 < ni.second().first())
|
||||||
{
|
{
|
||||||
ni.second().first() = d2;
|
ni.second().first() = d2;
|
||||||
ni.first().setHit();
|
ni.first().hitPoint(fc);
|
||||||
ni.first().setPoint(fc);
|
|
||||||
ni.first().setIndex(i);
|
ni.first().setIndex(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,8 +139,7 @@ Foam::pointHit Foam::faceTriangulation::rayEdgeIntersect
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Hit
|
// Hit
|
||||||
result.setHit();
|
result.hitPoint(intersectPt);
|
||||||
result.setPoint(intersectPt);
|
|
||||||
result.setDistance(mag(intersectPt - rayOrigin));
|
result.setDistance(mag(intersectPt - rayOrigin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -847,15 +847,13 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge
|
|||||||
|
|
||||||
if (d[fp1] == 0.0)
|
if (d[fp1] == 0.0)
|
||||||
{
|
{
|
||||||
cut.setHit();
|
cut.hitPoint(points[f[fp1]]);
|
||||||
cut.setPoint(points[f[fp1]]);
|
|
||||||
cut.elementType() = triPointRef::POINT;
|
cut.elementType() = triPointRef::POINT;
|
||||||
cut.setIndex(s.localFaces()[triI][fp1]);
|
cut.setIndex(s.localFaces()[triI][fp1]);
|
||||||
}
|
}
|
||||||
else if (d[fp2] == 0.0)
|
else if (d[fp2] == 0.0)
|
||||||
{
|
{
|
||||||
cut.setHit();
|
cut.hitPoint(points[f[fp2]]);
|
||||||
cut.setPoint(points[f[fp2]]);
|
|
||||||
cut.elementType() = triPointRef::POINT;
|
cut.elementType() = triPointRef::POINT;
|
||||||
cut.setIndex(s.localFaces()[triI][fp2]);
|
cut.setIndex(s.localFaces()[triI][fp2]);
|
||||||
}
|
}
|
||||||
@ -870,8 +868,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cut.setHit();
|
cut.hitPoint
|
||||||
cut.setPoint
|
|
||||||
(
|
(
|
||||||
(d[fp2]*points[f[fp1]] - d[fp1]*points[f[fp2]])
|
(d[fp2]*points[f[fp1]] - d[fp1]*points[f[fp2]])
|
||||||
/ (d[fp2] - d[fp1])
|
/ (d[fp2] - d[fp1])
|
||||||
@ -899,8 +896,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge
|
|||||||
<< "triangle:" << f.tri(points)
|
<< "triangle:" << f.tri(points)
|
||||||
<< " d:" << d << abort(FatalError);
|
<< " d:" << d << abort(FatalError);
|
||||||
}
|
}
|
||||||
inters[interI].setHit();
|
inters[interI].hitPoint(points[f[fp0]]);
|
||||||
inters[interI].setPoint(points[f[fp0]]);
|
|
||||||
inters[interI].elementType() = triPointRef::POINT;
|
inters[interI].elementType() = triPointRef::POINT;
|
||||||
inters[interI].setIndex(s.localFaces()[triI][fp0]);
|
inters[interI].setIndex(s.localFaces()[triI][fp0]);
|
||||||
interI++;
|
interI++;
|
||||||
@ -918,8 +914,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge
|
|||||||
<< "triangle:" << f.tri(points)
|
<< "triangle:" << f.tri(points)
|
||||||
<< " d:" << d << abort(FatalError);
|
<< " d:" << d << abort(FatalError);
|
||||||
}
|
}
|
||||||
inters[interI].setHit();
|
inters[interI].hitPoint
|
||||||
inters[interI].setPoint
|
|
||||||
(
|
(
|
||||||
(d[fp0]*points[f[fp1]] - d[fp1]*points[f[fp0]])
|
(d[fp0]*points[f[fp1]] - d[fp1]*points[f[fp0]])
|
||||||
/ (d[fp0] - d[fp1])
|
/ (d[fp0] - d[fp1])
|
||||||
|
|||||||
@ -1596,7 +1596,7 @@ Foam::volumeType Foam::distributedTriSurfaceMesh::calcVolumeType
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store octant type
|
// Store octant type
|
||||||
nodeTypes.set((nodeI<<3)+octant, subType);
|
nodeTypes.set(labelBits::pack(nodeI, octant), subType);
|
||||||
|
|
||||||
// Combine sub node types into type for treeNode. Result is 'mixed' if
|
// Combine sub node types into type for treeNode. Result is 'mixed' if
|
||||||
// types differ among subnodes.
|
// types differ among subnodes.
|
||||||
@ -1625,7 +1625,7 @@ Foam::volumeType Foam::distributedTriSurfaceMesh::cachedVolumeType
|
|||||||
|
|
||||||
volumeType octantType = volumeType::type
|
volumeType octantType = volumeType::type
|
||||||
(
|
(
|
||||||
tree().nodeTypes().get((nodeI<<3)+octant)
|
tree().nodeTypes().get(labelBits::pack(nodeI, octant))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (octantType == volumeType::INSIDE)
|
if (octantType == volumeType::INSIDE)
|
||||||
|
|||||||
@ -131,8 +131,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface
|
|||||||
if (localTris.size() == 1)
|
if (localTris.size() == 1)
|
||||||
{
|
{
|
||||||
const labelledTri& tri = localTris[0];
|
const labelledTri& tri = localTris[0];
|
||||||
info.setPoint(tri.centre(localPoints));
|
info.hitPoint(tri.centre(localPoints));
|
||||||
info.setHit();
|
|
||||||
}
|
}
|
||||||
else if (localTris.size() == 2)
|
else if (localTris.size() == 2)
|
||||||
{
|
{
|
||||||
@ -157,7 +156,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface
|
|||||||
|| (n0 & n1) >= 0
|
|| (n0 & n1) >= 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
info.setPoint
|
info.hitPoint
|
||||||
(
|
(
|
||||||
0.5
|
0.5
|
||||||
* (
|
* (
|
||||||
@ -165,7 +164,6 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface
|
|||||||
+ tri1.centre(localPoints)
|
+ tri1.centre(localPoints)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
info.setHit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,8 +202,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface
|
|||||||
|
|
||||||
if (minCos > 0)
|
if (minCos > 0)
|
||||||
{
|
{
|
||||||
info.setPoint(calcCentre(surf));
|
info.hitPoint(calcCentre(surf));
|
||||||
info.setHit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user