Moving cfMesh into place. Updated contibutors list
[foam-extend-3.2.git] / applications / utilities / mesh / cfMesh / surfaceFeatureEdges / surfaceFeatureEdges.C
blobd05cd58741d37aeb30cf8c3b371aa7a95b9fc755
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | cfMesh: A library for mesh generation
4    \\    /   O peration     |
5     \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6      \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9     This file is part of cfMesh.
11     cfMesh is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 3 of the License, or (at your
14     option) any later version.
16     cfMesh is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with cfMesh.  If not, see <http://www.gnu.org/licenses/>.
24 Description
25     Finds feature edges and corners of a triangulated surface
27 \*---------------------------------------------------------------------------*/
29 #include "argList.H"
30 #include "IFstream.H"
31 #include "fileName.H"
32 #include "triSurf.H"
33 #include "OFstream.H"
34 #include "OSspecific.H"
35 #include "demandDrivenData.H"
36 #include <cstdlib>
37 #include <sstream>
39 #include "triSurfaceDetectFeatureEdges.H"
40 #include "triSurfacePatchManipulator.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // Main program:
44 using namespace Foam;
46 int main(int argc, char *argv[])
48     argList::noParallel();
49     argList::validArgs.clear();
50     argList::validArgs.append("input surface file");
51     argList::validArgs.append("output surface file");
52     argList::validOptions.insert("angle", "scalar");
53     argList args(argc, argv);
55     fileName inFileName(args.args()[1]);
56     fileName outFileName(args.args()[2]);
58     if (outFileName == inFileName)
59     {
60         FatalErrorIn(args.executable())
61             << "Output file " << outFileName
62             << " would overwrite the input file."
63             << exit(FatalError);
64     }
66     scalar tol(45.0);
67     if( args.options().found("angle") )
68     {
69         const scalar ang = readScalar(IStringStream(args.options()["angle"])());
70         tol = ang;
71     }
72     else
73     {
74         Info << "Using 45 deg as default angle!" << endl;
75     }
77     triSurf originalSurface(inFileName);
79     triSurfaceDetectFeatureEdges edgeDetector(originalSurface, tol);
80     edgeDetector.detectFeatureEdges();
82     if( outFileName.ext() == "fms" || outFileName.ext() == "FMS" )
83     {
84         Info << "Writing : " << outFileName << endl;
85         originalSurface.writeSurface(outFileName);
86     }
87     else
88     {
89         triSurfacePatchManipulator manipulator(originalSurface);
90         const triSurf* newSurfPtr = manipulator.surfaceWithPatches();
92         Info << "Writing : " << outFileName << endl;
93         newSurfPtr->writeSurface(outFileName);
95         deleteDemandDrivenData(newSurfPtr);
96     }
98     Info << "End\n" << endl;
100     return 0;
104 // ************************************************************************* //