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