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

surfacePointMerge.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     Merges points on surface if they are within absolute distance.
00027     Since absolute distance use with care!
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 #include "triSurface.H"
00032 #include "triSurfaceTools.H"
00033 #include "argList.H"
00034 #include "OFstream.H"
00035 #include "boundBox.H"
00036 
00037 using namespace Foam;
00038 
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 // Main program:
00042 
00043 int main(int argc, char *argv[])
00044 {
00045     argList::noParallel();
00046     argList::validArgs.clear();
00047     argList::validArgs.append("surface file");
00048     argList::validArgs.append("merge distance");
00049     argList::validArgs.append("output file");
00050     argList args(argc, argv);
00051 
00052     fileName surfFileName(args.additionalArgs()[0]);
00053     scalar mergeTol(readScalar(IStringStream(args.additionalArgs()[1])()));
00054     fileName outFileName(args.additionalArgs()[2]);
00055 
00056     Info<< "Reading surface from " << surfFileName << " ..." << endl;
00057     Info<< "Merging points within " << mergeTol << " meter." << endl;
00058 
00059     triSurface surf1(surfFileName);
00060 
00061     Info<< "Original surface:" << endl;
00062 
00063     surf1.writeStats(Info);
00064 
00065 
00066     triSurface cleanSurf(surf1);
00067 
00068     while(true)
00069     {
00070         label nOldVert = cleanSurf.nPoints();
00071 
00072         cleanSurf = triSurfaceTools::mergePoints(cleanSurf, mergeTol);
00073 
00074         Info<< "After merging points:" << endl;
00075 
00076         cleanSurf.writeStats(Info);
00077 
00078         if (nOldVert == cleanSurf.nPoints())
00079         {
00080             break;
00081         }
00082     }
00083 
00084     cleanSurf.write(outFileName);
00085 
00086     Info << "End\n" << endl;
00087 
00088     return 0;
00089 }
00090 
00091 
00092 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd