ENH: cvMesh: Move feature point tree into extendedFeatureEdgeMesh from cvMesh

This commit is contained in:
laurence
2012-02-09 12:25:42 +00:00
parent 779d1548d1
commit ecb31dc57f
6 changed files with 120 additions and 40 deletions

View File

@ -72,6 +72,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
edgeNormals_(0),
featurePointNormals_(0),
regionEdges_(0),
pointTree_(),
edgeTree_(),
edgeTreesByType_()
{
@ -159,6 +160,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeNormals_(fem.edgeNormals()),
featurePointNormals_(fem.featurePointNormals()),
regionEdges_(fem.regionEdges()),
pointTree_(),
edgeTree_(),
edgeTreesByType_()
{}
@ -185,6 +187,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeNormals_(0),
featurePointNormals_(0),
regionEdges_(0),
pointTree_(),
edgeTree_(),
edgeTreesByType_()
{}
@ -222,6 +225,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeNormals_(0),
featurePointNormals_(0),
regionEdges_(0),
pointTree_(),
edgeTree_(),
edgeTreesByType_()
{
@ -578,6 +582,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeNormals_(edgeNormals),
featurePointNormals_(featurePointNormals),
regionEdges_(regionEdges),
pointTree_(),
edgeTree_(),
edgeTreesByType_()
{}
@ -684,6 +689,21 @@ Foam::extendedFeatureEdgeMesh::classifyEdge
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::extendedFeatureEdgeMesh::nearestFeaturePoint
(
const point& sample,
scalar searchDistSqr,
pointIndexHit& info
) const
{
info = pointTree().findNearest
(
sample,
searchDistSqr
);
}
void Foam::extendedFeatureEdgeMesh::nearestFeatureEdge
(
const point& sample,
@ -816,6 +836,42 @@ void Foam::extendedFeatureEdgeMesh::allNearestFeatureEdges
}
const Foam::indexedOctree<Foam::treeDataPoint>&
Foam::extendedFeatureEdgeMesh::pointTree() const
{
if (pointTree_.empty())
{
Random rndGen(17301893);
// Slightly extended bb. Slightly off-centred just so on symmetric
// geometry there are less face/edge aligned items.
treeBoundBox bb
(
treeBoundBox(points()).extend(rndGen, 1E-4)
);
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
labelList allPoints(identity(points().size()));
pointTree_.reset
(
new indexedOctree<treeDataPoint>
(
treeDataPoint(points()),
bb, // bb
8, // maxLevel
10, // leafsize
3.0 // duplicity
)
);
}
return pointTree_();
}
const Foam::indexedOctree<Foam::treeDataEdge>&
Foam::extendedFeatureEdgeMesh::edgeTree() const
{

View File

@ -61,6 +61,7 @@ SourceFiles
#include "IOdictionary.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "treeDataPoint.H"
#include "pointIndexHit.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -155,6 +156,9 @@ private:
//- Feature edges which are on the boundary between regions
labelList regionEdges_;
//- Search tree for all feature points
mutable autoPtr<indexedOctree<treeDataPoint> > pointTree_;
//- Search tree for all edges
mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
@ -247,6 +251,14 @@ public:
// Find
//- Find nearest surface edge for the sample point.
void nearestFeaturePoint
(
const point& sample,
scalar searchDistSqr,
pointIndexHit& info
) const;
//- Find nearest surface edge for the sample point.
void nearestFeatureEdge
(
@ -349,6 +361,9 @@ public:
//- Return the edgeStatus of a specified edge
inline edgeStatus getEdgeStatus(label edgeI) const;
//- Demand driven construction of octree for feature points
const indexedOctree<treeDataPoint>& pointTree() const;
//- Demand driven construction of octree for boundary edges
const indexedOctree<treeDataEdge>& edgeTree() const;