37 #include "triSurface.H"
48 int main(
int argc,
char *argv[])
52 "add two surfaces via a geometric merge on points."
64 "provide additional points"
69 "combine regions from both surfaces"
83 Info<<
"Reading a surface and adding points from a file"
84 <<
"; merging the points and writing the surface to another file"
87 Info<<
"Surface : " << inFileName1<<
nl
88 <<
"Points : " <<
args[
"points"] <<
nl
89 <<
"Writing : " << outFileName <<
nl <<
endl;
93 Info<<
"Reading two surfaces"
94 <<
"; merging points and writing the surface to another file"
99 Info<<
"Regions from the two files will get merged" <<
nl
100 <<
"Do not use this option if you want to keep the regions"
101 <<
" separate" <<
nl <<
endl;
105 Info<<
"Regions from the two files will not get merged" <<
nl
106 <<
"Regions from " << inFileName2 <<
" will get offset so"
107 <<
" as not to overlap with the regions in " << inFileName1
112 Info<<
"Surface1 : " << inFileName1<<
nl
113 <<
"Surface2 : " << inFileName2<<
nl
114 <<
"Writing : " << outFileName <<
nl <<
endl;
120 surface1.writeStats(
Info);
123 const pointField& points1 = surface1.points();
133 Info<<
"Additional Points:" << extraPoints.size() <<
endl;
136 label pointI = pointsAll.size();
137 pointsAll.setSize(pointsAll.size() + extraPoints.size());
141 pointsAll[pointI++] = extraPoints[i];
144 combinedSurf =
triSurface(surface1, surface1.patches(), pointsAll);
151 surface2.writeStats(
Info);
158 const pointField& points2 = surface2.points();
160 vectorField pointsAll(points1.size() + points2.size());
167 pointsAll[pointi++] = points1[point1i];
172 pointsAll[pointi++] = points2[point2i];
181 facesAll[trianglei++] = surface1[faceI];
183 label nRegions1 = surface1.patches().size();
188 Info<<
"Surface " << inFileName1 <<
" has " << nRegions1
191 <<
"All region numbers in " << inFileName2 <<
" will be offset"
192 <<
" by this amount" <<
nl <<
endl;
201 destTri[0] = tri[0] + points1.size();
202 destTri[1] = tri[1] + points1.size();
203 destTri[2] = tri[2] + points1.size();
214 label nRegions2 = surface2.patches().size();
221 newPatches.
setSize(
max(nRegions1, nRegions2));
223 forAll(surface1.patches(), patchI)
225 newPatches[patchI] = surface1.patches()[patchI];
227 forAll(surface2.patches(), patchI)
229 newPatches[patchI] = surface2.patches()[patchI];
234 Info<<
"Regions from " << inFileName2 <<
" have been renumbered:"
236 <<
" old\tnew" <<
nl;
238 for (
label regionI = 0; regionI < nRegions2; regionI++)
240 Info<<
" " << regionI <<
'\t' << regionI+nRegions1
245 newPatches.
setSize(nRegions1 + nRegions2);
249 forAll(surface1.patches(), patchI)
251 newPatches[newPatchI++] = surface1.patches()[patchI];
254 forAll(surface2.patches(), patchI)
256 newPatches[newPatchI++] = surface2.patches()[patchI];
261 Info<<
"New patches:" <<
nl;
262 forAll(newPatches, patchI)
264 Info<<
" " << patchI <<
'\t' << newPatches[patchI].name() <<
nl;
270 combinedSurf =
triSurface(facesAll, newPatches, pointsAll);
282 Info<<
"Writing : " << outFileName <<
endl;
285 combinedSurf.
write(outFileName);