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 vector span = bb.span();
|
||||
const scalar minDim = min(span[0], min(span[1], span[2]));
|
||||
const scalar mergeDim = 1E-4 * minDim;
|
||||
const scalar mergeDim = 1E-4 * bb.minDim();
|
||||
|
||||
Pout<< "Mesh bounding box:" << bb << nl
|
||||
<< " with span:" << span << nl
|
||||
|
||||
@ -26,9 +26,12 @@ License
|
||||
|
||||
#include "boundBox.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "tmp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::scalar Foam::boundBox::great(VGREAT);
|
||||
|
||||
const Foam::boundBox Foam::boundBox::greatBox
|
||||
(
|
||||
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)
|
||||
:
|
||||
min_(point::zero),
|
||||
max_(point::zero)
|
||||
void Foam::boundBox::calculate(const pointField& points, const bool doReduce)
|
||||
{
|
||||
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
|
||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
||||
@ -64,22 +67,43 @@ Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
|
||||
min_ = points[0];
|
||||
max_ = points[0];
|
||||
|
||||
forAll(points, i)
|
||||
for (label i = 1; i < points.size(); i++)
|
||||
{
|
||||
min_ = ::Foam::min(min_, points[i]);
|
||||
max_ = ::Foam::max(max_, points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce parallel information
|
||||
if (doReduce)
|
||||
{
|
||||
// Reduce parallel information
|
||||
reduce(min_, minOp<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)
|
||||
{
|
||||
operator>>(is, *this);
|
||||
|
||||
@ -43,6 +43,7 @@ namespace Foam
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class boundBox;
|
||||
template<class T> class tmp;
|
||||
|
||||
Ostream& operator<<(Ostream& os, const boundBox& b);
|
||||
|
||||
@ -58,11 +59,19 @@ class boundBox
|
||||
//- Minimum and maximum describing the bounding box
|
||||
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:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- The great value used for greatBox and invertedBox
|
||||
static const scalar great;
|
||||
|
||||
//- A very large boundBox: min/max == -/+ VGREAT
|
||||
static const boundBox greatBox;
|
||||
|
||||
@ -88,7 +97,11 @@ public:
|
||||
|
||||
//- Construct as the bounding box of the given pointField.
|
||||
// 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
|
||||
boundBox(Istream&);
|
||||
@ -122,6 +135,12 @@ public:
|
||||
return max_;
|
||||
}
|
||||
|
||||
//- The midpoint of the bounding box
|
||||
point midpoint() const
|
||||
{
|
||||
return 0.5 * (max_ + min_);
|
||||
}
|
||||
|
||||
//- The bounding box span (from minimum to maximum)
|
||||
vector span() const
|
||||
{
|
||||
@ -134,28 +153,57 @@ public:
|
||||
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
|
||||
|
||||
//- Intersects other boundingBox?
|
||||
//- Completely contains other boundingBox? (inside or on edge)
|
||||
bool overlaps(const boundBox& bb) const
|
||||
{
|
||||
return
|
||||
(
|
||||
min_.x() <= bb.max().x() && max_.x() >= bb.min().x()
|
||||
&& min_.y() <= bb.max().y() && max_.y() >= bb.min().y()
|
||||
&& min_.z() <= bb.max().z() && max_.z() >= bb.min().z()
|
||||
bb.max_.x() >= min_.x() && bb.min_.x() <= max_.x()
|
||||
&& bb.max_.y() >= min_.y() && bb.min_.y() <= max_.y()
|
||||
&& 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
|
||||
{
|
||||
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()
|
||||
pt.x() >= min_.x() && pt.x() <= max_.x()
|
||||
&& pt.y() >= min_.y() && pt.y() <= max_.y()
|
||||
&& 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
|
||||
|
||||
// #include "boundBoxI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
@ -728,8 +728,8 @@ void Foam::globalMeshData::updateMesh()
|
||||
// Do processor patch addressing
|
||||
initProcAddr();
|
||||
|
||||
// Bounding box (does communication)
|
||||
bb_ = boundBox(mesh_.points(), true);
|
||||
// Note: boundBox does reduce
|
||||
bb_ = boundBox(mesh_.points());
|
||||
|
||||
scalar tolDim = matchTol_ * bb_.mag();
|
||||
|
||||
@ -740,7 +740,6 @@ void Foam::globalMeshData::updateMesh()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Option 1. Topological
|
||||
{
|
||||
// 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.
|
||||
nTotalFaces_ = mesh_.nFaces();
|
||||
|
||||
// Do not count processorpatch faces that are coincident.
|
||||
// Do not count processor-patch faces that are coincident.
|
||||
forAll(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)
|
||||
// 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();
|
||||
bbMin.x() -= tol;
|
||||
|
||||
@ -224,8 +224,8 @@ void Foam::displacementSBRStressFvMotionSolver::updateMesh
|
||||
);
|
||||
|
||||
// Note: boundBox does reduce
|
||||
const vector span0 = boundBox(points0_, true).span();
|
||||
const vector span = boundBox(points, true).span();
|
||||
const vector span0 = boundBox(points0_).span();
|
||||
const vector span = boundBox(points).span();
|
||||
|
||||
vector scaleFactors(cmptDivide(span0, span));
|
||||
|
||||
@ -246,9 +246,7 @@ void Foam::displacementSBRStressFvMotionSolver::updateMesh
|
||||
else
|
||||
{
|
||||
// New point. Assume motion is scaling.
|
||||
newPoints0[pointI] =
|
||||
points0_[oldPointI]
|
||||
+ cmptMultiply
|
||||
newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
|
||||
(
|
||||
scaleFactors,
|
||||
points[pointI]-points[masterPointI]
|
||||
|
||||
@ -433,8 +433,8 @@ void Foam::displacementInterpolationFvMotionSolver::updateMesh
|
||||
);
|
||||
|
||||
// Note: boundBox does reduce
|
||||
const vector span0 = boundBox(points0_, true).span();
|
||||
const vector span = boundBox(points, true).span();
|
||||
const vector span0 = boundBox(points0_).span();
|
||||
const vector span = boundBox(points).span();
|
||||
|
||||
vector scaleFactors(cmptDivide(span0, span));
|
||||
|
||||
@ -455,9 +455,7 @@ void Foam::displacementInterpolationFvMotionSolver::updateMesh
|
||||
else
|
||||
{
|
||||
// New point. Assume motion is scaling.
|
||||
newPoints0[pointI] =
|
||||
points0_[oldPointI]
|
||||
+ cmptMultiply
|
||||
newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
|
||||
(
|
||||
scaleFactors,
|
||||
points[pointI]-points[masterPointI]
|
||||
|
||||
@ -272,8 +272,8 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh
|
||||
);
|
||||
|
||||
// Note: boundBox does reduce
|
||||
const vector span0 = boundBox(points0_, true).span();
|
||||
const vector span = boundBox(points, true).span();
|
||||
const vector span0 = boundBox(points0_).span();
|
||||
const vector span = boundBox(points).span();
|
||||
|
||||
vector scaleFactors(cmptDivide(span0, span));
|
||||
|
||||
@ -294,9 +294,7 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh
|
||||
else
|
||||
{
|
||||
// New point. Assume motion is scaling.
|
||||
newPoints0[pointI] =
|
||||
points0_[oldPointI]
|
||||
+ cmptMultiply
|
||||
newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
|
||||
(
|
||||
scaleFactors,
|
||||
points[pointI]-points[masterPointI]
|
||||
|
||||
@ -150,7 +150,7 @@ Foam::boolList Foam::cellClassification::markFaces
|
||||
treeBoundBox allBb(mesh_.points());
|
||||
|
||||
// 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();
|
||||
bbMin.x() -= tol;
|
||||
|
||||
@ -26,21 +26,16 @@ License
|
||||
|
||||
#include "indexedOctree.H"
|
||||
#include "linePointRef.H"
|
||||
//#include "triSurface.H"
|
||||
// #include "triSurface.H"
|
||||
#include "meshTools.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Does bb intersect a sphere around sample? Or is any corner point of bb
|
||||
// closer than nearestDistSqr to sample.
|
||||
template <class Type>
|
||||
bool indexedOctree<Type>::overlaps
|
||||
bool Foam::indexedOctree<Type>::overlaps
|
||||
(
|
||||
const point& p0,
|
||||
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
|
||||
// closer than nearestDistSqr to sample.
|
||||
template <class Type>
|
||||
bool indexedOctree<Type>::overlaps
|
||||
bool Foam::indexedOctree<Type>::overlaps
|
||||
(
|
||||
const treeBoundBox& parentBb,
|
||||
const direction octant,
|
||||
@ -92,7 +87,7 @@ bool indexedOctree<Type>::overlaps
|
||||
const point& sample
|
||||
)
|
||||
{
|
||||
//- Speeded up version of
|
||||
//- Accelerated version of
|
||||
// treeBoundBox subBb(parentBb.subBbox(mid, octant))
|
||||
// overlaps
|
||||
// (
|
||||
@ -147,7 +142,7 @@ bool indexedOctree<Type>::overlaps
|
||||
|
||||
// Split list of indices into 8 bins
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::divide
|
||||
void Foam::indexedOctree<Type>::divide
|
||||
(
|
||||
const labelList& indices,
|
||||
const treeBoundBox& bb,
|
||||
@ -190,7 +185,8 @@ void indexedOctree<Type>::divide
|
||||
|
||||
// Subdivide the (content) node.
|
||||
template <class Type>
|
||||
typename indexedOctree<Type>::node indexedOctree<Type>::divide
|
||||
typename Foam::indexedOctree<Type>::node
|
||||
Foam::indexedOctree<Type>::divide
|
||||
(
|
||||
const treeBoundBox& bb,
|
||||
DynamicList<labelList>& contents,
|
||||
@ -259,7 +255,7 @@ typename indexedOctree<Type>::node indexedOctree<Type>::divide
|
||||
|
||||
// Split any contents node with more than minSize elements.
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::splitNodes
|
||||
void Foam::indexedOctree<Type>::splitNodes
|
||||
(
|
||||
const label minSize,
|
||||
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
|
||||
// the compactLevel.
|
||||
template <class Type>
|
||||
label indexedOctree<Type>::compactContents
|
||||
Foam::label Foam::indexedOctree<Type>::compactContents
|
||||
(
|
||||
DynamicList<node>& nodes,
|
||||
DynamicList<labelList>& contents,
|
||||
@ -383,7 +379,8 @@ label indexedOctree<Type>::compactContents
|
||||
// Recurses to determine status of lowest level boxes. Level above is
|
||||
// combination of octants below.
|
||||
template <class Type>
|
||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::calcVolumeType
|
||||
typename Foam::indexedOctree<Type>::volumeType
|
||||
Foam::indexedOctree<Type>::calcVolumeType
|
||||
(
|
||||
const label nodeI
|
||||
) const
|
||||
@ -415,7 +412,10 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::calcVolumeType
|
||||
// of its bounding box.
|
||||
const treeBoundBox subBb = nod.bb_.subBbox(octant);
|
||||
|
||||
subType = volumeType(shapes_.getVolumeType(*this, subBb.mid()));
|
||||
subType = volumeType
|
||||
(
|
||||
shapes_.getVolumeType(*this, subBb.midpoint())
|
||||
);
|
||||
}
|
||||
|
||||
// Store octant type
|
||||
@ -437,7 +437,8 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::calcVolumeType
|
||||
|
||||
|
||||
template <class Type>
|
||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
||||
typename Foam::indexedOctree<Type>::volumeType
|
||||
Foam::indexedOctree<Type>::getVolumeType
|
||||
(
|
||||
const label nodeI,
|
||||
const point& sample
|
||||
@ -512,7 +513,8 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
||||
|
||||
|
||||
template <class Type>
|
||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::getSide
|
||||
typename Foam::indexedOctree<Type>::volumeType
|
||||
Foam::indexedOctree<Type>::getSide
|
||||
(
|
||||
const vector& outsideNormal,
|
||||
const vector& vec
|
||||
@ -536,7 +538,7 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::getSide
|
||||
|
||||
// Find nearest point starting from nodeI
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::findNearest
|
||||
void Foam::indexedOctree<Type>::findNearest
|
||||
(
|
||||
const label nodeI,
|
||||
const point& sample,
|
||||
@ -608,7 +610,7 @@ void indexedOctree<Type>::findNearest
|
||||
|
||||
// Find nearest point to line.
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::findNearest
|
||||
void Foam::indexedOctree<Type>::findNearest
|
||||
(
|
||||
const label nodeI,
|
||||
const linePointRef& ln,
|
||||
@ -678,7 +680,7 @@ void indexedOctree<Type>::findNearest
|
||||
// the faceID (one of treeBoundBox::LEFTBIT, RIGHTBIT etc.)
|
||||
// Returns false if edge of tree hit.
|
||||
template <class Type>
|
||||
bool indexedOctree<Type>::walkToNeighbour
|
||||
bool Foam::indexedOctree<Type>::walkToNeighbour
|
||||
(
|
||||
const point& facePoint,
|
||||
const direction faceID, // direction to walk in
|
||||
@ -785,7 +787,11 @@ bool indexedOctree<Type>::walkToNeighbour
|
||||
// (number is single bit but not really nessecary)
|
||||
// Return 0 if point not on any face of bb.
|
||||
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;
|
||||
|
||||
@ -824,7 +830,7 @@ direction indexedOctree<Type>::getFace(const treeBoundBox& bb, const point& pt)
|
||||
// hitInfo.point = coordinate of intersection of ray with bounding box
|
||||
// faceID = index of bounding box face
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::traverseNode
|
||||
void Foam::indexedOctree<Type>::traverseNode
|
||||
(
|
||||
const bool findAny,
|
||||
const point& start,
|
||||
@ -950,7 +956,7 @@ void indexedOctree<Type>::traverseNode
|
||||
|
||||
// Find first intersection
|
||||
template <class Type>
|
||||
pointIndexHit indexedOctree<Type>::findLine
|
||||
Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
|
||||
(
|
||||
const bool findAny,
|
||||
const point& treeStart,
|
||||
@ -1037,7 +1043,7 @@ pointIndexHit indexedOctree<Type>::findLine
|
||||
|
||||
// Find first intersection
|
||||
template <class Type>
|
||||
pointIndexHit indexedOctree<Type>::findLine
|
||||
Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
|
||||
(
|
||||
const bool findAny,
|
||||
const point& start,
|
||||
@ -1101,7 +1107,7 @@ pointIndexHit indexedOctree<Type>::findLine
|
||||
|
||||
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::findBox
|
||||
void Foam::indexedOctree<Type>::findBox
|
||||
(
|
||||
const label nodeI,
|
||||
const treeBoundBox& searchBox,
|
||||
@ -1149,7 +1155,10 @@ void indexedOctree<Type>::findBox
|
||||
|
||||
// Number of elements in node.
|
||||
template <class Type>
|
||||
label indexedOctree<Type>::countElements(const labelBits index) const
|
||||
Foam::label Foam::indexedOctree<Type>::countElements
|
||||
(
|
||||
const labelBits index
|
||||
) const
|
||||
{
|
||||
label nElems = 0;
|
||||
|
||||
@ -1179,7 +1188,7 @@ label indexedOctree<Type>::countElements(const labelBits index) const
|
||||
|
||||
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::writeOBJ
|
||||
void Foam::indexedOctree<Type>::writeOBJ
|
||||
(
|
||||
const label nodeI,
|
||||
const direction octant
|
||||
@ -1256,7 +1265,7 @@ void indexedOctree<Type>::writeOBJ
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
indexedOctree<Type>::indexedOctree(const Type& shapes)
|
||||
Foam::indexedOctree<Type>::indexedOctree(const Type& shapes)
|
||||
:
|
||||
shapes_(shapes),
|
||||
nodes_(0),
|
||||
@ -1266,7 +1275,7 @@ indexedOctree<Type>::indexedOctree(const Type& shapes)
|
||||
|
||||
|
||||
template <class Type>
|
||||
indexedOctree<Type>::indexedOctree
|
||||
Foam::indexedOctree<Type>::indexedOctree
|
||||
(
|
||||
const Type& shapes,
|
||||
const List<node>& nodes,
|
||||
@ -1281,7 +1290,7 @@ indexedOctree<Type>::indexedOctree
|
||||
|
||||
|
||||
template <class Type>
|
||||
indexedOctree<Type>::indexedOctree
|
||||
Foam::indexedOctree<Type>::indexedOctree
|
||||
(
|
||||
const Type& shapes,
|
||||
const treeBoundBox& bb,
|
||||
@ -1422,7 +1431,7 @@ indexedOctree<Type>::indexedOctree
|
||||
|
||||
|
||||
template <class Type>
|
||||
indexedOctree<Type>::indexedOctree
|
||||
Foam::indexedOctree<Type>::indexedOctree
|
||||
(
|
||||
const Type& shapes,
|
||||
Istream& is
|
||||
@ -1438,7 +1447,7 @@ indexedOctree<Type>::indexedOctree
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
pointIndexHit indexedOctree<Type>::findNearest
|
||||
Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
|
||||
(
|
||||
const point& sample,
|
||||
const scalar startDistSqr
|
||||
@ -1470,7 +1479,7 @@ pointIndexHit indexedOctree<Type>::findNearest
|
||||
|
||||
|
||||
template <class Type>
|
||||
pointIndexHit indexedOctree<Type>::findNearest
|
||||
Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
|
||||
(
|
||||
const linePointRef& ln,
|
||||
treeBoundBox& tightest,
|
||||
@ -1504,7 +1513,7 @@ pointIndexHit indexedOctree<Type>::findNearest
|
||||
|
||||
// Find nearest intersection
|
||||
template <class Type>
|
||||
pointIndexHit indexedOctree<Type>::findLine
|
||||
Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
|
||||
(
|
||||
const point& start,
|
||||
const point& end
|
||||
@ -1516,7 +1525,7 @@ pointIndexHit indexedOctree<Type>::findLine
|
||||
|
||||
// Find nearest intersection
|
||||
template <class Type>
|
||||
pointIndexHit indexedOctree<Type>::findLineAny
|
||||
Foam::pointIndexHit Foam::indexedOctree<Type>::findLineAny
|
||||
(
|
||||
const point& start,
|
||||
const point& end
|
||||
@ -1527,7 +1536,10 @@ pointIndexHit indexedOctree<Type>::findLineAny
|
||||
|
||||
|
||||
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.
|
||||
labelHashSet elements(shapes_.size() / 100);
|
||||
@ -1543,7 +1555,7 @@ labelList indexedOctree<Type>::findBox(const boundBox& searchBox) const
|
||||
|
||||
// Find node (as parent+octant) containing point
|
||||
template <class Type>
|
||||
labelBits indexedOctree<Type>::findNode
|
||||
Foam::labelBits Foam::indexedOctree<Type>::findNode
|
||||
(
|
||||
const label nodeI,
|
||||
const point& sample
|
||||
@ -1581,7 +1593,8 @@ labelBits indexedOctree<Type>::findNode
|
||||
|
||||
// Determine type (inside/outside/mixed) per node.
|
||||
template <class Type>
|
||||
typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
||||
typename Foam::indexedOctree<Type>::volumeType
|
||||
Foam::indexedOctree<Type>::getVolumeType
|
||||
(
|
||||
const point& sample
|
||||
) const
|
||||
@ -1651,7 +1664,7 @@ typename indexedOctree<Type>::volumeType indexedOctree<Type>::getVolumeType
|
||||
|
||||
// Print contents of nodeI
|
||||
template <class Type>
|
||||
void indexedOctree<Type>::print
|
||||
void Foam::indexedOctree<Type>::print
|
||||
(
|
||||
prefixOSstream& os,
|
||||
const bool printContents,
|
||||
@ -1715,7 +1728,7 @@ void indexedOctree<Type>::print
|
||||
|
||||
// Print contents of nodeI
|
||||
template <class Type>
|
||||
bool indexedOctree<Type>::write(Ostream& os) const
|
||||
bool Foam::indexedOctree<Type>::write(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
|
||||
@ -1724,7 +1737,7 @@ bool indexedOctree<Type>::write(Ostream& os) const
|
||||
|
||||
|
||||
template <class Type>
|
||||
Ostream& operator<<(Ostream& os, const indexedOctree<Type>& t)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const indexedOctree<Type>& t)
|
||||
{
|
||||
return
|
||||
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 "pointIndexHit.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
string octree<Type>::volType(const label type)
|
||||
Foam::string Foam::octree<Type>::volType(const label type)
|
||||
{
|
||||
if (type == UNKNOWN)
|
||||
{
|
||||
@ -70,10 +65,13 @@ string octree<Type>::volType(const label type)
|
||||
}
|
||||
|
||||
|
||||
// Determine inside/outside status of vector compared to geometry based
|
||||
// normal
|
||||
// Determine inside/outside status of vector compared to geometry-based normal
|
||||
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;
|
||||
|
||||
@ -91,7 +89,7 @@ label octree<Type>::getVolType(const vector& geomNormal, const vector& vec)
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
octree<Type>::octree
|
||||
Foam::octree<Type>::octree
|
||||
(
|
||||
const treeBoundBox& octreeBb,
|
||||
const Type& shapes,
|
||||
@ -233,7 +231,7 @@ octree<Type>::octree
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
octree<Type>::~octree()
|
||||
Foam::octree<Type>::~octree()
|
||||
{
|
||||
delete topNode_;
|
||||
}
|
||||
@ -242,28 +240,27 @@ octree<Type>::~octree()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool octree<Type>::findTightest(const point& sample, treeBoundBox& tightest)
|
||||
const
|
||||
bool Foam::octree<Type>::findTightest
|
||||
(
|
||||
const point& sample,
|
||||
treeBoundBox& tightest
|
||||
) const
|
||||
{
|
||||
label tightesti = -1;
|
||||
scalar tightestDist = GREAT;
|
||||
|
||||
return
|
||||
topNode_->findTightest
|
||||
return topNode_->findTightest
|
||||
(
|
||||
shapes_,
|
||||
sample,
|
||||
@ -273,14 +270,14 @@ bool octree<Type>::findTightest(const point& sample, treeBoundBox& tightest)
|
||||
|
||||
|
||||
template <class Type>
|
||||
label octree<Type>::findNearest
|
||||
Foam::label Foam::octree<Type>::findNearest
|
||||
(
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
scalar& tightestDist
|
||||
) const
|
||||
{
|
||||
label tightesti = -1;
|
||||
label tightestI = -1;
|
||||
|
||||
if (debug & 4)
|
||||
{
|
||||
@ -294,7 +291,7 @@ label octree<Type>::findNearest
|
||||
shapes_,
|
||||
sample,
|
||||
tightest,
|
||||
tightesti,
|
||||
tightestI,
|
||||
tightestDist
|
||||
);
|
||||
|
||||
@ -302,18 +299,18 @@ label octree<Type>::findNearest
|
||||
{
|
||||
Pout<< "octree::findNearest : found nearest for "
|
||||
<< "sample:" << sample << " with "
|
||||
<< " tightesti:" << tightesti
|
||||
<< " tightestI:" << tightestI
|
||||
<< " tightest:" << tightest
|
||||
<< " tightestDist:" << tightestDist
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return tightesti;
|
||||
return tightestI;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
label octree<Type>::findNearest
|
||||
Foam::label Foam::octree<Type>::findNearest
|
||||
(
|
||||
const linePointRef& ln,
|
||||
treeBoundBox& tightest,
|
||||
@ -322,7 +319,7 @@ label octree<Type>::findNearest
|
||||
) const
|
||||
{
|
||||
// Start off from miss with points at large distance apart.
|
||||
label tightesti = -1;
|
||||
label tightestI = -1;
|
||||
linePoint = point(-GREAT, -GREAT, -GREAT);
|
||||
shapePoint = point(GREAT, GREAT, GREAT);
|
||||
|
||||
@ -331,17 +328,17 @@ label octree<Type>::findNearest
|
||||
shapes_,
|
||||
ln,
|
||||
tightest,
|
||||
tightesti,
|
||||
tightestI,
|
||||
linePoint,
|
||||
shapePoint
|
||||
);
|
||||
|
||||
return tightesti;
|
||||
return tightestI;
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
labelHashSet elements(100);
|
||||
@ -353,7 +350,7 @@ labelList octree<Type>::findBox(const boundBox& bb) const
|
||||
|
||||
|
||||
template <class Type>
|
||||
pointIndexHit octree<Type>::findLine
|
||||
Foam::pointIndexHit Foam::octree<Type>::findLine
|
||||
(
|
||||
const point& treeStart,
|
||||
const point& treeEnd
|
||||
@ -368,13 +365,12 @@ pointIndexHit octree<Type>::findLine
|
||||
point start(treeStart);
|
||||
point end(treeEnd);
|
||||
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
// Find nearest treeLeaf intersected by line
|
||||
point leafIntPoint;
|
||||
|
||||
const treeLeaf<Type>* leafPtr =
|
||||
findLeafLine
|
||||
const treeLeaf<Type>* leafPtr = findLeafLine
|
||||
(
|
||||
start,
|
||||
end,
|
||||
@ -435,15 +431,18 @@ pointIndexHit octree<Type>::findLine
|
||||
|
||||
|
||||
template <class Type>
|
||||
pointIndexHit octree<Type>::findLineAny(const point& start, const point& end)
|
||||
const
|
||||
Foam::pointIndexHit Foam::octree<Type>::findLineAny
|
||||
(
|
||||
const point& start,
|
||||
const point& end
|
||||
) const
|
||||
{
|
||||
// Initialize to a miss
|
||||
pointIndexHit hitInfo(false, start, -1);
|
||||
|
||||
// Start of segment in current treeNode.
|
||||
point p(start);
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
// Find treeLeaf intersected by line
|
||||
point leafIntPoint;
|
||||
@ -469,8 +468,7 @@ pointIndexHit octree<Type>::findLineAny(const point& start, const point& end)
|
||||
label index = indices[elemI];
|
||||
|
||||
point pt;
|
||||
bool hit =
|
||||
shapes().intersects
|
||||
bool hit = shapes().intersects
|
||||
(
|
||||
index,
|
||||
p,
|
||||
@ -503,7 +501,7 @@ pointIndexHit octree<Type>::findLineAny(const point& start, const point& end)
|
||||
|
||||
|
||||
template <class Type>
|
||||
const treeLeaf<Type>* octree<Type>::findLeafLine
|
||||
const Foam::treeLeaf<Type>* Foam::octree<Type>::findLeafLine
|
||||
(
|
||||
const point& start,
|
||||
const point& end,
|
||||
@ -546,8 +544,7 @@ const treeLeaf<Type>* octree<Type>::findLeafLine
|
||||
}
|
||||
|
||||
// Normal action: find next intersection along line
|
||||
const treeLeaf<Type>* leafPtr =
|
||||
topNode_->findLeafLine
|
||||
const treeLeaf<Type>* leafPtr = topNode_->findLeafLine
|
||||
(
|
||||
0,
|
||||
shapes_,
|
||||
@ -567,7 +564,11 @@ const treeLeaf<Type>* octree<Type>::findLeafLine
|
||||
|
||||
|
||||
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 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 " << minx << " " << maxy << " " << maxz << endl;
|
||||
|
||||
// Botttom face
|
||||
// Bottom face
|
||||
os << "l " << vertNo + 1 << " " << vertNo + 2 << endl;
|
||||
os << "l " << vertNo + 2 << " " << vertNo + 3 << endl;
|
||||
os << "l " << vertNo + 3 << " " << vertNo + 4 << endl;
|
||||
@ -612,7 +613,7 @@ void octree<Type>::writeOBJ(Ostream& os, label& vertNo) const
|
||||
|
||||
|
||||
template <class Type>
|
||||
void octree<Type>::printStats(Ostream& os) const
|
||||
void Foam::octree<Type>::printStats(Ostream& os) const
|
||||
{
|
||||
os << "Statistics after iteration " << deepestLevel() << ':' << endl
|
||||
<< " nShapes :" << shapes().size() << endl
|
||||
@ -637,7 +638,7 @@ void octree<Type>::printStats(Ostream& os) const
|
||||
|
||||
// Construct from a octree. Set index at end.
|
||||
template <class Type>
|
||||
octree<Type>::iterator::iterator(octree<Type>& oc)
|
||||
Foam::octree<Type>::iterator::iterator(octree<Type>& oc)
|
||||
:
|
||||
octree_(oc),
|
||||
curLeaf_(oc.nLeaves())
|
||||
@ -648,7 +649,7 @@ octree<Type>::iterator::iterator(octree<Type>& oc)
|
||||
|
||||
// Construct from octree. Set index.
|
||||
template <class Type>
|
||||
octree<Type>::iterator::iterator(octree<Type>& oc, label index)
|
||||
Foam::octree<Type>::iterator::iterator(octree<Type>& oc, label index)
|
||||
:
|
||||
octree_(oc),
|
||||
curLeaf_(index)
|
||||
@ -676,7 +677,7 @@ octree<Type>::iterator::iterator(octree<Type>& oc, label index)
|
||||
|
||||
|
||||
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))
|
||||
{
|
||||
@ -694,7 +695,7 @@ void octree<Type>::iterator::operator=(const iterator& iter)
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool octree<Type>::iterator::operator==(const iterator& iter) const
|
||||
bool Foam::octree<Type>::iterator::operator==(const iterator& iter) const
|
||||
{
|
||||
label index1 =
|
||||
(curLeaf_ >= 0 ? curLeaf_ : octree_.nLeaves());
|
||||
@ -706,21 +707,22 @@ bool octree<Type>::iterator::operator==(const iterator& iter) const
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
treeLeaf<Type>& octree<Type>::iterator::operator*()
|
||||
Foam::treeLeaf<Type>& Foam::octree<Type>::iterator::operator*()
|
||||
{
|
||||
return *leaves_[curLeaf_];
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
typename octree<Type>::iterator& octree<Type>::iterator::operator++()
|
||||
typename Foam::octree<Type>::iterator&
|
||||
Foam::octree<Type>::iterator::operator++()
|
||||
{
|
||||
curLeaf_++;
|
||||
return *this;
|
||||
@ -728,7 +730,8 @@ typename octree<Type>::iterator& octree<Type>::iterator::operator++()
|
||||
|
||||
|
||||
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;
|
||||
++*this;
|
||||
@ -737,14 +740,16 @@ typename octree<Type>::iterator octree<Type>::iterator::operator++(int)
|
||||
|
||||
|
||||
template <class Type>
|
||||
typename octree<Type>::iterator octree<Type>::begin()
|
||||
typename Foam::octree<Type>::iterator
|
||||
Foam::octree<Type>::begin()
|
||||
{
|
||||
return iterator(*this, 0);
|
||||
}
|
||||
|
||||
|
||||
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_;
|
||||
}
|
||||
@ -754,7 +759,7 @@ const typename octree<Type>::iterator& octree<Type>::end()
|
||||
|
||||
// Construct for a given octree
|
||||
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),
|
||||
curLeaf_(oc.nLeaves())
|
||||
@ -765,7 +770,7 @@ octree<Type>::const_iterator::const_iterator(const octree<Type>& oc)
|
||||
|
||||
// Construct for a given octree
|
||||
template <class Type>
|
||||
octree<Type>::const_iterator::const_iterator
|
||||
Foam::octree<Type>::const_iterator::const_iterator
|
||||
(
|
||||
const octree<Type>& oc,
|
||||
label index
|
||||
@ -797,7 +802,7 @@ octree<Type>::const_iterator::const_iterator
|
||||
|
||||
|
||||
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))
|
||||
{
|
||||
@ -816,7 +821,7 @@ void octree<Type>::const_iterator::operator=(const const_iterator& iter)
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool octree<Type>::const_iterator::operator==
|
||||
bool Foam::octree<Type>::const_iterator::operator==
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
@ -831,7 +836,7 @@ bool octree<Type>::const_iterator::operator==
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool octree<Type>::const_iterator::operator!=
|
||||
bool Foam::octree<Type>::const_iterator::operator!=
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
@ -841,15 +846,15 @@ bool octree<Type>::const_iterator::operator!=
|
||||
|
||||
|
||||
template <class Type>
|
||||
const treeLeaf<Type>& octree<Type>::const_iterator::operator*()
|
||||
const Foam::treeLeaf<Type>& Foam::octree<Type>::const_iterator::operator*()
|
||||
{
|
||||
return *leaves_[curLeaf_];
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
typename octree<Type>::const_iterator&
|
||||
octree<Type>::const_iterator::operator++()
|
||||
typename Foam::octree<Type>::const_iterator&
|
||||
Foam::octree<Type>::const_iterator::operator++()
|
||||
{
|
||||
curLeaf_++;
|
||||
return *this;
|
||||
@ -857,8 +862,8 @@ octree<Type>::const_iterator::operator++()
|
||||
|
||||
|
||||
template <class Type>
|
||||
typename octree<Type>::const_iterator
|
||||
octree<Type>::const_iterator::operator++(int)
|
||||
typename Foam::octree<Type>::const_iterator
|
||||
Foam::octree<Type>::const_iterator::operator++(int)
|
||||
{
|
||||
const_iterator tmp = *this;
|
||||
++*this;
|
||||
@ -867,14 +872,16 @@ octree<Type>::const_iterator::operator++(int)
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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_;
|
||||
}
|
||||
@ -883,7 +890,7 @@ const typename octree<Type>::const_iterator& octree<Type>::end() const
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
//<< token::SPACE << oc.shapes_
|
||||
@ -899,8 +906,5 @@ Ostream& operator<<(Ostream& os, const octree<Type>& oc)
|
||||
<< token::SPACE << token::END_LIST;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -58,11 +58,7 @@ Foam::octreeDataCell::octreeDataCell
|
||||
bbs_
|
||||
(
|
||||
mesh_.nCells(),
|
||||
treeBoundBox
|
||||
(
|
||||
vector(GREAT, GREAT, GREAT),
|
||||
vector(-GREAT, -GREAT, -GREAT)
|
||||
)
|
||||
treeBoundBox::invertedBox
|
||||
)
|
||||
{
|
||||
// Set one-one indexing
|
||||
|
||||
@ -73,16 +73,13 @@ public:
|
||||
//- Construct from components.
|
||||
octreeDataCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const polyMesh&,
|
||||
const labelList& cellLabels,
|
||||
const treeBoundBoxList& bbs
|
||||
);
|
||||
|
||||
//- Construct from mesh. Uses all cells in mesh.
|
||||
octreeDataCell
|
||||
(
|
||||
const polyMesh& mesh
|
||||
);
|
||||
octreeDataCell(const polyMesh&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -152,7 +149,7 @@ public:
|
||||
//- Given index get unit normal and calculate (numerical) sign
|
||||
// of sample.
|
||||
// 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
|
||||
(
|
||||
const label index,
|
||||
|
||||
@ -36,7 +36,7 @@ License
|
||||
|
||||
defineTypeNameAndDebug(Foam::octreeDataEdges, 0);
|
||||
|
||||
Foam::scalar Foam::octreeDataEdges::tol = 1E-6;
|
||||
Foam::scalar Foam::octreeDataEdges::tol(1E-6);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -154,8 +154,8 @@ public:
|
||||
const point& sample
|
||||
) const;
|
||||
|
||||
//- Segment (from start to end) intersection with shape
|
||||
// at index. If intersects returns true and sets intersectionPoint
|
||||
//- Segment (from start to end) intersection with shape at index.
|
||||
// If intersects returns true and sets intersectionPoint
|
||||
bool intersects
|
||||
(
|
||||
const label index,
|
||||
|
||||
@ -36,7 +36,7 @@ License
|
||||
|
||||
defineTypeNameAndDebug(Foam::octreeDataFace, 0);
|
||||
|
||||
Foam::scalar Foam::octreeDataFace::tol = 1E-6;
|
||||
Foam::scalar Foam::octreeDataFace::tol(1E-6);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -44,11 +44,7 @@ Foam::scalar Foam::octreeDataFace::tol = 1E-6;
|
||||
void Foam::octreeDataFace::calcBb()
|
||||
{
|
||||
allBb_.setSize(meshFaces_.size());
|
||||
allBb_ = treeBoundBox
|
||||
(
|
||||
vector(GREAT, GREAT, GREAT),
|
||||
vector(-GREAT, -GREAT, -GREAT)
|
||||
);
|
||||
allBb_ = treeBoundBox::invertedBox;
|
||||
|
||||
forAll (meshFaces_, i)
|
||||
{
|
||||
@ -104,8 +100,8 @@ Foam::octreeDataFace::octreeDataFace
|
||||
Foam::octreeDataFace::octreeDataFace
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const List<const labelList*>& meshFaceListPtrs,
|
||||
const List<const treeBoundBoxList*>& bbListPtrs
|
||||
const UList<const labelList*>& meshFaceListPtrs,
|
||||
const UList<const treeBoundBoxList*>& bbListPtrs
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
@ -143,7 +139,7 @@ Foam::octreeDataFace::octreeDataFace
|
||||
Foam::octreeDataFace::octreeDataFace
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const List<const labelList*>& meshFaceListPtrs
|
||||
const UList<const labelList*>& meshFaceListPtrs
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
@ -204,7 +200,7 @@ Foam::octreeDataFace::octreeDataFace(const primitiveMesh& mesh)
|
||||
// Set info for all boundary faces.
|
||||
label boundaryFaceI = 0;
|
||||
|
||||
for(label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
|
||||
for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); 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
|
||||
// information.
|
||||
|
||||
|
||||
// Find nearest face to sample
|
||||
treeBoundBox tightest(treeBoundBox::greatBox);
|
||||
|
||||
scalar tightestDist = GREAT;
|
||||
|
||||
scalar tightestDist(treeBoundBox::great);
|
||||
// Find nearest face to sample
|
||||
label index = oc.findNearest(sample, tightest, tightestDist);
|
||||
|
||||
if (index == -1)
|
||||
@ -383,8 +376,7 @@ Foam::label Foam::octreeDataFace::getSampleType
|
||||
{
|
||||
const edge& e = mesh_.edges()[myEdges[myEdgeI]];
|
||||
|
||||
pointHit edgeHit =
|
||||
line<point, const point&>
|
||||
pointHit edgeHit = line<point, const point&>
|
||||
(
|
||||
points[e.start()],
|
||||
points[e.end()]
|
||||
@ -540,8 +532,7 @@ bool Foam::octreeDataFace::overlaps
|
||||
{
|
||||
label fp1 = (fp == f.size()-1 ? 0 : fp+1);
|
||||
|
||||
bool triIntersects =
|
||||
triangleFuncs::intersectBb
|
||||
bool triIntersects = triangleFuncs::intersectBb
|
||||
(
|
||||
points[f[fp]],
|
||||
points[f[fp1]],
|
||||
@ -585,8 +576,7 @@ bool Foam::octreeDataFace::intersects
|
||||
// Disable picking up intersections behind us.
|
||||
scalar oldTol = intersection::setPlanarTol(0.0);
|
||||
|
||||
pointHit inter =
|
||||
f.ray
|
||||
pointHit inter = f.ray
|
||||
(
|
||||
start,
|
||||
dir,
|
||||
|
||||
@ -111,20 +111,20 @@ public:
|
||||
octreeDataFace
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const List<const labelList*>&,
|
||||
const List<const treeBoundBoxList*>&
|
||||
const UList<const labelList*>&,
|
||||
const UList<const treeBoundBoxList*>&
|
||||
);
|
||||
|
||||
//- Construct from selected mesh faces. Tight fitting bounding boxes
|
||||
// generated internally.
|
||||
octreeDataFace(const primitiveMesh&, const List<const labelList*>&);
|
||||
//- Construct from selected mesh faces.
|
||||
// Tight-fitting bounding boxes generated internally.
|
||||
octreeDataFace(const primitiveMesh&, const UList<const labelList*>&);
|
||||
|
||||
//- Construct from alll faces in patch. Tight fitting bounding boxes
|
||||
// generated internally.
|
||||
octreeDataFace(const polyPatch& patch);
|
||||
//- Construct from all faces in patch.
|
||||
// Tight-fitting bounding boxes generated internally.
|
||||
octreeDataFace(const polyPatch&);
|
||||
|
||||
//- Construct from all boundary faces. Tight fitting bounding boxes
|
||||
// generated internally.
|
||||
//- Construct from all boundary faces.
|
||||
// Tight-fitting bounding boxes generated internally.
|
||||
octreeDataFace(const primitiveMesh&);
|
||||
|
||||
//- Construct as copy
|
||||
|
||||
@ -69,7 +69,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components. Holds reference to points!
|
||||
octreeDataPoint(const pointField& points);
|
||||
octreeDataPoint(const pointField&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -56,7 +56,7 @@ bool Foam::treeLeaf<Foam::octreeDataPoint>::findNearest
|
||||
const octreeDataPoint& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const
|
||||
{
|
||||
@ -93,7 +93,7 @@ bool Foam::treeLeaf<Foam::octreeDataPoint>::findNearest
|
||||
tMax.y() = sample.y() + tightestDist;
|
||||
tMax.z() = sample.z() + tightestDist;
|
||||
|
||||
tightesti = minIndex;
|
||||
tightestI = minIndex;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ bool treeLeaf<octreeDataPoint>::findNearest
|
||||
const octreeDataPoint& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const;
|
||||
|
||||
|
||||
@ -27,16 +27,11 @@ License
|
||||
#include "octreeLine.H"
|
||||
#include "octree.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Calculate sorted list of intersections
|
||||
template <class Type>
|
||||
void octreeLine<Type>::calcSortedIntersections()
|
||||
void Foam::octreeLine<Type>::calcSortedIntersections()
|
||||
{
|
||||
// Determine intersections and sort acc. to distance to start
|
||||
|
||||
@ -51,8 +46,7 @@ void octreeLine<Type>::calcSortedIntersections()
|
||||
forAll(indices, elemI)
|
||||
{
|
||||
point pt;
|
||||
bool hit =
|
||||
tree_.shapes().intersects
|
||||
bool hit = tree_.shapes().intersects
|
||||
(
|
||||
indices[elemI],
|
||||
realStartPoint_,
|
||||
@ -62,8 +56,7 @@ void octreeLine<Type>::calcSortedIntersections()
|
||||
|
||||
if (hit && (indices[elemI] != lastElem_))
|
||||
{
|
||||
sortedIntersections_[nHits++] =
|
||||
pointHitSort
|
||||
sortedIntersections_[nHits++] = pointHitSort
|
||||
(
|
||||
pointHit
|
||||
(
|
||||
@ -108,7 +101,7 @@ void octreeLine<Type>::calcSortedIntersections()
|
||||
// Searches for leaf with intersected elements. Return true if found; false
|
||||
// otherwise. Sets currentLeaf_ and sortedIntersections_.
|
||||
template <class Type>
|
||||
bool octreeLine<Type>::getNextLeaf()
|
||||
bool Foam::octreeLine<Type>::getNextLeaf()
|
||||
{
|
||||
do
|
||||
{
|
||||
@ -136,7 +129,7 @@ bool octreeLine<Type>::getNextLeaf()
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
octreeLine<Type>::octreeLine
|
||||
Foam::octreeLine<Type>::octreeLine
|
||||
(
|
||||
const octree<Type>& tree,
|
||||
const point& startPoint,
|
||||
@ -158,14 +151,14 @@ octreeLine<Type>::octreeLine
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
octreeLine<Type>::~octreeLine()
|
||||
Foam::octreeLine<Type>::~octreeLine()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
bool octreeLine<Type>::getIntersection()
|
||||
bool Foam::octreeLine<Type>::getIntersection()
|
||||
{
|
||||
// Go to next element in sortedIntersections
|
||||
|
||||
@ -185,9 +178,4 @@ bool octreeLine<Type>::getIntersection()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,6 +29,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::scalar Foam::treeBoundBox::great(GREAT);
|
||||
|
||||
const Foam::treeBoundBox Foam::treeBoundBox::greatBox
|
||||
(
|
||||
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
|
||||
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
|
||||
{
|
||||
if (octant > 7)
|
||||
{
|
||||
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)
|
||||
);
|
||||
return subBbox(midpoint(), octant);
|
||||
}
|
||||
|
||||
|
||||
@ -256,44 +209,41 @@ Foam::treeBoundBox Foam::treeBoundBox::subBbox
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"treeBoundBox::subCube(const point&, const direction)"
|
||||
"treeBoundBox::subBbox(const point&, const direction)"
|
||||
) << "octant should be [0..7]"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
treeBoundBox subBb;
|
||||
point& subMin = subBb.min();
|
||||
point& subMax = subBb.max();
|
||||
// start with a copy of this bounding box and adjust limits accordingly
|
||||
treeBoundBox subBb(*this);
|
||||
point& bbMin = subBb.min();
|
||||
point& bbMax = subBb.max();
|
||||
|
||||
if (octant & treeBoundBox::RIGHTHALF)
|
||||
{
|
||||
subMin.x() = mid.x();
|
||||
subMax.x() = max().x();
|
||||
bbMin.x() = mid.x(); // mid -> max
|
||||
}
|
||||
else
|
||||
{
|
||||
subMin.x() = min().x();
|
||||
subMax.x() = mid.x();
|
||||
bbMax.x() = mid.x(); // min -> mid
|
||||
}
|
||||
|
||||
if (octant & treeBoundBox::TOPHALF)
|
||||
{
|
||||
subMin.y() = mid.y();
|
||||
subMax.y() = max().y();
|
||||
bbMin.y() = mid.y(); // mid -> max
|
||||
}
|
||||
else
|
||||
{
|
||||
subMin.y() = min().y();
|
||||
subMax.y() = mid.y();
|
||||
bbMax.y() = mid.y(); // min -> mid
|
||||
}
|
||||
|
||||
if (octant & treeBoundBox::FRONTHALF)
|
||||
{
|
||||
subMin.z() = mid.z();
|
||||
subMax.z() = max().z();
|
||||
bbMin.z() = mid.z(); // mid -> max
|
||||
}
|
||||
else
|
||||
{
|
||||
subMin.z() = min().z();
|
||||
subMax.z() = mid.z();
|
||||
bbMax.z() = mid.z(); // min -> mid
|
||||
}
|
||||
|
||||
return subBb;
|
||||
@ -364,13 +314,11 @@ bool Foam::treeBoundBox::intersects
|
||||
point& pt
|
||||
) const
|
||||
{
|
||||
vector vec(end - start);
|
||||
|
||||
const vector vec(end - start);
|
||||
const direction endBits = posBits(end);
|
||||
pt = start;
|
||||
|
||||
const direction endBits = posBits(end);
|
||||
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
direction ptBits = posBits(pt);
|
||||
|
||||
@ -465,32 +413,18 @@ bool Foam::treeBoundBox::contains(const treeBoundBox& bb) const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::treeBoundBox::containsNarrow(const point& sample) 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
|
||||
bool Foam::treeBoundBox::contains(const vector& dir, const point& pt) const
|
||||
{
|
||||
//
|
||||
// Compare all components against min and max of bb
|
||||
//
|
||||
|
||||
for (direction cmpt=0; cmpt<3; cmpt++)
|
||||
{
|
||||
if (sample[cmpt] < min()[cmpt])
|
||||
if (pt[cmpt] < min()[cmpt])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (sample[cmpt] == min()[cmpt])
|
||||
else if (pt[cmpt] == min()[cmpt])
|
||||
{
|
||||
// On edge. Outside if direction points outwards.
|
||||
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;
|
||||
}
|
||||
else if (sample[cmpt] == max()[cmpt])
|
||||
else if (pt[cmpt] == max()[cmpt])
|
||||
{
|
||||
// On edge. Outside if direction points outwards.
|
||||
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!
|
||||
void Foam::treeBoundBox::calcExtremities
|
||||
(
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
point& nearest,
|
||||
point& furthest
|
||||
) const
|
||||
@ -565,7 +499,7 @@ void Foam::treeBoundBox::calcExtremities
|
||||
scalar nearX, nearY, nearZ;
|
||||
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();
|
||||
farX = max().x();
|
||||
@ -576,7 +510,7 @@ void Foam::treeBoundBox::calcExtremities
|
||||
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();
|
||||
farY = max().y();
|
||||
@ -587,7 +521,7 @@ void Foam::treeBoundBox::calcExtremities
|
||||
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();
|
||||
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;
|
||||
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
|
||||
Foam::label Foam::treeBoundBox::distanceCmp
|
||||
(
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
const treeBoundBox& other
|
||||
) const
|
||||
{
|
||||
//
|
||||
// Distance sample <-> nearest and furthest away vertex of this
|
||||
// Distance point <-> nearest and furthest away vertex of this
|
||||
//
|
||||
|
||||
point nearThis, farThis;
|
||||
|
||||
// get nearest and furthest away vertex
|
||||
calcExtremities(sample, nearThis, farThis);
|
||||
calcExtremities(pt, nearThis, farThis);
|
||||
|
||||
const scalar minDistThis =
|
||||
sqr(nearThis.x() - sample.x())
|
||||
+ sqr(nearThis.y() - sample.y())
|
||||
+ sqr(nearThis.z() - sample.z());
|
||||
sqr(nearThis.x() - pt.x())
|
||||
+ sqr(nearThis.y() - pt.y())
|
||||
+ sqr(nearThis.z() - pt.z());
|
||||
const scalar maxDistThis =
|
||||
sqr(farThis.x() - sample.x())
|
||||
+ sqr(farThis.y() - sample.y())
|
||||
+ sqr(farThis.z() - sample.z());
|
||||
sqr(farThis.x() - pt.x())
|
||||
+ sqr(farThis.y() - pt.y())
|
||||
+ sqr(farThis.z() - pt.z());
|
||||
|
||||
//
|
||||
// Distance sample <-> other
|
||||
// Distance point <-> other
|
||||
//
|
||||
|
||||
point nearOther, farOther;
|
||||
|
||||
// get nearest and furthest away vertex
|
||||
other.calcExtremities(sample, nearOther, farOther);
|
||||
other.calcExtremities(pt, nearOther, farOther);
|
||||
|
||||
const scalar minDistOther =
|
||||
sqr(nearOther.x() - sample.x())
|
||||
+ sqr(nearOther.y() - sample.y())
|
||||
+ sqr(nearOther.z() - sample.z());
|
||||
sqr(nearOther.x() - pt.x())
|
||||
+ sqr(nearOther.y() - pt.y())
|
||||
+ sqr(nearOther.z() - pt.z());
|
||||
const scalar maxDistOther =
|
||||
sqr(farOther.x() - sample.x())
|
||||
+ sqr(farOther.y() - sample.y())
|
||||
+ sqr(farOther.z() - sample.z());
|
||||
sqr(farOther.x() - pt.x())
|
||||
+ sqr(farOther.y() - pt.y())
|
||||
+ sqr(farOther.z() - pt.z());
|
||||
|
||||
//
|
||||
// Categorize
|
||||
//
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
||||
@ -87,11 +87,17 @@ public:
|
||||
|
||||
// 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
|
||||
static const treeBoundBox greatBox;
|
||||
|
||||
//- Bits used for octant/point coding. Every octant/corner point
|
||||
// is the combination of three faces.
|
||||
//- As per boundBox::invertedBox, but with GREAT instead of VGREAT
|
||||
static const treeBoundBox invertedBox;
|
||||
|
||||
//- Bits used for octant/point coding.
|
||||
// Every octant/corner point is the combination of three faces.
|
||||
enum octantBit
|
||||
{
|
||||
RIGHTHALF = 0x1 << 0,
|
||||
@ -167,11 +173,12 @@ public:
|
||||
//- Construct from components
|
||||
inline treeBoundBox(const boundBox& bb);
|
||||
|
||||
//- Construct as the bounding box of the given pointField. Local
|
||||
// processor domain only (no reduce as in boundBox)
|
||||
treeBoundBox(const UList<point>& points);
|
||||
//- Construct as the bounding box of the given pointField.
|
||||
// Local processor domain only (no reduce as in boundBox)
|
||||
treeBoundBox(const UList<point>&);
|
||||
|
||||
//- Construct as subset of points
|
||||
// Local processor domain only (no reduce as in boundBox)
|
||||
treeBoundBox(const UList<point>&, const UList<label>& meshPoints);
|
||||
|
||||
//- Construct from Istream
|
||||
@ -182,15 +189,6 @@ public:
|
||||
|
||||
// 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
|
||||
inline scalar typDim() const;
|
||||
|
||||
@ -203,64 +201,61 @@ public:
|
||||
//- Corner point given octant
|
||||
inline point corner(const direction) const;
|
||||
|
||||
//- Calculates midpoint
|
||||
inline point mid() const;
|
||||
|
||||
//- Sub box given by octant number. Midpoint calculated.
|
||||
treeBoundBox subBbox(const direction) const;
|
||||
|
||||
//- Sub box given by octant number. Midpoint provided.
|
||||
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
|
||||
(
|
||||
const point& sample
|
||||
const point& pt
|
||||
) const;
|
||||
|
||||
//- Returns octant number given point. Midpoint provided.
|
||||
//- Returns octant number given point and midpoint.
|
||||
static inline direction subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const point& sample
|
||||
const point& pt
|
||||
);
|
||||
|
||||
//- Returns octant number given point. Midpoint calculated.
|
||||
// onEdge set if sample on edge of subOctant
|
||||
//- Returns octant number given point and the calculated midpoint.
|
||||
// onEdge set if the point is on edge of subOctant
|
||||
inline direction subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const point& pt,
|
||||
bool& onEdge
|
||||
) const;
|
||||
|
||||
//- Returns octant number given point. Midpoint provided.
|
||||
// onEdge set if sample on edge of subOctant
|
||||
//- Returns octant number given point and midpoint.
|
||||
// onEdge set if the point is on edge of subOctant
|
||||
static inline direction subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
bool& onEdge
|
||||
);
|
||||
|
||||
//- Returns octant number given intersection. Midpoint provided.
|
||||
// onEdge set if sample on edge of subOctant. If onEdge
|
||||
// the direction vector determines which octant to use
|
||||
// (acc. to which octant the sample would be if it were moved
|
||||
//- Returns octant number given intersection and midpoint.
|
||||
// onEdge set if the point is on edge of subOctant
|
||||
// If onEdge, the direction vector determines which octant to use
|
||||
// (acc. to which octant the point would be if it were moved
|
||||
// along dir)
|
||||
static inline direction subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const vector& dir,
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
bool& onEdge
|
||||
);
|
||||
|
||||
//- Calculates optimal order to look for nearest to sample. First
|
||||
// will be the octant containing the sample, second the octant
|
||||
// with boundary nearest to the sample etc.
|
||||
//- Calculates optimal order to look for nearest to point.
|
||||
// First will be the octant containing the point,
|
||||
// second the octant with boundary nearest to the point etc.
|
||||
inline void searchOrder
|
||||
(
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
FixedList<direction, 8>& octantOrder
|
||||
) const;
|
||||
|
||||
@ -273,36 +268,37 @@ public:
|
||||
//- Intersects segment; set point to intersection position,
|
||||
// return true if intersection found.
|
||||
// (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
|
||||
bool contains(const treeBoundBox& bb) const;
|
||||
//- fully contains other boundingBox?
|
||||
inline bool contains(const treeBoundBox&) const;
|
||||
|
||||
//- Contains point? (inside or on edge)
|
||||
inline bool contains(const point&) const;
|
||||
|
||||
//- Contains point? (only inside)
|
||||
bool containsNarrow(const point&) const;
|
||||
|
||||
//- Contains point inside or
|
||||
// on edge and moving in direction 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;
|
||||
|
||||
//- Position of point relative to bb
|
||||
//- Position of point relative to bounding box
|
||||
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
|
||||
void calcExtremities
|
||||
(
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
point& nearest,
|
||||
point& furthest
|
||||
) const;
|
||||
|
||||
//- Returns distance sample to furthest away corner.
|
||||
scalar maxDist(const point& sample) const;
|
||||
//- Returns distance point to furthest away corner.
|
||||
scalar maxDist(const point&) const;
|
||||
|
||||
//- Compare distance to point with other bounding box
|
||||
// return:
|
||||
|
||||
@ -49,114 +49,51 @@ inline Foam::treeBoundBox::treeBoundBox(const boundBox& bb)
|
||||
|
||||
// * * * * * * * * * * * * * * * 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
|
||||
{
|
||||
return avgDim();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point Foam::treeBoundBox::mid() const
|
||||
{
|
||||
return 0.5*(min() + max());
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point Foam::treeBoundBox::corner(const direction octant) const
|
||||
{
|
||||
return point
|
||||
(
|
||||
(octant&RIGHTHALF) ? max().x() : min().x(),
|
||||
(octant&TOPHALF) ? max().y() : min().y(),
|
||||
(octant&FRONTHALF) ? max().z() : min().z()
|
||||
(octant & RIGHTHALF) ? max().x() : min().x(),
|
||||
(octant & TOPHALF) ? max().y() : min().y(),
|
||||
(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());
|
||||
|
||||
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;
|
||||
return subOctant(midpoint(), pt);
|
||||
}
|
||||
|
||||
|
||||
// Returns octant in which sample resides. Reverse of subBbox. Precalculated
|
||||
// midpoint
|
||||
// Returns octant in which point resides. Reverse of subBbox.
|
||||
// Precalculated midpoint
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const point& sample
|
||||
const point& pt
|
||||
)
|
||||
{
|
||||
direction octant = 0;
|
||||
|
||||
if (sample.x() > mid.x())
|
||||
if (pt.x() > mid.x())
|
||||
{
|
||||
octant |= treeBoundBox::RIGHTHALF;
|
||||
}
|
||||
|
||||
if (sample.y() > mid.y())
|
||||
if (pt.y() > mid.y())
|
||||
{
|
||||
octant |= treeBoundBox::TOPHALF;
|
||||
}
|
||||
|
||||
if (sample.z() > mid.z())
|
||||
if (pt.z() > mid.z())
|
||||
{
|
||||
octant |= treeBoundBox::FRONTHALF;
|
||||
}
|
||||
@ -165,85 +102,53 @@ inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
}
|
||||
|
||||
|
||||
// Returns octant in which sample resides. Reverse of subBbox. Flags sample
|
||||
// exactly on edge.
|
||||
// Returns octant in which point resides. Reverse of subBbox.
|
||||
// Flags point exactly on edge.
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
(
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
bool& onEdge
|
||||
) const
|
||||
{
|
||||
point mid = 0.5*(max() + min());
|
||||
|
||||
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;
|
||||
return subOctant(midpoint(), pt, onEdge);
|
||||
}
|
||||
|
||||
|
||||
// Returns octant in which sample resides. Reverse of subBbox. Precalculated
|
||||
// midpoint
|
||||
// Returns octant in which point resides. Reverse of subBbox.
|
||||
// Precalculated midpoint
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
bool& onEdge
|
||||
)
|
||||
{
|
||||
direction octant = 0;
|
||||
|
||||
onEdge = false;
|
||||
if (sample.x() > mid.x())
|
||||
|
||||
if (pt.x() > mid.x())
|
||||
{
|
||||
octant |= treeBoundBox::RIGHTHALF;
|
||||
}
|
||||
else if (sample.x() == mid.x())
|
||||
else if (pt.x() == mid.x())
|
||||
{
|
||||
onEdge = true;
|
||||
}
|
||||
|
||||
if (sample.y() > mid.y())
|
||||
if (pt.y() > mid.y())
|
||||
{
|
||||
octant |= treeBoundBox::TOPHALF;
|
||||
}
|
||||
else if (sample.y() == mid.y())
|
||||
else if (pt.y() == mid.y())
|
||||
{
|
||||
onEdge = true;
|
||||
}
|
||||
|
||||
if (sample.z() > mid.z())
|
||||
if (pt.z() > mid.z())
|
||||
{
|
||||
octant |= treeBoundBox::FRONTHALF;
|
||||
}
|
||||
else if (sample.z() == mid.z())
|
||||
else if (pt.z() == mid.z())
|
||||
{
|
||||
onEdge = true;
|
||||
}
|
||||
@ -253,57 +158,53 @@ inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
|
||||
|
||||
// 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
|
||||
// (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
|
||||
(
|
||||
const point& mid,
|
||||
const vector& dir,
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
bool& onEdge
|
||||
)
|
||||
{
|
||||
direction octant = 0;
|
||||
|
||||
onEdge = false;
|
||||
|
||||
if (sample.x() > mid.x())
|
||||
if (pt.x() > mid.x())
|
||||
{
|
||||
octant |= treeBoundBox::RIGHTHALF;
|
||||
}
|
||||
else if (sample.x() == mid.x())
|
||||
else if (pt.x() == mid.x())
|
||||
{
|
||||
onEdge = true;
|
||||
|
||||
if (dir.x() > 0)
|
||||
{
|
||||
octant |= treeBoundBox::RIGHTHALF;
|
||||
}
|
||||
}
|
||||
|
||||
if (sample.y() > mid.y())
|
||||
if (pt.y() > mid.y())
|
||||
{
|
||||
octant |= treeBoundBox::TOPHALF;
|
||||
}
|
||||
else if (sample.y() == mid.y())
|
||||
else if (pt.y() == mid.y())
|
||||
{
|
||||
onEdge = true;
|
||||
|
||||
if (dir.y() > 0)
|
||||
{
|
||||
octant |= treeBoundBox::TOPHALF;
|
||||
}
|
||||
}
|
||||
|
||||
if (sample.z() > mid.z())
|
||||
if (pt.z() > mid.z())
|
||||
{
|
||||
octant |= treeBoundBox::FRONTHALF;
|
||||
}
|
||||
else if (sample.z() == mid.z())
|
||||
else if (pt.z() == mid.z())
|
||||
{
|
||||
onEdge = true;
|
||||
|
||||
if (dir.z() > 0)
|
||||
{
|
||||
octant |= treeBoundBox::FRONTHALF;
|
||||
@ -318,11 +219,11 @@ inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
// order to do the search.
|
||||
inline void Foam::treeBoundBox::searchOrder
|
||||
(
|
||||
const point& sample,
|
||||
const point& pt,
|
||||
FixedList<direction,8>& octantOrder
|
||||
) const
|
||||
{
|
||||
vector dist = mid() - sample;
|
||||
vector dist = midpoint() - pt;
|
||||
|
||||
direction octant = 0;
|
||||
|
||||
@ -348,15 +249,15 @@ inline void Foam::treeBoundBox::searchOrder
|
||||
direction mid = 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;
|
||||
mid = treeBoundBox::TOPHALF;
|
||||
max = treeBoundBox::FRONTHALF;
|
||||
}
|
||||
else if( dist.z() < dist.x())
|
||||
else if (dist.z() < dist.x())
|
||||
{
|
||||
min = treeBoundBox::FRONTHALF;
|
||||
mid = treeBoundBox::RIGHTHALF;
|
||||
@ -371,13 +272,13 @@ inline void Foam::treeBoundBox::searchOrder
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dist.z() < dist.y())
|
||||
if (dist.z() < dist.y())
|
||||
{
|
||||
min = treeBoundBox::FRONTHALF;
|
||||
mid = treeBoundBox::TOPHALF;
|
||||
max = treeBoundBox::RIGHTHALF;
|
||||
}
|
||||
else if( dist.x() < dist.z())
|
||||
else if (dist.x() < dist.z())
|
||||
{
|
||||
min = treeBoundBox::TOPHALF;
|
||||
mid = treeBoundBox::RIGHTHALF;
|
||||
@ -390,6 +291,7 @@ inline void Foam::treeBoundBox::searchOrder
|
||||
max = treeBoundBox::RIGHTHALF;
|
||||
}
|
||||
}
|
||||
|
||||
// Primary subOctant
|
||||
octantOrder[0] = octant;
|
||||
// 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
|
||||
(
|
||||
(sample.x() >= min().x()) &&
|
||||
(sample.y() >= min().y()) &&
|
||||
(sample.z() >= min().z()) &&
|
||||
(sample.x() <= max().x()) &&
|
||||
(sample.y() <= max().y()) &&
|
||||
(sample.z() <= max().z())
|
||||
);
|
||||
return boundBox::contains(pt);
|
||||
}
|
||||
|
||||
|
||||
@ -443,7 +337,7 @@ inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
||||
|
||||
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);
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from bb
|
||||
//- Construct from bounding box
|
||||
treeElem(const treeBoundBox& bb)
|
||||
:
|
||||
bb_(bb)
|
||||
@ -70,11 +70,13 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Bounding box of this node
|
||||
const treeBoundBox& bb() const
|
||||
{
|
||||
return bb_;
|
||||
}
|
||||
|
||||
//- Bounding box of this node
|
||||
treeBoundBox& bb()
|
||||
{
|
||||
return bb_;
|
||||
|
||||
@ -32,17 +32,12 @@ Description
|
||||
#include "octree.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
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<< ' ';
|
||||
}
|
||||
@ -53,7 +48,7 @@ void treeLeaf<Type>::space(Ostream& os, const label n)
|
||||
|
||||
// Construct with given size
|
||||
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)
|
||||
{}
|
||||
@ -61,7 +56,7 @@ treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const label size)
|
||||
|
||||
// Construct from list
|
||||
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)
|
||||
{
|
||||
@ -70,7 +65,7 @@ treeLeaf<Type>::treeLeaf(const treeBoundBox& bb, const labelList& indices)
|
||||
|
||||
// Construct from Istream
|
||||
template <class Type>
|
||||
treeLeaf<Type>::treeLeaf(Istream& is)
|
||||
Foam::treeLeaf<Type>::treeLeaf(Istream& is)
|
||||
{
|
||||
is >> *this;
|
||||
}
|
||||
@ -79,7 +74,7 @@ treeLeaf<Type>::treeLeaf(Istream& is)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
template <class Type>
|
||||
treeLeaf<Type>* treeLeaf<Type>::redistribute
|
||||
Foam::treeLeaf<Type>* Foam::treeLeaf<Type>::redistribute
|
||||
(
|
||||
const label level,
|
||||
octree<Type>& top,
|
||||
@ -140,7 +135,7 @@ treeLeaf<Type>* treeLeaf<Type>::redistribute
|
||||
|
||||
// Set type of subnodes. Since contains elements return mixed type always.
|
||||
template <class Type>
|
||||
Foam::label treeLeaf<Type>::setSubNodeType
|
||||
Foam::label Foam::treeLeaf<Type>::setSubNodeType
|
||||
(
|
||||
const label level,
|
||||
octree<Type>& top,
|
||||
@ -161,7 +156,7 @@ Foam::label treeLeaf<Type>::setSubNodeType
|
||||
|
||||
|
||||
template <class Type>
|
||||
Foam::label treeLeaf<Type>::getSampleType
|
||||
Foam::label Foam::treeLeaf<Type>::getSampleType
|
||||
(
|
||||
const label level,
|
||||
const octree<Type>& top,
|
||||
@ -174,7 +169,7 @@ Foam::label treeLeaf<Type>::getSampleType
|
||||
|
||||
|
||||
template <class Type>
|
||||
label treeLeaf<Type>::find
|
||||
Foam::label Foam::treeLeaf<Type>::find
|
||||
(
|
||||
const Type& shapes,
|
||||
const point& sample
|
||||
@ -193,7 +188,7 @@ label treeLeaf<Type>::find
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeLeaf<Type>::findTightest
|
||||
bool Foam::treeLeaf<Type>::findTightest
|
||||
(
|
||||
const Type& shapes,
|
||||
const point& sample,
|
||||
@ -204,8 +199,7 @@ bool treeLeaf<Type>::findTightest
|
||||
|
||||
forAll(indices_, i)
|
||||
{
|
||||
changed |=
|
||||
shapes.findTightest
|
||||
changed |= shapes.findTightest
|
||||
(
|
||||
indices_[i],
|
||||
sample,
|
||||
@ -218,12 +212,12 @@ bool treeLeaf<Type>::findTightest
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeLeaf<Type>::findNearest
|
||||
bool Foam::treeLeaf<Type>::findNearest
|
||||
(
|
||||
const Type& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const
|
||||
{
|
||||
@ -252,7 +246,7 @@ bool treeLeaf<Type>::findNearest
|
||||
tightest.max() = sample + dist;
|
||||
|
||||
// Update other return values
|
||||
tightesti = indices_[i];
|
||||
tightestI = indices_[i];
|
||||
|
||||
tightestDist = thisDist;
|
||||
|
||||
@ -262,7 +256,7 @@ bool treeLeaf<Type>::findNearest
|
||||
{
|
||||
//space(Pout, level);
|
||||
Pout<< "treeLeaf<Type>::findNearest : Found nearer : shape:"
|
||||
<< tightesti << " distance:" << tightestDist
|
||||
<< tightestI << " distance:" << tightestDist
|
||||
<< " to sample:" << sample << endl;
|
||||
}
|
||||
}
|
||||
@ -284,12 +278,12 @@ bool treeLeaf<Type>::findNearest
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeLeaf<Type>::findNearest
|
||||
bool Foam::treeLeaf<Type>::findNearest
|
||||
(
|
||||
const Type& shapes,
|
||||
const linePointRef& ln,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
point& linePoint, // nearest point on line
|
||||
point& shapePoint // nearest point on shape
|
||||
) const
|
||||
@ -317,7 +311,7 @@ bool treeLeaf<Type>::findNearest
|
||||
{
|
||||
// Found nearer. Use.
|
||||
tightestDist = thisDist;
|
||||
tightesti = indices_[i];
|
||||
tightestI = indices_[i];
|
||||
linePoint = linePt;
|
||||
shapePoint = shapePt;
|
||||
// Construct new tightest Bb. Nearest point can never be further
|
||||
@ -337,7 +331,7 @@ bool treeLeaf<Type>::findNearest
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeLeaf<Type>::findBox
|
||||
bool Foam::treeLeaf<Type>::findBox
|
||||
(
|
||||
const Type& shapes,
|
||||
const boundBox& box,
|
||||
@ -361,7 +355,7 @@ bool treeLeaf<Type>::findBox
|
||||
|
||||
|
||||
template <class Type>
|
||||
void treeLeaf<Type>::printLeaf
|
||||
void Foam::treeLeaf<Type>::printLeaf
|
||||
(
|
||||
Ostream& os,
|
||||
const label level
|
||||
@ -380,7 +374,7 @@ void treeLeaf<Type>::printLeaf
|
||||
|
||||
// Dump cube coordinates in OBJ format
|
||||
template <class Type>
|
||||
void treeLeaf<Type>::writeOBJ
|
||||
void Foam::treeLeaf<Type>::writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const label level,
|
||||
@ -420,7 +414,7 @@ void treeLeaf<Type>::writeOBJ
|
||||
|
||||
|
||||
template <class Type>
|
||||
label treeLeaf<Type>::countLeaf
|
||||
Foam::label Foam::treeLeaf<Type>::countLeaf
|
||||
(
|
||||
Ostream& os,
|
||||
const label level
|
||||
@ -439,7 +433,7 @@ label treeLeaf<Type>::countLeaf
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
Istream& operator>> (Istream& is, treeLeaf<Type>& leaf)
|
||||
Foam::Istream& Foam::operator>> (Istream& is, treeLeaf<Type>& leaf)
|
||||
{
|
||||
is >> leaf.bb() >> leaf.indices_;
|
||||
|
||||
@ -450,7 +444,7 @@ Istream& operator>> (Istream& is, treeLeaf<Type>& leaf)
|
||||
|
||||
|
||||
template <class Type>
|
||||
Ostream& operator<< (Ostream& os, const treeLeaf<Type>& leaf)
|
||||
Foam::Ostream& Foam::operator<< (Ostream& os, const treeLeaf<Type>& leaf)
|
||||
{
|
||||
os << leaf.bb();
|
||||
|
||||
@ -472,9 +466,4 @@ Ostream& operator<< (Ostream& os, const treeLeaf<Type>& leaf)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,8 +30,8 @@ Description
|
||||
|
||||
SourceFiles
|
||||
treeLeaf.C
|
||||
octreeDataPointTreaLeaf.H (specialization for points only )
|
||||
octreeDataPointTreeLeaf.C ( ,, )
|
||||
octreeDataPointTreeLeaf.C (specialization for points only)
|
||||
octreeDataPointTreeLeaf.H (specialization for points only)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -212,7 +212,7 @@ public:
|
||||
const Type& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const;
|
||||
|
||||
@ -224,7 +224,7 @@ public:
|
||||
const Type& shapes,
|
||||
const linePointRef& ln,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti, // index of nearest shape
|
||||
label& tightestI, // index of nearest shape
|
||||
point& linePoint, // nearest point on line
|
||||
point& shapePoint // nearest point on shape
|
||||
) const;
|
||||
|
||||
@ -33,31 +33,23 @@ Description
|
||||
#include "long.H"
|
||||
#include "linePointRef.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
const label treeNode<Type>::leafOffset = 100;
|
||||
|
||||
template <class Type>
|
||||
const labelList treeNode<Type>::dummy(1);
|
||||
const Foam::label Foam::treeNode<Type>::leafOffset(100);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
void treeNode<Type>::setAsNode(const label octant)
|
||||
void Foam::treeNode<Type>::setAsNode(const label octant)
|
||||
{
|
||||
subNodeTypes_ |= (0x1 << octant);
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
void treeNode<Type>::setAsLeaf(const label octant)
|
||||
void Foam::treeNode<Type>::setAsLeaf(const label octant)
|
||||
{
|
||||
subNodeTypes_ &= ~(0x1 << octant);
|
||||
}
|
||||
@ -65,7 +57,11 @@ void treeNode<Type>::setAsLeaf(const label octant)
|
||||
|
||||
// Set pointer to sub node
|
||||
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);
|
||||
subNodes_[octant] = treeNodePtr;
|
||||
@ -74,7 +70,11 @@ void treeNode<Type>::setNodePtr(const label octant, treeElem<Type>* treeNodePtr)
|
||||
|
||||
// Set pointer to sub leaf
|
||||
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);
|
||||
subNodes_[octant] = treeLeafPtr;
|
||||
@ -82,7 +82,11 @@ void treeNode<Type>::setLeafPtr(const label octant, treeElem<Type>* treeLeafPtr)
|
||||
|
||||
|
||||
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))
|
||||
{
|
||||
@ -99,9 +103,9 @@ void treeNode<Type>::setVolType(const label octant, const label 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<< ' ';
|
||||
}
|
||||
@ -110,7 +114,7 @@ void treeNode<Type>::space(Ostream& os, const label n)
|
||||
|
||||
// look in single octant starting from <start>
|
||||
template <class Type>
|
||||
const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
||||
const Foam::treeLeaf<Type>* Foam::treeNode<Type>::findLeafLineOctant
|
||||
(
|
||||
const int level,
|
||||
const Type& shapes,
|
||||
@ -131,7 +135,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
||||
Pout<< "findLeafLineOctant : bb:" << this->bb()
|
||||
<< " start:" << start
|
||||
<< " end:" << end
|
||||
<< " mid:" << mid()
|
||||
<< " mid:" << midpoint()
|
||||
<< " Searching octant:" << octant
|
||||
<< endl;
|
||||
}
|
||||
@ -146,8 +150,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
||||
if (subNodePtr->bb().contains(direction, start))
|
||||
{
|
||||
// Search on lower level
|
||||
const treeLeaf<Type>* subLeafPtr =
|
||||
subNodePtr->findLeafLine
|
||||
const treeLeaf<Type>* subLeafPtr = subNodePtr->findLeafLine
|
||||
(
|
||||
level + 1,
|
||||
shapes,
|
||||
@ -226,7 +229,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
||||
else
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
@ -293,28 +296,25 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLineOctant
|
||||
|
||||
// Construct from components
|
||||
template <class Type>
|
||||
treeNode<Type>::treeNode(const treeBoundBox& bb)
|
||||
Foam::treeNode<Type>::treeNode(const treeBoundBox& bb)
|
||||
:
|
||||
treeElem<Type>(bb),
|
||||
treeNodeName(),
|
||||
mid_(bb.mid()),
|
||||
mid_(bb.midpoint()),
|
||||
subNodeTypes_(0),
|
||||
volType_(0)
|
||||
{
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octantI=0; octantI<8; octantI++)
|
||||
{
|
||||
subNodes_[octant] = NULL;
|
||||
setVolType(octant, octree<Type>::UNKNOWN);
|
||||
subNodes_[octantI] = NULL;
|
||||
setVolType(octantI, octree<Type>::UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from Istream
|
||||
template <class Type>
|
||||
treeNode<Type>::treeNode
|
||||
(
|
||||
Istream& is
|
||||
)
|
||||
Foam::treeNode<Type>::treeNode(Istream& is)
|
||||
{
|
||||
is >> *this;
|
||||
}
|
||||
@ -323,9 +323,9 @@ treeNode<Type>::treeNode
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
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])
|
||||
{
|
||||
@ -346,7 +346,7 @@ treeNode<Type>::~treeNode()
|
||||
|
||||
// Distributes cells to subLeaves
|
||||
template <class Type>
|
||||
void treeNode<Type>::distribute
|
||||
void Foam::treeNode<Type>::distribute
|
||||
(
|
||||
const label level,
|
||||
octree<Type>& top,
|
||||
@ -360,8 +360,8 @@ void treeNode<Type>::distribute
|
||||
Pout<< "treeNode::distributing " << indices.size() << endl;
|
||||
}
|
||||
|
||||
// Create subLeaves if nessecary
|
||||
for(label octant=0; octant<8; octant++)
|
||||
// Create subLeaves if necessary
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
if (subNodes()[octant])
|
||||
{
|
||||
@ -375,10 +375,9 @@ void treeNode<Type>::distribute
|
||||
}
|
||||
else
|
||||
{
|
||||
treeLeaf<Type>* subLeafPtr =
|
||||
new treeLeaf<Type>
|
||||
treeLeaf<Type>* subLeafPtr = new treeLeaf<Type>
|
||||
(
|
||||
this->bb().subBbox(mid(), octant),
|
||||
this->bb().subBbox(midpoint(), octant),
|
||||
indices.size()
|
||||
);
|
||||
|
||||
@ -393,7 +392,7 @@ void treeNode<Type>::distribute
|
||||
{
|
||||
const label shapei = indices[i];
|
||||
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
treeLeaf<Type>* leafPtr = getLeafPtr(octant);
|
||||
|
||||
@ -413,7 +412,7 @@ void treeNode<Type>::distribute
|
||||
}
|
||||
|
||||
// Trim size of subLeaves
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
treeLeaf<Type>* subLeafPtr = getLeafPtr(octant);
|
||||
|
||||
@ -441,7 +440,7 @@ void treeNode<Type>::distribute
|
||||
|
||||
// Descends to refineLevel and checks the subLeaves for redistribution
|
||||
template <class Type>
|
||||
void treeNode<Type>::redistribute
|
||||
void Foam::treeNode<Type>::redistribute
|
||||
(
|
||||
const label level,
|
||||
octree<Type>& top,
|
||||
@ -459,7 +458,7 @@ void treeNode<Type>::redistribute
|
||||
// Descend to correct level
|
||||
if (level < refineLevel)
|
||||
{
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
if (subNodes()[octant])
|
||||
{
|
||||
@ -486,7 +485,7 @@ void treeNode<Type>::redistribute
|
||||
}
|
||||
|
||||
// handle redistribution of sub leaves
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
if (subNodes()[octant])
|
||||
{
|
||||
@ -549,7 +548,7 @@ void treeNode<Type>::redistribute
|
||||
|
||||
// Set type of node.
|
||||
template <class Type>
|
||||
label treeNode<Type>::setSubNodeType
|
||||
Foam::label Foam::treeNode<Type>::setSubNodeType
|
||||
(
|
||||
const label level,
|
||||
octree<Type>& top,
|
||||
@ -565,7 +564,7 @@ label treeNode<Type>::setSubNodeType
|
||||
|
||||
label myType = -1;
|
||||
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
label subType = -1;
|
||||
|
||||
@ -594,16 +593,16 @@ label treeNode<Type>::setSubNodeType
|
||||
{
|
||||
// No data in this one. Set type for octant acc. to its bounding
|
||||
// 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)
|
||||
{
|
||||
space(Pout, level);
|
||||
Pout<< "treeNode::setSubNodeType : setting octant with bb:"
|
||||
<< this->bb().subBbox(mid(), octant)
|
||||
<< this->bb().subBbox(midpoint(), octant)
|
||||
<< " to type:" << octree<Type>::volType(subType) << endl;
|
||||
}
|
||||
setVolType(octant, subType);
|
||||
@ -634,7 +633,7 @@ label treeNode<Type>::setSubNodeType
|
||||
|
||||
// Get type of node.
|
||||
template <class Type>
|
||||
label treeNode<Type>::getSampleType
|
||||
Foam::label Foam::treeNode<Type>::getSampleType
|
||||
(
|
||||
const label level,
|
||||
const octree<Type>& top,
|
||||
@ -652,7 +651,7 @@ label treeNode<Type>::getSampleType
|
||||
// Determine octant of bb. If on edge just use whichever octant.
|
||||
bool onEdge = false;
|
||||
|
||||
label octant = this->bb().subOctant(mid(), sample, onEdge);
|
||||
label octant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||
|
||||
label type = getVolType(octant);
|
||||
|
||||
@ -691,7 +690,7 @@ label treeNode<Type>::getSampleType
|
||||
(
|
||||
"treeNode<Type>::getSampleType"
|
||||
"(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:"
|
||||
<< octree<Type>::volType(type)
|
||||
<< abort(FatalError);
|
||||
@ -723,7 +722,7 @@ label treeNode<Type>::getSampleType
|
||||
|
||||
|
||||
template <class Type>
|
||||
label treeNode<Type>::find
|
||||
Foam::label Foam::treeNode<Type>::find
|
||||
(
|
||||
const Type& shapes,
|
||||
const point& sample
|
||||
@ -733,18 +732,14 @@ label treeNode<Type>::find
|
||||
// will have been inserted in both subcubes)
|
||||
bool onEdge = false;
|
||||
|
||||
label octant = this->bb().subOctant(mid(), sample, onEdge);
|
||||
label octant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||
|
||||
if (subNodes()[octant])
|
||||
{
|
||||
if (isNode(octant))
|
||||
{
|
||||
// Node: recurse into subnodes
|
||||
return getNodePtr(octant)->find
|
||||
(
|
||||
shapes,
|
||||
sample
|
||||
);
|
||||
return getNodePtr(octant)->find(shapes, sample);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -757,7 +752,7 @@ label treeNode<Type>::find
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeNode<Type>::findTightest
|
||||
bool Foam::treeNode<Type>::findTightest
|
||||
(
|
||||
const Type& shapes,
|
||||
const point& sample,
|
||||
@ -765,30 +760,28 @@ bool treeNode<Type>::findTightest
|
||||
) const
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
// Get best guess for starting octant
|
||||
bool onEdge = false;
|
||||
|
||||
label sampleOctant = this->bb().subOctant(mid(), sample, onEdge);
|
||||
// Estimate for best place to start searching
|
||||
label sampleOctant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||
|
||||
// Go into all suboctants (one containing sample first) and update tightest.
|
||||
// Order of visiting is if e.g. sampleOctant = 5:
|
||||
// 5 1 2 3 4 0 6 7
|
||||
for(label octanti=0; octanti<8; octanti++)
|
||||
for (label octantI=0; octantI<8; octantI++)
|
||||
{
|
||||
label octant;
|
||||
if (octanti == 0)
|
||||
if (octantI == 0)
|
||||
{
|
||||
// Use sampleOctant first
|
||||
octant = sampleOctant;
|
||||
}
|
||||
else if (octanti == sampleOctant)
|
||||
else if (octantI == sampleOctant)
|
||||
{
|
||||
octant = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
octant = octanti;
|
||||
octant = octantI;
|
||||
}
|
||||
|
||||
if (subNodes()[octant])
|
||||
@ -801,8 +794,7 @@ bool treeNode<Type>::findTightest
|
||||
if (subNodePtr->bb().overlaps(tightest))
|
||||
{
|
||||
// there might be a better fit inside this subNode
|
||||
changed |=
|
||||
subNodePtr->findTightest
|
||||
changed |= subNodePtr->findTightest
|
||||
(
|
||||
shapes,
|
||||
sample,
|
||||
@ -818,8 +810,7 @@ bool treeNode<Type>::findTightest
|
||||
if (subLeafPtr->bb().overlaps(tightest))
|
||||
{
|
||||
// there might be a better fit inside this subLeaf
|
||||
changed |=
|
||||
subLeafPtr->findTightest
|
||||
changed |= subLeafPtr->findTightest
|
||||
(
|
||||
shapes,
|
||||
sample,
|
||||
@ -835,46 +826,44 @@ bool treeNode<Type>::findTightest
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeNode<Type>::findNearest
|
||||
bool Foam::treeNode<Type>::findNearest
|
||||
(
|
||||
const Type& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
||||
if (debug & 8)
|
||||
{
|
||||
Pout<< "In findNearest with sample:" << sample << " cube:"
|
||||
<< this->bb() << " tightest:" << tightest << endl;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
bool onEdge = false;
|
||||
|
||||
label sampleOctant = this->bb().subOctant(mid(), sample, onEdge);
|
||||
// Estimate for best place to start searching
|
||||
label sampleOctant = this->bb().subOctant(midpoint(), sample, onEdge);
|
||||
|
||||
// Go into all suboctants (one containing sample first) and update tightest.
|
||||
// Order of visiting is if e.g. sampleOctant = 5:
|
||||
// 5 1 2 3 4 0 6 7
|
||||
for(label octanti=0; octanti<8; octanti++)
|
||||
for (label octantI=0; octantI<8; octantI++)
|
||||
{
|
||||
label octant;
|
||||
if (octanti == 0)
|
||||
if (octantI == 0)
|
||||
{
|
||||
// Use sampleOctant first
|
||||
octant = sampleOctant;
|
||||
}
|
||||
else if (octanti == sampleOctant)
|
||||
else if (octantI == sampleOctant)
|
||||
{
|
||||
octant = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
octant = octanti;
|
||||
octant = octantI;
|
||||
}
|
||||
|
||||
if (subNodes()[octant])
|
||||
@ -887,13 +876,12 @@ bool treeNode<Type>::findNearest
|
||||
if (subNodePtr->bb().overlaps(tightest))
|
||||
{
|
||||
// there might be a better fit inside this subNode
|
||||
changed |=
|
||||
subNodePtr->findNearest
|
||||
changed |= subNodePtr->findNearest
|
||||
(
|
||||
shapes,
|
||||
sample,
|
||||
tightest,
|
||||
tightesti,
|
||||
tightestI,
|
||||
tightestDist
|
||||
);
|
||||
}
|
||||
@ -906,13 +894,12 @@ bool treeNode<Type>::findNearest
|
||||
if (subLeafPtr->bb().overlaps(tightest))
|
||||
{
|
||||
// there might be a better fit inside this subNode
|
||||
changed |=
|
||||
subLeafPtr->findNearest
|
||||
changed |= subLeafPtr->findNearest
|
||||
(
|
||||
shapes,
|
||||
sample,
|
||||
tightest,
|
||||
tightesti,
|
||||
tightestI,
|
||||
tightestDist
|
||||
);
|
||||
}
|
||||
@ -923,7 +910,7 @@ bool treeNode<Type>::findNearest
|
||||
if (debug & 8)
|
||||
{
|
||||
Pout<< "Exiting findNearest for sample:" << sample << " cube:"
|
||||
<< this->bb() << " tightesti:" << tightesti << endl;
|
||||
<< this->bb() << " tightestI:" << tightestI << endl;
|
||||
}
|
||||
|
||||
return changed;
|
||||
@ -931,41 +918,39 @@ bool treeNode<Type>::findNearest
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeNode<Type>::findNearest
|
||||
bool Foam::treeNode<Type>::findNearest
|
||||
(
|
||||
const Type& shapes,
|
||||
const linePointRef& ln,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
point& linePoint, // nearest point on line
|
||||
point& shapePoint // nearest point on shape
|
||||
) const
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
bool onEdge = false;
|
||||
|
||||
// Estimate for where best to start searching
|
||||
label sampleOctant = this->bb().subOctant(mid(), ln.centre(), onEdge);
|
||||
// Estimate for best place to start searching
|
||||
label sampleOctant = this->bb().subOctant(midpoint(), ln.centre(), onEdge);
|
||||
|
||||
// Go into all suboctants (one containing sample first) and update tightest.
|
||||
// Order of visiting is if e.g. sampleOctant = 5:
|
||||
// 5 1 2 3 4 0 6 7
|
||||
for(label octanti=0; octanti<8; octanti++)
|
||||
for (label octantI=0; octantI<8; octantI++)
|
||||
{
|
||||
label octant;
|
||||
if (octanti == 0)
|
||||
if (octantI == 0)
|
||||
{
|
||||
// Use sampleOctant first
|
||||
octant = sampleOctant;
|
||||
}
|
||||
else if (octanti == sampleOctant)
|
||||
else if (octantI == sampleOctant)
|
||||
{
|
||||
octant = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
octant = octanti;
|
||||
octant = octantI;
|
||||
}
|
||||
|
||||
if (subNodes()[octant])
|
||||
@ -978,13 +963,12 @@ bool treeNode<Type>::findNearest
|
||||
if (subNodePtr->bb().overlaps(tightest))
|
||||
{
|
||||
// there might be a better fit inside this subNode
|
||||
changed |=
|
||||
subNodePtr->findNearest
|
||||
changed |= subNodePtr->findNearest
|
||||
(
|
||||
shapes,
|
||||
ln,
|
||||
tightest,
|
||||
tightesti,
|
||||
tightestI,
|
||||
linePoint,
|
||||
shapePoint
|
||||
);
|
||||
@ -998,13 +982,12 @@ bool treeNode<Type>::findNearest
|
||||
if (subLeafPtr->bb().overlaps(tightest))
|
||||
{
|
||||
// there might be a better fit inside this subNode
|
||||
changed |=
|
||||
subLeafPtr->findNearest
|
||||
changed |= subLeafPtr->findNearest
|
||||
(
|
||||
shapes,
|
||||
ln,
|
||||
tightest,
|
||||
tightesti,
|
||||
tightestI,
|
||||
linePoint,
|
||||
shapePoint
|
||||
);
|
||||
@ -1018,7 +1001,7 @@ bool treeNode<Type>::findNearest
|
||||
|
||||
|
||||
template <class Type>
|
||||
bool treeNode<Type>::findBox
|
||||
bool Foam::treeNode<Type>::findBox
|
||||
(
|
||||
const Type& shapes,
|
||||
const boundBox& box,
|
||||
@ -1026,31 +1009,33 @@ bool treeNode<Type>::findBox
|
||||
) const
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
bool onEdge = false;
|
||||
|
||||
// Estimate for where best to start searching
|
||||
point boxMid(0.5*(box.min() + box.max()));
|
||||
label sampleOctant = this->bb().subOctant(mid(), boxMid, onEdge);
|
||||
// Estimate for best place to start searching
|
||||
label sampleOctant = this->bb().subOctant
|
||||
(
|
||||
midpoint(),
|
||||
box.midpoint(),
|
||||
onEdge
|
||||
);
|
||||
|
||||
// Go into all suboctants (one containing sample first) and update tightest.
|
||||
// Order of visiting is if e.g. sampleOctant = 5:
|
||||
// 5 1 2 3 4 0 6 7
|
||||
for(label octanti=0; octanti<8; octanti++)
|
||||
for (label octantI=0; octantI<8; octantI++)
|
||||
{
|
||||
label octant;
|
||||
if (octanti == 0)
|
||||
if (octantI == 0)
|
||||
{
|
||||
// Use sampleOctant first
|
||||
octant = sampleOctant;
|
||||
}
|
||||
else if (octanti == sampleOctant)
|
||||
else if (octantI == sampleOctant)
|
||||
{
|
||||
octant = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
octant = octanti;
|
||||
octant = octantI;
|
||||
}
|
||||
|
||||
if (subNodes()[octant])
|
||||
@ -1086,7 +1071,7 @@ bool treeNode<Type>::findBox
|
||||
|
||||
// look from <start> in current cube (given by this->bb()).
|
||||
template <class Type>
|
||||
const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
||||
const Foam::treeLeaf<Type>* Foam::treeNode<Type>::findLeafLine
|
||||
(
|
||||
const int level,
|
||||
const Type& shapes,
|
||||
@ -1097,7 +1082,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
||||
if (debug & 2)
|
||||
{
|
||||
space(Pout, 2*level);
|
||||
Pout<< "findLeafLine : bb:" << this->bb() << " mid:" << mid()
|
||||
Pout<< "findLeafLine : bb:" << this->bb() << " mid:" << midpoint()
|
||||
<< " start:" << start << endl;
|
||||
}
|
||||
|
||||
@ -1111,7 +1096,7 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
||||
|
||||
label iter = 0;
|
||||
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
if (!this->bb().contains(direction, start))
|
||||
{
|
||||
@ -1145,11 +1130,13 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
||||
}
|
||||
|
||||
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
|
||||
const treeLeaf<Type>* leafPtr =
|
||||
findLeafLineOctant
|
||||
const treeLeaf<Type>* leafPtr = findLeafLineOctant
|
||||
(
|
||||
level,
|
||||
shapes,
|
||||
@ -1193,14 +1180,14 @@ const treeLeaf<Type>* treeNode<Type>::findLeafLine
|
||||
|
||||
|
||||
template <class Type>
|
||||
void treeNode<Type>::findLeaves
|
||||
void Foam::treeNode<Type>::findLeaves
|
||||
(
|
||||
List<treeLeaf<Type>*>& leafArray,
|
||||
label& leafIndex
|
||||
) const
|
||||
{
|
||||
// Go into all sub boxes
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
if (subNodes()[octant])
|
||||
{
|
||||
@ -1222,14 +1209,14 @@ void treeNode<Type>::findLeaves
|
||||
|
||||
|
||||
template <class Type>
|
||||
void treeNode<Type>::findLeaves
|
||||
void Foam::treeNode<Type>::findLeaves
|
||||
(
|
||||
List<const treeLeaf<Type>*>& leafArray,
|
||||
label& leafIndex
|
||||
) const
|
||||
{
|
||||
// Go into all sub boxes
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
if (subNodes()[octant])
|
||||
{
|
||||
@ -1251,7 +1238,7 @@ void treeNode<Type>::findLeaves
|
||||
|
||||
|
||||
template <class Type>
|
||||
void treeNode<Type>::printNode
|
||||
void Foam::treeNode<Type>::printNode
|
||||
(
|
||||
Ostream& os,
|
||||
const label level
|
||||
@ -1261,7 +1248,7 @@ void treeNode<Type>::printNode
|
||||
|
||||
os << "node:" << this->bb() << endl;
|
||||
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
label type = getVolType(octant);
|
||||
|
||||
@ -1291,21 +1278,21 @@ void treeNode<Type>::printNode
|
||||
|
||||
|
||||
template <class Type>
|
||||
void treeNode<Type>::writeOBJ
|
||||
void Foam::treeNode<Type>::writeOBJ
|
||||
(
|
||||
Ostream& os,
|
||||
const label level,
|
||||
label& vertNo
|
||||
) const
|
||||
{
|
||||
point midPoint(this->bb().mid());
|
||||
point midPoint(this->bb().midpoint());
|
||||
|
||||
label midVertNo = vertNo;
|
||||
os << "v " << midPoint.x() << " " << midPoint.y() << " "
|
||||
<< midPoint.z() << endl;
|
||||
vertNo++;
|
||||
|
||||
for(label octant=0; octant<8; octant++)
|
||||
for (label octant=0; octant<8; octant++)
|
||||
{
|
||||
if (subNodes_[octant])
|
||||
{
|
||||
@ -1313,7 +1300,7 @@ void treeNode<Type>::writeOBJ
|
||||
{
|
||||
treeNode<Type>* nodePtr = getNodePtr(octant);
|
||||
|
||||
point subMidPoint(nodePtr->bb().mid());
|
||||
point subMidPoint(nodePtr->bb().midpoint());
|
||||
os << "v " << subMidPoint.x() << " " << subMidPoint.y() << " "
|
||||
<< subMidPoint.z() << endl;
|
||||
os << "l " << midVertNo + 1<< " " << vertNo + 1 << endl;
|
||||
@ -1325,7 +1312,7 @@ void treeNode<Type>::writeOBJ
|
||||
{
|
||||
treeLeaf<Type>* leafPtr = getLeafPtr(octant);
|
||||
|
||||
point subMidPoint(leafPtr->bb().mid());
|
||||
point subMidPoint(leafPtr->bb().midpoint());
|
||||
os << "v " << subMidPoint.x() << " " << subMidPoint.y() << " "
|
||||
<< subMidPoint.z() << endl;
|
||||
os << "l " << midVertNo + 1<< " " << vertNo + 1 << endl;
|
||||
@ -1341,9 +1328,9 @@ void treeNode<Type>::writeOBJ
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
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;
|
||||
}
|
||||
@ -1384,7 +1371,7 @@ Istream& operator>>(Istream& is, treeNode<Type>& oc)
|
||||
|
||||
|
||||
template <class Type>
|
||||
Ostream& operator<<(Ostream& os, const treeNode<Type>& tn)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const treeNode<Type>& tn)
|
||||
{
|
||||
// Count valid subnodes:
|
||||
// - treeNode
|
||||
@ -1440,8 +1427,4 @@ Ostream& operator<<(Ostream& os, const treeNode<Type>& tn)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -28,12 +28,13 @@ Class
|
||||
Description
|
||||
Class to implement octree.
|
||||
|
||||
Holds the pointers to subcubes. These are either other treeNodes or
|
||||
treeLeafs. treeLeafs hold the actual data as a list of indices into
|
||||
Holds the pointers to sub-octants. These are either other treeNodes or
|
||||
treeLeafs. The treeLeafs hold the actual data as a list of indices into
|
||||
octreeData.
|
||||
|
||||
To prevent calculation errors all bb's used in octrees are calculated
|
||||
only once.
|
||||
Note
|
||||
To prevent calculation errors all bounding boxes used in octrees are
|
||||
calculated only once.
|
||||
|
||||
The pointers to either treeNode/treeLeaf are implemented 'by hand'
|
||||
(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>&);
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeNodeName Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -89,7 +89,7 @@ class treeNode
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- position of midPoint
|
||||
//- Position of the midpoint
|
||||
const point mid_;
|
||||
|
||||
//- Type stored in subNodes_
|
||||
@ -103,9 +103,6 @@ class treeNode
|
||||
|
||||
// Static data members
|
||||
|
||||
//- empty labelList to satisfy compiler
|
||||
static const labelList dummy;
|
||||
|
||||
//- leaf offset for octant index
|
||||
static const label leafOffset;
|
||||
|
||||
@ -157,7 +154,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
treeNode(const treeBoundBox& bb);
|
||||
treeNode(const treeBoundBox&);
|
||||
|
||||
//- Construct from Istream
|
||||
treeNode(Istream&);
|
||||
@ -172,8 +169,8 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- position of midPoint
|
||||
const point& mid() const;
|
||||
//- The midpoint position
|
||||
inline const point& midpoint() const;
|
||||
|
||||
//- array of 8 subNodes/leaves
|
||||
inline treeElem<Type>* const* subNodes() const;
|
||||
@ -247,13 +244,13 @@ public:
|
||||
|
||||
//- Find nearest shape to sample
|
||||
// Returns true if found nearer shape and updates
|
||||
// tightest, tightesti, tightestDist
|
||||
// tightest, tightestI, tightestDist
|
||||
bool findNearest
|
||||
(
|
||||
const Type& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const;
|
||||
|
||||
@ -265,7 +262,7 @@ public:
|
||||
const Type& shapes,
|
||||
const linePointRef& ln,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti, // index of nearest shape
|
||||
label& tightestI, // index of nearest shape
|
||||
point& linePoint, // nearest point on line
|
||||
point& shapePoint // nearest point on shape
|
||||
) const;
|
||||
|
||||
@ -26,45 +26,44 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Get type of octant
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
inline const point& treeNode<Type>::mid() const
|
||||
inline const Foam::point& Foam::treeNode<Type>::midpoint() const
|
||||
{
|
||||
return mid_;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
inline treeElem<Type>* const* treeNode<Type>::subNodes() const
|
||||
inline Foam::treeElem<Type>* const* Foam::treeNode<Type>::subNodes() const
|
||||
{
|
||||
return subNodes_;
|
||||
}
|
||||
|
||||
|
||||
// octant contains pointer to treeNode(1) or treeLeaf(0)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// Get pointer to sub node
|
||||
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
|
||||
if (!isNode(octant))
|
||||
@ -81,7 +80,10 @@ inline treeNode<Type>* treeNode<Type>::getNodePtr(const label octant) const
|
||||
|
||||
// Get pointer to sub leaf
|
||||
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
|
||||
if (isNode(octant))
|
||||
@ -95,8 +97,5 @@ inline treeLeaf<Type>* treeNode<Type>::getLeafPtr(const label octant) const
|
||||
return static_cast<treeLeaf<Type>*>(subNodes_[octant]);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -38,12 +38,15 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(distributedTriSurfaceMesh, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
searchableSurface,
|
||||
distributedTriSurfaceMesh,
|
||||
dict
|
||||
);
|
||||
|
||||
defineTypeNameAndDebug(distributedTriSurfaceMesh, 0);
|
||||
addToRunTimeSelectionTable(searchableSurface, distributedTriSurfaceMesh, dict);
|
||||
|
||||
scalar distributedTriSurfaceMesh::mergeDist_ = SMALL;
|
||||
|
||||
scalar distributedTriSurfaceMesh::mergeDist_ = SMALL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -32,10 +32,8 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(searchableBox, 0);
|
||||
addToRunTimeSelectionTable(searchableSurface, searchableBox, dict);
|
||||
|
||||
defineTypeNameAndDebug(searchableBox, 0);
|
||||
addToRunTimeSelectionTable(searchableSurface, searchableBox, dict);
|
||||
}
|
||||
|
||||
|
||||
@ -211,7 +209,7 @@ Foam::pointIndexHit Foam::searchableBox::findNearest
|
||||
const scalar nearestDistSqr
|
||||
) const
|
||||
{
|
||||
return findNearest(mid(), sample, nearestDistSqr);
|
||||
return findNearest(midpoint(), sample, nearestDistSqr);
|
||||
}
|
||||
|
||||
|
||||
@ -221,7 +219,7 @@ Foam::pointIndexHit Foam::searchableBox::findNearestOnEdge
|
||||
const scalar nearestDistSqr
|
||||
) const
|
||||
{
|
||||
const point bbMid(mid());
|
||||
const point bbMid(midpoint());
|
||||
|
||||
// Outside point projected onto cube. Assume faces 0..5.
|
||||
pointIndexHit info(true, sample, -1);
|
||||
@ -383,7 +381,7 @@ void Foam::searchableBox::findNearest
|
||||
{
|
||||
info.setSize(samples.size());
|
||||
|
||||
const point bbMid(mid());
|
||||
const point bbMid(midpoint());
|
||||
|
||||
forAll(samples, i)
|
||||
{
|
||||
|
||||
@ -59,7 +59,7 @@ void Foam::edgeIntersections::checkEdges(const triSurface& surf)
|
||||
|
||||
treeBoundBox bb(localPoints);
|
||||
|
||||
scalar minSize = SMALL*bb.minDim();
|
||||
scalar minSize = SMALL * bb.minDim();
|
||||
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@ Description
|
||||
|
||||
defineTypeNameAndDebug(Foam::octreeDataTriSurface, 0);
|
||||
|
||||
Foam::scalar Foam::octreeDataTriSurface::tol = 1E-6;
|
||||
Foam::scalar Foam::octreeDataTriSurface::tol(1E-6);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -181,9 +181,9 @@ void Foam::octreeDataTriSurface::nearestCoords
|
||||
// with points very close to one of the triangle vertices.
|
||||
// (seen up to -9e-15). Alternatively add some small value.
|
||||
|
||||
//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 Foam::mag(a*s*s + 2*b*s*t + c*t*t + 2*d*s + 2*e*t + f);
|
||||
// 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 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
|
||||
)
|
||||
{
|
||||
treeBoundBox illegalBb
|
||||
(
|
||||
vector(GREAT, GREAT, GREAT),
|
||||
vector(-GREAT, -GREAT, -GREAT)
|
||||
);
|
||||
|
||||
treeBoundBoxList allBb(surf.size(), illegalBb);
|
||||
treeBoundBoxList allBb(surf.size(), treeBoundBox::invertedBox);
|
||||
|
||||
const labelListList& pointFcs = surf.pointFaces();
|
||||
const pointField& localPts = surf.localPoints();
|
||||
@ -325,12 +319,12 @@ Foam::label Foam::octreeDataTriSurface::getSampleType
|
||||
const octree<octreeDataTriSurface>& oc,
|
||||
const point& sample
|
||||
) const
|
||||
|
||||
{
|
||||
// Find nearest face to sample
|
||||
treeBoundBox tightest(treeBoundBox::greatBox);
|
||||
scalar tightestDist(treeBoundBox::great);
|
||||
|
||||
scalar tightestDist = GREAT;
|
||||
|
||||
// Find nearest face to sample
|
||||
label faceI = oc.findNearest(sample, tightest, tightestDist);
|
||||
|
||||
if (debug & 2)
|
||||
@ -350,11 +344,9 @@ Foam::label Foam::octreeDataTriSurface::getSampleType
|
||||
}
|
||||
|
||||
const pointField& pts = surface_.points();
|
||||
|
||||
const labelledTri& f = surface_[faceI];
|
||||
|
||||
pointHit curHit =
|
||||
triPointRef
|
||||
pointHit curHit = triPointRef
|
||||
(
|
||||
pts[f[0]],
|
||||
pts[f[1]],
|
||||
@ -557,8 +549,8 @@ Foam::scalar Foam::octreeDataTriSurface::calcNearest
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"octreeDataTriSurface::calcNearest(const label, const linePointRef&"
|
||||
", point& linePt, point&)"
|
||||
"octreeDataTriSurface::calcNearest"
|
||||
"(const label, const linePointRef&, point& linePt, point&)"
|
||||
);
|
||||
return GREAT;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ bool Foam::treeLeaf<Foam::octreeDataTriSurface>::findNearest
|
||||
const octreeDataTriSurface& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const
|
||||
{
|
||||
@ -70,7 +70,7 @@ bool Foam::treeLeaf<Foam::octreeDataTriSurface>::findNearest
|
||||
max.y() = sample.y() + dist;
|
||||
max.z() = sample.z() + dist;
|
||||
|
||||
tightesti = faceI;
|
||||
tightestI = faceI;
|
||||
tightestDist = dist;
|
||||
|
||||
changed = true;
|
||||
|
||||
@ -52,7 +52,7 @@ bool treeLeaf<octreeDataTriSurface>::findNearest
|
||||
const octreeDataTriSurface& shapes,
|
||||
const point& sample,
|
||||
treeBoundBox& tightest,
|
||||
label& tightesti,
|
||||
label& tightestI,
|
||||
scalar& tightestDist
|
||||
) const;
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
|
||||
{
|
||||
treeBoundBox treeBb(surface_.points(), surface_.meshPoints());
|
||||
|
||||
scalar tol = 1E-6*treeBb.avgDim();
|
||||
scalar tol = 1E-6 * treeBb.avgDim();
|
||||
|
||||
point& bbMin = treeBb.min();
|
||||
bbMin.x() -= tol;
|
||||
|
||||
Reference in New Issue
Block a user