48 bool fullMatch =
true;
50 point compareOrigin = origin;
56 compareOrigin =
sum(pts1)/pts1.
size();
61 compareOrigin = point::zero;
71 scalar dist0 = pts0MagSqr[i];
73 label face0I = pts0MagSqr.
indices()[i];
75 scalar matchDist = matchDistances[face0I];
77 label startI =
findLower(pts1MagSqr, 0.99999*dist0 - 2*matchDist);
86 scalar minDistSqr = VGREAT;
93 (j < pts1MagSqr.
size())
94 && (pts1MagSqr[j] < 1.00001*dist0 + 2*matchDist)
99 label facei = pts1MagSqr.
indices()[j];
101 scalar distSqr =
magSqr(pts0[face0I] - pts1[facei]);
103 if (distSqr <=
sqr(matchDist) && distSqr < minDistSqr)
105 minDistSqr = distSqr;
116 Pout<<
"Cannot find point in pts1 matching point " << face0I
117 <<
" coord:" << pts0[face0I]
118 <<
" in pts0 when using tolerance " << matchDist <<
endl;
121 Pout<<
"Searching started from:" << startI <<
" in pts1" 127 (j < pts1MagSqr.
size())
128 && (pts1MagSqr[j] < 1.00001*dist0 + 2*matchDist)
133 label facei = pts1MagSqr.
indices()[j];
135 Pout<<
" Compared coord: " << pts1[facei]
137 <<
" with difference to point " 138 <<
mag(pts1[facei] - pts0[face0I]) <<
endl;
143 from0To1[face0I] = minFacei;
152 const UList<point>& pts0,
153 const UList<point>& pts1,
154 const UList<point>& pts0Dir,
155 const UList<point>& pts1Dir,
156 const UList<scalar>& matchDistances,
162 from0To1.setSize(pts0.size());
165 bool fullMatch =
true;
167 point compareOrigin = origin;
173 compareOrigin =
sum(pts1)/pts1.size();
178 compareOrigin = point::zero;
182 SortableList<scalar> pts0MagSqr(
magSqr(pts0 - compareOrigin));
184 SortableList<scalar> pts1MagSqr(
magSqr(pts1 - compareOrigin));
188 scalar dist0 = pts0MagSqr[i];
190 label face0I = pts0MagSqr.indices()[i];
192 scalar matchDist = matchDistances[face0I];
194 label startI =
findLower(pts1MagSqr, 0.99999*dist0 - 2*matchDist);
202 scalar minDistSqr = VGREAT;
206 const scalar minDistNorm = 0;
212 (j < pts1MagSqr.size())
213 && (pts1MagSqr[j] < 1.00001*dist0 + 2*matchDist)
218 label facei = pts1MagSqr.indices()[j];
220 scalar distSqr =
magSqr(pts0[face0I] - pts1[facei]);
222 scalar distNorm = (pts0Dir[face0I] & pts1Dir[facei]);
233 if (distSqr <=
sqr(matchDist) && distSqr < minDistSqr)
236 if (distNorm < minDistNorm)
238 minDistSqr = distSqr;
250 Pout<<
"Cannot find point in pts1 matching point " << face0I
251 <<
" coord:" << pts0[face0I]
252 <<
" in pts0 when using tolerance " << matchDist <<
endl;
255 Pout<<
"Searching started from:" << startI <<
" in pts1" 261 (j < pts1MagSqr.size())
262 && (pts1MagSqr[j] < 1.00001*dist0 + 2*matchDist)
267 label facei = pts1MagSqr.indices()[j];
269 Pout<<
" Compared coord: " << pts1[facei]
271 <<
" with difference to point " 272 <<
mag(pts1[facei] - pts0[face0I]) <<
endl;
277 from0To1[face0I] = minFacei;
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list that is sorted upon construction or when explicitly requested with the sort() method...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Determine correspondence between points. See below.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
bool matchPoints(const UList< point > &pts0, const UList< point > &pts1, const UList< scalar > &matchDistance, const bool verbose, labelList &from0To1, const point &origin=point::zero)
Determine correspondence between pointFields. Gets passed.
void setSize(const label n)
Alias for resize()
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
vector point
Point is a vector.
const labelList & indices() const noexcept
Return the list of sorted indices. Updated every sort.
List< label > labelList
A List of labels.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)