mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: adjust mergePoints to ease adoption of different list types (issue #250)
- A preliminary minor adjustment only.
This commit is contained in:
@ -39,23 +39,22 @@ Foam::label Foam::mergePoints
|
|||||||
const Type& origin
|
const Type& origin
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Type compareOrigin = origin;
|
|
||||||
|
|
||||||
if (origin == Type::max)
|
|
||||||
{
|
|
||||||
if (points.size())
|
|
||||||
{
|
|
||||||
compareOrigin = sum(points)/points.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a old to new point mapping array
|
// Create a old to new point mapping array
|
||||||
pointMap.setSize(points.size());
|
pointMap.setSize(points.size());
|
||||||
pointMap = -1;
|
pointMap = -1;
|
||||||
|
|
||||||
if (points.empty())
|
if (points.empty())
|
||||||
{
|
{
|
||||||
return points.size();
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Explicitly convert to Field to support various list types
|
||||||
|
tmp<Field<Type>> tPoints(new Field<Type>(points));
|
||||||
|
|
||||||
|
Type compareOrigin = origin;
|
||||||
|
if (origin == Type::max)
|
||||||
|
{
|
||||||
|
compareOrigin = sum(tPoints())/points.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're comparing distance squared to origin first.
|
// We're comparing distance squared to origin first.
|
||||||
@ -70,7 +69,7 @@ Foam::label Foam::mergePoints
|
|||||||
const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol));
|
const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol));
|
||||||
|
|
||||||
// Sort points by magSqr
|
// Sort points by magSqr
|
||||||
const Field<Type> d(points - compareOrigin);
|
const Field<Type> d(tPoints - compareOrigin);
|
||||||
|
|
||||||
List<scalar> magSqrD(d.size());
|
List<scalar> magSqrD(d.size());
|
||||||
forAll(d, pointI)
|
forAll(d, pointI)
|
||||||
@ -98,12 +97,10 @@ Foam::label Foam::mergePoints
|
|||||||
|
|
||||||
label newPointI = 0;
|
label newPointI = 0;
|
||||||
|
|
||||||
|
|
||||||
// Handle 0th point separately (is always unique)
|
// Handle 0th point separately (is always unique)
|
||||||
label pointI = order[0];
|
label pointI = order[0];
|
||||||
pointMap[pointI] = newPointI++;
|
pointMap[pointI] = newPointI++;
|
||||||
|
|
||||||
|
|
||||||
for (label sortI = 1; sortI < order.size(); sortI++)
|
for (label sortI = 1; sortI < order.size(); sortI++)
|
||||||
{
|
{
|
||||||
// Get original point index
|
// Get original point index
|
||||||
|
|||||||
Reference in New Issue
Block a user