00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Application 00025 surfaceClean 00026 00027 Description 00028 Collapses small edges, removing triangles and converts sliver triangles 00029 into split edges by projecting point onto base of triangle. 00030 00031 Usage 00032 00033 - surfaceClean [OPTIONS] <Foam surface file> <min length> <Foam output surface file> 00034 00035 @param <Foam surface file> \n 00036 @todo Detailed description of argument. 00037 00038 @param <min length> \n 00039 @todo Detailed description of argument. 00040 00041 @param <Foam output surface file> \n 00042 @todo Detailed description of argument. 00043 00044 @param -case <dir>\n 00045 Case directory. 00046 00047 @param -help \n 00048 Display help message. 00049 00050 @param -doc \n 00051 Display Doxygen API documentation page for this application. 00052 00053 @param -srcDoc \n 00054 Display Doxygen source documentation page for this application. 00055 00056 \*---------------------------------------------------------------------------*/ 00057 00058 #include <triSurface/triSurface.H> 00059 #include <OpenFOAM/argList.H> 00060 #include <OpenFOAM/OFstream.H> 00061 00062 #include "collapseBase.H" 00063 #include "collapseEdge.H" 00064 00065 using namespace Foam; 00066 00067 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00068 00069 // Main program: 00070 00071 int main(int argc, char *argv[]) 00072 { 00073 argList::validArgs.clear(); 00074 argList::noParallel(); 00075 argList::validArgs.append("surface file"); 00076 argList::validArgs.append("min length"); 00077 argList::validArgs.append("output surface file"); 00078 argList args(argc, argv); 00079 00080 fileName inFileName(args.additionalArgs()[0]); 00081 scalar minLen(readScalar(IStringStream(args.additionalArgs()[1])())); 00082 fileName outFileName(args.additionalArgs()[2]); 00083 00084 Pout<< "Reading surface " << inFileName << nl 00085 << "Collapsing all triangles with edges or heights < " << minLen << nl 00086 << "Writing result to " << outFileName << nl << endl; 00087 00088 00089 Pout<< "Reading surface from " << inFileName << " ..." << nl << endl; 00090 triSurface surf(inFileName); 00091 surf.writeStats(Pout); 00092 00093 00094 Pout<< "Collapsing triangles to edges ..." << nl << endl; 00095 00096 while (true) 00097 { 00098 label nEdgeCollapse = collapseEdge(surf, minLen); 00099 00100 if (nEdgeCollapse == 0) 00101 { 00102 break; 00103 } 00104 } 00105 while (true) 00106 { 00107 label nSplitEdge = collapseBase(surf, minLen); 00108 00109 if (nSplitEdge == 0) 00110 { 00111 break; 00112 } 00113 } 00114 00115 Pout<< nl << "Resulting surface:" << endl; 00116 surf.writeStats(Pout); 00117 Pout<< nl; 00118 00119 Pout<< "Writing refined surface to " << outFileName << " ..." << endl; 00120 surf.write(outFileName); 00121 Pout<< nl; 00122 00123 Pout<< "End\n" << endl; 00124 00125 return 0; 00126 } 00127 00128 00129 // ************************ vim: set sw=4 sts=4 et: ************************ //