1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 - collapses small edges, removing triangles.
30 - converts sliver triangles into split edges by projecting point onto
33 \*---------------------------------------------------------------------------*/
35 #include "triSurface.H"
39 #include "collapseBase.H"
40 #include "collapseEdge.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 int main(int argc, char *argv[])
50 argList::validArgs.clear();
51 argList::noParallel();
52 argList::validArgs.append("surface file");
53 argList::validArgs.append("min length");
54 argList::validArgs.append("output surface file");
55 argList args(argc, argv);
57 fileName inFileName(args.additionalArgs()[0]);
58 scalar minLen(readScalar(IStringStream(args.additionalArgs()[1])()));
59 fileName outFileName(args.additionalArgs()[2]);
61 Pout<< "Reading surface " << inFileName << nl
62 << "Collapsing all triangles with edges or heights < " << minLen << nl
63 << "Writing result to " << outFileName << nl << endl;
66 Pout<< "Reading surface from " << inFileName << " ..." << nl << endl;
67 triSurface surf(inFileName);
68 surf.writeStats(Pout);
71 Pout<< "Collapsing triangles to edges ..." << nl << endl;
75 label nEdgeCollapse = collapseEdge(surf, minLen);
77 if (nEdgeCollapse == 0)
84 label nSplitEdge = collapseBase(surf, minLen);
92 Pout<< nl << "Resulting surface:" << endl;
93 surf.writeStats(Pout);
96 Pout<< "Writing refined surface to " << outFileName << " ..." << endl;
97 surf.write(outFileName);
100 Pout<< "End\n" << endl;
106 // ************************************************************************* //