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

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-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 Description
00026     Set normal consistent with respect to a user provided 'outside' point.
00027     If -inside the point is considered inside.
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 #include "argList.H"
00032 #include "orientedSurface.H"
00033 
00034 using namespace Foam;
00035 
00036 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00037 
00038 
00039 // Main program:
00040 
00041 int main(int argc, char *argv[])
00042 {
00043     argList::noParallel();
00044     argList::validArgs.clear();
00045     argList::validArgs.append("Foam surface file");
00046     argList::validArgs.append("visiblePoint");
00047     argList::validArgs.append("output file");
00048     argList::validOptions.insert("inside", "");
00049     argList args(argc, argv);
00050 
00051     fileName surfFileName(args.additionalArgs()[0]);
00052     Info<< "Reading surface from " << surfFileName << endl;
00053 
00054     point visiblePoint(IStringStream(args.additionalArgs()[1])());
00055     Info<< "Visible point " << visiblePoint << endl;
00056 
00057     bool orientInside = args.optionFound("inside");
00058 
00059     if (orientInside)
00060     {
00061         Info<< "Orienting surface such that visiblePoint " << visiblePoint
00062             << " is inside" << endl;
00063     }
00064     else
00065     {
00066         Info<< "Orienting surface such that visiblePoint " << visiblePoint
00067             << " is outside" << endl;
00068     }
00069 
00070     fileName outFileName(args.additionalArgs()[2]);
00071     Info<< "Writing surface to " << outFileName << endl;
00072 
00073 
00074     // Load surface
00075     triSurface surf(surfFileName);
00076 
00077     //orientedSurface normalSurf(surf, visiblePoint, !orientInside);
00078     bool anyFlipped = orientedSurface::orient
00079     (
00080         surf,
00081         visiblePoint,
00082        !orientInside
00083     );
00084 
00085     if (anyFlipped)
00086     {
00087         Info<< "Flipped orientation of (part of) surface." << endl;
00088     }
00089     else
00090     {
00091         Info<< "Did not flip orientation of any triangle of surface." << endl;
00092     }
00093 
00094     Info<< "Writing new surface to " << outFileName << endl;
00095 
00096     surf.write(outFileName);
00097 
00098     Info << "End\n" << endl;
00099 
00100     return 0;
00101 }
00102 
00103 
00104 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd