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 surfaceConvert 00026 00027 Description 00028 Converts from one surface mesh format to another 00029 00030 Usage 00031 00032 - surfaceConvert [OPTIONS] <Foam surface file> <Foam output surface file> 00033 00034 @param <Foam surface file> \n 00035 @todo Detailed description of argument. 00036 00037 @param <Foam output surface file> \n 00038 @todo Detailed description of argument. 00039 00040 @param -clean \n 00041 Perform some surface checking/cleanup on the input surface 00042 00043 @param -scale <scale> \n 00044 Specify a scaling factor for writing the files 00045 00046 @param -group \n 00047 Reorder faces into groups by region. 00048 00049 @param -case <dir>\n 00050 Case directory. 00051 00052 @param -help \n 00053 Display help message. 00054 00055 @param -doc \n 00056 Display Doxygen API documentation page for this application. 00057 00058 @param -srcDoc \n 00059 Display Doxygen source documentation page for this application. 00060 00061 Note 00062 The filename extensions are used to determine the file format type. 00063 00064 \*---------------------------------------------------------------------------*/ 00065 00066 #include <OpenFOAM/argList.H> 00067 #include <OpenFOAM/fileName.H> 00068 #include <triSurface/triSurface.H> 00069 #include <OpenFOAM/OFstream.H> 00070 #include <OpenFOAM/OSspecific.H> 00071 00072 using namespace Foam; 00073 00074 00075 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00076 // Main program: 00077 00078 int main(int argc, char *argv[]) 00079 { 00080 argList::noParallel(); 00081 argList::validArgs.clear(); 00082 argList::validArgs.append("inputFile"); 00083 argList::validArgs.append("outputFile"); 00084 argList::validOptions.insert("clean", ""); 00085 argList::validOptions.insert("scale", "scale"); 00086 argList::validOptions.insert("group", ""); 00087 00088 argList args(argc, argv); 00089 const stringList& params = args.additionalArgs(); 00090 00091 fileName importName(params[0]); 00092 fileName exportName(params[1]); 00093 00094 if (importName == exportName) 00095 { 00096 FatalErrorIn(args.executable()) 00097 << "Output file " << exportName << " would overwrite input file." 00098 << exit(FatalError); 00099 } 00100 00101 Info<< "Reading : " << importName << endl; 00102 triSurface surf(importName); 00103 00104 Info<< "Read surface:" << endl; 00105 surf.writeStats(Info); 00106 Info<< endl; 00107 00108 if (args.optionFound("clean")) 00109 { 00110 Info<< "Cleaning up surface" << endl; 00111 surf.cleanup(true); 00112 00113 Info<< "After cleaning up surface:" << endl; 00114 surf.writeStats(Info); 00115 Info<< endl; 00116 } 00117 00118 bool sortByRegion = args.optionFound("group"); 00119 00120 if (sortByRegion) 00121 { 00122 Info<< "Reordering faces into groups; one per region." << endl; 00123 } 00124 else 00125 { 00126 Info<< "Maintaining face ordering" << endl; 00127 } 00128 00129 Info<< "writing " << exportName; 00130 00131 scalar scaleFactor = 0; 00132 if (args.optionReadIfPresent("scale", scaleFactor) && scaleFactor > 0) 00133 { 00134 Info<< " with scaling " << scaleFactor; 00135 surf.scalePoints(scaleFactor); 00136 } 00137 Info<< endl; 00138 00139 surf.write(exportName, sortByRegion); 00140 00141 Info<< "\nEnd\n" << endl; 00142 00143 return 0; 00144 } 00145 00146 // ************************ vim: set sw=4 sts=4 et: ************************ //