53 int main(
int argc,
char *argv[])
57 "Add two surfaces via a geometric merge on points."
58 " Does not check for overlapping/intersecting triangles."
70 "Provide additional points"
75 "Combine regions from both surfaces"
81 "Geometry scaling factor on input surfaces"
90 const bool addPoint =
args.
found(
"points");
91 const bool mergeRegions =
args.
found(
"mergeRegions");
97 Info<<
"Reading a surface and adding points from a file"
98 <<
"; merging the points and writing the surface to another file"
101 Info<<
"Surface : " << inFileName1<<
nl
103 <<
"Writing : " << outFileName <<
nl <<
endl;
107 Info<<
"Reading two surfaces"
108 <<
"; merging points and writing the surface to another file"
113 Info<<
"Regions from the two files will get merged" <<
nl
114 <<
"Do not use this option if you want to keep the regions"
115 <<
" separate" <<
nl <<
endl;
119 Info<<
"Regions from the two files will not get merged" <<
nl
120 <<
"Regions from " << inFileName2 <<
" will get offset so"
121 <<
" as not to overlap with the regions in " << inFileName1
126 Info<<
"Surface1 : " << inFileName1<<
nl
127 <<
"Surface2 : " << inFileName2<<
nl
128 <<
"Writing : " << outFileName <<
nl <<
endl;
133 Info<<
"Scaling : " << scaleFactor <<
nl;
136 const triSurface surface1(inFileName1, scaleFactor);
138 surface1.writeStats(
Info);
141 const pointField& points1 = surface1.points();
151 Info<<
"Additional Points:" << extraPoints.size() <<
endl;
154 label pointi = pointsAll.size();
155 pointsAll.setSize(pointsAll.size() + extraPoints.size());
157 for (
const auto& pt : extraPoints)
159 pointsAll[pointi++] = pt;
162 combinedSurf =
triSurface(surface1, surface1.patches(), pointsAll);
166 const triSurface surface2(inFileName2, scaleFactor);
168 surface2.writeStats(
Info);
175 const pointField& points2 = surface2.points();
177 vectorField pointsAll(points1.size() + points2.size());
182 for (
const auto& pt : points1)
184 pointsAll[pointi++] = pt;
187 for (
const auto& pt : points2)
189 pointsAll[pointi++] = pt;
196 label nNewPatches = 0;
197 labelList patch1Map(surface1.patches().size());
198 labelList patch2Map(surface2.patches().size());
204 forAll(surface1.patches(), i)
206 const word&
name = surface1.patches()[i].name();
209 const label combinedi = nameToPatch(
name, nameToPatch.
size());
211 patch1Map[i] = combinedi;
216 forAll(surface2.patches(), i)
218 const word&
name = surface2.patches()[i].name();
221 const label combinedi = nameToPatch(
name, nameToPatch.
size());
223 patch2Map[i] = combinedi;
226 nNewPatches = nameToPatch.
size();
230 Info<<
"Surface " << inFileName1
231 <<
" has " << surface1.patches().size()
234 <<
"All region numbers in " << inFileName2 <<
" will be offset"
235 <<
" by this amount" <<
nl <<
endl;
237 patch1Map =
identity(surface1.patches().size());
238 patch2Map =
identity(surface2.patches().size(), patch1Map.size());
240 nNewPatches = surface1.patches().size()+surface2.patches().size();
249 destTri.triFace::operator=(tri);
250 destTri.
region() = patch1Map[tri.region()];
257 destTri[0] = tri[0] + points1.
size();
258 destTri[1] = tri[1] + points1.
size();
259 destTri[2] = tri[2] + points1.
size();
260 destTri.
region() = patch2Map[tri.region()];
265 forAll(surface1.patches(), patchi)
267 newPatches[patch1Map[patchi]] = surface1.patches()[patchi];
269 forAll(surface2.patches(), patchi)
271 newPatches[patch2Map[patchi]] = surface2.patches()[patchi];
274 Info<<
"New patches:" <<
nl;
275 forAll(newPatches, patchi)
277 Info<<
" " << patchi <<
'\t' << newPatches[patchi].name() <<
nl;
283 combinedSurf =
triSurface(facesAll, newPatches, pointsAll);
295 Info<<
"Writing : " << outFileName <<
endl;
298 combinedSurf.
write(outFileName, mergeRegions);