Commit 96bc1191 authored by Mark Olesen's avatar Mark Olesen Committed by Mark OLESEN
Browse files

ENH: make maxTreeDepth optional in triSurfaceSearch constructor

- makes it easier to construct with a tolerance only
parent 4ce77f68
......@@ -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<treeDataTriSurface>::perturbTol();
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......@@ -227,7 +232,7 @@ Foam::triSurfaceSearch::tree() const
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
}
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance_;
treePtr_.reset
......@@ -285,7 +290,7 @@ void Foam::triSurfaceSearch::findNearest
List<pointIndexHit>& info
) const
{
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance();
const indexedOctree<treeDataTriSurface>& octree = tree();
......@@ -332,7 +337,7 @@ void Foam::triSurfaceSearch::findLine
info.setSize(start.size());
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance();
forAll(start, i)
......@@ -355,7 +360,7 @@ void Foam::triSurfaceSearch::findLineAny
info.setSize(start.size());
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance();
forAll(start, i)
......@@ -378,7 +383,7 @@ void Foam::triSurfaceSearch::findLineAll
info.setSize(start.size());
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance();
// Work array
......
......@@ -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
(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment