mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: treeDataPoint: work on subset of points
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "treeDataPoint.H"
|
||||
#include "treeBoundBox.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "polyMesh.H"
|
||||
#include "triangleFuncs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -42,6 +41,17 @@ Foam::treeDataPoint::treeDataPoint(const pointField& points)
|
||||
{}
|
||||
|
||||
|
||||
Foam::treeDataPoint::treeDataPoint
|
||||
(
|
||||
const pointField& points,
|
||||
const labelList& pointLabels
|
||||
)
|
||||
:
|
||||
points_(points),
|
||||
pointLabels_(pointLabels)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointField Foam::treeDataPoint::points() const
|
||||
@ -69,7 +79,8 @@ bool Foam::treeDataPoint::overlaps
|
||||
const treeBoundBox& cubeBb
|
||||
) const
|
||||
{
|
||||
return cubeBb.contains(points_[index]);
|
||||
label pointI = (pointLabels_.size() ? pointLabels_[index] : index);
|
||||
return cubeBb.contains(points_[pointI]);
|
||||
}
|
||||
|
||||
|
||||
@ -88,8 +99,9 @@ void Foam::treeDataPoint::findNearest
|
||||
forAll(indices, i)
|
||||
{
|
||||
const label index = indices[i];
|
||||
label pointI = (pointLabels_.size() ? pointLabels_[index] : index);
|
||||
|
||||
const point& pt = points_[index];
|
||||
const point& pt = points_[pointI];
|
||||
|
||||
scalar distSqr = magSqr(pt - sample);
|
||||
|
||||
@ -122,8 +134,9 @@ void Foam::treeDataPoint::findNearest
|
||||
forAll(indices, i)
|
||||
{
|
||||
const label index = indices[i];
|
||||
label pointI = (pointLabels_.size() ? pointLabels_[index] : index);
|
||||
|
||||
const point& shapePt = points_[index];
|
||||
const point& shapePt = points_[pointI];
|
||||
|
||||
if (tightest.contains(shapePt))
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -30,6 +30,8 @@ Description
|
||||
Used for searching for nearest point. No bounding boxes around points.
|
||||
Only overlaps and calcNearest are implemented, rest makes little sense.
|
||||
|
||||
Optionally works on subset of points.
|
||||
|
||||
SourceFiles
|
||||
treeDataPoint.C
|
||||
|
||||
@ -60,6 +62,9 @@ class treeDataPoint
|
||||
|
||||
const pointField& points_;
|
||||
|
||||
//- Subset of points to work on (or empty)
|
||||
const labelList pointLabels_;
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
@ -68,9 +73,12 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components. Holds reference to points!
|
||||
//- Construct from pointField. Holds reference!
|
||||
treeDataPoint(const pointField&);
|
||||
|
||||
//- Construct from subset of pointField. Holds reference!
|
||||
treeDataPoint(const pointField&, const labelList&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -81,6 +89,11 @@ public:
|
||||
return points_.size();
|
||||
}
|
||||
|
||||
inline const labelList& pointLabels() const
|
||||
{
|
||||
return pointLabels_;
|
||||
}
|
||||
|
||||
//- Get representative point cloud for all shapes inside
|
||||
// (one point per shape)
|
||||
pointField points() const;
|
||||
|
||||
Reference in New Issue
Block a user