FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

surfaceOrient.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-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     surfaceOrient
00026 
00027 Description
00028     Set normal consistent with respect to a user provided 'outside' point.
00029 
00030     If -inside the point is considered inside.
00031 
00032 Usage
00033 
00034     - surfaceOrient [OPTIONS] <Foam surface file> <visiblePoint> <output file>
00035 
00036     @param <Foam surface file> \n
00037     @todo Detailed description of argument.
00038 
00039     @param <visiblePoint> \n
00040     @todo Detailed description of argument.
00041 
00042     @param <output file> \n
00043     @todo Detailed description of argument.
00044 
00045     @param -inside \n
00046     The point is inside instead of outside.
00047 
00048     @param -case <dir>\n
00049     Case directory.
00050 
00051     @param -help \n
00052     Display help message.
00053 
00054     @param -doc \n
00055     Display Doxygen API documentation page for this application.
00056 
00057     @param -srcDoc \n
00058     Display Doxygen source documentation page for this application.
00059 
00060 \*---------------------------------------------------------------------------*/
00061 
00062 #include <OpenFOAM/argList.H>
00063 #include <meshTools/orientedSurface.H>
00064 
00065 using namespace Foam;
00066 
00067 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00068 
00069 
00070 // Main program:
00071 
00072 int main(int argc, char *argv[])
00073 {
00074     argList::noParallel();
00075     argList::validArgs.clear();
00076     argList::validArgs.append("Foam surface file");
00077     argList::validArgs.append("visiblePoint");
00078     argList::validArgs.append("output file");
00079     argList::validOptions.insert("inside", "");
00080     argList args(argc, argv);
00081 
00082     fileName surfFileName(args.additionalArgs()[0]);
00083     Info<< "Reading surface from " << surfFileName << endl;
00084 
00085     point visiblePoint(IStringStream(args.additionalArgs()[1])());
00086     Info<< "Visible point " << visiblePoint << endl;
00087 
00088     bool orientInside = args.optionFound("inside");
00089 
00090     if (orientInside)
00091     {
00092         Info<< "Orienting surface such that visiblePoint " << visiblePoint
00093             << " is inside" << endl;
00094     }
00095     else
00096     {
00097         Info<< "Orienting surface such that visiblePoint " << visiblePoint
00098             << " is outside" << endl;
00099     }
00100 
00101     fileName outFileName(args.additionalArgs()[2]);
00102     Info<< "Writing surface to " << outFileName << endl;
00103 
00104 
00105     // Load surface
00106     triSurface surf(surfFileName);
00107 
00108     //orientedSurface normalSurf(surf, visiblePoint, !orientInside);
00109     bool anyFlipped = orientedSurface::orient
00110     (
00111         surf,
00112         visiblePoint,
00113        !orientInside
00114     );
00115 
00116     if (anyFlipped)
00117     {
00118         Info<< "Flipped orientation of (part of) surface." << endl;
00119     }
00120     else
00121     {
00122         Info<< "Did not flip orientation of any triangle of surface." << endl;
00123     }
00124 
00125     Info<< "Writing new surface to " << outFileName << endl;
00126 
00127     surf.write(outFileName);
00128 
00129     Info << "End\n" << endl;
00130 
00131     return 0;
00132 }
00133 
00134 
00135 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines