Go to the documentation of this file.
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);
78 magSqrD[pointI] =
magSqr(d[pointI]);
84 Field<scalar> sortedTol(
points.size());
87 label pointI = order[sortI];
92 scalar(d[pointI].
x()),
93 scalar(d[pointI].
y()),
96 sortedTol[sortI] = 2*mergeTol*(
mag(pt.x())+
mag(pt.y())+
mag(pt.z()));
103 label pointI = order[0];
104 pointMap[pointI] = newPointI++;
107 for (
label sortI = 1; sortI < order.size(); sortI++)
110 label pointI = order[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]);
132 label prevPointI = order[prevSortI];
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]
167 pointMap[pointI] = newPointI++;
179 const scalar mergeTol,
198 newPoints[pointMap[pointI]] =
points[pointI];
201 return (nUnique !=
points.size());
List< label > labelList
A List of labels.
#define forAll(list, i)
Loop across all elements in list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
prefixOSstream Pout(cout, "Pout")
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Various functions to operate on Lists.
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 > magSqr(const dimensioned< Type > &)