OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

surfaceConvert.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     surfaceConvert
00027 
00028 Description
00029     Converts from one surface mesh format to another
00030 
00031 Usage
00032     - surfaceConvert inputFile outputFile [OPTION]
00033 
00034     @param -clean \n
00035     Perform some surface checking/cleanup on the input surface
00036 
00037     @param -scale <scale> \n
00038     Specify a scaling factor for writing the files
00039 
00040     @param -group \n
00041     Orders faces by region
00042 
00043 Note
00044     The filename extensions are used to determine the file format type.
00045 
00046 \*---------------------------------------------------------------------------*/
00047 
00048 #include "argList.H"
00049 #include "fileName.H"
00050 #include "triSurface.H"
00051 #include "OFstream.H"
00052 #include "OSspecific.H"
00053 
00054 using namespace Foam;
00055 
00056 
00057 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00058 // Main program:
00059 
00060 int main(int argc, char *argv[])
00061 {
00062     argList::noParallel();
00063     argList::validArgs.clear();
00064     argList::validArgs.append("inputFile");
00065     argList::validArgs.append("outputFile");
00066     argList::validOptions.insert("clean", "");
00067     argList::validOptions.insert("scale", "scale");
00068     argList::validOptions.insert("group", "");
00069 
00070     argList args(argc, argv);
00071     const stringList& params = args.additionalArgs();
00072 
00073     fileName importName(params[0]);
00074     fileName exportName(params[1]);
00075 
00076     if (importName == exportName)
00077     {
00078         FatalErrorIn(args.executable())
00079             << "Output file " << exportName << " would overwrite input file."
00080             << exit(FatalError);
00081     }
00082 
00083     Info<< "Reading : " << importName << endl;
00084     triSurface surf(importName);
00085 
00086     Info<< "Read surface:" << endl;
00087     surf.writeStats(Info);
00088     Info<< endl;
00089 
00090     if (args.optionFound("clean"))
00091     {
00092         Info<< "Cleaning up surface" << endl;
00093         surf.cleanup(true);
00094 
00095         Info<< "After cleaning up surface:" << endl;
00096         surf.writeStats(Info);
00097         Info<< endl;
00098     }
00099 
00100     bool sortByRegion = args.optionFound("group");
00101 
00102     if (sortByRegion)
00103     {
00104         Info<< "Reordering faces into groups; one per region." << endl;
00105     }
00106     else
00107     {
00108         Info<< "Maintaining face ordering" << endl;
00109     }
00110 
00111     Info<< "writing " << exportName;
00112 
00113     scalar scaleFactor = 0;
00114     if (args.optionReadIfPresent("scale", scaleFactor) && scaleFactor > 0)
00115     {
00116         Info<< " with scaling " << scaleFactor;
00117         surf.scalePoints(scaleFactor);
00118     }
00119     Info<< endl;
00120 
00121     surf.write(exportName, sortByRegion);
00122 
00123     Info<< "\nEnd\n" << endl;
00124 
00125     return 0;
00126 }
00127 
00128 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd