ENH: setter/getter for octree permutation tolerance

- make template invariant
This commit is contained in:
Mark Olesen
2022-10-13 16:05:25 +02:00
committed by Andrew Heather
parent 3d7dc6a870
commit b8d01a88ea
8 changed files with 50 additions and 78 deletions

View File

@ -31,11 +31,6 @@ License
#include "OFstream.H" #include "OFstream.H"
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type>
Foam::scalar Foam::dynamicIndexedOctree<Type>::perturbTol_ = 10*SMALL;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
@ -2046,13 +2041,6 @@ Foam::dynamicIndexedOctree<Type>::dynamicIndexedOctree
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::scalar& Foam::dynamicIndexedOctree<Type>::perturbTol()
{
return perturbTol_;
}
template<class Type> template<class Type>
Foam::pointIndexHit Foam::dynamicIndexedOctree<Type>::findNearest Foam::pointIndexHit Foam::dynamicIndexedOctree<Type>::findNearest
( (

View File

@ -89,15 +89,6 @@ class dynamicIndexedOctree
: :
public dynamicIndexedOctreeBase public dynamicIndexedOctreeBase
{ {
// Static data
//- Relative perturbation tolerance. Determines when point is
// considered to be close to face/edge of bb of node.
// The tolerance is relative to the bounding box of the smallest
// node.
static scalar perturbTol_;
// Private Data // Private Data
//- Underlying shapes for geometric queries. //- Underlying shapes for geometric queries.
@ -333,10 +324,6 @@ class dynamicIndexedOctree
public: public:
//- Get the perturbation tolerance
static scalar& perturbTol();
// Constructors // Constructors
//- Construct from shapes //- Construct from shapes

View File

@ -32,12 +32,6 @@ License
#include "ListOps.H" #include "ListOps.H"
#include "memInfo.H" #include "memInfo.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type>
Foam::scalar Foam::indexedOctree<Type>::perturbTol_ = 10*SMALL;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
@ -2293,13 +2287,6 @@ Foam::indexedOctree<Type>::indexedOctree
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::scalar& Foam::indexedOctree<Type>::perturbTol()
{
return perturbTol_;
}
template<class Type> template<class Type>
Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
( (

View File

@ -178,6 +178,16 @@ public:
protected: protected:
// Static Data
//- Relative perturbation tolerance.
// Determines when point is considered to be close to face/edge
// of bb of node.
// The tolerance is relative to the bounding box of the smallest
// node.
static scalar perturbTol_;
// Protected Member Functions // Protected Member Functions
// Encode node addressing // Encode node addressing
@ -204,6 +214,18 @@ protected:
public: public:
//- Get the perturbation tolerance
static scalar& perturbTol() noexcept { return perturbTol_; }
//- Set the perturbation tolerance, return the old value
static scalar perturbTol(scalar tol) noexcept
{
scalar old(perturbTol_);
perturbTol_ = tol;
return old;
}
//- Runtime type information //- Runtime type information
ClassName("indexedOctree"); ClassName("indexedOctree");
@ -236,15 +258,6 @@ class indexedOctree
: :
public indexedOctreeBase public indexedOctreeBase
{ {
// Static data
//- Relative perturbation tolerance. Determines when point is
// considered to be close to face/edge of bb of node.
// The tolerance is relative to the bounding box of the smallest
// node.
static scalar perturbTol_;
// Private Data // Private Data
//- Underlying shapes for geometric queries. //- Underlying shapes for geometric queries.
@ -489,10 +502,6 @@ class indexedOctree
public: public:
//- Get the perturbation tolerance
static scalar& perturbTol();
// Constructors // Constructors
//- Construct null //- Construct null

View File

@ -34,6 +34,8 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(indexedOctreeBase, 0); defineTypeNameAndDebug(indexedOctreeBase, 0);
scalar indexedOctreeBase::perturbTol_ = 10*SMALL;
} }

View File

@ -801,8 +801,8 @@ Foam::triSurfaceMesh::edgeTree() const
<< "calculating edge tree for bb:" << bb << endl; << "calculating edge tree for bb:" << bb << endl;
} }
scalar oldTol = indexedOctree<treeDataEdge>::perturbTol(); const scalar oldTol =
indexedOctree<treeDataEdge>::perturbTol() = tolerance(); indexedOctree<treeDataEdge>::perturbTol(tolerance());
edgeTree_.reset edgeTree_.reset
( (
@ -822,7 +822,7 @@ Foam::triSurfaceMesh::edgeTree() const
) )
); );
indexedOctree<treeDataEdge>::perturbTol() = oldTol; indexedOctree<treeDataEdge>::perturbTol(oldTol);
if (debug) if (debug)
{ {
@ -1221,8 +1221,8 @@ void Foam::triSurfaceMesh::getVolumeType
List<volumeType>& volType List<volumeType>& volType
) const ) const
{ {
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); const scalar oldTol =
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance(); indexedOctree<treeDataTriSurface>::perturbTol(tolerance());
if (debug) if (debug)
{ {
@ -1258,7 +1258,8 @@ void Foam::triSurfaceMesh::getVolumeType
} }
} }
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol; indexedOctree<treeDataTriSurface>::perturbTol(oldTol);
if (debug) if (debug)
{ {
Pout<< "triSurfaceMesh::getVolumeType :" Pout<< "triSurfaceMesh::getVolumeType :"

View File

@ -108,8 +108,7 @@ Foam::triSurfaceRegionSearch::treeByRegion() const
forAll(regionsAddressing, regionI) forAll(regionsAddressing, regionI)
{ {
scalar oldTol = treeType::perturbTol(); const scalar oldTol = treeType::perturbTol(tolerance());
treeType::perturbTol() = tolerance();
indirectRegionPatches_.set indirectRegionPatches_.set
( (
@ -177,7 +176,7 @@ Foam::triSurfaceRegionSearch::treeByRegion() const
) )
); );
treeType::perturbTol() = oldTol; treeType::perturbTol(oldTol);
} }
} }
@ -199,8 +198,7 @@ void Foam::triSurfaceRegionSearch::findNearest
} }
else else
{ {
scalar oldTol = treeType::perturbTol(); const scalar oldTol = treeType::perturbTol(tolerance());
treeType::perturbTol() = tolerance();
const PtrList<treeType>& octrees = treeByRegion(); const PtrList<treeType>& octrees = treeByRegion();
@ -249,7 +247,7 @@ void Foam::triSurfaceRegionSearch::findNearest
} }
} }
treeType::perturbTol() = oldTol; treeType::perturbTol(oldTol);
} }
} }

View File

@ -233,8 +233,8 @@ Foam::triSurfaceSearch::tree() const
bb.inflate(rndGen, 1e-4, ROOTVSMALL); bb.inflate(rndGen, 1e-4, ROOTVSMALL);
} }
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); const scalar oldTol =
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance_; indexedOctree<treeDataTriSurface>::perturbTol(tolerance_);
treePtr_.reset treePtr_.reset
( (
@ -248,7 +248,7 @@ Foam::triSurfaceSearch::tree() const
) )
); );
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol; indexedOctree<treeDataTriSurface>::perturbTol(oldTol);
} }
return *treePtr_; return *treePtr_;
@ -291,8 +291,8 @@ void Foam::triSurfaceSearch::findNearest
List<pointIndexHit>& info List<pointIndexHit>& info
) const ) const
{ {
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); const scalar oldTol =
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance(); indexedOctree<treeDataTriSurface>::perturbTol(tolerance());
const indexedOctree<treeDataTriSurface>& octree = tree(); const indexedOctree<treeDataTriSurface>& octree = tree();
@ -310,7 +310,7 @@ void Foam::triSurfaceSearch::findNearest
); );
} }
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol; indexedOctree<treeDataTriSurface>::perturbTol(oldTol);
} }
@ -338,15 +338,15 @@ void Foam::triSurfaceSearch::findLine
info.setSize(start.size()); info.setSize(start.size());
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); const scalar oldTol =
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance(); indexedOctree<treeDataTriSurface>::perturbTol(tolerance());
forAll(start, i) forAll(start, i)
{ {
info[i] = octree.findLine(start[i], end[i]); info[i] = octree.findLine(start[i], end[i]);
} }
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol; indexedOctree<treeDataTriSurface>::perturbTol(oldTol);
} }
@ -361,15 +361,15 @@ void Foam::triSurfaceSearch::findLineAny
info.setSize(start.size()); info.setSize(start.size());
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); const scalar oldTol =
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance(); indexedOctree<treeDataTriSurface>::perturbTol(tolerance());
forAll(start, i) forAll(start, i)
{ {
info[i] = octree.findLineAny(start[i], end[i]); info[i] = octree.findLineAny(start[i], end[i]);
} }
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol; indexedOctree<treeDataTriSurface>::perturbTol(oldTol);
} }
@ -384,8 +384,8 @@ void Foam::triSurfaceSearch::findLineAll
info.setSize(start.size()); info.setSize(start.size());
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); const scalar oldTol =
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance(); indexedOctree<treeDataTriSurface>::perturbTol(tolerance());
// Work array // Work array
DynamicList<pointIndexHit> hits; DynamicList<pointIndexHit> hits;
@ -437,7 +437,7 @@ void Foam::triSurfaceSearch::findLineAll
info[pointi].transfer(hits); info[pointi].transfer(hits);
} }
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol; indexedOctree<treeDataTriSurface>::perturbTol(oldTol);
} }