36 const scalar mergeTol,
42 Type compareOrigin = origin;
53 pointMap.setSize(
points.size());
70 const scalar mergeTolSqr =
Foam::sqr(scalar(mergeTol));
73 const Field<Type> d(
points - compareOrigin);
75 List<scalar> magSqrD(d.size());
78 magSqrD[pointi] =
magSqr(d[pointi]);
84 Field<scalar> sortedTol(
points.size());
92 scalar(d[pointi].
x()),
93 scalar(d[pointi].
y()),
96 sortedTol[sortI] = 2*mergeTol*(
mag(pt.x())+
mag(pt.y())+
mag(pt.z()));
107 for (
label sortI = 1; sortI <
order.size(); sortI++)
111 const scalar mag2 = magSqrD[
order[sortI]];
117 scalar(
points[pointi].z())
122 label equalPointi = -1;
126 label prevSortI = sortI - 1;
128 && (
mag(magSqrD[
order[prevSortI]] - mag2) <= sortedTol[sortI]);
135 scalar(
points[prevPointi].
x()),
136 scalar(
points[prevPointi].
y()),
137 scalar(
points[prevPointi].z())
140 if (
magSqr(pt - prevPt) <= mergeTolSqr)
143 equalPointi = prevPointi;
150 if (equalPointi != -1)
153 pointMap[pointi] = pointMap[equalPointi];
157 Pout<<
"Foam::mergePoints : Merging points "
158 << pointi <<
" and " << equalPointi
159 <<
" with coordinates:" <<
points[pointi]
160 <<
" and " <<
points[equalPointi]
179 const scalar mergeTol,
198 newPoints[pointMap[pointi]] =
points[pointi];
201 return (nUnique !=
points.size());
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
void setSize(const label)
Reset size of List.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
int order(const scalar s)
vector point
Point is a vector.
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
dimensioned< scalar > magSqr(const dimensioned< Type > &)