diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index e826500f15..e4c4b9c14c 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -175,7 +175,12 @@ Foam::triSurfaceSearch::triSurfaceSearch tolerance_(tolerance), maxTreeDepth_(maxTreeDepth), treePtr_(nullptr) -{} +{ + if (tolerance_ < 0) + { + tolerance_ = indexedOctree::perturbTol(); + } +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -227,7 +232,7 @@ Foam::triSurfaceSearch::tree() const bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); } - scalar oldTol = indexedOctree::perturbTol(); + const scalar oldTol = indexedOctree::perturbTol(); indexedOctree::perturbTol() = tolerance_; treePtr_.reset @@ -285,7 +290,7 @@ void Foam::triSurfaceSearch::findNearest List& info ) const { - scalar oldTol = indexedOctree::perturbTol(); + const scalar oldTol = indexedOctree::perturbTol(); indexedOctree::perturbTol() = tolerance(); const indexedOctree& octree = tree(); @@ -332,7 +337,7 @@ void Foam::triSurfaceSearch::findLine info.setSize(start.size()); - scalar oldTol = indexedOctree::perturbTol(); + const scalar oldTol = indexedOctree::perturbTol(); indexedOctree::perturbTol() = tolerance(); forAll(start, i) @@ -355,7 +360,7 @@ void Foam::triSurfaceSearch::findLineAny info.setSize(start.size()); - scalar oldTol = indexedOctree::perturbTol(); + const scalar oldTol = indexedOctree::perturbTol(); indexedOctree::perturbTol() = tolerance(); forAll(start, i) @@ -378,7 +383,7 @@ void Foam::triSurfaceSearch::findLineAll info.setSize(start.size()); - scalar oldTol = indexedOctree::perturbTol(); + const scalar oldTol = indexedOctree::perturbTol(); indexedOctree::perturbTol() = tolerance(); // Work array diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H index 1debfc8ff6..b46e758985 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,10 +85,10 @@ class triSurfaceSearch ) const; //- Disallow default bitwise copy construct - triSurfaceSearch(const triSurfaceSearch&); + triSurfaceSearch(const triSurfaceSearch&) = delete; //- Disallow default bitwise assignment - void operator=(const triSurfaceSearch&); + void operator=(const triSurfaceSearch&) = delete; public: @@ -96,17 +96,18 @@ public: // Constructors //- Construct from surface. Holds reference to surface! - explicit triSurfaceSearch(const triSurface&); + explicit triSurfaceSearch(const triSurface& surface); //- Construct from surface and dictionary. - triSurfaceSearch(const triSurface&, const dictionary& dict); + triSurfaceSearch(const triSurface& surface, const dictionary& dict); - //- Construct from components + //- Construct from components. + // A invalid (negative) tolerance uses the default tolerance. triSurfaceSearch ( const triSurface& surface, const scalar tolerance, - const label maxTreeDepth + const label maxTreeDepth = 10 ); @@ -155,7 +156,7 @@ public: // - hit() : whether nearest point found within bounding box // - hitPoint() : coordinate of nearest point // - index() : surface triangle label - pointIndexHit nearest(const point&, const vector& span) const; + pointIndexHit nearest(const point& pt, const vector& span) const; void findLine (