mergePoints.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Description
28 Geometric merging of points. See below.
29
30SourceFiles
31 mergePoints.C
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef Foam_mergePoints_H
36#define Foam_mergePoints_H
37
38#include "scalar.H"
39#include "labelList.H"
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43namespace Foam
44{
45
46namespace Detail
47{
48
49/*---------------------------------------------------------------------------*\
50 Function Detail::mergePoints Declaration
51\*---------------------------------------------------------------------------*/
52
53//- Implementation detail for Foam::mergePoints
54//
55// The implementation algorithm is provided with an \em indexer functor
56// to map the subset of points to be merged into the full list.
57// if passed the identityOp this is the same as merging all points.
58//
59// \returns Number of point duplicates \em removed by merging.
60template<class PointList, class IndexerOp>
62(
63 const PointList& points,
64 const IndexerOp& indexer,
65 const label nSubPoints,
66 labelList& pointToUnique,
67 labelList& uniquePoints,
68 const scalar mergeTol,
69 const bool verbose
70);
71
72} // End namespace Detail
73
74
75/*---------------------------------------------------------------------------*\
76 Function mergePoints Declarations
77\*---------------------------------------------------------------------------*/
78
79//- Calculate merge mapping, preserving the original point order.
80//- All points closer/equal mergeTol are to be merged.
81//
82// \param[in] points The input (unmerged) points
83// \param[out] pointToUnique An old-to-new mapping from the original
84// unmerged point index to the index into unique points.
85// \param[out] uniquePoints List of unique points from the original
86// list of unmerged points
87// \param[in] mergeTol Geometric merge tolerance
88// \param[in] verbose Debug verbosity
89//
90// \returns Number of point duplicates \em removed by merging.
91template<class PointList>
93(
94 const PointList& points,
95 labelList& pointToUnique,
96 labelList& uniquePoints,
97 const scalar mergeTol = SMALL,
98 const bool verbose = false
99);
100
101
102//- Calculate merge mapping using a subset of points,
103//- preserving the original point order.
104//- All points closer/equal mergeTol are to be merged.
105//
106// \param[in] allPoints The input of all (unmerged) points
107// \param[in] selection The subset of points to consider for merging
108// \param[out] pointToUnique An old-to-new mapping from the original
109// unmerged point index to the index into unique points.
110// \param[out] uniquePoints List of unique points from the original
111// list of unmerged points
112// \param[in] mergeTol Geometric merge tolerance
113// \param[in] verbose Additional debug verbosity
114//
115// \returns Number of point duplicates \em removed by merging.
116template<class PointList>
118(
119 const PointList& points,
120 const labelUList& selection,
121 labelList& pointToUnique,
122 labelList& uniquePoints,
123 const scalar mergeTol = SMALL,
124 const bool verbose = false
125);
126
127
128//- Calculate merge mapping, preserving the original point order.
129//- All points closer/equal mergeTol are to be merged.
130//
131// \param[in] points The input (unmerged) points
132// \param[in] mergeTol Geometric merge tolerance
133// \param[in] verbose Debug verbosity
134// \param[out] pointToUnique An old-to-new mapping from original
135// unmerged point index to the index into unique points.
136//
137// \returns Number of \em unique points after merging.
138// Can check against the size of points or pointToUnique to determine
139// if further action (eg, merging, renumbering) is required.
140template<class PointList>
142(
143 const PointList& points,
144 const scalar mergeTol,
145 const bool verbose,
146 labelList& pointToUnique
147);
148
149
150//- Inplace merge points, preserving the original point order.
151//- All points closer/equal mergeTol are to be merged.
152//
153// \note The list of points must be a concrete List/Field etc.
154// It cannot be an indirect list.
155//
156// \param[in,out] points The unmerged points on input, and unique merged
157// points on output
158// \param[in] mergeTol Geometric merge tolerance
159// \param[in] verbose Debug verbosity
160// \param[out] pointToUnique An old-to-new mapping from original
161// unmerged point index to the index into unique points.
162//
163// \returns Number of point duplicates \em removed by merging.
164// Can test as true/false to determine further actions.
165template<class PointList>
167(
168 PointList& points,
169 const scalar mergeTol,
170 const bool verbose,
171 labelList& pointToUnique
172);
173
174
175//- Inplace merge points a subset of points,
176//- preserving the original point order.
177//- All points closer/equal mergeTol are to be merged.
178//
179// \note The list of points must be a concrete List/Field etc.
180// It cannot be an indirect list.
181//
182// \param[in,out] points The unmerged points on input, and unique merged
183// points on output
184// \param[in] selection The subset of points to consider for merging
185// \param[in] mergeTol Geometric merge tolerance
186// \param[in] verbose Debug verbosity
187// \param[out] pointToUnique An old-to-new mapping from original
188// unmerged point index to the index into unique points.
189//
190// \returns Number of point duplicates \em removed by merging.
191// Can test as true/false to determine further actions.
192template<class PointList>
194(
195 PointList& points,
196 const labelUList& selection,
197 const scalar mergeTol,
198 const bool verbose,
199 labelList& pointToUnique
200);
201
202
203//- Merge points, preserving the original point order.
204//- All points closer/equal mergeTol are to be merged.
205//
206// \param[in] points The input (unmerged) points
207// \param[in] mergeTol Geometric merge tolerance
208// \param[in] verbose Debug verbosity
209// \param[out] pointToUnique An old-to-new mapping from original
210// unmerged point index to the index into unique points.
211// \param[out] newPoints The new unique (merged) points.
212//
213// \returns Number of point duplicates \em removed by merging.
214// Can test as true/false to determine further actions.
215template<class PointList>
217(
218 const PointList& points,
219 const scalar mergeTol,
220 const bool verbose,
221 labelList& pointToUnique,
223);
224
225
226
227//
228// Housekeeping
229//
230
231//- Deprecated (MAR-2022) reference point is ignored
232// \deprecated(2022-03) reference point is ignored
233template<class PointList>
234FOAM_DEPRECATED_FOR(2022-03, "mergePoint() methods without reference point")
235inline label mergePoints
236(
237 const PointList& points,
238 const scalar mergeTol,
239 const bool verbose,
240 labelList& pointMap,
241 typename PointList::value_type origin /* Used for v2112 and earlier */
242)
243{
244 return Foam::mergePoints(points, mergeTol, verbose, pointMap);
245}
246
247
248//- Deprecated (MAR-2022) reference point is ignored
249// \deprecated(2022-03) reference point is ignored
250template<class PointList>
251FOAM_DEPRECATED_FOR(2022-03, "mergePoint() methods without reference point")
252inline label mergePoints
253(
254 const PointList& points,
255 const scalar mergeTol,
256 const bool verbose,
257 labelList& pointMap,
258 List<typename PointList::value_type>& newPoints,
259 typename PointList::value_type origin /* Used for v2112 and earlier */
260)
261{
262 return Foam::mergePoints(points, mergeTol, verbose, pointMap, newPoints);
263}
264
265} // End namespace Foam
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269#ifdef NoRepository
270 #include "mergePoints.C"
271#endif
272
273// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274
275#endif
276
277// ************************************************************************* //
const pointField & points
label mergePoints(const PointList &points, const IndexerOp &indexer, const label nSubPoints, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol, const bool verbose)
Implementation detail for Foam::mergePoints.
Namespace for OpenFOAM.
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
label inplaceMergePoints(PointList &points, const scalar mergeTol, const bool verbose, labelList &pointToUnique)
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition: stdFoam.H:52