1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
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::noParallel();
51 argList::validArgs.append("surfaceFile");
52 argList::validArgs.append("min length");
53 argList::validArgs.append("output surfaceFile");
54 argList::addBoolOption
57 "perform some surface checking/cleanup on the input surface"
59 argList args(argc, argv);
61 const fileName inFileName = args[1];
62 const scalar minLen = args.argRead<scalar>(2);
63 const fileName outFileName = args[3];
65 Info<< "Reading surface " << inFileName << nl
66 << "Collapsing all triangles with edges or heights < " << minLen << nl
67 << "Writing result to " << outFileName << nl << endl;
70 Info<< "Reading surface from " << inFileName << " ..." << nl << endl;
71 triSurface surf(inFileName);
72 surf.writeStats(Info);
74 if (!args.optionFound("noClean"))
76 Info<< "Removing duplicate and illegal triangles ..." << nl << endl;
80 Info<< "Collapsing triangles to edges ..." << nl << endl;
84 label nEdgeCollapse = collapseEdge(surf, minLen);
86 if (nEdgeCollapse == 0)
93 label nSplitEdge = collapseBase(surf, minLen);
102 << "Resulting surface:" << endl;
103 surf.writeStats(Info);
106 << "Writing refined surface to " << outFileName << " ..." << endl;
107 surf.write(outFileName);
109 Info<< "\nEnd\n" << endl;
115 // ************************************************************************* //