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();
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);
void cleanup(const bool verbose)
Remove non-valid triangles.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
void writeStats(Ostream &os) const
Write some statistics.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void noParallel()
Remove the parallel options.
label size() const noexcept
The number of elements in table.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
void write(Ostream &os) const
Write to Ostream in simple OpenFOAM format.
#define forAll(list, i)
Loop across all elements in list.
static constexpr label size() noexcept
Return the number of elements in the FixedList.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
label region() const noexcept
Return the region index.
A class for handling words, derived from Foam::string.
Extract command arguments and options from the supplied argc and argv parameters. ...
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
A triFace with additional (region) index.
Input from file stream, using an ISstream.
T get(const label index) const
Get a value from the argument at index.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.