mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
boundBox, octree cleanup
- added boundBox(const tmp<pointField>&) constructor for use with
coordinate systems
- moved some methods from treeBoundBox to boundBox and use VectorSpace ops
This commit is contained in:
@ -178,8 +178,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
const boundBox& bb = mesh.globalData().bb();
|
const boundBox& bb = mesh.globalData().bb();
|
||||||
const vector span = bb.span();
|
const vector span = bb.span();
|
||||||
const scalar minDim = min(span[0], min(span[1], span[2]));
|
const scalar mergeDim = 1E-4 * bb.minDim();
|
||||||
const scalar mergeDim = 1E-4 * minDim;
|
|
||||||
|
|
||||||
Pout<< "Mesh bounding box:" << bb << nl
|
Pout<< "Mesh bounding box:" << bb << nl
|
||||||
<< " with span:" << span << nl
|
<< " with span:" << span << nl
|
||||||
|
|||||||
@ -26,9 +26,12 @@ License
|
|||||||
|
|
||||||
#include "boundBox.H"
|
#include "boundBox.H"
|
||||||
#include "PstreamReduceOps.H"
|
#include "PstreamReduceOps.H"
|
||||||
|
#include "tmp.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::scalar Foam::boundBox::great(VGREAT);
|
||||||
|
|
||||||
const Foam::boundBox Foam::boundBox::greatBox
|
const Foam::boundBox Foam::boundBox::greatBox
|
||||||
(
|
(
|
||||||
point(-VGREAT, -VGREAT, -VGREAT),
|
point(-VGREAT, -VGREAT, -VGREAT),
|
||||||
@ -43,16 +46,16 @@ const Foam::boundBox Foam::boundBox::invertedBox
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
|
void Foam::boundBox::calculate(const pointField& points, const bool doReduce)
|
||||||
:
|
|
||||||
min_(point::zero),
|
|
||||||
max_(point::zero)
|
|
||||||
{
|
{
|
||||||
if (points.size() == 0)
|
if (points.size() == 0)
|
||||||
{
|
{
|
||||||
if (Pstream::parRun() && doReduce)
|
min_ = point::zero;
|
||||||
|
max_ = point::zero;
|
||||||
|
|
||||||
|
if (doReduce && Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Use values that get overwritten by reduce minOp, maxOp below
|
// Use values that get overwritten by reduce minOp, maxOp below
|
||||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
min_ = point(VGREAT, VGREAT, VGREAT);
|
||||||
@ -64,22 +67,43 @@ Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
|
|||||||
min_ = points[0];
|
min_ = points[0];
|
||||||
max_ = points[0];
|
max_ = points[0];
|
||||||
|
|
||||||
forAll(points, i)
|
for (label i = 1; i < points.size(); i++)
|
||||||
{
|
{
|
||||||
min_ = ::Foam::min(min_, points[i]);
|
min_ = ::Foam::min(min_, points[i]);
|
||||||
max_ = ::Foam::max(max_, points[i]);
|
max_ = ::Foam::max(max_, points[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce parallel information
|
||||||
if (doReduce)
|
if (doReduce)
|
||||||
{
|
{
|
||||||
// Reduce parallel information
|
|
||||||
reduce(min_, minOp<point>());
|
reduce(min_, minOp<point>());
|
||||||
reduce(max_, maxOp<point>());
|
reduce(max_, maxOp<point>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
|
||||||
|
:
|
||||||
|
min_(point::zero),
|
||||||
|
max_(point::zero)
|
||||||
|
{
|
||||||
|
calculate(points, doReduce);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::boundBox::boundBox(const tmp<pointField>& points, const bool doReduce)
|
||||||
|
:
|
||||||
|
min_(point::zero),
|
||||||
|
max_(point::zero)
|
||||||
|
{
|
||||||
|
calculate(points(), doReduce);
|
||||||
|
points.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::boundBox::boundBox(Istream& is)
|
Foam::boundBox::boundBox(Istream& is)
|
||||||
{
|
{
|
||||||
operator>>(is, *this);
|
operator>>(is, *this);
|
||||||
|
|||||||
@ -43,12 +43,13 @@ namespace Foam
|
|||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
class boundBox;
|
class boundBox;
|
||||||
|
template<class T> class tmp;
|
||||||
|
|
||||||
Ostream& operator<<(Ostream& os, const boundBox& b);
|
Ostream& operator<<(Ostream& os, const boundBox& b);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class boundBox Declaration
|
Class boundBox Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class boundBox
|
class boundBox
|
||||||
@ -58,11 +59,19 @@ class boundBox
|
|||||||
//- Minimum and maximum describing the bounding box
|
//- Minimum and maximum describing the bounding box
|
||||||
point min_, max_;
|
point min_, max_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Calculate the bounding box from the given pointField.
|
||||||
|
// Does parallel communication (doReduce = true)
|
||||||
|
void calculate(const pointField&, const bool doReduce = true);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
|
//- The great value used for greatBox and invertedBox
|
||||||
|
static const scalar great;
|
||||||
|
|
||||||
//- A very large boundBox: min/max == -/+ VGREAT
|
//- A very large boundBox: min/max == -/+ VGREAT
|
||||||
static const boundBox greatBox;
|
static const boundBox greatBox;
|
||||||
|
|
||||||
@ -88,7 +97,11 @@ public:
|
|||||||
|
|
||||||
//- Construct as the bounding box of the given pointField.
|
//- Construct as the bounding box of the given pointField.
|
||||||
// Does parallel communication (doReduce = true)
|
// Does parallel communication (doReduce = true)
|
||||||
boundBox(const pointField& points, const bool doReduce = true);
|
boundBox(const pointField&, const bool doReduce = true);
|
||||||
|
|
||||||
|
//- Construct as the bounding box of the given temporary pointField.
|
||||||
|
// Does parallel communication (doReduce = true)
|
||||||
|
boundBox(const tmp<pointField>&, const bool doReduce = true);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
boundBox(Istream&);
|
boundBox(Istream&);
|
||||||
@ -122,6 +135,12 @@ public:
|
|||||||
return max_;
|
return max_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- The midpoint of the bounding box
|
||||||
|
point midpoint() const
|
||||||
|
{
|
||||||
|
return 0.5 * (max_ + min_);
|
||||||
|
}
|
||||||
|
|
||||||
//- The bounding box span (from minimum to maximum)
|
//- The bounding box span (from minimum to maximum)
|
||||||
vector span() const
|
vector span() const
|
||||||
{
|
{
|
||||||
@ -134,28 +153,57 @@ public:
|
|||||||
return ::Foam::mag(max_ - min_);
|
return ::Foam::mag(max_ - min_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Smallest length/height/width dimension
|
||||||
|
scalar minDim() const
|
||||||
|
{
|
||||||
|
return cmptMin(span());
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Largest length/height/width dimension
|
||||||
|
scalar maxDim() const
|
||||||
|
{
|
||||||
|
return cmptMax(span());
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Average length/height/width dimension
|
||||||
|
scalar avgDim() const
|
||||||
|
{
|
||||||
|
return cmptAv(span());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
|
||||||
//- Intersects other boundingBox?
|
//- Completely contains other boundingBox? (inside or on edge)
|
||||||
bool overlaps(const boundBox& bb) const
|
bool overlaps(const boundBox& bb) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
min_.x() <= bb.max().x() && max_.x() >= bb.min().x()
|
bb.max_.x() >= min_.x() && bb.min_.x() <= max_.x()
|
||||||
&& min_.y() <= bb.max().y() && max_.y() >= bb.min().y()
|
&& bb.max_.y() >= min_.y() && bb.min_.y() <= max_.y()
|
||||||
&& min_.z() <= bb.max().z() && max_.z() >= bb.min().z()
|
&& bb.max_.z() >= min_.z() && bb.min_.z() <= max_.z()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Contains a point?
|
//- Contains point? (inside or on edge)
|
||||||
bool contains(const point& pt) const
|
bool contains(const point& pt) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
pt.x() >= min().x() && pt.x() <= max().x()
|
pt.x() >= min_.x() && pt.x() <= max_.x()
|
||||||
&& pt.y() >= min().y() && pt.y() <= max().y()
|
&& pt.y() >= min_.y() && pt.y() <= max_.y()
|
||||||
&& pt.z() >= min().z() && pt.z() <= max().z()
|
&& pt.z() >= min_.z() && pt.z() <= max_.z()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Contains point? (inside only)
|
||||||
|
bool containsInside(const point& pt) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
pt.x() > min_.x() && pt.x() < max_.x()
|
||||||
|
&& pt.y() > min_.y() && pt.y() < max_.y()
|
||||||
|
&& pt.z() > min_.z() && pt.z() < max_.z()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +237,8 @@ inline bool contiguous<boundBox>() {return contiguous<point>();}
|
|||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// #include "boundBoxI.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -728,8 +728,8 @@ void Foam::globalMeshData::updateMesh()
|
|||||||
// Do processor patch addressing
|
// Do processor patch addressing
|
||||||
initProcAddr();
|
initProcAddr();
|
||||||
|
|
||||||
// Bounding box (does communication)
|
// Note: boundBox does reduce
|
||||||
bb_ = boundBox(mesh_.points(), true);
|
bb_ = boundBox(mesh_.points());
|
||||||
|
|
||||||
scalar tolDim = matchTol_ * bb_.mag();
|
scalar tolDim = matchTol_ * bb_.mag();
|
||||||
|
|
||||||
@ -740,7 +740,6 @@ void Foam::globalMeshData::updateMesh()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Option 1. Topological
|
// Option 1. Topological
|
||||||
{
|
{
|
||||||
// Calculate all shared points. This does all the hard work.
|
// Calculate all shared points. This does all the hard work.
|
||||||
@ -770,7 +769,7 @@ void Foam::globalMeshData::updateMesh()
|
|||||||
// processor faces (on highest numbered processor) before summing.
|
// processor faces (on highest numbered processor) before summing.
|
||||||
nTotalFaces_ = mesh_.nFaces();
|
nTotalFaces_ = mesh_.nFaces();
|
||||||
|
|
||||||
// Do not count processorpatch faces that are coincident.
|
// Do not count processor-patch faces that are coincident.
|
||||||
forAll(processorPatches_, i)
|
forAll(processorPatches_, i)
|
||||||
{
|
{
|
||||||
label patchI = processorPatches_[i];
|
label patchI = processorPatches_[i];
|
||||||
|
|||||||
@ -902,7 +902,7 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
|||||||
|
|
||||||
// Extend domain slightly (also makes it 3D if was 2D)
|
// Extend domain slightly (also makes it 3D if was 2D)
|
||||||
// Note asymmetry to avoid having faces align with octree cubes.
|
// Note asymmetry to avoid having faces align with octree cubes.
|
||||||
scalar tol = 1E-6*overallBb.avgDim();
|
scalar tol = 1E-6 * overallBb.avgDim();
|
||||||
|
|
||||||
point& bbMin = overallBb.min();
|
point& bbMin = overallBb.min();
|
||||||
bbMin.x() -= tol;
|
bbMin.x() -= tol;
|
||||||
|
|||||||
@ -224,8 +224,8 @@ void Foam::displacementSBRStressFvMotionSolver::updateMesh
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Note: boundBox does reduce
|
// Note: boundBox does reduce
|
||||||
const vector span0 = boundBox(points0_, true).span();
|
const vector span0 = boundBox(points0_).span();
|
||||||
const vector span = boundBox(points, true).span();
|
const vector span = boundBox(points).span();
|
||||||
|
|
||||||
vector scaleFactors(cmptDivide(span0, span));
|
vector scaleFactors(cmptDivide(span0, span));
|
||||||
|
|
||||||
@ -246,13 +246,11 @@ void Foam::displacementSBRStressFvMotionSolver::updateMesh
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// New point. Assume motion is scaling.
|
// New point. Assume motion is scaling.
|
||||||
newPoints0[pointI] =
|
newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
|
||||||
points0_[oldPointI]
|
(
|
||||||
+ cmptMultiply
|
scaleFactors,
|
||||||
(
|
points[pointI]-points[masterPointI]
|
||||||
scaleFactors,
|
);
|
||||||
points[pointI]-points[masterPointI]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -433,8 +433,8 @@ void Foam::displacementInterpolationFvMotionSolver::updateMesh
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Note: boundBox does reduce
|
// Note: boundBox does reduce
|
||||||
const vector span0 = boundBox(points0_, true).span();
|
const vector span0 = boundBox(points0_).span();
|
||||||
const vector span = boundBox(points, true).span();
|
const vector span = boundBox(points).span();
|
||||||
|
|
||||||
vector scaleFactors(cmptDivide(span0, span));
|
vector scaleFactors(cmptDivide(span0, span));
|
||||||
|
|
||||||
@ -455,13 +455,11 @@ void Foam::displacementInterpolationFvMotionSolver::updateMesh
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// New point. Assume motion is scaling.
|
// New point. Assume motion is scaling.
|
||||||
newPoints0[pointI] =
|
newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
|
||||||
points0_[oldPointI]
|
(
|
||||||
+ cmptMultiply
|
scaleFactors,
|
||||||
(
|
points[pointI]-points[masterPointI]
|
||||||
scaleFactors,
|
);
|
||||||
points[pointI]-points[masterPointI]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -272,8 +272,8 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Note: boundBox does reduce
|
// Note: boundBox does reduce
|
||||||
const vector span0 = boundBox(points0_, true).span();
|
const vector span0 = boundBox(points0_).span();
|
||||||
const vector span = boundBox(points, true).span();
|
const vector span = boundBox(points).span();
|
||||||
|
|
||||||
vector scaleFactors(cmptDivide(span0, span));
|
vector scaleFactors(cmptDivide(span0, span));
|
||||||
|
|
||||||
@ -294,13 +294,11 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// New point. Assume motion is scaling.
|
// New point. Assume motion is scaling.
|
||||||
newPoints0[pointI] =
|
newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
|
||||||
points0_[oldPointI]
|
(
|
||||||
+ cmptMultiply
|
scaleFactors,
|
||||||
(
|
points[pointI]-points[masterPointI]
|
||||||
scaleFactors,
|
);
|
||||||
points[pointI]-points[masterPointI]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -63,7 +63,7 @@ Foam::label Foam::cellClassification::count
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ Foam::boolList Foam::cellClassification::markFaces
|
|||||||
treeBoundBox allBb(mesh_.points());
|
treeBoundBox allBb(mesh_.points());
|
||||||
|
|
||||||
// Extend domain slightly (also makes it 3D if was 2D)
|
// Extend domain slightly (also makes it 3D if was 2D)
|
||||||
scalar tol = 1E-6*allBb.avgDim();
|
scalar tol = 1E-6 * allBb.avgDim();
|
||||||
|
|
||||||
point& bbMin = allBb.min();
|
point& bbMin = allBb.min();
|
||||||
bbMin.x() -= tol;
|
bbMin.x() -= tol;
|
||||||
@ -166,9 +166,9 @@ Foam::boolList Foam::cellClassification::markFaces
|
|||||||
(
|
(
|
||||||
treeDataFace(false, mesh_, allFaces),
|
treeDataFace(false, mesh_, allFaces),
|
||||||
allBb, // overall search domain
|
allBb, // overall search domain
|
||||||
8, // maxLevel
|
8, // maxLevel
|
||||||
10, // leafsize
|
10, // leafsize
|
||||||
3.0 // duplicity
|
3.0 // duplicity
|
||||||
);
|
);
|
||||||
|
|
||||||
const triSurface& surf = search.surface();
|
const triSurface& surf = search.surface();
|
||||||
@ -359,7 +359,7 @@ void Foam::cellClassification::classifyPoints
|
|||||||
const labelList& pCells = mesh_.pointCells()[pointI];
|
const labelList& pCells = mesh_.pointCells()[pointI];
|
||||||
|
|
||||||
pointSide[pointI] = UNSET;
|
pointSide[pointI] = UNSET;
|
||||||
|
|
||||||
forAll(pCells, i)
|
forAll(pCells, i)
|
||||||
{
|
{
|
||||||
label type = cellType[pCells[i]];
|
label type = cellType[pCells[i]];
|
||||||
@ -665,7 +665,7 @@ Foam::label Foam::cellClassification::growSurface
|
|||||||
|
|
||||||
nChanged++;
|
nChanged++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nChanged;
|
return nChanged;
|
||||||
@ -694,7 +694,7 @@ Foam::label Foam::cellClassification::fillHangingCells
|
|||||||
classifyPoints(meshType, *this, pointSide);
|
classifyPoints(meshType, *this, pointSide);
|
||||||
|
|
||||||
// Check all cells using mixed point type for whether they use mixed
|
// Check all cells using mixed point type for whether they use mixed
|
||||||
// points only. Note: could probably speed this up by counting number
|
// points only. Note: could probably speed this up by counting number
|
||||||
// of mixed verts per face and mixed faces per cell or something?
|
// of mixed verts per face and mixed faces per cell or something?
|
||||||
forAll(pointSide, pointI)
|
forAll(pointSide, pointI)
|
||||||
{
|
{
|
||||||
@ -800,7 +800,7 @@ Foam::label Foam::cellClassification::fillRegionEdges
|
|||||||
|
|
||||||
return nTotChanged;
|
return nTotChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::cellClassification::fillRegionPoints
|
Foam::label Foam::cellClassification::fillRegionPoints
|
||||||
(
|
(
|
||||||
|
|||||||
@ -26,21 +26,16 @@ License
|
|||||||
|
|
||||||
#include "indexedOctree.H"
|
#include "indexedOctree.H"
|
||||||
#include "linePointRef.H"
|
#include "linePointRef.H"
|
||||||
//#include "triSurface.H"
|
// #include "triSurface.H"
|
||||||
#include "meshTools.H"
|
#include "meshTools.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
// Does bb intersect a sphere around sample? Or is any corner point of bb
|
// Does bb intersect a sphere around sample? Or is any corner point of bb
|
||||||
// closer than nearestDistSqr to sample.
|
// closer than nearestDistSqr to sample.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool indexedOctree<Type>::overlaps
|
bool Foam::indexedOctree<Type>::overlaps
|
||||||
(
|
(
|
||||||
const point& p0,
|
const point& p0,
|
||||||
const point& p1,
|
const point& p1,
|
||||||
@ -84,7 +79,7 @@ bool indexedOctree<Type>::overlaps
|
|||||||
// Does bb intersect a sphere around sample? Or is any corner point of bb
|
// Does bb intersect a sphere around sample? Or is any corner point of bb
|
||||||
// closer than nearestDistSqr to sample.
|
// closer than nearestDistSqr to sample.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool indexedOctree<Type>::overlaps
|
bool Foam::indexedOctree<Type>::overlaps
|
||||||
(
|
(
|
||||||
const treeBoundBox& parentBb,
|
const treeBoundBox& parentBb,
|
||||||
const direction octant,
|
const direction octant,
|
||||||
@ -92,7 +87,7 @@ bool indexedOctree<Type>::overlaps
|
|||||||
const point& sample
|
const point& sample
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//- Speeded up version of
|
//- Accelerated version of
|
||||||
// treeBoundBox subBb(parentBb.subBbox(mid, octant))
|
// treeBoundBox subBb(parentBb.subBbox(mid, octant))
|
||||||
// overlaps
|
// overlaps
|
||||||
// (
|
// (
|
||||||
@ -147,7 +142,7 @@ bool indexedOctree<Type>::overlaps
|
|||||||
|
|
||||||
// Split list of indices into 8 bins
|
// Split list of indices into 8 bins
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::divide
|
void Foam::indexedOctree<Type>::divide
|
||||||
(
|
(
|
||||||
const labelList& indices,
|
const labelList& indices,
|
||||||
const treeBoundBox& bb,
|
const treeBoundBox& bb,
|
||||||
@ -190,7 +185,8 @@ void indexedOctree<Type>::divide
|
|||||||
|
|
||||||
// Subdivide the (content) node.
|
// Subdivide the (content) node.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename indexedOctree<Type>::node indexedOctree<Type>::divide
|
typename Foam::indexedOctree<Type>::node
|
||||||
|
Foam::indexedOctree<Type>::divide
|
||||||
(
|
(
|
||||||
const treeBoundBox& bb,
|
const treeBoundBox& bb,
|
||||||
DynamicList<labelList>& contents,
|
DynamicList<labelList>& contents,
|
||||||
@ -259,7 +255,7 @@ typename indexedOctree<Type>::node indexedOctree<Type>::divide
|
|||||||
|
|
||||||
// Split any contents node with more than minSize elements.
|
// Split any contents node with more than minSize elements.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::splitNodes
|
void Foam::indexedOctree<Type>::splitNodes
|
||||||
(
|
(
|
||||||
const label minSize,
|
const label minSize,
|
||||||
DynamicList<indexedOctree<Type>::node>& nodes,
|
DynamicList<indexedOctree<Type>::node>& nodes,
|
||||||
@ -313,7 +309,7 @@ void indexedOctree<Type>::splitNodes
|
|||||||
// Reorder contents to be in same order as nodes. Returns number of nodes on
|
// Reorder contents to be in same order as nodes. Returns number of nodes on
|
||||||
// the compactLevel.
|
// the compactLevel.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label indexedOctree<Type>::compactContents
|
Foam::label Foam::indexedOctree<Type>::compactContents
|
||||||
(
|
(
|
||||||
DynamicList<node>& nodes,
|
DynamicList<node>& nodes,
|
||||||
DynamicList<labelList>& contents,
|
DynamicList<labelList>& contents,
|
||||||
@ -383,7 +379,8 @@ label indexedOctree<Type>::compactContents
|
|||||||
// Recurses to determine status of lowest level boxes. Level above is
|
// Recurses to determine status of lowest level boxes. Level above is
|
||||||
// combination of octants below.
|
// combination of octants below.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::calcVolumeType
|
typename Foam::indexedOctree<Type>::volumeType
|
||||||
|
Foam::indexedOctree<Type>::calcVolumeType
|
||||||
(
|
(
|
||||||
const label nodeI
|
const label nodeI
|
||||||
) const
|
) const
|
||||||
@ -415,7 +412,10 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::calcVolumeType
|
|||||||
// of its bounding box.
|
// of its bounding box.
|
||||||
const treeBoundBox subBb = nod.bb_.subBbox(octant);
|
const treeBoundBox subBb = nod.bb_.subBbox(octant);
|
||||||
|
|
||||||
subType = volumeType(shapes_.getVolumeType(*this, subBb.mid()));
|
subType = volumeType
|
||||||
|
(
|
||||||
|
shapes_.getVolumeType(*this, subBb.midpoint())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store octant type
|
// Store octant type
|
||||||
@ -437,7 +437,8 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::calcVolumeType
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
typename Foam::indexedOctree<Type>::volumeType
|
||||||
|
Foam::indexedOctree<Type>::getVolumeType
|
||||||
(
|
(
|
||||||
const label nodeI,
|
const label nodeI,
|
||||||
const point& sample
|
const point& sample
|
||||||
@ -512,7 +513,8 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::getSide
|
typename Foam::indexedOctree<Type>::volumeType
|
||||||
|
Foam::indexedOctree<Type>::getSide
|
||||||
(
|
(
|
||||||
const vector& outsideNormal,
|
const vector& outsideNormal,
|
||||||
const vector& vec
|
const vector& vec
|
||||||
@ -536,7 +538,7 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::getSide
|
|||||||
|
|
||||||
// Find nearest point starting from nodeI
|
// Find nearest point starting from nodeI
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::findNearest
|
void Foam::indexedOctree<Type>::findNearest
|
||||||
(
|
(
|
||||||
const label nodeI,
|
const label nodeI,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
@ -608,7 +610,7 @@ void indexedOctree<Type>::findNearest
|
|||||||
|
|
||||||
// Find nearest point to line.
|
// Find nearest point to line.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::findNearest
|
void Foam::indexedOctree<Type>::findNearest
|
||||||
(
|
(
|
||||||
const label nodeI,
|
const label nodeI,
|
||||||
const linePointRef& ln,
|
const linePointRef& ln,
|
||||||
@ -678,7 +680,7 @@ void indexedOctree<Type>::findNearest
|
|||||||
// the faceID (one of treeBoundBox::LEFTBIT, RIGHTBIT etc.)
|
// the faceID (one of treeBoundBox::LEFTBIT, RIGHTBIT etc.)
|
||||||
// Returns false if edge of tree hit.
|
// Returns false if edge of tree hit.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool indexedOctree<Type>::walkToNeighbour
|
bool Foam::indexedOctree<Type>::walkToNeighbour
|
||||||
(
|
(
|
||||||
const point& facePoint,
|
const point& facePoint,
|
||||||
const direction faceID, // direction to walk in
|
const direction faceID, // direction to walk in
|
||||||
@ -785,7 +787,11 @@ bool indexedOctree<Type>::walkToNeighbour
|
|||||||
// (number is single bit but not really nessecary)
|
// (number is single bit but not really nessecary)
|
||||||
// Return 0 if point not on any face of bb.
|
// Return 0 if point not on any face of bb.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
direction indexedOctree<Type>::getFace(const treeBoundBox& bb, const point& pt)
|
Foam::direction Foam::indexedOctree<Type>::getFace
|
||||||
|
(
|
||||||
|
const treeBoundBox& bb,
|
||||||
|
const point& pt
|
||||||
|
)
|
||||||
{
|
{
|
||||||
direction faceID = 0;
|
direction faceID = 0;
|
||||||
|
|
||||||
@ -824,7 +830,7 @@ direction indexedOctree<Type>::getFace(const treeBoundBox& bb, const point& pt)
|
|||||||
// hitInfo.point = coordinate of intersection of ray with bounding box
|
// hitInfo.point = coordinate of intersection of ray with bounding box
|
||||||
// faceID = index of bounding box face
|
// faceID = index of bounding box face
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::traverseNode
|
void Foam::indexedOctree<Type>::traverseNode
|
||||||
(
|
(
|
||||||
const bool findAny,
|
const bool findAny,
|
||||||
const point& start,
|
const point& start,
|
||||||
@ -950,7 +956,7 @@ void indexedOctree<Type>::traverseNode
|
|||||||
|
|
||||||
// Find first intersection
|
// Find first intersection
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit indexedOctree<Type>::findLine
|
Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
|
||||||
(
|
(
|
||||||
const bool findAny,
|
const bool findAny,
|
||||||
const point& treeStart,
|
const point& treeStart,
|
||||||
@ -1037,7 +1043,7 @@ pointIndexHit indexedOctree<Type>::findLine
|
|||||||
|
|
||||||
// Find first intersection
|
// Find first intersection
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit indexedOctree<Type>::findLine
|
Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
|
||||||
(
|
(
|
||||||
const bool findAny,
|
const bool findAny,
|
||||||
const point& start,
|
const point& start,
|
||||||
@ -1101,7 +1107,7 @@ pointIndexHit indexedOctree<Type>::findLine
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::findBox
|
void Foam::indexedOctree<Type>::findBox
|
||||||
(
|
(
|
||||||
const label nodeI,
|
const label nodeI,
|
||||||
const treeBoundBox& searchBox,
|
const treeBoundBox& searchBox,
|
||||||
@ -1149,7 +1155,10 @@ void indexedOctree<Type>::findBox
|
|||||||
|
|
||||||
// Number of elements in node.
|
// Number of elements in node.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label indexedOctree<Type>::countElements(const labelBits index) const
|
Foam::label Foam::indexedOctree<Type>::countElements
|
||||||
|
(
|
||||||
|
const labelBits index
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
label nElems = 0;
|
label nElems = 0;
|
||||||
|
|
||||||
@ -1179,7 +1188,7 @@ label indexedOctree<Type>::countElements(const labelBits index) const
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::writeOBJ
|
void Foam::indexedOctree<Type>::writeOBJ
|
||||||
(
|
(
|
||||||
const label nodeI,
|
const label nodeI,
|
||||||
const direction octant
|
const direction octant
|
||||||
@ -1256,7 +1265,7 @@ void indexedOctree<Type>::writeOBJ
|
|||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
indexedOctree<Type>::indexedOctree(const Type& shapes)
|
Foam::indexedOctree<Type>::indexedOctree(const Type& shapes)
|
||||||
:
|
:
|
||||||
shapes_(shapes),
|
shapes_(shapes),
|
||||||
nodes_(0),
|
nodes_(0),
|
||||||
@ -1266,7 +1275,7 @@ indexedOctree<Type>::indexedOctree(const Type& shapes)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
indexedOctree<Type>::indexedOctree
|
Foam::indexedOctree<Type>::indexedOctree
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const List<node>& nodes,
|
const List<node>& nodes,
|
||||||
@ -1281,7 +1290,7 @@ indexedOctree<Type>::indexedOctree
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
indexedOctree<Type>::indexedOctree
|
Foam::indexedOctree<Type>::indexedOctree
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const treeBoundBox& bb,
|
const treeBoundBox& bb,
|
||||||
@ -1422,7 +1431,7 @@ indexedOctree<Type>::indexedOctree
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
indexedOctree<Type>::indexedOctree
|
Foam::indexedOctree<Type>::indexedOctree
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
Istream& is
|
Istream& is
|
||||||
@ -1438,7 +1447,7 @@ indexedOctree<Type>::indexedOctree
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit indexedOctree<Type>::findNearest
|
Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& sample,
|
||||||
const scalar startDistSqr
|
const scalar startDistSqr
|
||||||
@ -1470,7 +1479,7 @@ pointIndexHit indexedOctree<Type>::findNearest
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit indexedOctree<Type>::findNearest
|
Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
|
||||||
(
|
(
|
||||||
const linePointRef& ln,
|
const linePointRef& ln,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
@ -1504,7 +1513,7 @@ pointIndexHit indexedOctree<Type>::findNearest
|
|||||||
|
|
||||||
// Find nearest intersection
|
// Find nearest intersection
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit indexedOctree<Type>::findLine
|
Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
|
||||||
(
|
(
|
||||||
const point& start,
|
const point& start,
|
||||||
const point& end
|
const point& end
|
||||||
@ -1516,7 +1525,7 @@ pointIndexHit indexedOctree<Type>::findLine
|
|||||||
|
|
||||||
// Find nearest intersection
|
// Find nearest intersection
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit indexedOctree<Type>::findLineAny
|
Foam::pointIndexHit Foam::indexedOctree<Type>::findLineAny
|
||||||
(
|
(
|
||||||
const point& start,
|
const point& start,
|
||||||
const point& end
|
const point& end
|
||||||
@ -1527,7 +1536,10 @@ pointIndexHit indexedOctree<Type>::findLineAny
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
labelList indexedOctree<Type>::findBox(const boundBox& searchBox) const
|
Foam::labelList Foam::indexedOctree<Type>::findBox
|
||||||
|
(
|
||||||
|
const boundBox& searchBox
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
// Storage for labels of shapes inside bb. Size estimate.
|
// Storage for labels of shapes inside bb. Size estimate.
|
||||||
labelHashSet elements(shapes_.size() / 100);
|
labelHashSet elements(shapes_.size() / 100);
|
||||||
@ -1543,7 +1555,7 @@ labelList indexedOctree<Type>::findBox(const boundBox& searchBox) const
|
|||||||
|
|
||||||
// Find node (as parent+octant) containing point
|
// Find node (as parent+octant) containing point
|
||||||
template <class Type>
|
template <class Type>
|
||||||
labelBits indexedOctree<Type>::findNode
|
Foam::labelBits Foam::indexedOctree<Type>::findNode
|
||||||
(
|
(
|
||||||
const label nodeI,
|
const label nodeI,
|
||||||
const point& sample
|
const point& sample
|
||||||
@ -1581,7 +1593,8 @@ labelBits indexedOctree<Type>::findNode
|
|||||||
|
|
||||||
// Determine type (inside/outside/mixed) per node.
|
// Determine type (inside/outside/mixed) per node.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
typename Foam::indexedOctree<Type>::volumeType
|
||||||
|
Foam::indexedOctree<Type>::getVolumeType
|
||||||
(
|
(
|
||||||
const point& sample
|
const point& sample
|
||||||
) const
|
) const
|
||||||
@ -1651,7 +1664,7 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
|||||||
|
|
||||||
// Print contents of nodeI
|
// Print contents of nodeI
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void indexedOctree<Type>::print
|
void Foam::indexedOctree<Type>::print
|
||||||
(
|
(
|
||||||
prefixOSstream& os,
|
prefixOSstream& os,
|
||||||
const bool printContents,
|
const bool printContents,
|
||||||
@ -1715,7 +1728,7 @@ void indexedOctree<Type>::print
|
|||||||
|
|
||||||
// Print contents of nodeI
|
// Print contents of nodeI
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool indexedOctree<Type>::write(Ostream& os) const
|
bool Foam::indexedOctree<Type>::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << *this;
|
os << *this;
|
||||||
|
|
||||||
@ -1724,7 +1737,7 @@ bool indexedOctree<Type>::write(Ostream& os) const
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Ostream& operator<<(Ostream& os, const indexedOctree<Type>& t)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const indexedOctree<Type>& t)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
os << t.bb() << token::SPACE << t.nodes()
|
os << t.bb() << token::SPACE << t.nodes()
|
||||||
@ -1732,8 +1745,4 @@ Ostream& operator<<(Ostream& os, const indexedOctree<Type>& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -34,15 +34,10 @@ Description
|
|||||||
#include "linePointRef.H"
|
#include "linePointRef.H"
|
||||||
#include "pointIndexHit.H"
|
#include "pointIndexHit.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
string octree<Type>::volType(const label type)
|
Foam::string Foam::octree<Type>::volType(const label type)
|
||||||
{
|
{
|
||||||
if (type == UNKNOWN)
|
if (type == UNKNOWN)
|
||||||
{
|
{
|
||||||
@ -70,10 +65,13 @@ string octree<Type>::volType(const label type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Determine inside/outside status of vector compared to geometry based
|
// Determine inside/outside status of vector compared to geometry-based normal
|
||||||
// normal
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label octree<Type>::getVolType(const vector& geomNormal, const vector& vec)
|
Foam::label Foam::octree<Type>::getVolType
|
||||||
|
(
|
||||||
|
const vector& geomNormal,
|
||||||
|
const vector& vec
|
||||||
|
)
|
||||||
{
|
{
|
||||||
scalar sign = geomNormal & vec;
|
scalar sign = geomNormal & vec;
|
||||||
|
|
||||||
@ -91,7 +89,7 @@ label octree<Type>::getVolType(const vector& geomNormal, const vector& vec)
|
|||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octree<Type>::octree
|
Foam::octree<Type>::octree
|
||||||
(
|
(
|
||||||
const treeBoundBox& octreeBb,
|
const treeBoundBox& octreeBb,
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
@ -141,7 +139,7 @@ octree<Type>::octree
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Breadth first creation of tree
|
// Breadth first creation of tree
|
||||||
// Stop if: - level above minlevel and
|
// Stop if: - level above minlevel and
|
||||||
// - less than so many cells per endpoint
|
// - less than so many cells per endpoint
|
||||||
// (so bottom level is fine enough)
|
// (so bottom level is fine enough)
|
||||||
// - every shape mentioned in only so many
|
// - every shape mentioned in only so many
|
||||||
@ -233,7 +231,7 @@ octree<Type>::octree
|
|||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octree<Type>::~octree()
|
Foam::octree<Type>::~octree()
|
||||||
{
|
{
|
||||||
delete topNode_;
|
delete topNode_;
|
||||||
}
|
}
|
||||||
@ -242,45 +240,44 @@ octree<Type>::~octree()
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label octree<Type>::getSampleType(const point& sample) const
|
Foam::label Foam::octree<Type>::getSampleType(const point& sample) const
|
||||||
{
|
{
|
||||||
return topNode_->getSampleType(0, *this, shapes_, sample);
|
return topNode_->getSampleType(0, *this, shapes_, sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label octree<Type>::find(const point& sample) const
|
Foam::label Foam::octree<Type>::find(const point& sample) const
|
||||||
{
|
{
|
||||||
return topNode_->find(shapes_, sample);
|
return topNode_->find(shapes_, sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool octree<Type>::findTightest(const point& sample, treeBoundBox& tightest)
|
bool Foam::octree<Type>::findTightest
|
||||||
const
|
(
|
||||||
|
const point& sample,
|
||||||
|
treeBoundBox& tightest
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
label tightesti = -1;
|
return topNode_->findTightest
|
||||||
scalar tightestDist = GREAT;
|
(
|
||||||
|
shapes_,
|
||||||
return
|
sample,
|
||||||
topNode_->findTightest
|
tightest
|
||||||
(
|
);
|
||||||
shapes_,
|
|
||||||
sample,
|
|
||||||
tightest
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label octree<Type>::findNearest
|
Foam::label Foam::octree<Type>::findNearest
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
label tightesti = -1;
|
label tightestI = -1;
|
||||||
|
|
||||||
if (debug & 4)
|
if (debug & 4)
|
||||||
{
|
{
|
||||||
@ -294,7 +291,7 @@ label octree<Type>::findNearest
|
|||||||
shapes_,
|
shapes_,
|
||||||
sample,
|
sample,
|
||||||
tightest,
|
tightest,
|
||||||
tightesti,
|
tightestI,
|
||||||
tightestDist
|
tightestDist
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -302,18 +299,18 @@ label octree<Type>::findNearest
|
|||||||
{
|
{
|
||||||
Pout<< "octree::findNearest : found nearest for "
|
Pout<< "octree::findNearest : found nearest for "
|
||||||
<< "sample:" << sample << " with "
|
<< "sample:" << sample << " with "
|
||||||
<< " tightesti:" << tightesti
|
<< " tightestI:" << tightestI
|
||||||
<< " tightest:" << tightest
|
<< " tightest:" << tightest
|
||||||
<< " tightestDist:" << tightestDist
|
<< " tightestDist:" << tightestDist
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tightesti;
|
return tightestI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label octree<Type>::findNearest
|
Foam::label Foam::octree<Type>::findNearest
|
||||||
(
|
(
|
||||||
const linePointRef& ln,
|
const linePointRef& ln,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
@ -322,7 +319,7 @@ label octree<Type>::findNearest
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Start off from miss with points at large distance apart.
|
// Start off from miss with points at large distance apart.
|
||||||
label tightesti = -1;
|
label tightestI = -1;
|
||||||
linePoint = point(-GREAT, -GREAT, -GREAT);
|
linePoint = point(-GREAT, -GREAT, -GREAT);
|
||||||
shapePoint = point(GREAT, GREAT, GREAT);
|
shapePoint = point(GREAT, GREAT, GREAT);
|
||||||
|
|
||||||
@ -331,17 +328,17 @@ label octree<Type>::findNearest
|
|||||||
shapes_,
|
shapes_,
|
||||||
ln,
|
ln,
|
||||||
tightest,
|
tightest,
|
||||||
tightesti,
|
tightestI,
|
||||||
linePoint,
|
linePoint,
|
||||||
shapePoint
|
shapePoint
|
||||||
);
|
);
|
||||||
|
|
||||||
return tightesti;
|
return tightestI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
labelList octree<Type>::findBox(const boundBox& bb) const
|
Foam::labelList Foam::octree<Type>::findBox(const boundBox& bb) const
|
||||||
{
|
{
|
||||||
// Storage for labels of shapes inside bb. Size estimate.
|
// Storage for labels of shapes inside bb. Size estimate.
|
||||||
labelHashSet elements(100);
|
labelHashSet elements(100);
|
||||||
@ -353,7 +350,7 @@ labelList octree<Type>::findBox(const boundBox& bb) const
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit octree<Type>::findLine
|
Foam::pointIndexHit Foam::octree<Type>::findLine
|
||||||
(
|
(
|
||||||
const point& treeStart,
|
const point& treeStart,
|
||||||
const point& treeEnd
|
const point& treeEnd
|
||||||
@ -368,18 +365,17 @@ pointIndexHit octree<Type>::findLine
|
|||||||
point start(treeStart);
|
point start(treeStart);
|
||||||
point end(treeEnd);
|
point end(treeEnd);
|
||||||
|
|
||||||
while(true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Find nearest treeLeaf intersected by line
|
// Find nearest treeLeaf intersected by line
|
||||||
point leafIntPoint;
|
point leafIntPoint;
|
||||||
|
|
||||||
const treeLeaf<Type>* leafPtr =
|
const treeLeaf<Type>* leafPtr = findLeafLine
|
||||||
findLeafLine
|
(
|
||||||
(
|
start,
|
||||||
start,
|
end,
|
||||||
end,
|
leafIntPoint
|
||||||
leafIntPoint
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (!leafPtr)
|
if (!leafPtr)
|
||||||
{
|
{
|
||||||
@ -389,7 +385,7 @@ pointIndexHit octree<Type>::findLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inside treeLeaf find nearest intersection
|
// Inside treeLeaf find nearest intersection
|
||||||
scalar minS = GREAT;
|
scalar minS = GREAT;
|
||||||
|
|
||||||
const labelList& indices = leafPtr->indices();
|
const labelList& indices = leafPtr->indices();
|
||||||
|
|
||||||
@ -435,15 +431,18 @@ pointIndexHit octree<Type>::findLine
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
pointIndexHit octree<Type>::findLineAny(const point& start, const point& end)
|
Foam::pointIndexHit Foam::octree<Type>::findLineAny
|
||||||
const
|
(
|
||||||
|
const point& start,
|
||||||
|
const point& end
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
// Initialize to a miss
|
// Initialize to a miss
|
||||||
pointIndexHit hitInfo(false, start, -1);
|
pointIndexHit hitInfo(false, start, -1);
|
||||||
|
|
||||||
// Start of segment in current treeNode.
|
// Start of segment in current treeNode.
|
||||||
point p(start);
|
point p(start);
|
||||||
while(true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Find treeLeaf intersected by line
|
// Find treeLeaf intersected by line
|
||||||
point leafIntPoint;
|
point leafIntPoint;
|
||||||
@ -469,14 +468,13 @@ pointIndexHit octree<Type>::findLineAny(const point& start, const point& end)
|
|||||||
label index = indices[elemI];
|
label index = indices[elemI];
|
||||||
|
|
||||||
point pt;
|
point pt;
|
||||||
bool hit =
|
bool hit = shapes().intersects
|
||||||
shapes().intersects
|
(
|
||||||
(
|
index,
|
||||||
index,
|
p,
|
||||||
p,
|
end,
|
||||||
end,
|
pt
|
||||||
pt
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (hit)
|
if (hit)
|
||||||
{
|
{
|
||||||
@ -503,7 +501,7 @@ pointIndexHit octree<Type>::findLineAny(const point& start, const point& end)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
const treeLeaf<Type>* octree<Type>::findLeafLine
|
const Foam::treeLeaf<Type>* Foam::octree<Type>::findLeafLine
|
||||||
(
|
(
|
||||||
const point& start,
|
const point& start,
|
||||||
const point& end,
|
const point& end,
|
||||||
@ -518,7 +516,7 @@ const treeLeaf<Type>* octree<Type>::findLeafLine
|
|||||||
<< "start:" << start
|
<< "start:" << start
|
||||||
<< " end:" << end << endl;
|
<< " end:" << end << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If start is outside project onto top cube
|
// If start is outside project onto top cube
|
||||||
if (octreeBb_.contains(start))
|
if (octreeBb_.contains(start))
|
||||||
{
|
{
|
||||||
@ -546,14 +544,13 @@ const treeLeaf<Type>* octree<Type>::findLeafLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normal action: find next intersection along line
|
// Normal action: find next intersection along line
|
||||||
const treeLeaf<Type>* leafPtr =
|
const treeLeaf<Type>* leafPtr = topNode_->findLeafLine
|
||||||
topNode_->findLeafLine
|
(
|
||||||
(
|
0,
|
||||||
0,
|
shapes_,
|
||||||
shapes_,
|
leafIntPoint,
|
||||||
leafIntPoint,
|
end
|
||||||
end
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (debug & 2)
|
if (debug & 2)
|
||||||
{
|
{
|
||||||
@ -567,7 +564,11 @@ const treeLeaf<Type>* octree<Type>::findLeafLine
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void octree<Type>::writeOBJ(Ostream& os, label& vertNo) const
|
void Foam::octree<Type>::writeOBJ
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
label& vertNo
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
scalar minx = octreeBb_.min().x();
|
scalar minx = octreeBb_.min().x();
|
||||||
scalar miny = octreeBb_.min().y();
|
scalar miny = octreeBb_.min().y();
|
||||||
@ -587,7 +588,7 @@ void octree<Type>::writeOBJ(Ostream& os, label& vertNo) const
|
|||||||
os << "v " << maxx << " " << maxy << " " << maxz << endl;
|
os << "v " << maxx << " " << maxy << " " << maxz << endl;
|
||||||
os << "v " << minx << " " << maxy << " " << maxz << endl;
|
os << "v " << minx << " " << maxy << " " << maxz << endl;
|
||||||
|
|
||||||
// Botttom face
|
// Bottom face
|
||||||
os << "l " << vertNo + 1 << " " << vertNo + 2 << endl;
|
os << "l " << vertNo + 1 << " " << vertNo + 2 << endl;
|
||||||
os << "l " << vertNo + 2 << " " << vertNo + 3 << endl;
|
os << "l " << vertNo + 2 << " " << vertNo + 3 << endl;
|
||||||
os << "l " << vertNo + 3 << " " << vertNo + 4 << endl;
|
os << "l " << vertNo + 3 << " " << vertNo + 4 << endl;
|
||||||
@ -612,7 +613,7 @@ void octree<Type>::writeOBJ(Ostream& os, label& vertNo) const
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void octree<Type>::printStats(Ostream& os) const
|
void Foam::octree<Type>::printStats(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << "Statistics after iteration " << deepestLevel() << ':' << endl
|
os << "Statistics after iteration " << deepestLevel() << ':' << endl
|
||||||
<< " nShapes :" << shapes().size() << endl
|
<< " nShapes :" << shapes().size() << endl
|
||||||
@ -637,7 +638,7 @@ void octree<Type>::printStats(Ostream& os) const
|
|||||||
|
|
||||||
// Construct from a octree. Set index at end.
|
// Construct from a octree. Set index at end.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octree<Type>::iterator::iterator(octree<Type>& oc)
|
Foam::octree<Type>::iterator::iterator(octree<Type>& oc)
|
||||||
:
|
:
|
||||||
octree_(oc),
|
octree_(oc),
|
||||||
curLeaf_(oc.nLeaves())
|
curLeaf_(oc.nLeaves())
|
||||||
@ -648,7 +649,7 @@ octree<Type>::iterator::iterator(octree<Type>& oc)
|
|||||||
|
|
||||||
// Construct from octree. Set index.
|
// Construct from octree. Set index.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octree<Type>::iterator::iterator(octree<Type>& oc, label index)
|
Foam::octree<Type>::iterator::iterator(octree<Type>& oc, label index)
|
||||||
:
|
:
|
||||||
octree_(oc),
|
octree_(oc),
|
||||||
curLeaf_(index)
|
curLeaf_(index)
|
||||||
@ -676,7 +677,7 @@ octree<Type>::iterator::iterator(octree<Type>& oc, label index)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void octree<Type>::iterator::operator=(const iterator& iter)
|
void Foam::octree<Type>::iterator::operator=(const iterator& iter)
|
||||||
{
|
{
|
||||||
if ((curLeaf_ < 0) && (iter.curLeaf_ >= 0))
|
if ((curLeaf_ < 0) && (iter.curLeaf_ >= 0))
|
||||||
{
|
{
|
||||||
@ -694,7 +695,7 @@ void octree<Type>::iterator::operator=(const iterator& iter)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool octree<Type>::iterator::operator==(const iterator& iter) const
|
bool Foam::octree<Type>::iterator::operator==(const iterator& iter) const
|
||||||
{
|
{
|
||||||
label index1 =
|
label index1 =
|
||||||
(curLeaf_ >= 0 ? curLeaf_ : octree_.nLeaves());
|
(curLeaf_ >= 0 ? curLeaf_ : octree_.nLeaves());
|
||||||
@ -706,21 +707,22 @@ bool octree<Type>::iterator::operator==(const iterator& iter) const
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool octree<Type>::iterator::operator!=(const iterator& iter) const
|
bool Foam::octree<Type>::iterator::operator!=(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return !(iterator::operator==(iter));
|
return !(iterator::operator==(iter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeLeaf<Type>& octree<Type>::iterator::operator*()
|
Foam::treeLeaf<Type>& Foam::octree<Type>::iterator::operator*()
|
||||||
{
|
{
|
||||||
return *leaves_[curLeaf_];
|
return *leaves_[curLeaf_];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename octree<Type>::iterator& octree<Type>::iterator::operator++()
|
typename Foam::octree<Type>::iterator&
|
||||||
|
Foam::octree<Type>::iterator::operator++()
|
||||||
{
|
{
|
||||||
curLeaf_++;
|
curLeaf_++;
|
||||||
return *this;
|
return *this;
|
||||||
@ -728,7 +730,8 @@ typename octree<Type>::iterator& octree<Type>::iterator::operator++()
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename octree<Type>::iterator octree<Type>::iterator::operator++(int)
|
typename Foam::octree<Type>::iterator
|
||||||
|
Foam::octree<Type>::iterator::operator++(int)
|
||||||
{
|
{
|
||||||
iterator tmp = *this;
|
iterator tmp = *this;
|
||||||
++*this;
|
++*this;
|
||||||
@ -737,14 +740,16 @@ typename octree<Type>::iterator octree<Type>::iterator::operator++(int)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename octree<Type>::iterator octree<Type>::begin()
|
typename Foam::octree<Type>::iterator
|
||||||
|
Foam::octree<Type>::begin()
|
||||||
{
|
{
|
||||||
return iterator(*this, 0);
|
return iterator(*this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
const typename octree<Type>::iterator& octree<Type>::end()
|
const typename Foam::octree<Type>::iterator&
|
||||||
|
Foam::octree<Type>::end()
|
||||||
{
|
{
|
||||||
return octree<Type>::endIter_;
|
return octree<Type>::endIter_;
|
||||||
}
|
}
|
||||||
@ -754,7 +759,7 @@ const typename octree<Type>::iterator& octree<Type>::end()
|
|||||||
|
|
||||||
// Construct for a given octree
|
// Construct for a given octree
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octree<Type>::const_iterator::const_iterator(const octree<Type>& oc)
|
Foam::octree<Type>::const_iterator::const_iterator(const octree<Type>& oc)
|
||||||
:
|
:
|
||||||
octree_(oc),
|
octree_(oc),
|
||||||
curLeaf_(oc.nLeaves())
|
curLeaf_(oc.nLeaves())
|
||||||
@ -765,7 +770,7 @@ octree<Type>::const_iterator::const_iterator(const octree<Type>& oc)
|
|||||||
|
|
||||||
// Construct for a given octree
|
// Construct for a given octree
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octree<Type>::const_iterator::const_iterator
|
Foam::octree<Type>::const_iterator::const_iterator
|
||||||
(
|
(
|
||||||
const octree<Type>& oc,
|
const octree<Type>& oc,
|
||||||
label index
|
label index
|
||||||
@ -797,7 +802,7 @@ octree<Type>::const_iterator::const_iterator
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void octree<Type>::const_iterator::operator=(const const_iterator& iter)
|
void Foam::octree<Type>::const_iterator::operator=(const const_iterator& iter)
|
||||||
{
|
{
|
||||||
if ((curLeaf_ < 0) && (iter.curLeaf_ >= 0))
|
if ((curLeaf_ < 0) && (iter.curLeaf_ >= 0))
|
||||||
{
|
{
|
||||||
@ -816,7 +821,7 @@ void octree<Type>::const_iterator::operator=(const const_iterator& iter)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool octree<Type>::const_iterator::operator==
|
bool Foam::octree<Type>::const_iterator::operator==
|
||||||
(
|
(
|
||||||
const const_iterator& iter
|
const const_iterator& iter
|
||||||
) const
|
) const
|
||||||
@ -831,7 +836,7 @@ bool octree<Type>::const_iterator::operator==
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool octree<Type>::const_iterator::operator!=
|
bool Foam::octree<Type>::const_iterator::operator!=
|
||||||
(
|
(
|
||||||
const const_iterator& iter
|
const const_iterator& iter
|
||||||
) const
|
) const
|
||||||
@ -841,15 +846,15 @@ bool octree<Type>::const_iterator::operator!=
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
const treeLeaf<Type>& octree<Type>::const_iterator::operator*()
|
const Foam::treeLeaf<Type>& Foam::octree<Type>::const_iterator::operator*()
|
||||||
{
|
{
|
||||||
return *leaves_[curLeaf_];
|
return *leaves_[curLeaf_];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename octree<Type>::const_iterator&
|
typename Foam::octree<Type>::const_iterator&
|
||||||
octree<Type>::const_iterator::operator++()
|
Foam::octree<Type>::const_iterator::operator++()
|
||||||
{
|
{
|
||||||
curLeaf_++;
|
curLeaf_++;
|
||||||
return *this;
|
return *this;
|
||||||
@ -857,8 +862,8 @@ octree<Type>::const_iterator::operator++()
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename octree<Type>::const_iterator
|
typename Foam::octree<Type>::const_iterator
|
||||||
octree<Type>::const_iterator::operator++(int)
|
Foam::octree<Type>::const_iterator::operator++(int)
|
||||||
{
|
{
|
||||||
const_iterator tmp = *this;
|
const_iterator tmp = *this;
|
||||||
++*this;
|
++*this;
|
||||||
@ -867,14 +872,16 @@ octree<Type>::const_iterator::operator++(int)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
typename octree<Type>::const_iterator octree<Type>::begin() const
|
typename Foam::octree<Type>::const_iterator
|
||||||
|
Foam::octree<Type>::begin() const
|
||||||
{
|
{
|
||||||
return const_iterator(*this, 0);
|
return const_iterator(*this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
const typename octree<Type>::const_iterator& octree<Type>::end() const
|
const typename Foam::octree<Type>::const_iterator&
|
||||||
|
Foam::octree<Type>::end() const
|
||||||
{
|
{
|
||||||
return octree<Type>::endConstIter_;
|
return octree<Type>::endConstIter_;
|
||||||
}
|
}
|
||||||
@ -883,10 +890,10 @@ const typename octree<Type>::const_iterator& octree<Type>::end() const
|
|||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Ostream& operator<<(Ostream& os, const octree<Type>& oc)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const octree<Type>& oc)
|
||||||
{
|
{
|
||||||
return os << token::BEGIN_LIST
|
return os << token::BEGIN_LIST
|
||||||
//<< token::SPACE << oc.shapes_
|
//<< token::SPACE << oc.shapes_
|
||||||
<< token::SPACE << oc.octreeBb_
|
<< token::SPACE << oc.octreeBb_
|
||||||
<< token::SPACE << oc.maxLeafRatio_
|
<< token::SPACE << oc.maxLeafRatio_
|
||||||
<< token::SPACE << oc.maxShapeRatio_
|
<< token::SPACE << oc.maxShapeRatio_
|
||||||
@ -899,8 +906,5 @@ Ostream& operator<<(Ostream& os, const octree<Type>& oc)
|
|||||||
<< token::SPACE << token::END_LIST;
|
<< token::SPACE << token::END_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -58,11 +58,7 @@ Foam::octreeDataCell::octreeDataCell
|
|||||||
bbs_
|
bbs_
|
||||||
(
|
(
|
||||||
mesh_.nCells(),
|
mesh_.nCells(),
|
||||||
treeBoundBox
|
treeBoundBox::invertedBox
|
||||||
(
|
|
||||||
vector(GREAT, GREAT, GREAT),
|
|
||||||
vector(-GREAT, -GREAT, -GREAT)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Set one-one indexing
|
// Set one-one indexing
|
||||||
|
|||||||
@ -52,7 +52,7 @@ class polyMesh;
|
|||||||
template<class Type> class octree;
|
template<class Type> class octree;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class octreeDataCell Declaration
|
Class octreeDataCell Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class octreeDataCell
|
class octreeDataCell
|
||||||
@ -73,16 +73,13 @@ public:
|
|||||||
//- Construct from components.
|
//- Construct from components.
|
||||||
octreeDataCell
|
octreeDataCell
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh&,
|
||||||
const labelList& cellLabels,
|
const labelList& cellLabels,
|
||||||
const treeBoundBoxList& bbs
|
const treeBoundBoxList& bbs
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from mesh. Uses all cells in mesh.
|
//- Construct from mesh. Uses all cells in mesh.
|
||||||
octreeDataCell
|
octreeDataCell(const polyMesh&);
|
||||||
(
|
|
||||||
const polyMesh& mesh
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -149,10 +146,10 @@ public:
|
|||||||
treeBoundBox& tightest
|
treeBoundBox& tightest
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Given index get unit normal and calculate (numerical) sign
|
//- Given index get unit normal and calculate (numerical) sign
|
||||||
// of sample.
|
// of sample.
|
||||||
// Used to determine accuracy of calcNearest or inside/outside.
|
// Used to determine accuracy of calcNearest or inside/outside.
|
||||||
//Note: always returns GREAT since no inside/outside.
|
// Note: always returns GREAT since no inside/outside.
|
||||||
scalar calcSign
|
scalar calcSign
|
||||||
(
|
(
|
||||||
const label index,
|
const label index,
|
||||||
|
|||||||
@ -36,7 +36,7 @@ License
|
|||||||
|
|
||||||
defineTypeNameAndDebug(Foam::octreeDataEdges, 0);
|
defineTypeNameAndDebug(Foam::octreeDataEdges, 0);
|
||||||
|
|
||||||
Foam::scalar Foam::octreeDataEdges::tol = 1E-6;
|
Foam::scalar Foam::octreeDataEdges::tol(1E-6);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|||||||
@ -51,7 +51,7 @@ namespace Foam
|
|||||||
template<class Type> class octree;
|
template<class Type> class octree;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class octreeDataEdges Declaration
|
Class octreeDataEdges Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class octreeDataEdges
|
class octreeDataEdges
|
||||||
@ -154,8 +154,8 @@ public:
|
|||||||
const point& sample
|
const point& sample
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Segment (from start to end) intersection with shape
|
//- Segment (from start to end) intersection with shape at index.
|
||||||
// at index. If intersects returns true and sets intersectionPoint
|
// If intersects returns true and sets intersectionPoint
|
||||||
bool intersects
|
bool intersects
|
||||||
(
|
(
|
||||||
const label index,
|
const label index,
|
||||||
@ -174,7 +174,7 @@ public:
|
|||||||
treeBoundBox& tightest
|
treeBoundBox& tightest
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Given index get unit normal and calculate (numerical) sign
|
//- Given index get unit normal and calculate (numerical) sign
|
||||||
// of sample.
|
// of sample.
|
||||||
// Used to determine accuracy of calcNearest or inside/outside.
|
// Used to determine accuracy of calcNearest or inside/outside.
|
||||||
scalar calcSign
|
scalar calcSign
|
||||||
|
|||||||
@ -36,7 +36,7 @@ License
|
|||||||
|
|
||||||
defineTypeNameAndDebug(Foam::octreeDataFace, 0);
|
defineTypeNameAndDebug(Foam::octreeDataFace, 0);
|
||||||
|
|
||||||
Foam::scalar Foam::octreeDataFace::tol = 1E-6;
|
Foam::scalar Foam::octreeDataFace::tol(1E-6);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -44,11 +44,7 @@ Foam::scalar Foam::octreeDataFace::tol = 1E-6;
|
|||||||
void Foam::octreeDataFace::calcBb()
|
void Foam::octreeDataFace::calcBb()
|
||||||
{
|
{
|
||||||
allBb_.setSize(meshFaces_.size());
|
allBb_.setSize(meshFaces_.size());
|
||||||
allBb_ = treeBoundBox
|
allBb_ = treeBoundBox::invertedBox;
|
||||||
(
|
|
||||||
vector(GREAT, GREAT, GREAT),
|
|
||||||
vector(-GREAT, -GREAT, -GREAT)
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll (meshFaces_, i)
|
forAll (meshFaces_, i)
|
||||||
{
|
{
|
||||||
@ -104,8 +100,8 @@ Foam::octreeDataFace::octreeDataFace
|
|||||||
Foam::octreeDataFace::octreeDataFace
|
Foam::octreeDataFace::octreeDataFace
|
||||||
(
|
(
|
||||||
const primitiveMesh& mesh,
|
const primitiveMesh& mesh,
|
||||||
const List<const labelList*>& meshFaceListPtrs,
|
const UList<const labelList*>& meshFaceListPtrs,
|
||||||
const List<const treeBoundBoxList*>& bbListPtrs
|
const UList<const treeBoundBoxList*>& bbListPtrs
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
@ -122,7 +118,7 @@ Foam::octreeDataFace::octreeDataFace
|
|||||||
meshFaces_.setSize(faceI);
|
meshFaces_.setSize(faceI);
|
||||||
allBb_.setSize(faceI);
|
allBb_.setSize(faceI);
|
||||||
|
|
||||||
faceI = 0;
|
faceI = 0;
|
||||||
|
|
||||||
forAll(meshFaceListPtrs, listI)
|
forAll(meshFaceListPtrs, listI)
|
||||||
{
|
{
|
||||||
@ -143,7 +139,7 @@ Foam::octreeDataFace::octreeDataFace
|
|||||||
Foam::octreeDataFace::octreeDataFace
|
Foam::octreeDataFace::octreeDataFace
|
||||||
(
|
(
|
||||||
const primitiveMesh& mesh,
|
const primitiveMesh& mesh,
|
||||||
const List<const labelList*>& meshFaceListPtrs
|
const UList<const labelList*>& meshFaceListPtrs
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
@ -158,7 +154,7 @@ Foam::octreeDataFace::octreeDataFace
|
|||||||
|
|
||||||
meshFaces_.setSize(faceI);
|
meshFaces_.setSize(faceI);
|
||||||
|
|
||||||
faceI = 0;
|
faceI = 0;
|
||||||
|
|
||||||
forAll(meshFaceListPtrs, listI)
|
forAll(meshFaceListPtrs, listI)
|
||||||
{
|
{
|
||||||
@ -204,7 +200,7 @@ Foam::octreeDataFace::octreeDataFace(const primitiveMesh& mesh)
|
|||||||
// Set info for all boundary faces.
|
// Set info for all boundary faces.
|
||||||
label boundaryFaceI = 0;
|
label boundaryFaceI = 0;
|
||||||
|
|
||||||
for(label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
|
for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
|
||||||
{
|
{
|
||||||
meshFaces_[boundaryFaceI++] = faceI;
|
meshFaces_[boundaryFaceI++] = faceI;
|
||||||
}
|
}
|
||||||
@ -247,12 +243,9 @@ Foam::label Foam::octreeDataFace::getSampleType
|
|||||||
// or where on the face it has hit so we have to recreate all that
|
// or where on the face it has hit so we have to recreate all that
|
||||||
// information.
|
// information.
|
||||||
|
|
||||||
|
|
||||||
// Find nearest face to sample
|
|
||||||
treeBoundBox tightest(treeBoundBox::greatBox);
|
treeBoundBox tightest(treeBoundBox::greatBox);
|
||||||
|
scalar tightestDist(treeBoundBox::great);
|
||||||
scalar tightestDist = GREAT;
|
// Find nearest face to sample
|
||||||
|
|
||||||
label index = oc.findNearest(sample, tightest, tightestDist);
|
label index = oc.findNearest(sample, tightest, tightestDist);
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
@ -383,12 +376,11 @@ Foam::label Foam::octreeDataFace::getSampleType
|
|||||||
{
|
{
|
||||||
const edge& e = mesh_.edges()[myEdges[myEdgeI]];
|
const edge& e = mesh_.edges()[myEdges[myEdgeI]];
|
||||||
|
|
||||||
pointHit edgeHit =
|
pointHit edgeHit = line<point, const point&>
|
||||||
line<point, const point&>
|
(
|
||||||
(
|
points[e.start()],
|
||||||
points[e.start()],
|
points[e.end()]
|
||||||
points[e.end()]
|
).nearestDist(sample);
|
||||||
).nearestDist(sample);
|
|
||||||
|
|
||||||
|
|
||||||
if ((mag(edgeHit.rawPoint() - curHit.missPoint())/typDim) < tol)
|
if ((mag(edgeHit.rawPoint() - curHit.missPoint())/typDim) < tol)
|
||||||
@ -540,14 +532,13 @@ bool Foam::octreeDataFace::overlaps
|
|||||||
{
|
{
|
||||||
label fp1 = (fp == f.size()-1 ? 0 : fp+1);
|
label fp1 = (fp == f.size()-1 ? 0 : fp+1);
|
||||||
|
|
||||||
bool triIntersects =
|
bool triIntersects = triangleFuncs::intersectBb
|
||||||
triangleFuncs::intersectBb
|
(
|
||||||
(
|
points[f[fp]],
|
||||||
points[f[fp]],
|
points[f[fp1]],
|
||||||
points[f[fp1]],
|
fc,
|
||||||
fc,
|
sampleBb
|
||||||
sampleBb
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (triIntersects)
|
if (triIntersects)
|
||||||
{
|
{
|
||||||
@ -585,15 +576,14 @@ bool Foam::octreeDataFace::intersects
|
|||||||
// Disable picking up intersections behind us.
|
// Disable picking up intersections behind us.
|
||||||
scalar oldTol = intersection::setPlanarTol(0.0);
|
scalar oldTol = intersection::setPlanarTol(0.0);
|
||||||
|
|
||||||
pointHit inter =
|
pointHit inter = f.ray
|
||||||
f.ray
|
(
|
||||||
(
|
start,
|
||||||
start,
|
dir,
|
||||||
dir,
|
mesh_.points(),
|
||||||
mesh_.points(),
|
intersection::HALF_RAY,
|
||||||
intersection::HALF_RAY,
|
intersection::VECTOR
|
||||||
intersection::VECTOR
|
);
|
||||||
);
|
|
||||||
|
|
||||||
intersection::setPlanarTol(oldTol);
|
intersection::setPlanarTol(oldTol);
|
||||||
|
|
||||||
@ -637,7 +627,7 @@ bool Foam::octreeDataFace::findTightest
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Construct bb around sample and myFar
|
// Construct bb around sample and myFar
|
||||||
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
|
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
|
||||||
|
|
||||||
tightest.min() = sample - dist2;
|
tightest.min() = sample - dist2;
|
||||||
tightest.max() = sample + dist2;
|
tightest.max() = sample + dist2;
|
||||||
|
|||||||
@ -56,7 +56,7 @@ template<class Type> class octree;
|
|||||||
class polyPatch;
|
class polyPatch;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class octreeDataFace Declaration
|
Class octreeDataFace Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class octreeDataFace
|
class octreeDataFace
|
||||||
@ -111,20 +111,20 @@ public:
|
|||||||
octreeDataFace
|
octreeDataFace
|
||||||
(
|
(
|
||||||
const primitiveMesh&,
|
const primitiveMesh&,
|
||||||
const List<const labelList*>&,
|
const UList<const labelList*>&,
|
||||||
const List<const treeBoundBoxList*>&
|
const UList<const treeBoundBoxList*>&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from selected mesh faces. Tight fitting bounding boxes
|
//- Construct from selected mesh faces.
|
||||||
// generated internally.
|
// Tight-fitting bounding boxes generated internally.
|
||||||
octreeDataFace(const primitiveMesh&, const List<const labelList*>&);
|
octreeDataFace(const primitiveMesh&, const UList<const labelList*>&);
|
||||||
|
|
||||||
//- Construct from alll faces in patch. Tight fitting bounding boxes
|
//- Construct from all faces in patch.
|
||||||
// generated internally.
|
// Tight-fitting bounding boxes generated internally.
|
||||||
octreeDataFace(const polyPatch& patch);
|
octreeDataFace(const polyPatch&);
|
||||||
|
|
||||||
//- Construct from all boundary faces. Tight fitting bounding boxes
|
//- Construct from all boundary faces.
|
||||||
// generated internally.
|
// Tight-fitting bounding boxes generated internally.
|
||||||
octreeDataFace(const primitiveMesh&);
|
octreeDataFace(const primitiveMesh&);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
@ -200,7 +200,7 @@ public:
|
|||||||
treeBoundBox& tightest
|
treeBoundBox& tightest
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Given index get unit normal and calculate (numerical) sign
|
//- Given index get unit normal and calculate (numerical) sign
|
||||||
// of sample.
|
// of sample.
|
||||||
// Used to determine accuracy of calcNearest or inside/outside.
|
// Used to determine accuracy of calcNearest or inside/outside.
|
||||||
scalar calcSign
|
scalar calcSign
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components. Holds reference to points!
|
//- Construct from components. Holds reference to points!
|
||||||
octreeDataPoint(const pointField& points);
|
octreeDataPoint(const pointField&);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -56,7 +56,7 @@ bool Foam::treeLeaf<Foam::octreeDataPoint>::findNearest
|
|||||||
const octreeDataPoint& shapes,
|
const octreeDataPoint& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ bool Foam::treeLeaf<Foam::octreeDataPoint>::findNearest
|
|||||||
tMax.y() = sample.y() + tightestDist;
|
tMax.y() = sample.y() + tightestDist;
|
||||||
tMax.z() = sample.z() + tightestDist;
|
tMax.z() = sample.z() + tightestDist;
|
||||||
|
|
||||||
tightesti = minIndex;
|
tightestI = minIndex;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,7 @@ bool treeLeaf<octreeDataPoint>::findNearest
|
|||||||
const octreeDataPoint& shapes,
|
const octreeDataPoint& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -27,16 +27,11 @@ License
|
|||||||
#include "octreeLine.H"
|
#include "octreeLine.H"
|
||||||
#include "octree.H"
|
#include "octree.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
// Calculate sorted list of intersections
|
// Calculate sorted list of intersections
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void octreeLine<Type>::calcSortedIntersections()
|
void Foam::octreeLine<Type>::calcSortedIntersections()
|
||||||
{
|
{
|
||||||
// Determine intersections and sort acc. to distance to start
|
// Determine intersections and sort acc. to distance to start
|
||||||
|
|
||||||
@ -45,35 +40,33 @@ void octreeLine<Type>::calcSortedIntersections()
|
|||||||
sortedIntersections_.setSize(indices.size());
|
sortedIntersections_.setSize(indices.size());
|
||||||
|
|
||||||
const vector direction = endPoint_ - realStartPoint_;
|
const vector direction = endPoint_ - realStartPoint_;
|
||||||
|
|
||||||
label nHits = 0;
|
label nHits = 0;
|
||||||
|
|
||||||
forAll(indices, elemI)
|
forAll(indices, elemI)
|
||||||
{
|
{
|
||||||
point pt;
|
point pt;
|
||||||
bool hit =
|
bool hit = tree_.shapes().intersects
|
||||||
tree_.shapes().intersects
|
(
|
||||||
(
|
indices[elemI],
|
||||||
indices[elemI],
|
realStartPoint_,
|
||||||
realStartPoint_,
|
direction,
|
||||||
direction,
|
pt
|
||||||
pt
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (hit && (indices[elemI] != lastElem_))
|
if (hit && (indices[elemI] != lastElem_))
|
||||||
{
|
{
|
||||||
sortedIntersections_[nHits++] =
|
sortedIntersections_[nHits++] = pointHitSort
|
||||||
pointHitSort
|
(
|
||||||
|
pointHit
|
||||||
(
|
(
|
||||||
pointHit
|
true,
|
||||||
(
|
pt,
|
||||||
true,
|
Foam::magSqr(pt - leafExitPoint_),
|
||||||
pt,
|
false
|
||||||
Foam::magSqr(pt - leafExitPoint_),
|
),
|
||||||
false
|
indices[elemI]
|
||||||
),
|
);
|
||||||
indices[elemI]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +101,7 @@ void octreeLine<Type>::calcSortedIntersections()
|
|||||||
// Searches for leaf with intersected elements. Return true if found; false
|
// Searches for leaf with intersected elements. Return true if found; false
|
||||||
// otherwise. Sets currentLeaf_ and sortedIntersections_.
|
// otherwise. Sets currentLeaf_ and sortedIntersections_.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool octreeLine<Type>::getNextLeaf()
|
bool Foam::octreeLine<Type>::getNextLeaf()
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -136,7 +129,7 @@ bool octreeLine<Type>::getNextLeaf()
|
|||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octreeLine<Type>::octreeLine
|
Foam::octreeLine<Type>::octreeLine
|
||||||
(
|
(
|
||||||
const octree<Type>& tree,
|
const octree<Type>& tree,
|
||||||
const point& startPoint,
|
const point& startPoint,
|
||||||
@ -158,14 +151,14 @@ octreeLine<Type>::octreeLine
|
|||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
octreeLine<Type>::~octreeLine()
|
Foam::octreeLine<Type>::~octreeLine()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool octreeLine<Type>::getIntersection()
|
bool Foam::octreeLine<Type>::getIntersection()
|
||||||
{
|
{
|
||||||
// Go to next element in sortedIntersections
|
// Go to next element in sortedIntersections
|
||||||
|
|
||||||
@ -185,9 +178,4 @@ bool octreeLine<Type>::getIntersection()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -29,6 +29,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::scalar Foam::treeBoundBox::great(GREAT);
|
||||||
|
|
||||||
const Foam::treeBoundBox Foam::treeBoundBox::greatBox
|
const Foam::treeBoundBox Foam::treeBoundBox::greatBox
|
||||||
(
|
(
|
||||||
vector(-GREAT, -GREAT, -GREAT),
|
vector(-GREAT, -GREAT, -GREAT),
|
||||||
@ -36,6 +38,13 @@ const Foam::treeBoundBox Foam::treeBoundBox::greatBox
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::treeBoundBox Foam::treeBoundBox::invertedBox
|
||||||
|
(
|
||||||
|
vector(GREAT, GREAT, GREAT),
|
||||||
|
vector(-GREAT, -GREAT, -GREAT)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//! @cond - skip documentation : local scope only
|
//! @cond - skip documentation : local scope only
|
||||||
const Foam::label facesArray[6][4] =
|
const Foam::label facesArray[6][4] =
|
||||||
{
|
{
|
||||||
@ -185,63 +194,7 @@ Foam::pointField Foam::treeBoundBox::points() const
|
|||||||
|
|
||||||
Foam::treeBoundBox Foam::treeBoundBox::subBbox(const direction octant) const
|
Foam::treeBoundBox Foam::treeBoundBox::subBbox(const direction octant) const
|
||||||
{
|
{
|
||||||
if (octant > 7)
|
return subBbox(midpoint(), octant);
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"treeBoundBox::subCube(const direction)"
|
|
||||||
) << "octant should be [0..7]"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar leftx, lefty, leftz;
|
|
||||||
scalar rightx, righty, rightz;
|
|
||||||
|
|
||||||
scalar midx=0.5*(min().x() + max().x());
|
|
||||||
scalar midy=0.5*(min().y() + max().y());
|
|
||||||
scalar midz=0.5*(min().z() + max().z());
|
|
||||||
|
|
||||||
// X half
|
|
||||||
if (octant & treeBoundBox::RIGHTHALF)
|
|
||||||
{
|
|
||||||
leftx = midx;
|
|
||||||
rightx = max().x();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
leftx = min().x();
|
|
||||||
rightx = midx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Y half
|
|
||||||
if (octant & treeBoundBox::TOPHALF)
|
|
||||||
{
|
|
||||||
lefty = midy;
|
|
||||||
righty = max().y();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lefty = min().y();
|
|
||||||
righty = midy;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Z half
|
|
||||||
if (octant & treeBoundBox::FRONTHALF)
|
|
||||||
{
|
|
||||||
leftz = midz;
|
|
||||||
rightz = max().z();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
leftz = min().z();
|
|
||||||
rightz = midz;
|
|
||||||
}
|
|
||||||
|
|
||||||
return treeBoundBox
|
|
||||||
(
|
|
||||||
point(leftx, lefty, leftz),
|
|
||||||
point(rightx, righty, rightz)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -256,44 +209,41 @@ Foam::treeBoundBox Foam::treeBoundBox::subBbox
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"treeBoundBox::subCube(const point&, const direction)"
|
"treeBoundBox::subBbox(const point&, const direction)"
|
||||||
) << "octant should be [0..7]"
|
) << "octant should be [0..7]"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
treeBoundBox subBb;
|
// start with a copy of this bounding box and adjust limits accordingly
|
||||||
point& subMin = subBb.min();
|
treeBoundBox subBb(*this);
|
||||||
point& subMax = subBb.max();
|
point& bbMin = subBb.min();
|
||||||
|
point& bbMax = subBb.max();
|
||||||
|
|
||||||
if (octant & treeBoundBox::RIGHTHALF)
|
if (octant & treeBoundBox::RIGHTHALF)
|
||||||
{
|
{
|
||||||
subMin.x() = mid.x();
|
bbMin.x() = mid.x(); // mid -> max
|
||||||
subMax.x() = max().x();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
subMin.x() = min().x();
|
bbMax.x() = mid.x(); // min -> mid
|
||||||
subMax.x() = mid.x();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (octant & treeBoundBox::TOPHALF)
|
if (octant & treeBoundBox::TOPHALF)
|
||||||
{
|
{
|
||||||
subMin.y() = mid.y();
|
bbMin.y() = mid.y(); // mid -> max
|
||||||
subMax.y() = max().y();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
subMin.y() = min().y();
|
bbMax.y() = mid.y(); // min -> mid
|
||||||
subMax.y() = mid.y();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (octant & treeBoundBox::FRONTHALF)
|
if (octant & treeBoundBox::FRONTHALF)
|
||||||
{
|
{
|
||||||
subMin.z() = mid.z();
|
bbMin.z() = mid.z(); // mid -> max
|
||||||
subMax.z() = max().z();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
subMin.z() = min().z();
|
bbMax.z() = mid.z(); // min -> mid
|
||||||
subMax.z() = mid.z();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return subBb;
|
return subBb;
|
||||||
@ -364,13 +314,11 @@ bool Foam::treeBoundBox::intersects
|
|||||||
point& pt
|
point& pt
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
vector vec(end - start);
|
const vector vec(end - start);
|
||||||
|
const direction endBits = posBits(end);
|
||||||
pt = start;
|
pt = start;
|
||||||
|
|
||||||
const direction endBits = posBits(end);
|
while (true)
|
||||||
|
|
||||||
while(true)
|
|
||||||
{
|
{
|
||||||
direction ptBits = posBits(pt);
|
direction ptBits = posBits(pt);
|
||||||
|
|
||||||
@ -465,32 +413,18 @@ bool Foam::treeBoundBox::contains(const treeBoundBox& bb) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::treeBoundBox::containsNarrow(const point& sample) const
|
bool Foam::treeBoundBox::contains(const vector& dir, const point& pt) const
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
(sample.x() > min().x()) &&
|
|
||||||
(sample.y() > min().y()) &&
|
|
||||||
(sample.z() > min().z()) &&
|
|
||||||
(sample.x() < max().x()) &&
|
|
||||||
(sample.y() < max().y()) &&
|
|
||||||
(sample.z() < max().z())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Foam::treeBoundBox::contains(const vector& dir, const point& sample) const
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Compare all components against min and max of bb
|
// Compare all components against min and max of bb
|
||||||
//
|
//
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<3; cmpt++)
|
for (direction cmpt=0; cmpt<3; cmpt++)
|
||||||
{
|
{
|
||||||
if (sample[cmpt] < min()[cmpt])
|
if (pt[cmpt] < min()[cmpt])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (sample[cmpt] == min()[cmpt])
|
else if (pt[cmpt] == min()[cmpt])
|
||||||
{
|
{
|
||||||
// On edge. Outside if direction points outwards.
|
// On edge. Outside if direction points outwards.
|
||||||
if (dir[cmpt] < 0)
|
if (dir[cmpt] < 0)
|
||||||
@ -499,11 +433,11 @@ bool Foam::treeBoundBox::contains(const vector& dir, const point& sample) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample[cmpt] > max()[cmpt])
|
if (pt[cmpt] > max()[cmpt])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (sample[cmpt] == max()[cmpt])
|
else if (pt[cmpt] == max()[cmpt])
|
||||||
{
|
{
|
||||||
// On edge. Outside if direction points outwards.
|
// On edge. Outside if direction points outwards.
|
||||||
if (dir[cmpt] > 0)
|
if (dir[cmpt] > 0)
|
||||||
@ -557,7 +491,7 @@ Foam::direction Foam::treeBoundBox::posBits(const point& pt) const
|
|||||||
// !names of treeBoundBox::min() and treeBoundBox::max() are confusing!
|
// !names of treeBoundBox::min() and treeBoundBox::max() are confusing!
|
||||||
void Foam::treeBoundBox::calcExtremities
|
void Foam::treeBoundBox::calcExtremities
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& pt,
|
||||||
point& nearest,
|
point& nearest,
|
||||||
point& furthest
|
point& furthest
|
||||||
) const
|
) const
|
||||||
@ -565,7 +499,7 @@ void Foam::treeBoundBox::calcExtremities
|
|||||||
scalar nearX, nearY, nearZ;
|
scalar nearX, nearY, nearZ;
|
||||||
scalar farX, farY, farZ;
|
scalar farX, farY, farZ;
|
||||||
|
|
||||||
if (Foam::mag(min().x() - sample.x()) < Foam::mag(max().x() - sample.x()))
|
if (Foam::mag(min().x() - pt.x()) < Foam::mag(max().x() - pt.x()))
|
||||||
{
|
{
|
||||||
nearX = min().x();
|
nearX = min().x();
|
||||||
farX = max().x();
|
farX = max().x();
|
||||||
@ -576,7 +510,7 @@ void Foam::treeBoundBox::calcExtremities
|
|||||||
farX = min().x();
|
farX = min().x();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Foam::mag(min().y() - sample.y()) < Foam::mag(max().y() - sample.y()))
|
if (Foam::mag(min().y() - pt.y()) < Foam::mag(max().y() - pt.y()))
|
||||||
{
|
{
|
||||||
nearY = min().y();
|
nearY = min().y();
|
||||||
farY = max().y();
|
farY = max().y();
|
||||||
@ -587,7 +521,7 @@ void Foam::treeBoundBox::calcExtremities
|
|||||||
farY = min().y();
|
farY = min().y();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Foam::mag(min().z() - sample.z()) < Foam::mag(max().z() - sample.z()))
|
if (Foam::mag(min().z() - pt.z()) < Foam::mag(max().z() - pt.z()))
|
||||||
{
|
{
|
||||||
nearZ = min().z();
|
nearZ = min().z();
|
||||||
farZ = max().z();
|
farZ = max().z();
|
||||||
@ -603,12 +537,12 @@ void Foam::treeBoundBox::calcExtremities
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::treeBoundBox::maxDist(const point& sample) const
|
Foam::scalar Foam::treeBoundBox::maxDist(const point& pt) const
|
||||||
{
|
{
|
||||||
point near, far;
|
point near, far;
|
||||||
calcExtremities(sample, near, far);
|
calcExtremities(pt, near, far);
|
||||||
|
|
||||||
return Foam::mag(far - sample);
|
return Foam::mag(far - pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -617,57 +551,57 @@ Foam::scalar Foam::treeBoundBox::maxDist(const point& sample) const
|
|||||||
// box to see if all vertices of one are nearer
|
// box to see if all vertices of one are nearer
|
||||||
Foam::label Foam::treeBoundBox::distanceCmp
|
Foam::label Foam::treeBoundBox::distanceCmp
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& pt,
|
||||||
const treeBoundBox& other
|
const treeBoundBox& other
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Distance sample <-> nearest and furthest away vertex of this
|
// Distance point <-> nearest and furthest away vertex of this
|
||||||
//
|
//
|
||||||
|
|
||||||
point nearThis, farThis;
|
point nearThis, farThis;
|
||||||
|
|
||||||
// get nearest and furthest away vertex
|
// get nearest and furthest away vertex
|
||||||
calcExtremities(sample, nearThis, farThis);
|
calcExtremities(pt, nearThis, farThis);
|
||||||
|
|
||||||
const scalar minDistThis =
|
const scalar minDistThis =
|
||||||
sqr(nearThis.x() - sample.x())
|
sqr(nearThis.x() - pt.x())
|
||||||
+ sqr(nearThis.y() - sample.y())
|
+ sqr(nearThis.y() - pt.y())
|
||||||
+ sqr(nearThis.z() - sample.z());
|
+ sqr(nearThis.z() - pt.z());
|
||||||
const scalar maxDistThis =
|
const scalar maxDistThis =
|
||||||
sqr(farThis.x() - sample.x())
|
sqr(farThis.x() - pt.x())
|
||||||
+ sqr(farThis.y() - sample.y())
|
+ sqr(farThis.y() - pt.y())
|
||||||
+ sqr(farThis.z() - sample.z());
|
+ sqr(farThis.z() - pt.z());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Distance sample <-> other
|
// Distance point <-> other
|
||||||
//
|
//
|
||||||
|
|
||||||
point nearOther, farOther;
|
point nearOther, farOther;
|
||||||
|
|
||||||
// get nearest and furthest away vertex
|
// get nearest and furthest away vertex
|
||||||
other.calcExtremities(sample, nearOther, farOther);
|
other.calcExtremities(pt, nearOther, farOther);
|
||||||
|
|
||||||
const scalar minDistOther =
|
const scalar minDistOther =
|
||||||
sqr(nearOther.x() - sample.x())
|
sqr(nearOther.x() - pt.x())
|
||||||
+ sqr(nearOther.y() - sample.y())
|
+ sqr(nearOther.y() - pt.y())
|
||||||
+ sqr(nearOther.z() - sample.z());
|
+ sqr(nearOther.z() - pt.z());
|
||||||
const scalar maxDistOther =
|
const scalar maxDistOther =
|
||||||
sqr(farOther.x() - sample.x())
|
sqr(farOther.x() - pt.x())
|
||||||
+ sqr(farOther.y() - sample.y())
|
+ sqr(farOther.y() - pt.y())
|
||||||
+ sqr(farOther.z() - sample.z());
|
+ sqr(farOther.z() - pt.z());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Categorize
|
// Categorize
|
||||||
//
|
//
|
||||||
if (maxDistThis < minDistOther)
|
if (maxDistThis < minDistOther)
|
||||||
{
|
{
|
||||||
// All vertices of this are nearer to sample than any vertex of other
|
// All vertices of this are nearer to point than any vertex of other
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (minDistThis > maxDistOther)
|
else if (minDistThis > maxDistOther)
|
||||||
{
|
{
|
||||||
// All vertices of this are further from sample than any vertex of other
|
// All vertices of this are further from point than any vertex of other
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -87,16 +87,22 @@ public:
|
|||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
|
//- The great value used for greatBox and invertedBox
|
||||||
|
static const scalar great;
|
||||||
|
|
||||||
//- As per boundBox::greatBox, but with GREAT instead of VGREAT
|
//- As per boundBox::greatBox, but with GREAT instead of VGREAT
|
||||||
static const treeBoundBox greatBox;
|
static const treeBoundBox greatBox;
|
||||||
|
|
||||||
//- Bits used for octant/point coding. Every octant/corner point
|
//- As per boundBox::invertedBox, but with GREAT instead of VGREAT
|
||||||
// is the combination of three faces.
|
static const treeBoundBox invertedBox;
|
||||||
|
|
||||||
|
//- Bits used for octant/point coding.
|
||||||
|
// Every octant/corner point is the combination of three faces.
|
||||||
enum octantBit
|
enum octantBit
|
||||||
{
|
{
|
||||||
RIGHTHALF = 0x1 << 0,
|
RIGHTHALF = 0x1 << 0,
|
||||||
TOPHALF = 0x1 << 1,
|
TOPHALF = 0x1 << 1,
|
||||||
FRONTHALF = 0x1 << 2
|
FRONTHALF = 0x1 << 2
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Face codes
|
//- Face codes
|
||||||
@ -167,11 +173,12 @@ public:
|
|||||||
//- Construct from components
|
//- Construct from components
|
||||||
inline treeBoundBox(const boundBox& bb);
|
inline treeBoundBox(const boundBox& bb);
|
||||||
|
|
||||||
//- Construct as the bounding box of the given pointField. Local
|
//- Construct as the bounding box of the given pointField.
|
||||||
// processor domain only (no reduce as in boundBox)
|
// Local processor domain only (no reduce as in boundBox)
|
||||||
treeBoundBox(const UList<point>& points);
|
treeBoundBox(const UList<point>&);
|
||||||
|
|
||||||
//- Construct as subset of points
|
//- Construct as subset of points
|
||||||
|
// Local processor domain only (no reduce as in boundBox)
|
||||||
treeBoundBox(const UList<point>&, const UList<label>& meshPoints);
|
treeBoundBox(const UList<point>&, const UList<label>& meshPoints);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
@ -182,15 +189,6 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Smallest of length,height,width
|
|
||||||
inline scalar minDim() const;
|
|
||||||
|
|
||||||
//- Largest of length,height,width
|
|
||||||
inline scalar maxDim() const;
|
|
||||||
|
|
||||||
//- Average of length,height,width
|
|
||||||
inline scalar avgDim() const;
|
|
||||||
|
|
||||||
//- Typical dimension length,height,width
|
//- Typical dimension length,height,width
|
||||||
inline scalar typDim() const;
|
inline scalar typDim() const;
|
||||||
|
|
||||||
@ -203,64 +201,61 @@ public:
|
|||||||
//- Corner point given octant
|
//- Corner point given octant
|
||||||
inline point corner(const direction) const;
|
inline point corner(const direction) const;
|
||||||
|
|
||||||
//- Calculates midpoint
|
|
||||||
inline point mid() const;
|
|
||||||
|
|
||||||
//- Sub box given by octant number. Midpoint calculated.
|
//- Sub box given by octant number. Midpoint calculated.
|
||||||
treeBoundBox subBbox(const direction) const;
|
treeBoundBox subBbox(const direction) const;
|
||||||
|
|
||||||
//- Sub box given by octant number. Midpoint provided.
|
//- Sub box given by octant number. Midpoint provided.
|
||||||
treeBoundBox subBbox(const point& mid, const direction) const;
|
treeBoundBox subBbox(const point& mid, const direction) const;
|
||||||
|
|
||||||
//- Returns octant number given point. Midpoint calculated.
|
//- Returns octant number given point and the calculated midpoint.
|
||||||
inline direction subOctant
|
inline direction subOctant
|
||||||
(
|
(
|
||||||
const point& sample
|
const point& pt
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Returns octant number given point. Midpoint provided.
|
//- Returns octant number given point and midpoint.
|
||||||
static inline direction subOctant
|
static inline direction subOctant
|
||||||
(
|
(
|
||||||
const point& mid,
|
const point& mid,
|
||||||
const point& sample
|
const point& pt
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Returns octant number given point. Midpoint calculated.
|
//- Returns octant number given point and the calculated midpoint.
|
||||||
// onEdge set if sample on edge of subOctant
|
// onEdge set if the point is on edge of subOctant
|
||||||
inline direction subOctant
|
inline direction subOctant
|
||||||
(
|
(
|
||||||
const point& mid,
|
const point& pt,
|
||||||
bool& onEdge
|
bool& onEdge
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Returns octant number given point. Midpoint provided.
|
//- Returns octant number given point and midpoint.
|
||||||
// onEdge set if sample on edge of subOctant
|
// onEdge set if the point is on edge of subOctant
|
||||||
static inline direction subOctant
|
static inline direction subOctant
|
||||||
(
|
(
|
||||||
const point& mid,
|
const point& mid,
|
||||||
const point& sample,
|
const point& pt,
|
||||||
bool& onEdge
|
bool& onEdge
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Returns octant number given intersection. Midpoint provided.
|
//- Returns octant number given intersection and midpoint.
|
||||||
// onEdge set if sample on edge of subOctant. If onEdge
|
// onEdge set if the point is on edge of subOctant
|
||||||
// the direction vector determines which octant to use
|
// If onEdge, the direction vector determines which octant to use
|
||||||
// (acc. to which octant the sample would be if it were moved
|
// (acc. to which octant the point would be if it were moved
|
||||||
// along dir)
|
// along dir)
|
||||||
static inline direction subOctant
|
static inline direction subOctant
|
||||||
(
|
(
|
||||||
const point& mid,
|
const point& mid,
|
||||||
const vector& dir,
|
const vector& dir,
|
||||||
const point& sample,
|
const point& pt,
|
||||||
bool& onEdge
|
bool& onEdge
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Calculates optimal order to look for nearest to sample. First
|
//- Calculates optimal order to look for nearest to point.
|
||||||
// will be the octant containing the sample, second the octant
|
// First will be the octant containing the point,
|
||||||
// with boundary nearest to the sample etc.
|
// second the octant with boundary nearest to the point etc.
|
||||||
inline void searchOrder
|
inline void searchOrder
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& pt,
|
||||||
FixedList<direction, 8>& octantOrder
|
FixedList<direction, 8>& octantOrder
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -273,36 +268,37 @@ public:
|
|||||||
//- Intersects segment; set point to intersection position,
|
//- Intersects segment; set point to intersection position,
|
||||||
// return true if intersection found.
|
// return true if intersection found.
|
||||||
// (intPt argument used during calculation even if not intersecting)
|
// (intPt argument used during calculation even if not intersecting)
|
||||||
bool intersects(const point&, const point&, point& intPt) const;
|
bool intersects
|
||||||
|
(
|
||||||
|
const point& start,
|
||||||
|
const point& end,
|
||||||
|
point& pt
|
||||||
|
) const;
|
||||||
|
|
||||||
//- fully contains bb
|
//- fully contains other boundingBox?
|
||||||
bool contains(const treeBoundBox& bb) const;
|
inline bool contains(const treeBoundBox&) const;
|
||||||
|
|
||||||
//- Contains point? (inside or on edge)
|
//- Contains point? (inside or on edge)
|
||||||
inline bool contains(const point&) const;
|
inline bool contains(const point&) const;
|
||||||
|
|
||||||
//- Contains point? (only inside)
|
//- Contains point (inside or on edge) and moving in direction
|
||||||
bool containsNarrow(const point&) const;
|
// dir would cause it to go inside.
|
||||||
|
|
||||||
//- Contains point inside or
|
|
||||||
// on edge and moving in direction dir would cause it to go
|
|
||||||
// inside.
|
|
||||||
bool contains(const vector& dir, const point&) const;
|
bool contains(const vector& dir, const point&) const;
|
||||||
|
|
||||||
//- Position of point relative to bb
|
//- Position of point relative to bounding box
|
||||||
direction posBits(const point&) const;
|
direction posBits(const point&) const;
|
||||||
|
|
||||||
//- Calculate nearest and furthest (to sample) vertex coords of
|
//- Calculate nearest and furthest (to point) vertex coords of
|
||||||
// bounding box
|
// bounding box
|
||||||
void calcExtremities
|
void calcExtremities
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& pt,
|
||||||
point& nearest,
|
point& nearest,
|
||||||
point& furthest
|
point& furthest
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Returns distance sample to furthest away corner.
|
//- Returns distance point to furthest away corner.
|
||||||
scalar maxDist(const point& sample) const;
|
scalar maxDist(const point&) const;
|
||||||
|
|
||||||
//- Compare distance to point with other bounding box
|
//- Compare distance to point with other bounding box
|
||||||
// return:
|
// return:
|
||||||
|
|||||||
@ -49,114 +49,51 @@ inline Foam::treeBoundBox::treeBoundBox(const boundBox& bb)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::scalar Foam::treeBoundBox::minDim() const
|
|
||||||
{
|
|
||||||
return ::Foam::min
|
|
||||||
(
|
|
||||||
max().x() - min().x(),
|
|
||||||
::Foam::min
|
|
||||||
(
|
|
||||||
max().y() - min().y(),
|
|
||||||
max().z() - min().z()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar Foam::treeBoundBox::maxDim() const
|
|
||||||
{
|
|
||||||
return ::Foam::max
|
|
||||||
(
|
|
||||||
max().x() - min().x(),
|
|
||||||
::Foam::max
|
|
||||||
(
|
|
||||||
max().y() - min().y(),
|
|
||||||
max().z() - min().z()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar Foam::treeBoundBox::avgDim() const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
(max().x() - min().x()) +
|
|
||||||
(max().y() - min().y()) +
|
|
||||||
(max().z() - min().z())
|
|
||||||
)/3.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar Foam::treeBoundBox::typDim() const
|
inline Foam::scalar Foam::treeBoundBox::typDim() const
|
||||||
{
|
{
|
||||||
return avgDim();
|
return avgDim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::point Foam::treeBoundBox::mid() const
|
|
||||||
{
|
|
||||||
return 0.5*(min() + max());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::point Foam::treeBoundBox::corner(const direction octant) const
|
inline Foam::point Foam::treeBoundBox::corner(const direction octant) const
|
||||||
{
|
{
|
||||||
return point
|
return point
|
||||||
(
|
(
|
||||||
(octant&RIGHTHALF) ? max().x() : min().x(),
|
(octant & RIGHTHALF) ? max().x() : min().x(),
|
||||||
(octant&TOPHALF) ? max().y() : min().y(),
|
(octant & TOPHALF) ? max().y() : min().y(),
|
||||||
(octant&FRONTHALF) ? max().z() : min().z()
|
(octant & FRONTHALF) ? max().z() : min().z()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns octant in which sample resides. Reverse of subBbox.
|
|
||||||
inline Foam::direction Foam::treeBoundBox::subOctant(const point& sample) const
|
// Returns octant in which point resides. Reverse of subBbox.
|
||||||
|
inline Foam::direction Foam::treeBoundBox::subOctant(const point& pt) const
|
||||||
{
|
{
|
||||||
point mid = 0.5*(max() + min());
|
return subOctant(midpoint(), pt);
|
||||||
|
|
||||||
direction octant = 0;
|
|
||||||
|
|
||||||
if (sample.x() > mid.x())
|
|
||||||
{
|
|
||||||
octant |= treeBoundBox::RIGHTHALF;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sample.y() > mid.y())
|
|
||||||
{
|
|
||||||
octant |= treeBoundBox::TOPHALF;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sample.z() > mid.z())
|
|
||||||
{
|
|
||||||
octant |= treeBoundBox::FRONTHALF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return octant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns octant in which sample resides. Reverse of subBbox. Precalculated
|
// Returns octant in which point resides. Reverse of subBbox.
|
||||||
// midpoint
|
// Precalculated midpoint
|
||||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||||
(
|
(
|
||||||
const point& mid,
|
const point& mid,
|
||||||
const point& sample
|
const point& pt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
direction octant = 0;
|
direction octant = 0;
|
||||||
|
|
||||||
if (sample.x() > mid.x())
|
if (pt.x() > mid.x())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::RIGHTHALF;
|
octant |= treeBoundBox::RIGHTHALF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample.y() > mid.y())
|
if (pt.y() > mid.y())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::TOPHALF;
|
octant |= treeBoundBox::TOPHALF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample.z() > mid.z())
|
if (pt.z() > mid.z())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::FRONTHALF;
|
octant |= treeBoundBox::FRONTHALF;
|
||||||
}
|
}
|
||||||
@ -165,85 +102,53 @@ inline Foam::direction Foam::treeBoundBox::subOctant
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns octant in which sample resides. Reverse of subBbox. Flags sample
|
// Returns octant in which point resides. Reverse of subBbox.
|
||||||
// exactly on edge.
|
// Flags point exactly on edge.
|
||||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& pt,
|
||||||
bool& onEdge
|
bool& onEdge
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
point mid = 0.5*(max() + min());
|
return subOctant(midpoint(), pt, onEdge);
|
||||||
|
|
||||||
direction octant = 0;
|
|
||||||
|
|
||||||
onEdge = false;
|
|
||||||
if (sample.x() > mid.x())
|
|
||||||
{
|
|
||||||
octant |= treeBoundBox::RIGHTHALF;
|
|
||||||
}
|
|
||||||
else if (sample.x() == mid.x())
|
|
||||||
{
|
|
||||||
onEdge = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sample.y() > mid.y())
|
|
||||||
{
|
|
||||||
octant |= treeBoundBox::TOPHALF;
|
|
||||||
}
|
|
||||||
else if (sample.y() == mid.y())
|
|
||||||
{
|
|
||||||
onEdge = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sample.z() > mid.z())
|
|
||||||
{
|
|
||||||
octant |= treeBoundBox::FRONTHALF;
|
|
||||||
}
|
|
||||||
else if (sample.z() == mid.z())
|
|
||||||
{
|
|
||||||
onEdge = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return octant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns octant in which sample resides. Reverse of subBbox. Precalculated
|
// Returns octant in which point resides. Reverse of subBbox.
|
||||||
// midpoint
|
// Precalculated midpoint
|
||||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||||
(
|
(
|
||||||
const point& mid,
|
const point& mid,
|
||||||
const point& sample,
|
const point& pt,
|
||||||
bool& onEdge
|
bool& onEdge
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
direction octant = 0;
|
direction octant = 0;
|
||||||
|
|
||||||
onEdge = false;
|
onEdge = false;
|
||||||
if (sample.x() > mid.x())
|
|
||||||
|
if (pt.x() > mid.x())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::RIGHTHALF;
|
octant |= treeBoundBox::RIGHTHALF;
|
||||||
}
|
}
|
||||||
else if (sample.x() == mid.x())
|
else if (pt.x() == mid.x())
|
||||||
{
|
{
|
||||||
onEdge = true;
|
onEdge = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample.y() > mid.y())
|
if (pt.y() > mid.y())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::TOPHALF;
|
octant |= treeBoundBox::TOPHALF;
|
||||||
}
|
}
|
||||||
else if (sample.y() == mid.y())
|
else if (pt.y() == mid.y())
|
||||||
{
|
{
|
||||||
onEdge = true;
|
onEdge = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample.z() > mid.z())
|
if (pt.z() > mid.z())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::FRONTHALF;
|
octant |= treeBoundBox::FRONTHALF;
|
||||||
}
|
}
|
||||||
else if (sample.z() == mid.z())
|
else if (pt.z() == mid.z())
|
||||||
{
|
{
|
||||||
onEdge = true;
|
onEdge = true;
|
||||||
}
|
}
|
||||||
@ -253,57 +158,53 @@ inline Foam::direction Foam::treeBoundBox::subOctant
|
|||||||
|
|
||||||
|
|
||||||
// Returns octant in which intersection resides.
|
// Returns octant in which intersection resides.
|
||||||
// Precalculated midpoint. If the sample is on the dividing line between
|
// Precalculated midpoint. If the point is on the dividing line between
|
||||||
// the octants the direction vector determines which octant to use
|
// the octants the direction vector determines which octant to use
|
||||||
// (i.e. in which octant the sample would be if it were moved along dir)
|
// (i.e. in which octant the point would be if it were moved along dir)
|
||||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||||
(
|
(
|
||||||
const point& mid,
|
const point& mid,
|
||||||
const vector& dir,
|
const vector& dir,
|
||||||
const point& sample,
|
const point& pt,
|
||||||
bool& onEdge
|
bool& onEdge
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
direction octant = 0;
|
direction octant = 0;
|
||||||
|
|
||||||
onEdge = false;
|
onEdge = false;
|
||||||
|
|
||||||
if (sample.x() > mid.x())
|
if (pt.x() > mid.x())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::RIGHTHALF;
|
octant |= treeBoundBox::RIGHTHALF;
|
||||||
}
|
}
|
||||||
else if (sample.x() == mid.x())
|
else if (pt.x() == mid.x())
|
||||||
{
|
{
|
||||||
onEdge = true;
|
onEdge = true;
|
||||||
|
|
||||||
if (dir.x() > 0)
|
if (dir.x() > 0)
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::RIGHTHALF;
|
octant |= treeBoundBox::RIGHTHALF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample.y() > mid.y())
|
if (pt.y() > mid.y())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::TOPHALF;
|
octant |= treeBoundBox::TOPHALF;
|
||||||
}
|
}
|
||||||
else if (sample.y() == mid.y())
|
else if (pt.y() == mid.y())
|
||||||
{
|
{
|
||||||
onEdge = true;
|
onEdge = true;
|
||||||
|
|
||||||
if (dir.y() > 0)
|
if (dir.y() > 0)
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::TOPHALF;
|
octant |= treeBoundBox::TOPHALF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sample.z() > mid.z())
|
if (pt.z() > mid.z())
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::FRONTHALF;
|
octant |= treeBoundBox::FRONTHALF;
|
||||||
}
|
}
|
||||||
else if (sample.z() == mid.z())
|
else if (pt.z() == mid.z())
|
||||||
{
|
{
|
||||||
onEdge = true;
|
onEdge = true;
|
||||||
|
|
||||||
if (dir.z() > 0)
|
if (dir.z() > 0)
|
||||||
{
|
{
|
||||||
octant |= treeBoundBox::FRONTHALF;
|
octant |= treeBoundBox::FRONTHALF;
|
||||||
@ -318,11 +219,11 @@ inline Foam::direction Foam::treeBoundBox::subOctant
|
|||||||
// order to do the search.
|
// order to do the search.
|
||||||
inline void Foam::treeBoundBox::searchOrder
|
inline void Foam::treeBoundBox::searchOrder
|
||||||
(
|
(
|
||||||
const point& sample,
|
const point& pt,
|
||||||
FixedList<direction,8>& octantOrder
|
FixedList<direction,8>& octantOrder
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
vector dist = mid() - sample;
|
vector dist = midpoint() - pt;
|
||||||
|
|
||||||
direction octant = 0;
|
direction octant = 0;
|
||||||
|
|
||||||
@ -348,15 +249,15 @@ inline void Foam::treeBoundBox::searchOrder
|
|||||||
direction mid = 0;
|
direction mid = 0;
|
||||||
direction max = 0;
|
direction max = 0;
|
||||||
|
|
||||||
if( dist.x() < dist.y())
|
if (dist.x() < dist.y())
|
||||||
{
|
{
|
||||||
if( dist.y() < dist.z())
|
if (dist.y() < dist.z())
|
||||||
{
|
{
|
||||||
min = treeBoundBox::RIGHTHALF;
|
min = treeBoundBox::RIGHTHALF;
|
||||||
mid = treeBoundBox::TOPHALF;
|
mid = treeBoundBox::TOPHALF;
|
||||||
max = treeBoundBox::FRONTHALF;
|
max = treeBoundBox::FRONTHALF;
|
||||||
}
|
}
|
||||||
else if( dist.z() < dist.x())
|
else if (dist.z() < dist.x())
|
||||||
{
|
{
|
||||||
min = treeBoundBox::FRONTHALF;
|
min = treeBoundBox::FRONTHALF;
|
||||||
mid = treeBoundBox::RIGHTHALF;
|
mid = treeBoundBox::RIGHTHALF;
|
||||||
@ -371,13 +272,13 @@ inline void Foam::treeBoundBox::searchOrder
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( dist.z() < dist.y())
|
if (dist.z() < dist.y())
|
||||||
{
|
{
|
||||||
min = treeBoundBox::FRONTHALF;
|
min = treeBoundBox::FRONTHALF;
|
||||||
mid = treeBoundBox::TOPHALF;
|
mid = treeBoundBox::TOPHALF;
|
||||||
max = treeBoundBox::RIGHTHALF;
|
max = treeBoundBox::RIGHTHALF;
|
||||||
}
|
}
|
||||||
else if( dist.x() < dist.z())
|
else if (dist.x() < dist.z())
|
||||||
{
|
{
|
||||||
min = treeBoundBox::TOPHALF;
|
min = treeBoundBox::TOPHALF;
|
||||||
mid = treeBoundBox::RIGHTHALF;
|
mid = treeBoundBox::RIGHTHALF;
|
||||||
@ -390,6 +291,7 @@ inline void Foam::treeBoundBox::searchOrder
|
|||||||
max = treeBoundBox::RIGHTHALF;
|
max = treeBoundBox::RIGHTHALF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Primary subOctant
|
// Primary subOctant
|
||||||
octantOrder[0] = octant;
|
octantOrder[0] = octant;
|
||||||
// subOctants joined to the primary by faces.
|
// subOctants joined to the primary by faces.
|
||||||
@ -413,17 +315,9 @@ inline bool Foam::treeBoundBox::overlaps(const treeBoundBox& bb) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::treeBoundBox::contains(const point& sample) const
|
inline bool Foam::treeBoundBox::contains(const point& pt) const
|
||||||
{
|
{
|
||||||
return
|
return boundBox::contains(pt);
|
||||||
(
|
|
||||||
(sample.x() >= min().x()) &&
|
|
||||||
(sample.y() >= min().y()) &&
|
|
||||||
(sample.z() >= min().z()) &&
|
|
||||||
(sample.x() <= max().x()) &&
|
|
||||||
(sample.y() <= max().y()) &&
|
|
||||||
(sample.z() <= max().z())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,7 +337,7 @@ inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
|||||||
|
|
||||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
for (direction dir = 0; dir < vector::nComponents; dir++)
|
||||||
{
|
{
|
||||||
newSpan[dir] = Foam::max(minSpan, newSpan[dir]);
|
newSpan[dir] = Foam::max(newSpan[dir], minSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
bb.min() -= cmptMultiply(s * rndGen.vector01(), newSpan);
|
bb.min() -= cmptMultiply(s * rndGen.vector01(), newSpan);
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from bb
|
//- Construct from bounding box
|
||||||
treeElem(const treeBoundBox& bb)
|
treeElem(const treeBoundBox& bb)
|
||||||
:
|
:
|
||||||
bb_(bb)
|
bb_(bb)
|
||||||
@ -70,11 +70,13 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- Bounding box of this node
|
||||||
const treeBoundBox& bb() const
|
const treeBoundBox& bb() const
|
||||||
{
|
{
|
||||||
return bb_;
|
return bb_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Bounding box of this node
|
||||||
treeBoundBox& bb()
|
treeBoundBox& bb()
|
||||||
{
|
{
|
||||||
return bb_;
|
return bb_;
|
||||||
|
|||||||
@ -32,17 +32,12 @@ Description
|
|||||||
#include "octree.H"
|
#include "octree.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeLeaf<Type>::space(Ostream& os, const label n)
|
void Foam::treeLeaf<Type>::space(Ostream& os, const label n)
|
||||||
{
|
{
|
||||||
for(label i=0; i<n; i++)
|
for (label i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
os<< ' ';
|
os<< ' ';
|
||||||
}
|
}
|
||||||
@ -53,7 +48,7 @@ void treeLeaf<Type>::space(Ostream& os, const label n)
|
|||||||
|
|
||||||
// Construct with given size
|
// Construct with given size
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const label size)
|
Foam::treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const label size)
|
||||||
:
|
:
|
||||||
treeElem<Type>(bb), size_(0), indices_(size)
|
treeElem<Type>(bb), size_(0), indices_(size)
|
||||||
{}
|
{}
|
||||||
@ -61,7 +56,7 @@ treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const label size)
|
|||||||
|
|
||||||
// Construct from list
|
// Construct from list
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const labelList& indices)
|
Foam::treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const labelList& indices)
|
||||||
:
|
:
|
||||||
treeElem<Type>(bb), size_(indices.size()), indices_(indices)
|
treeElem<Type>(bb), size_(indices.size()), indices_(indices)
|
||||||
{
|
{
|
||||||
@ -70,7 +65,7 @@ treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const labelList& indices)
|
|||||||
|
|
||||||
// Construct from Istream
|
// Construct from Istream
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeLeaf<Type>::treeLeaf(Istream& is)
|
Foam::treeLeaf<Type>::treeLeaf(Istream& is)
|
||||||
{
|
{
|
||||||
is >> *this;
|
is >> *this;
|
||||||
}
|
}
|
||||||
@ -79,7 +74,7 @@ treeLeaf<Type>::treeLeaf(Istream& is)
|
|||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeLeaf<Type>::~treeLeaf()
|
Foam::treeLeaf<Type>::~treeLeaf()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +82,7 @@ treeLeaf<Type>::~treeLeaf()
|
|||||||
|
|
||||||
// Take cells at this level and distribute them to lower levels
|
// Take cells at this level and distribute them to lower levels
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeLeaf<Type>* treeLeaf<Type>::redistribute
|
Foam::treeLeaf<Type>* Foam::treeLeaf<Type>::redistribute
|
||||||
(
|
(
|
||||||
const label level,
|
const label level,
|
||||||
octree<Type>& top,
|
octree<Type>& top,
|
||||||
@ -140,7 +135,7 @@ treeLeaf<Type>* treeLeaf<Type>::redistribute
|
|||||||
|
|
||||||
// Set type of subnodes. Since contains elements return mixed type always.
|
// Set type of subnodes. Since contains elements return mixed type always.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Foam::label treeLeaf<Type>::setSubNodeType
|
Foam::label Foam::treeLeaf<Type>::setSubNodeType
|
||||||
(
|
(
|
||||||
const label level,
|
const label level,
|
||||||
octree<Type>& top,
|
octree<Type>& top,
|
||||||
@ -154,14 +149,14 @@ Foam::label treeLeaf<Type>::setSubNodeType
|
|||||||
"treeLeaf<Type>::setSubNodeType(const label, octree<Type>&, "
|
"treeLeaf<Type>::setSubNodeType(const label, octree<Type>&, "
|
||||||
"const Type&)"
|
"const Type&)"
|
||||||
) << "empty leaf. bb:" << this->bb()
|
) << "empty leaf. bb:" << this->bb()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
return octree<Type>::MIXED;
|
return octree<Type>::MIXED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Foam::label treeLeaf<Type>::getSampleType
|
Foam::label Foam::treeLeaf<Type>::getSampleType
|
||||||
(
|
(
|
||||||
const label level,
|
const label level,
|
||||||
const octree<Type>& top,
|
const octree<Type>& top,
|
||||||
@ -174,7 +169,7 @@ Foam::label treeLeaf<Type>::getSampleType
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label treeLeaf<Type>::find
|
Foam::label Foam::treeLeaf<Type>::find
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample
|
const point& sample
|
||||||
@ -193,7 +188,7 @@ label treeLeaf<Type>::find
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeLeaf<Type>::findTightest
|
bool Foam::treeLeaf<Type>::findTightest
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
@ -204,13 +199,12 @@ bool treeLeaf<Type>::findTightest
|
|||||||
|
|
||||||
forAll(indices_, i)
|
forAll(indices_, i)
|
||||||
{
|
{
|
||||||
changed |=
|
changed |= shapes.findTightest
|
||||||
shapes.findTightest
|
(
|
||||||
(
|
indices_[i],
|
||||||
indices_[i],
|
sample,
|
||||||
sample,
|
tightest
|
||||||
tightest
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
@ -218,12 +212,12 @@ bool treeLeaf<Type>::findTightest
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeLeaf<Type>::findNearest
|
bool Foam::treeLeaf<Type>::findNearest
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -252,7 +246,7 @@ bool treeLeaf<Type>::findNearest
|
|||||||
tightest.max() = sample + dist;
|
tightest.max() = sample + dist;
|
||||||
|
|
||||||
// Update other return values
|
// Update other return values
|
||||||
tightesti = indices_[i];
|
tightestI = indices_[i];
|
||||||
|
|
||||||
tightestDist = thisDist;
|
tightestDist = thisDist;
|
||||||
|
|
||||||
@ -262,7 +256,7 @@ bool treeLeaf<Type>::findNearest
|
|||||||
{
|
{
|
||||||
//space(Pout, level);
|
//space(Pout, level);
|
||||||
Pout<< "treeLeaf<Type>::findNearest : Found nearer : shape:"
|
Pout<< "treeLeaf<Type>::findNearest : Found nearer : shape:"
|
||||||
<< tightesti << " distance:" << tightestDist
|
<< tightestI << " distance:" << tightestDist
|
||||||
<< " to sample:" << sample << endl;
|
<< " to sample:" << sample << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,12 +278,12 @@ bool treeLeaf<Type>::findNearest
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeLeaf<Type>::findNearest
|
bool Foam::treeLeaf<Type>::findNearest
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const linePointRef& ln,
|
const linePointRef& ln,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
point& linePoint, // nearest point on line
|
point& linePoint, // nearest point on line
|
||||||
point& shapePoint // nearest point on shape
|
point& shapePoint // nearest point on shape
|
||||||
) const
|
) const
|
||||||
@ -317,7 +311,7 @@ bool treeLeaf<Type>::findNearest
|
|||||||
{
|
{
|
||||||
// Found nearer. Use.
|
// Found nearer. Use.
|
||||||
tightestDist = thisDist;
|
tightestDist = thisDist;
|
||||||
tightesti = indices_[i];
|
tightestI = indices_[i];
|
||||||
linePoint = linePt;
|
linePoint = linePt;
|
||||||
shapePoint = shapePt;
|
shapePoint = shapePt;
|
||||||
// Construct new tightest Bb. Nearest point can never be further
|
// Construct new tightest Bb. Nearest point can never be further
|
||||||
@ -337,7 +331,7 @@ bool treeLeaf<Type>::findNearest
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeLeaf<Type>::findBox
|
bool Foam::treeLeaf<Type>::findBox
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const boundBox& box,
|
const boundBox& box,
|
||||||
@ -361,7 +355,7 @@ bool treeLeaf<Type>::findBox
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeLeaf<Type>::printLeaf
|
void Foam::treeLeaf<Type>::printLeaf
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const label level
|
const label level
|
||||||
@ -380,7 +374,7 @@ void treeLeaf<Type>::printLeaf
|
|||||||
|
|
||||||
// Dump cube coordinates in OBJ format
|
// Dump cube coordinates in OBJ format
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeLeaf<Type>::writeOBJ
|
void Foam::treeLeaf<Type>::writeOBJ
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const label level,
|
const label level,
|
||||||
@ -420,7 +414,7 @@ void treeLeaf<Type>::writeOBJ
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label treeLeaf<Type>::countLeaf
|
Foam::label Foam::treeLeaf<Type>::countLeaf
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const label level
|
const label level
|
||||||
@ -439,7 +433,7 @@ label treeLeaf<Type>::countLeaf
|
|||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Istream& operator>> (Istream& is, treeLeaf<Type>& leaf)
|
Foam::Istream& Foam::operator>> (Istream& is, treeLeaf<Type>& leaf)
|
||||||
{
|
{
|
||||||
is >> leaf.bb() >> leaf.indices_;
|
is >> leaf.bb() >> leaf.indices_;
|
||||||
|
|
||||||
@ -450,7 +444,7 @@ Istream& operator>> (Istream& is, treeLeaf<Type>& leaf)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Ostream& operator<< (Ostream& os, const treeLeaf<Type>& leaf)
|
Foam::Ostream& Foam::operator<< (Ostream& os, const treeLeaf<Type>& leaf)
|
||||||
{
|
{
|
||||||
os << leaf.bb();
|
os << leaf.bb();
|
||||||
|
|
||||||
@ -472,9 +466,4 @@ Ostream& operator<< (Ostream& os, const treeLeaf<Type>& leaf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -30,8 +30,8 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
treeLeaf.C
|
treeLeaf.C
|
||||||
octreeDataPointTreaLeaf.H (specialization for points only )
|
octreeDataPointTreeLeaf.C (specialization for points only)
|
||||||
octreeDataPointTreeLeaf.C ( ,, )
|
octreeDataPointTreeLeaf.H (specialization for points only)
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ public:
|
|||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public:
|
|||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const linePointRef& ln,
|
const linePointRef& ln,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti, // index of nearest shape
|
label& tightestI, // index of nearest shape
|
||||||
point& linePoint, // nearest point on line
|
point& linePoint, // nearest point on line
|
||||||
point& shapePoint // nearest point on shape
|
point& shapePoint // nearest point on shape
|
||||||
) const;
|
) const;
|
||||||
@ -250,7 +250,7 @@ public:
|
|||||||
label& vertNo
|
label& vertNo
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- debug:
|
//- debug:
|
||||||
label countLeaf(Ostream&, const label) const;
|
label countLeaf(Ostream&, const label) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -33,31 +33,23 @@ Description
|
|||||||
#include "long.H"
|
#include "long.H"
|
||||||
#include "linePointRef.H"
|
#include "linePointRef.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
const label treeNode<Type>::leafOffset = 100;
|
const Foam::label Foam::treeNode<Type>::leafOffset(100);
|
||||||
|
|
||||||
template <class Type>
|
|
||||||
const labelList treeNode<Type>::dummy(1);
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::setAsNode(const label octant)
|
void Foam::treeNode<Type>::setAsNode(const label octant)
|
||||||
{
|
{
|
||||||
subNodeTypes_ |= (0x1 << octant);
|
subNodeTypes_ |= (0x1 << octant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::setAsLeaf(const label octant)
|
void Foam::treeNode<Type>::setAsLeaf(const label octant)
|
||||||
{
|
{
|
||||||
subNodeTypes_ &= ~(0x1 << octant);
|
subNodeTypes_ &= ~(0x1 << octant);
|
||||||
}
|
}
|
||||||
@ -65,7 +57,11 @@ void treeNode<Type>::setAsLeaf(const label octant)
|
|||||||
|
|
||||||
// Set pointer to sub node
|
// Set pointer to sub node
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::setNodePtr(const label octant, treeElem<Type>* treeNodePtr)
|
void Foam::treeNode<Type>::setNodePtr
|
||||||
|
(
|
||||||
|
const label octant,
|
||||||
|
treeElem<Type>* treeNodePtr
|
||||||
|
)
|
||||||
{
|
{
|
||||||
setAsNode(octant);
|
setAsNode(octant);
|
||||||
subNodes_[octant] = treeNodePtr;
|
subNodes_[octant] = treeNodePtr;
|
||||||
@ -74,7 +70,11 @@ void treeNode<Type>::setNodePtr(const label octant, treeElem<Type>* treeNodePtr)
|
|||||||
|
|
||||||
// Set pointer to sub leaf
|
// Set pointer to sub leaf
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::setLeafPtr(const label octant, treeElem<Type>* treeLeafPtr)
|
void Foam::treeNode<Type>::setLeafPtr
|
||||||
|
(
|
||||||
|
const label octant,
|
||||||
|
treeElem<Type>* treeLeafPtr
|
||||||
|
)
|
||||||
{
|
{
|
||||||
setAsLeaf(octant);
|
setAsLeaf(octant);
|
||||||
subNodes_[octant] = treeLeafPtr;
|
subNodes_[octant] = treeLeafPtr;
|
||||||
@ -82,7 +82,11 @@ void treeNode<Type>::setLeafPtr(const label octant, treeElem<Type>* treeLeafPtr)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::setVolType(const label octant, const label type)
|
void Foam::treeNode<Type>::setVolType
|
||||||
|
(
|
||||||
|
const label octant,
|
||||||
|
const label type
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if ((type < 0) || (type > 3))
|
if ((type < 0) || (type > 3))
|
||||||
{
|
{
|
||||||
@ -99,9 +103,9 @@ void treeNode<Type>::setVolType(const label octant, const label type)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::space(Ostream& os, const label n)
|
void Foam::treeNode<Type>::space(Ostream& os, const label n)
|
||||||
{
|
{
|
||||||
for(label i=0; i<n; i++)
|
for (label i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
os<< ' ';
|
os<< ' ';
|
||||||
}
|
}
|
||||||
@ -110,7 +114,7 @@ void treeNode<Type>::space(Ostream& os, const label n)
|
|||||||
|
|
||||||
// look in single octant starting from <start>
|
// look in single octant starting from <start>
|
||||||
template <class Type>
|
template <class Type>
|
||||||
const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
const Foam::treeLeaf<Type>* Foam::treeNode<Type>::findLeafLineOctant
|
||||||
(
|
(
|
||||||
const int level,
|
const int level,
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
@ -131,7 +135,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
|||||||
Pout<< "findLeafLineOctant : bb:" << this->bb()
|
Pout<< "findLeafLineOctant : bb:" << this->bb()
|
||||||
<< " start:" << start
|
<< " start:" << start
|
||||||
<< " end:" << end
|
<< " end:" << end
|
||||||
<< " mid:" << mid()
|
<< " mid:" << midpoint()
|
||||||
<< " Searching octant:" << octant
|
<< " Searching octant:" << octant
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -146,14 +150,13 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
|||||||
if (subNodePtr->bb().contains(direction, start))
|
if (subNodePtr->bb().contains(direction, start))
|
||||||
{
|
{
|
||||||
// Search on lower level
|
// Search on lower level
|
||||||
const treeLeaf<Type>* subLeafPtr =
|
const treeLeaf<Type>* subLeafPtr = subNodePtr->findLeafLine
|
||||||
subNodePtr->findLeafLine
|
(
|
||||||
(
|
level + 1,
|
||||||
level + 1,
|
shapes,
|
||||||
shapes,
|
start,
|
||||||
start,
|
end
|
||||||
end
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (debug & 2)
|
if (debug & 2)
|
||||||
{
|
{
|
||||||
@ -184,9 +187,9 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
|||||||
{
|
{
|
||||||
// Step to end of subleaf bb
|
// Step to end of subleaf bb
|
||||||
point tmp;
|
point tmp;
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
!subLeafPtr->bb().intersects
|
!subLeafPtr->bb().intersects
|
||||||
(
|
(
|
||||||
end,
|
end,
|
||||||
start,
|
start,
|
||||||
@ -226,7 +229,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Empty subNode. Transfer across.
|
// Empty subNode. Transfer across.
|
||||||
const treeBoundBox emptyBb = this->bb().subBbox(mid(), octant);
|
const treeBoundBox emptyBb = this->bb().subBbox(midpoint(), octant);
|
||||||
|
|
||||||
if (emptyBb.contains(direction, start))
|
if (emptyBb.contains(direction, start))
|
||||||
{
|
{
|
||||||
@ -241,9 +244,9 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
|||||||
|
|
||||||
// Update start by clipping to emptyBb
|
// Update start by clipping to emptyBb
|
||||||
point tmp;
|
point tmp;
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
!emptyBb.intersects
|
!emptyBb.intersects
|
||||||
(
|
(
|
||||||
end,
|
end,
|
||||||
start,
|
start,
|
||||||
@ -293,28 +296,25 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
|||||||
|
|
||||||
// Construct from components
|
// Construct from components
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeNode<Type>::treeNode(const treeBoundBox& bb)
|
Foam::treeNode<Type>::treeNode(const treeBoundBox& bb)
|
||||||
:
|
:
|
||||||
treeElem<Type>(bb),
|
treeElem<Type>(bb),
|
||||||
treeNodeName(),
|
treeNodeName(),
|
||||||
mid_(bb.mid()),
|
mid_(bb.midpoint()),
|
||||||
subNodeTypes_(0),
|
subNodeTypes_(0),
|
||||||
volType_(0)
|
volType_(0)
|
||||||
{
|
{
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octantI=0; octantI<8; octantI++)
|
||||||
{
|
{
|
||||||
subNodes_[octant] = NULL;
|
subNodes_[octantI] = NULL;
|
||||||
setVolType(octant, octree<Type>::UNKNOWN);
|
setVolType(octantI, octree<Type>::UNKNOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Construct from Istream
|
// Construct from Istream
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeNode<Type>::treeNode
|
Foam::treeNode<Type>::treeNode(Istream& is)
|
||||||
(
|
|
||||||
Istream& is
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
is >> *this;
|
is >> *this;
|
||||||
}
|
}
|
||||||
@ -323,9 +323,9 @@ treeNode<Type>::treeNode
|
|||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
treeNode<Type>::~treeNode()
|
Foam::treeNode<Type>::~treeNode()
|
||||||
{
|
{
|
||||||
for(int octant=0; octant<8; octant++)
|
for (int octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
{
|
{
|
||||||
@ -346,7 +346,7 @@ treeNode<Type>::~treeNode()
|
|||||||
|
|
||||||
// Distributes cells to subLeaves
|
// Distributes cells to subLeaves
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::distribute
|
void Foam::treeNode<Type>::distribute
|
||||||
(
|
(
|
||||||
const label level,
|
const label level,
|
||||||
octree<Type>& top,
|
octree<Type>& top,
|
||||||
@ -360,8 +360,8 @@ void treeNode<Type>::distribute
|
|||||||
Pout<< "treeNode::distributing " << indices.size() << endl;
|
Pout<< "treeNode::distributing " << indices.size() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create subLeaves if nessecary
|
// Create subLeaves if necessary
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
{
|
{
|
||||||
@ -371,16 +371,15 @@ void treeNode<Type>::distribute
|
|||||||
"treeNode<Type>::distribute(const label, octree<Type>&, "
|
"treeNode<Type>::distribute(const label, octree<Type>&, "
|
||||||
"const Type&, const labelList&)"
|
"const Type&, const labelList&)"
|
||||||
) << "subNode already available at octant:" << octant
|
) << "subNode already available at octant:" << octant
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
treeLeaf<Type>* subLeafPtr =
|
treeLeaf<Type>* subLeafPtr = new treeLeaf<Type>
|
||||||
new treeLeaf<Type>
|
(
|
||||||
(
|
this->bb().subBbox(midpoint(), octant),
|
||||||
this->bb().subBbox(mid(), octant),
|
indices.size()
|
||||||
indices.size()
|
);
|
||||||
);
|
|
||||||
|
|
||||||
top.setLeaves(top.nLeaves() + 1);
|
top.setLeaves(top.nLeaves() + 1);
|
||||||
setLeafPtr(octant, subLeafPtr);
|
setLeafPtr(octant, subLeafPtr);
|
||||||
@ -393,7 +392,7 @@ void treeNode<Type>::distribute
|
|||||||
{
|
{
|
||||||
const label shapei = indices[i];
|
const label shapei = indices[i];
|
||||||
|
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
treeLeaf<Type>* leafPtr = getLeafPtr(octant);
|
treeLeaf<Type>* leafPtr = getLeafPtr(octant);
|
||||||
|
|
||||||
@ -413,7 +412,7 @@ void treeNode<Type>::distribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trim size of subLeaves
|
// Trim size of subLeaves
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
treeLeaf<Type>* subLeafPtr = getLeafPtr(octant);
|
treeLeaf<Type>* subLeafPtr = getLeafPtr(octant);
|
||||||
|
|
||||||
@ -441,7 +440,7 @@ void treeNode<Type>::distribute
|
|||||||
|
|
||||||
// Descends to refineLevel and checks the subLeaves for redistribution
|
// Descends to refineLevel and checks the subLeaves for redistribution
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::redistribute
|
void Foam::treeNode<Type>::redistribute
|
||||||
(
|
(
|
||||||
const label level,
|
const label level,
|
||||||
octree<Type>& top,
|
octree<Type>& top,
|
||||||
@ -459,7 +458,7 @@ void treeNode<Type>::redistribute
|
|||||||
// Descend to correct level
|
// Descend to correct level
|
||||||
if (level < refineLevel)
|
if (level < refineLevel)
|
||||||
{
|
{
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
{
|
{
|
||||||
@ -486,7 +485,7 @@ void treeNode<Type>::redistribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle redistribution of sub leaves
|
// handle redistribution of sub leaves
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
{
|
{
|
||||||
@ -549,7 +548,7 @@ void treeNode<Type>::redistribute
|
|||||||
|
|
||||||
// Set type of node.
|
// Set type of node.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label treeNode<Type>::setSubNodeType
|
Foam::label Foam::treeNode<Type>::setSubNodeType
|
||||||
(
|
(
|
||||||
const label level,
|
const label level,
|
||||||
octree<Type>& top,
|
octree<Type>& top,
|
||||||
@ -565,7 +564,7 @@ label treeNode<Type>::setSubNodeType
|
|||||||
|
|
||||||
label myType = -1;
|
label myType = -1;
|
||||||
|
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
label subType = -1;
|
label subType = -1;
|
||||||
|
|
||||||
@ -594,16 +593,16 @@ label treeNode<Type>::setSubNodeType
|
|||||||
{
|
{
|
||||||
// No data in this one. Set type for octant acc. to its bounding
|
// No data in this one. Set type for octant acc. to its bounding
|
||||||
// box.
|
// box.
|
||||||
const treeBoundBox subBb = this->bb().subBbox(mid(), octant);
|
const treeBoundBox subBb = this->bb().subBbox(midpoint(), octant);
|
||||||
|
|
||||||
subType = shapes.getSampleType(top, subBb.mid());
|
subType = shapes.getSampleType(top, subBb.midpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug & 4)
|
if (debug & 4)
|
||||||
{
|
{
|
||||||
space(Pout, level);
|
space(Pout, level);
|
||||||
Pout<< "treeNode::setSubNodeType : setting octant with bb:"
|
Pout<< "treeNode::setSubNodeType : setting octant with bb:"
|
||||||
<< this->bb().subBbox(mid(), octant)
|
<< this->bb().subBbox(midpoint(), octant)
|
||||||
<< " to type:" << octree<Type>::volType(subType) << endl;
|
<< " to type:" << octree<Type>::volType(subType) << endl;
|
||||||
}
|
}
|
||||||
setVolType(octant, subType);
|
setVolType(octant, subType);
|
||||||
@ -634,7 +633,7 @@ label treeNode<Type>::setSubNodeType
|
|||||||
|
|
||||||
// Get type of node.
|
// Get type of node.
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label treeNode<Type>::getSampleType
|
Foam::label Foam::treeNode<Type>::getSampleType
|
||||||
(
|
(
|
||||||
const label level,
|
const label level,
|
||||||
const octree<Type>& top,
|
const octree<Type>& top,
|
||||||
@ -652,7 +651,7 @@ label treeNode<Type>::getSampleType
|
|||||||
// Determine octant of bb. If on edge just use whichever octant.
|
// Determine octant of bb. If on edge just use whichever octant.
|
||||||
bool onEdge = false;
|
bool onEdge = false;
|
||||||
|
|
||||||
label octant = this->bb().subOctant(mid(), sample, onEdge);
|
label octant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||||
|
|
||||||
label type = getVolType(octant);
|
label type = getVolType(octant);
|
||||||
|
|
||||||
@ -691,7 +690,7 @@ label treeNode<Type>::getSampleType
|
|||||||
(
|
(
|
||||||
"treeNode<Type>::getSampleType"
|
"treeNode<Type>::getSampleType"
|
||||||
"(const label, octree<Type>&, const Type&, const point&)"
|
"(const label, octree<Type>&, const Type&, const point&)"
|
||||||
) << "Empty node bb:" << this->bb().subBbox(mid(), octant)
|
) << "Empty node bb:" << this->bb().subBbox(midpoint(), octant)
|
||||||
<< " has non-mixed type:"
|
<< " has non-mixed type:"
|
||||||
<< octree<Type>::volType(type)
|
<< octree<Type>::volType(type)
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -723,7 +722,7 @@ label treeNode<Type>::getSampleType
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
label treeNode<Type>::find
|
Foam::label Foam::treeNode<Type>::find
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample
|
const point& sample
|
||||||
@ -733,18 +732,14 @@ label treeNode<Type>::find
|
|||||||
// will have been inserted in both subcubes)
|
// will have been inserted in both subcubes)
|
||||||
bool onEdge = false;
|
bool onEdge = false;
|
||||||
|
|
||||||
label octant = this->bb().subOctant(mid(), sample, onEdge);
|
label octant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||||
|
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
{
|
{
|
||||||
if (isNode(octant))
|
if (isNode(octant))
|
||||||
{
|
{
|
||||||
// Node: recurse into subnodes
|
// Node: recurse into subnodes
|
||||||
return getNodePtr(octant)->find
|
return getNodePtr(octant)->find(shapes, sample);
|
||||||
(
|
|
||||||
shapes,
|
|
||||||
sample
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -757,7 +752,7 @@ label treeNode<Type>::find
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeNode<Type>::findTightest
|
bool Foam::treeNode<Type>::findTightest
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
@ -765,30 +760,28 @@ bool treeNode<Type>::findTightest
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
// Get best guess for starting octant
|
|
||||||
bool onEdge = false;
|
bool onEdge = false;
|
||||||
|
// Estimate for best place to start searching
|
||||||
label sampleOctant = this->bb().subOctant(mid(), sample, onEdge);
|
label sampleOctant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||||
|
|
||||||
// Go into all suboctants (one containing sample first) and update tightest.
|
// Go into all suboctants (one containing sample first) and update tightest.
|
||||||
// Order of visiting is if e.g. sampleOctant = 5:
|
// Order of visiting is if e.g. sampleOctant = 5:
|
||||||
// 5 1 2 3 4 0 6 7
|
// 5 1 2 3 4 0 6 7
|
||||||
for(label octanti=0; octanti<8; octanti++)
|
for (label octantI=0; octantI<8; octantI++)
|
||||||
{
|
{
|
||||||
label octant;
|
label octant;
|
||||||
if (octanti == 0)
|
if (octantI == 0)
|
||||||
{
|
{
|
||||||
// Use sampleOctant first
|
// Use sampleOctant first
|
||||||
octant = sampleOctant;
|
octant = sampleOctant;
|
||||||
}
|
}
|
||||||
else if (octanti == sampleOctant)
|
else if (octantI == sampleOctant)
|
||||||
{
|
{
|
||||||
octant = 0;
|
octant = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
octant = octanti;
|
octant = octantI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
@ -801,13 +794,12 @@ bool treeNode<Type>::findTightest
|
|||||||
if (subNodePtr->bb().overlaps(tightest))
|
if (subNodePtr->bb().overlaps(tightest))
|
||||||
{
|
{
|
||||||
// there might be a better fit inside this subNode
|
// there might be a better fit inside this subNode
|
||||||
changed |=
|
changed |= subNodePtr->findTightest
|
||||||
subNodePtr->findTightest
|
(
|
||||||
(
|
shapes,
|
||||||
shapes,
|
sample,
|
||||||
sample,
|
tightest
|
||||||
tightest
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -818,13 +810,12 @@ bool treeNode<Type>::findTightest
|
|||||||
if (subLeafPtr->bb().overlaps(tightest))
|
if (subLeafPtr->bb().overlaps(tightest))
|
||||||
{
|
{
|
||||||
// there might be a better fit inside this subLeaf
|
// there might be a better fit inside this subLeaf
|
||||||
changed |=
|
changed |= subLeafPtr->findTightest
|
||||||
subLeafPtr->findTightest
|
(
|
||||||
(
|
shapes,
|
||||||
shapes,
|
sample,
|
||||||
sample,
|
tightest
|
||||||
tightest
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -835,46 +826,44 @@ bool treeNode<Type>::findTightest
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeNode<Type>::findNearest
|
bool Foam::treeNode<Type>::findNearest
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
|
|
||||||
if (debug & 8)
|
if (debug & 8)
|
||||||
{
|
{
|
||||||
Pout<< "In findNearest with sample:" << sample << " cube:"
|
Pout<< "In findNearest with sample:" << sample << " cube:"
|
||||||
<< this->bb() << " tightest:" << tightest << endl;
|
<< this->bb() << " tightest:" << tightest << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
bool onEdge = false;
|
bool onEdge = false;
|
||||||
|
// Estimate for best place to start searching
|
||||||
|
label sampleOctant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||||
|
|
||||||
label sampleOctant = this->bb().subOctant(mid(), sample, onEdge);
|
|
||||||
|
|
||||||
// Go into all suboctants (one containing sample first) and update tightest.
|
// Go into all suboctants (one containing sample first) and update tightest.
|
||||||
// Order of visiting is if e.g. sampleOctant = 5:
|
// Order of visiting is if e.g. sampleOctant = 5:
|
||||||
// 5 1 2 3 4 0 6 7
|
// 5 1 2 3 4 0 6 7
|
||||||
for(label octanti=0; octanti<8; octanti++)
|
for (label octantI=0; octantI<8; octantI++)
|
||||||
{
|
{
|
||||||
label octant;
|
label octant;
|
||||||
if (octanti == 0)
|
if (octantI == 0)
|
||||||
{
|
{
|
||||||
// Use sampleOctant first
|
// Use sampleOctant first
|
||||||
octant = sampleOctant;
|
octant = sampleOctant;
|
||||||
}
|
}
|
||||||
else if (octanti == sampleOctant)
|
else if (octantI == sampleOctant)
|
||||||
{
|
{
|
||||||
octant = 0;
|
octant = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
octant = octanti;
|
octant = octantI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
@ -887,15 +876,14 @@ bool treeNode<Type>::findNearest
|
|||||||
if (subNodePtr->bb().overlaps(tightest))
|
if (subNodePtr->bb().overlaps(tightest))
|
||||||
{
|
{
|
||||||
// there might be a better fit inside this subNode
|
// there might be a better fit inside this subNode
|
||||||
changed |=
|
changed |= subNodePtr->findNearest
|
||||||
subNodePtr->findNearest
|
(
|
||||||
(
|
shapes,
|
||||||
shapes,
|
sample,
|
||||||
sample,
|
tightest,
|
||||||
tightest,
|
tightestI,
|
||||||
tightesti,
|
tightestDist
|
||||||
tightestDist
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -906,15 +894,14 @@ bool treeNode<Type>::findNearest
|
|||||||
if (subLeafPtr->bb().overlaps(tightest))
|
if (subLeafPtr->bb().overlaps(tightest))
|
||||||
{
|
{
|
||||||
// there might be a better fit inside this subNode
|
// there might be a better fit inside this subNode
|
||||||
changed |=
|
changed |= subLeafPtr->findNearest
|
||||||
subLeafPtr->findNearest
|
(
|
||||||
(
|
shapes,
|
||||||
shapes,
|
sample,
|
||||||
sample,
|
tightest,
|
||||||
tightest,
|
tightestI,
|
||||||
tightesti,
|
tightestDist
|
||||||
tightestDist
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -923,7 +910,7 @@ bool treeNode<Type>::findNearest
|
|||||||
if (debug & 8)
|
if (debug & 8)
|
||||||
{
|
{
|
||||||
Pout<< "Exiting findNearest for sample:" << sample << " cube:"
|
Pout<< "Exiting findNearest for sample:" << sample << " cube:"
|
||||||
<< this->bb() << " tightesti:" << tightesti << endl;
|
<< this->bb() << " tightestI:" << tightestI << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
@ -931,41 +918,39 @@ bool treeNode<Type>::findNearest
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeNode<Type>::findNearest
|
bool Foam::treeNode<Type>::findNearest
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const linePointRef& ln,
|
const linePointRef& ln,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
point& linePoint, // nearest point on line
|
point& linePoint, // nearest point on line
|
||||||
point& shapePoint // nearest point on shape
|
point& shapePoint // nearest point on shape
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
bool onEdge = false;
|
bool onEdge = false;
|
||||||
|
// Estimate for best place to start searching
|
||||||
|
label sampleOctant = this->bb().subOctant(midpoint(), ln.centre(), onEdge);
|
||||||
|
|
||||||
// Estimate for where best to start searching
|
|
||||||
label sampleOctant = this->bb().subOctant(mid(), ln.centre(), onEdge);
|
|
||||||
|
|
||||||
// Go into all suboctants (one containing sample first) and update tightest.
|
// Go into all suboctants (one containing sample first) and update tightest.
|
||||||
// Order of visiting is if e.g. sampleOctant = 5:
|
// Order of visiting is if e.g. sampleOctant = 5:
|
||||||
// 5 1 2 3 4 0 6 7
|
// 5 1 2 3 4 0 6 7
|
||||||
for(label octanti=0; octanti<8; octanti++)
|
for (label octantI=0; octantI<8; octantI++)
|
||||||
{
|
{
|
||||||
label octant;
|
label octant;
|
||||||
if (octanti == 0)
|
if (octantI == 0)
|
||||||
{
|
{
|
||||||
// Use sampleOctant first
|
// Use sampleOctant first
|
||||||
octant = sampleOctant;
|
octant = sampleOctant;
|
||||||
}
|
}
|
||||||
else if (octanti == sampleOctant)
|
else if (octantI == sampleOctant)
|
||||||
{
|
{
|
||||||
octant = 0;
|
octant = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
octant = octanti;
|
octant = octantI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
@ -978,16 +963,15 @@ bool treeNode<Type>::findNearest
|
|||||||
if (subNodePtr->bb().overlaps(tightest))
|
if (subNodePtr->bb().overlaps(tightest))
|
||||||
{
|
{
|
||||||
// there might be a better fit inside this subNode
|
// there might be a better fit inside this subNode
|
||||||
changed |=
|
changed |= subNodePtr->findNearest
|
||||||
subNodePtr->findNearest
|
(
|
||||||
(
|
shapes,
|
||||||
shapes,
|
ln,
|
||||||
ln,
|
tightest,
|
||||||
tightest,
|
tightestI,
|
||||||
tightesti,
|
linePoint,
|
||||||
linePoint,
|
shapePoint
|
||||||
shapePoint
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -998,16 +982,15 @@ bool treeNode<Type>::findNearest
|
|||||||
if (subLeafPtr->bb().overlaps(tightest))
|
if (subLeafPtr->bb().overlaps(tightest))
|
||||||
{
|
{
|
||||||
// there might be a better fit inside this subNode
|
// there might be a better fit inside this subNode
|
||||||
changed |=
|
changed |= subLeafPtr->findNearest
|
||||||
subLeafPtr->findNearest
|
(
|
||||||
(
|
shapes,
|
||||||
shapes,
|
ln,
|
||||||
ln,
|
tightest,
|
||||||
tightest,
|
tightestI,
|
||||||
tightesti,
|
linePoint,
|
||||||
linePoint,
|
shapePoint
|
||||||
shapePoint
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1018,7 +1001,7 @@ bool treeNode<Type>::findNearest
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
bool treeNode<Type>::findBox
|
bool Foam::treeNode<Type>::findBox
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const boundBox& box,
|
const boundBox& box,
|
||||||
@ -1026,31 +1009,33 @@ bool treeNode<Type>::findBox
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
bool onEdge = false;
|
bool onEdge = false;
|
||||||
|
// Estimate for best place to start searching
|
||||||
|
label sampleOctant = this->bb().subOctant
|
||||||
|
(
|
||||||
|
midpoint(),
|
||||||
|
box.midpoint(),
|
||||||
|
onEdge
|
||||||
|
);
|
||||||
|
|
||||||
// Estimate for where best to start searching
|
|
||||||
point boxMid(0.5*(box.min() + box.max()));
|
|
||||||
label sampleOctant = this->bb().subOctant(mid(), boxMid, onEdge);
|
|
||||||
|
|
||||||
// Go into all suboctants (one containing sample first) and update tightest.
|
// Go into all suboctants (one containing sample first) and update tightest.
|
||||||
// Order of visiting is if e.g. sampleOctant = 5:
|
// Order of visiting is if e.g. sampleOctant = 5:
|
||||||
// 5 1 2 3 4 0 6 7
|
// 5 1 2 3 4 0 6 7
|
||||||
for(label octanti=0; octanti<8; octanti++)
|
for (label octantI=0; octantI<8; octantI++)
|
||||||
{
|
{
|
||||||
label octant;
|
label octant;
|
||||||
if (octanti == 0)
|
if (octantI == 0)
|
||||||
{
|
{
|
||||||
// Use sampleOctant first
|
// Use sampleOctant first
|
||||||
octant = sampleOctant;
|
octant = sampleOctant;
|
||||||
}
|
}
|
||||||
else if (octanti == sampleOctant)
|
else if (octantI == sampleOctant)
|
||||||
{
|
{
|
||||||
octant = 0;
|
octant = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
octant = octanti;
|
octant = octantI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
@ -1086,7 +1071,7 @@ bool treeNode<Type>::findBox
|
|||||||
|
|
||||||
// look from <start> in current cube (given by this->bb()).
|
// look from <start> in current cube (given by this->bb()).
|
||||||
template <class Type>
|
template <class Type>
|
||||||
const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
const Foam::treeLeaf<Type>* Foam::treeNode<Type>::findLeafLine
|
||||||
(
|
(
|
||||||
const int level,
|
const int level,
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
@ -1097,7 +1082,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
|||||||
if (debug & 2)
|
if (debug & 2)
|
||||||
{
|
{
|
||||||
space(Pout, 2*level);
|
space(Pout, 2*level);
|
||||||
Pout<< "findLeafLine : bb:" << this->bb() << " mid:" << mid()
|
Pout<< "findLeafLine : bb:" << this->bb() << " mid:" << midpoint()
|
||||||
<< " start:" << start << endl;
|
<< " start:" << start << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1111,7 +1096,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
|||||||
|
|
||||||
label iter = 0;
|
label iter = 0;
|
||||||
|
|
||||||
while(true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (!this->bb().contains(direction, start))
|
if (!this->bb().contains(direction, start))
|
||||||
{
|
{
|
||||||
@ -1145,19 +1130,21 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool onEdge = false;
|
bool onEdge = false;
|
||||||
label octant = this->bb().subOctant(mid(), direction, start, onEdge);
|
label octant = this->bb().subOctant
|
||||||
|
(
|
||||||
|
midpoint(), direction, start, onEdge
|
||||||
|
);
|
||||||
|
|
||||||
// Try finding non-empty treeleaf in octant
|
// Try finding non-empty treeleaf in octant
|
||||||
const treeLeaf<Type>* leafPtr =
|
const treeLeaf<Type>* leafPtr = findLeafLineOctant
|
||||||
findLeafLineOctant
|
(
|
||||||
(
|
level,
|
||||||
level,
|
shapes,
|
||||||
shapes,
|
octant,
|
||||||
octant,
|
direction,
|
||||||
direction,
|
start,
|
||||||
start,
|
end
|
||||||
end
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (leafPtr)
|
if (leafPtr)
|
||||||
{
|
{
|
||||||
@ -1193,14 +1180,14 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::findLeaves
|
void Foam::treeNode<Type>::findLeaves
|
||||||
(
|
(
|
||||||
List<treeLeaf<Type>*>& leafArray,
|
List<treeLeaf<Type>*>& leafArray,
|
||||||
label& leafIndex
|
label& leafIndex
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Go into all sub boxes
|
// Go into all sub boxes
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
{
|
{
|
||||||
@ -1222,14 +1209,14 @@ void treeNode<Type>::findLeaves
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::findLeaves
|
void Foam::treeNode<Type>::findLeaves
|
||||||
(
|
(
|
||||||
List<const treeLeaf<Type>*>& leafArray,
|
List<const treeLeaf<Type>*>& leafArray,
|
||||||
label& leafIndex
|
label& leafIndex
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Go into all sub boxes
|
// Go into all sub boxes
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
if (subNodes()[octant])
|
if (subNodes()[octant])
|
||||||
{
|
{
|
||||||
@ -1251,7 +1238,7 @@ void treeNode<Type>::findLeaves
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::printNode
|
void Foam::treeNode<Type>::printNode
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const label level
|
const label level
|
||||||
@ -1261,7 +1248,7 @@ void treeNode<Type>::printNode
|
|||||||
|
|
||||||
os << "node:" << this->bb() << endl;
|
os << "node:" << this->bb() << endl;
|
||||||
|
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
label type = getVolType(octant);
|
label type = getVolType(octant);
|
||||||
|
|
||||||
@ -1273,7 +1260,7 @@ void treeNode<Type>::printNode
|
|||||||
os << octant << ":" << typeString << " : null" << endl;
|
os << octant << ":" << typeString << " : null" << endl;
|
||||||
}
|
}
|
||||||
else if (isNode(octant))
|
else if (isNode(octant))
|
||||||
{
|
{
|
||||||
space(os, level);
|
space(os, level);
|
||||||
os << octant << ":" << typeString << " : node" << endl;
|
os << octant << ":" << typeString << " : node" << endl;
|
||||||
getNodePtr(octant)->printNode(os, level+1);
|
getNodePtr(octant)->printNode(os, level+1);
|
||||||
@ -1291,21 +1278,21 @@ void treeNode<Type>::printNode
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void treeNode<Type>::writeOBJ
|
void Foam::treeNode<Type>::writeOBJ
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const label level,
|
const label level,
|
||||||
label& vertNo
|
label& vertNo
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
point midPoint(this->bb().mid());
|
point midPoint(this->bb().midpoint());
|
||||||
|
|
||||||
label midVertNo = vertNo;
|
label midVertNo = vertNo;
|
||||||
os << "v " << midPoint.x() << " " << midPoint.y() << " "
|
os << "v " << midPoint.x() << " " << midPoint.y() << " "
|
||||||
<< midPoint.z() << endl;
|
<< midPoint.z() << endl;
|
||||||
vertNo++;
|
vertNo++;
|
||||||
|
|
||||||
for(label octant=0; octant<8; octant++)
|
for (label octant=0; octant<8; octant++)
|
||||||
{
|
{
|
||||||
if (subNodes_[octant])
|
if (subNodes_[octant])
|
||||||
{
|
{
|
||||||
@ -1313,7 +1300,7 @@ void treeNode<Type>::writeOBJ
|
|||||||
{
|
{
|
||||||
treeNode<Type>* nodePtr = getNodePtr(octant);
|
treeNode<Type>* nodePtr = getNodePtr(octant);
|
||||||
|
|
||||||
point subMidPoint(nodePtr->bb().mid());
|
point subMidPoint(nodePtr->bb().midpoint());
|
||||||
os << "v " << subMidPoint.x() << " " << subMidPoint.y() << " "
|
os << "v " << subMidPoint.x() << " " << subMidPoint.y() << " "
|
||||||
<< subMidPoint.z() << endl;
|
<< subMidPoint.z() << endl;
|
||||||
os << "l " << midVertNo + 1<< " " << vertNo + 1 << endl;
|
os << "l " << midVertNo + 1<< " " << vertNo + 1 << endl;
|
||||||
@ -1325,7 +1312,7 @@ void treeNode<Type>::writeOBJ
|
|||||||
{
|
{
|
||||||
treeLeaf<Type>* leafPtr = getLeafPtr(octant);
|
treeLeaf<Type>* leafPtr = getLeafPtr(octant);
|
||||||
|
|
||||||
point subMidPoint(leafPtr->bb().mid());
|
point subMidPoint(leafPtr->bb().midpoint());
|
||||||
os << "v " << subMidPoint.x() << " " << subMidPoint.y() << " "
|
os << "v " << subMidPoint.x() << " " << subMidPoint.y() << " "
|
||||||
<< subMidPoint.z() << endl;
|
<< subMidPoint.z() << endl;
|
||||||
os << "l " << midVertNo + 1<< " " << vertNo + 1 << endl;
|
os << "l " << midVertNo + 1<< " " << vertNo + 1 << endl;
|
||||||
@ -1337,13 +1324,13 @@ void treeNode<Type>::writeOBJ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Istream& operator>>(Istream& is, treeNode<Type>& oc)
|
Foam::Istream& Foam::operator>>(Istream& is, treeNode<Type>& oc)
|
||||||
{
|
{
|
||||||
for(label octant = 0; octant < 8; octant++)
|
for (label octant = 0; octant < 8; octant++)
|
||||||
{
|
{
|
||||||
oc.subNodes_[octant] = NULL;
|
oc.subNodes_[octant] = NULL;
|
||||||
}
|
}
|
||||||
@ -1384,7 +1371,7 @@ Istream& operator>>(Istream& is, treeNode<Type>& oc)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Ostream& operator<<(Ostream& os, const treeNode<Type>& tn)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const treeNode<Type>& tn)
|
||||||
{
|
{
|
||||||
// Count valid subnodes:
|
// Count valid subnodes:
|
||||||
// - treeNode
|
// - treeNode
|
||||||
@ -1434,14 +1421,10 @@ Ostream& operator<<(Ostream& os, const treeNode<Type>& tn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
os << token::SPACE << token::END_LIST;
|
os << token::SPACE << token::END_LIST;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -28,12 +28,13 @@ Class
|
|||||||
Description
|
Description
|
||||||
Class to implement octree.
|
Class to implement octree.
|
||||||
|
|
||||||
Holds the pointers to subcubes. These are either other treeNodes or
|
Holds the pointers to sub-octants. These are either other treeNodes or
|
||||||
treeLeafs. treeLeafs hold the actual data as a list of indices into
|
treeLeafs. The treeLeafs hold the actual data as a list of indices into
|
||||||
octreeData.
|
octreeData.
|
||||||
|
|
||||||
To prevent calculation errors all bb's used in octrees are calculated
|
Note
|
||||||
only once.
|
To prevent calculation errors all bounding boxes used in octrees are
|
||||||
|
calculated only once.
|
||||||
|
|
||||||
The pointers to either treeNode/treeLeaf are implemented 'by hand'
|
The pointers to either treeNode/treeLeaf are implemented 'by hand'
|
||||||
(explicitly marking type) instead of using a proper virtual mechanism
|
(explicitly marking type) instead of using a proper virtual mechanism
|
||||||
@ -69,7 +70,6 @@ template<class Type> Istream& operator>>(Istream&, treeNode<Type>&);
|
|||||||
template<class Type> Ostream& operator<<(Ostream&, const treeNode<Type>&);
|
template<class Type> Ostream& operator<<(Ostream&, const treeNode<Type>&);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class treeNodeName Declaration
|
Class treeNodeName Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -78,7 +78,7 @@ TemplateName(treeNode);
|
|||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class treeNode Declaration
|
Class treeNode Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
@ -89,7 +89,7 @@ class treeNode
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- position of midPoint
|
//- Position of the midpoint
|
||||||
const point mid_;
|
const point mid_;
|
||||||
|
|
||||||
//- Type stored in subNodes_
|
//- Type stored in subNodes_
|
||||||
@ -103,9 +103,6 @@ class treeNode
|
|||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
//- empty labelList to satisfy compiler
|
|
||||||
static const labelList dummy;
|
|
||||||
|
|
||||||
//- leaf offset for octant index
|
//- leaf offset for octant index
|
||||||
static const label leafOffset;
|
static const label leafOffset;
|
||||||
|
|
||||||
@ -157,7 +154,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
treeNode(const treeBoundBox& bb);
|
treeNode(const treeBoundBox&);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
treeNode(Istream&);
|
treeNode(Istream&);
|
||||||
@ -172,8 +169,8 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- position of midPoint
|
//- The midpoint position
|
||||||
const point& mid() const;
|
inline const point& midpoint() const;
|
||||||
|
|
||||||
//- array of 8 subNodes/leaves
|
//- array of 8 subNodes/leaves
|
||||||
inline treeElem<Type>* const* subNodes() const;
|
inline treeElem<Type>* const* subNodes() const;
|
||||||
@ -227,7 +224,7 @@ public:
|
|||||||
const point& sample
|
const point& sample
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Find index of shape containing sample.
|
//- Find index of shape containing sample.
|
||||||
label find
|
label find
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
@ -236,7 +233,7 @@ public:
|
|||||||
|
|
||||||
//- Find tightest bounding box around sample which is guaranteed
|
//- Find tightest bounding box around sample which is guaranteed
|
||||||
// to hold at least one cell.
|
// to hold at least one cell.
|
||||||
// Current best bb in tightest,
|
// Current best bb in tightest,
|
||||||
// returns true if newTightest has changed, 0 otherwise.
|
// returns true if newTightest has changed, 0 otherwise.
|
||||||
bool findTightest
|
bool findTightest
|
||||||
(
|
(
|
||||||
@ -244,16 +241,16 @@ public:
|
|||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest
|
treeBoundBox& tightest
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Find nearest shape to sample
|
//- Find nearest shape to sample
|
||||||
// Returns true if found nearer shape and updates
|
// Returns true if found nearer shape and updates
|
||||||
// tightest, tightesti, tightestDist
|
// tightest, tightestI, tightestDist
|
||||||
bool findNearest
|
bool findNearest
|
||||||
(
|
(
|
||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -265,7 +262,7 @@ public:
|
|||||||
const Type& shapes,
|
const Type& shapes,
|
||||||
const linePointRef& ln,
|
const linePointRef& ln,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti, // index of nearest shape
|
label& tightestI, // index of nearest shape
|
||||||
point& linePoint, // nearest point on line
|
point& linePoint, // nearest point on line
|
||||||
point& shapePoint // nearest point on shape
|
point& shapePoint // nearest point on shape
|
||||||
) const;
|
) const;
|
||||||
|
|||||||
@ -26,45 +26,44 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// Get type of octant
|
// Get type of octant
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline label treeNode<Type>::getVolType(const label octant) const
|
inline Foam::label Foam::treeNode<Type>::getVolType(const label octant) const
|
||||||
{
|
{
|
||||||
return (volType_ >> 2*octant) & 0x3;
|
return (volType_ >> 2*octant) & 0x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline const point& treeNode<Type>::mid() const
|
inline const Foam::point& Foam::treeNode<Type>::midpoint() const
|
||||||
{
|
{
|
||||||
return mid_;
|
return mid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline treeElem<Type>* const* treeNode<Type>::subNodes() const
|
inline Foam::treeElem<Type>* const* Foam::treeNode<Type>::subNodes() const
|
||||||
{
|
{
|
||||||
return subNodes_;
|
return subNodes_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// octant contains pointer to treeNode(1) or treeLeaf(0)
|
// octant contains pointer to treeNode(1) or treeLeaf(0)
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline label treeNode<Type>::isNode(const label octant) const
|
inline Foam::label Foam::treeNode<Type>::isNode(const label octant) const
|
||||||
{
|
{
|
||||||
return subNodeTypes_ & (0x1 << octant);
|
return subNodeTypes_ & (0x1 << octant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get pointer to sub node
|
// Get pointer to sub node
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline treeNode<Type>* treeNode<Type>::getNodePtr(const label octant) const
|
inline Foam::treeNode<Type>* Foam::treeNode<Type>::getNodePtr
|
||||||
|
(
|
||||||
|
const label octant
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
# ifdef FULLDEBUG
|
# ifdef FULLDEBUG
|
||||||
if (!isNode(octant))
|
if (!isNode(octant))
|
||||||
@ -81,7 +80,10 @@ inline treeNode<Type>* treeNode<Type>::getNodePtr(const label octant) const
|
|||||||
|
|
||||||
// Get pointer to sub leaf
|
// Get pointer to sub leaf
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline treeLeaf<Type>* treeNode<Type>::getLeafPtr(const label octant) const
|
inline Foam::treeLeaf<Type>* Foam::treeNode<Type>::getLeafPtr
|
||||||
|
(
|
||||||
|
const label octant
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
# ifdef FULLDEBUG
|
# ifdef FULLDEBUG
|
||||||
if (isNode(octant))
|
if (isNode(octant))
|
||||||
@ -95,8 +97,5 @@ inline treeLeaf<Type>* treeNode<Type>::getLeafPtr(const label octant) const
|
|||||||
return static_cast<treeLeaf<Type>*>(subNodes_[octant]);
|
return static_cast<treeLeaf<Type>*>(subNodes_[octant]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -38,12 +38,15 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
defineTypeNameAndDebug(distributedTriSurfaceMesh, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
searchableSurface,
|
||||||
|
distributedTriSurfaceMesh,
|
||||||
|
dict
|
||||||
|
);
|
||||||
|
|
||||||
defineTypeNameAndDebug(distributedTriSurfaceMesh, 0);
|
scalar distributedTriSurfaceMesh::mergeDist_ = SMALL;
|
||||||
addToRunTimeSelectionTable(searchableSurface, distributedTriSurfaceMesh, dict);
|
|
||||||
|
|
||||||
scalar distributedTriSurfaceMesh::mergeDist_ = SMALL;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -32,10 +32,8 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
defineTypeNameAndDebug(searchableBox, 0);
|
||||||
defineTypeNameAndDebug(searchableBox, 0);
|
addToRunTimeSelectionTable(searchableSurface, searchableBox, dict);
|
||||||
addToRunTimeSelectionTable(searchableSurface, searchableBox, dict);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -211,7 +209,7 @@ Foam::pointIndexHit Foam::searchableBox::findNearest
|
|||||||
const scalar nearestDistSqr
|
const scalar nearestDistSqr
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return findNearest(mid(), sample, nearestDistSqr);
|
return findNearest(midpoint(), sample, nearestDistSqr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -221,7 +219,7 @@ Foam::pointIndexHit Foam::searchableBox::findNearestOnEdge
|
|||||||
const scalar nearestDistSqr
|
const scalar nearestDistSqr
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const point bbMid(mid());
|
const point bbMid(midpoint());
|
||||||
|
|
||||||
// Outside point projected onto cube. Assume faces 0..5.
|
// Outside point projected onto cube. Assume faces 0..5.
|
||||||
pointIndexHit info(true, sample, -1);
|
pointIndexHit info(true, sample, -1);
|
||||||
@ -383,7 +381,7 @@ void Foam::searchableBox::findNearest
|
|||||||
{
|
{
|
||||||
info.setSize(samples.size());
|
info.setSize(samples.size());
|
||||||
|
|
||||||
const point bbMid(mid());
|
const point bbMid(midpoint());
|
||||||
|
|
||||||
forAll(samples, i)
|
forAll(samples, i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -59,7 +59,7 @@ void Foam::edgeIntersections::checkEdges(const triSurface& surf)
|
|||||||
|
|
||||||
treeBoundBox bb(localPoints);
|
treeBoundBox bb(localPoints);
|
||||||
|
|
||||||
scalar minSize = SMALL*bb.minDim();
|
scalar minSize = SMALL * bb.minDim();
|
||||||
|
|
||||||
forAll(edges, edgeI)
|
forAll(edges, edgeI)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -40,7 +40,7 @@ Description
|
|||||||
|
|
||||||
defineTypeNameAndDebug(Foam::octreeDataTriSurface, 0);
|
defineTypeNameAndDebug(Foam::octreeDataTriSurface, 0);
|
||||||
|
|
||||||
Foam::scalar Foam::octreeDataTriSurface::tol = 1E-6;
|
Foam::scalar Foam::octreeDataTriSurface::tol(1E-6);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -181,9 +181,9 @@ void Foam::octreeDataTriSurface::nearestCoords
|
|||||||
// with points very close to one of the triangle vertices.
|
// with points very close to one of the triangle vertices.
|
||||||
// (seen up to -9e-15). Alternatively add some small value.
|
// (seen up to -9e-15). Alternatively add some small value.
|
||||||
|
|
||||||
//const scalar f = D & D;
|
// const scalar f = D & D;
|
||||||
//return a*s*s + 2*b*s*t + c*t*t + 2*d*s + 2*e*t + f + SMALL;
|
// return a*s*s + 2*b*s*t + c*t*t + 2*d*s + 2*e*t + f + SMALL;
|
||||||
//return Foam::mag(a*s*s + 2*b*s*t + c*t*t + 2*d*s + 2*e*t + f);
|
// return Foam::mag(a*s*s + 2*b*s*t + c*t*t + 2*d*s + 2*e*t + f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -219,13 +219,7 @@ Foam::treeBoundBoxList Foam::octreeDataTriSurface::calcBb
|
|||||||
const triSurface& surf
|
const triSurface& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
treeBoundBox illegalBb
|
treeBoundBoxList allBb(surf.size(), treeBoundBox::invertedBox);
|
||||||
(
|
|
||||||
vector(GREAT, GREAT, GREAT),
|
|
||||||
vector(-GREAT, -GREAT, -GREAT)
|
|
||||||
);
|
|
||||||
|
|
||||||
treeBoundBoxList allBb(surf.size(), illegalBb);
|
|
||||||
|
|
||||||
const labelListList& pointFcs = surf.pointFaces();
|
const labelListList& pointFcs = surf.pointFaces();
|
||||||
const pointField& localPts = surf.localPoints();
|
const pointField& localPts = surf.localPoints();
|
||||||
@ -245,7 +239,7 @@ Foam::treeBoundBoxList Foam::octreeDataTriSurface::calcBb
|
|||||||
bb.min() = min(bb.min(), vertCoord);
|
bb.min() = min(bb.min(), vertCoord);
|
||||||
bb.max() = max(bb.max(), vertCoord);
|
bb.max() = max(bb.max(), vertCoord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return allBb;
|
return allBb;
|
||||||
}
|
}
|
||||||
@ -274,7 +268,7 @@ Foam::octreeDataTriSurface::octreeDataTriSurface(const triSurface& surface)
|
|||||||
|
|
||||||
// Calculate base and spanning vectors of triangles
|
// Calculate base and spanning vectors of triangles
|
||||||
base_[faceI] = points[f[1]];
|
base_[faceI] = points[f[1]];
|
||||||
E0_[faceI] = points[f[0]] - points[f[1]];
|
E0_[faceI] = points[f[0]] - points[f[1]];
|
||||||
E1_[faceI] = points[f[2]] - points[f[1]];
|
E1_[faceI] = points[f[2]] - points[f[1]];
|
||||||
|
|
||||||
a_[faceI] = E0_[faceI] & E0_[faceI];
|
a_[faceI] = E0_[faceI] & E0_[faceI];
|
||||||
@ -308,7 +302,7 @@ Foam::octreeDataTriSurface::octreeDataTriSurface
|
|||||||
|
|
||||||
// Calculate base and spanning vectors of triangles
|
// Calculate base and spanning vectors of triangles
|
||||||
base_[faceI] = points[f[1]];
|
base_[faceI] = points[f[1]];
|
||||||
E0_[faceI] = points[f[0]] - points[f[1]];
|
E0_[faceI] = points[f[0]] - points[f[1]];
|
||||||
E1_[faceI] = points[f[2]] - points[f[1]];
|
E1_[faceI] = points[f[2]] - points[f[1]];
|
||||||
|
|
||||||
a_[faceI] = E0_[faceI] & E0_[faceI];
|
a_[faceI] = E0_[faceI] & E0_[faceI];
|
||||||
@ -325,12 +319,12 @@ Foam::label Foam::octreeDataTriSurface::getSampleType
|
|||||||
const octree<octreeDataTriSurface>& oc,
|
const octree<octreeDataTriSurface>& oc,
|
||||||
const point& sample
|
const point& sample
|
||||||
) const
|
) const
|
||||||
|
|
||||||
{
|
{
|
||||||
// Find nearest face to sample
|
|
||||||
treeBoundBox tightest(treeBoundBox::greatBox);
|
treeBoundBox tightest(treeBoundBox::greatBox);
|
||||||
|
scalar tightestDist(treeBoundBox::great);
|
||||||
|
|
||||||
scalar tightestDist = GREAT;
|
// Find nearest face to sample
|
||||||
|
|
||||||
label faceI = oc.findNearest(sample, tightest, tightestDist);
|
label faceI = oc.findNearest(sample, tightest, tightestDist);
|
||||||
|
|
||||||
if (debug & 2)
|
if (debug & 2)
|
||||||
@ -350,16 +344,14 @@ Foam::label Foam::octreeDataTriSurface::getSampleType
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pointField& pts = surface_.points();
|
const pointField& pts = surface_.points();
|
||||||
|
|
||||||
const labelledTri& f = surface_[faceI];
|
const labelledTri& f = surface_[faceI];
|
||||||
|
|
||||||
pointHit curHit =
|
pointHit curHit = triPointRef
|
||||||
triPointRef
|
(
|
||||||
(
|
pts[f[0]],
|
||||||
pts[f[0]],
|
pts[f[1]],
|
||||||
pts[f[1]],
|
pts[f[2]]
|
||||||
pts[f[2]]
|
).nearestPoint(sample);
|
||||||
).nearestPoint(sample);
|
|
||||||
|
|
||||||
// Get normal according to position on face. On point -> pointNormal,
|
// Get normal according to position on face. On point -> pointNormal,
|
||||||
// on edge-> edge normal, face normal on interior.
|
// on edge-> edge normal, face normal on interior.
|
||||||
@ -503,7 +495,7 @@ bool Foam::octreeDataTriSurface::findTightest
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Construct bb around sample and myFar
|
// Construct bb around sample and myFar
|
||||||
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
|
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
|
||||||
|
|
||||||
tightest.min() = sample - dist2;
|
tightest.min() = sample - dist2;
|
||||||
tightest.max() = sample + dist2;
|
tightest.max() = sample + dist2;
|
||||||
@ -557,12 +549,12 @@ Foam::scalar Foam::octreeDataTriSurface::calcNearest
|
|||||||
{
|
{
|
||||||
notImplemented
|
notImplemented
|
||||||
(
|
(
|
||||||
"octreeDataTriSurface::calcNearest(const label, const linePointRef&"
|
"octreeDataTriSurface::calcNearest"
|
||||||
", point& linePt, point&)"
|
"(const label, const linePointRef&, point& linePt, point&)"
|
||||||
);
|
);
|
||||||
return GREAT;
|
return GREAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::octreeDataTriSurface::write
|
void Foam::octreeDataTriSurface::write
|
||||||
(
|
(
|
||||||
|
|||||||
@ -37,7 +37,7 @@ bool Foam::treeLeaf<Foam::octreeDataTriSurface>::findNearest
|
|||||||
const octreeDataTriSurface& shapes,
|
const octreeDataTriSurface& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ bool Foam::treeLeaf<Foam::octreeDataTriSurface>::findNearest
|
|||||||
max.y() = sample.y() + dist;
|
max.y() = sample.y() + dist;
|
||||||
max.z() = sample.z() + dist;
|
max.z() = sample.z() + dist;
|
||||||
|
|
||||||
tightesti = faceI;
|
tightestI = faceI;
|
||||||
tightestDist = dist;
|
tightestDist = dist;
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|||||||
@ -52,7 +52,7 @@ bool treeLeaf<octreeDataTriSurface>::findNearest
|
|||||||
const octreeDataTriSurface& shapes,
|
const octreeDataTriSurface& shapes,
|
||||||
const point& sample,
|
const point& sample,
|
||||||
treeBoundBox& tightest,
|
treeBoundBox& tightest,
|
||||||
label& tightesti,
|
label& tightestI,
|
||||||
scalar& tightestDist
|
scalar& tightestDist
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
|
|||||||
{
|
{
|
||||||
treeBoundBox treeBb(surface_.points(), surface_.meshPoints());
|
treeBoundBox treeBb(surface_.points(), surface_.meshPoints());
|
||||||
|
|
||||||
scalar tol = 1E-6*treeBb.avgDim();
|
scalar tol = 1E-6 * treeBb.avgDim();
|
||||||
|
|
||||||
point& bbMin = treeBb.min();
|
point& bbMin = treeBb.min();
|
||||||
bbMin.x() -= tol;
|
bbMin.x() -= tol;
|
||||||
|
|||||||
@ -81,7 +81,7 @@ void meshToMesh::calcAddressing()
|
|||||||
{
|
{
|
||||||
// get reference to cells next to the boundary
|
// get reference to cells next to the boundary
|
||||||
const unallocLabelList& bCells = patchesFrom[patchI].faceCells();
|
const unallocLabelList& bCells = patchesFrom[patchI].faceCells();
|
||||||
|
|
||||||
forAll (bCells, faceI)
|
forAll (bCells, faceI)
|
||||||
{
|
{
|
||||||
boundaryCell[bCells[faceI]] = true;
|
boundaryCell[bCells[faceI]] = true;
|
||||||
@ -171,7 +171,7 @@ void meshToMesh::calcAddressing()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
treeBoundBox wallBb(fromPatch.localPoints());
|
treeBoundBox wallBb(fromPatch.localPoints());
|
||||||
scalar typDim =
|
scalar typDim =
|
||||||
wallBb.avgDim()/(2.0*sqrt(scalar(fromPatch.size())));
|
wallBb.avgDim()/(2.0*sqrt(scalar(fromPatch.size())));
|
||||||
|
|
||||||
treeBoundBox shiftedBb
|
treeBoundBox shiftedBb
|
||||||
@ -193,7 +193,7 @@ void meshToMesh::calcAddressing()
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const vectorField::subField centresToBoundary =
|
const vectorField::subField centresToBoundary =
|
||||||
toPatch.faceCentres();
|
toPatch.faceCentres();
|
||||||
|
|
||||||
boundaryAddressing_[patchi].setSize(toPatch.size());
|
boundaryAddressing_[patchi].setSize(toPatch.size());
|
||||||
@ -268,7 +268,7 @@ void meshToMesh::cellAddresses
|
|||||||
|
|
||||||
forAll (neighbours, nI)
|
forAll (neighbours, nI)
|
||||||
{
|
{
|
||||||
scalar curDistSqr =
|
scalar curDistSqr =
|
||||||
magSqr(p - centresFrom[neighbours[nI]]);
|
magSqr(p - centresFrom[neighbours[nI]]);
|
||||||
|
|
||||||
// search through all the neighbours.
|
// search through all the neighbours.
|
||||||
|
|||||||
Reference in New Issue
Block a user