FreeFOAM The Cross-Platform CFD Toolkit
surfaceOrient.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  surfaceOrient
26 
27 Description
28  Set normal consistent with respect to a user provided 'outside' point.
29 
30  If -inside the point is considered inside.
31 
32 Usage
33 
34  - surfaceOrient [OPTIONS] <Foam surface file> <visiblePoint> <output file>
35 
36  @param <Foam surface file> \n
37  @todo Detailed description of argument.
38 
39  @param <visiblePoint> \n
40  @todo Detailed description of argument.
41 
42  @param <output file> \n
43  @todo Detailed description of argument.
44 
45  @param -inside \n
46  The point is inside instead of outside.
47 
48  @param -case <dir>\n
49  Case directory.
50 
51  @param -help \n
52  Display help message.
53 
54  @param -doc \n
55  Display Doxygen API documentation page for this application.
56 
57  @param -srcDoc \n
58  Display Doxygen source documentation page for this application.
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #include <OpenFOAM/argList.H>
64 
65 using namespace Foam;
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 
70 // Main program:
71 
72 int main(int argc, char *argv[])
73 {
76  argList::validArgs.append("Foam surface file");
77  argList::validArgs.append("visiblePoint");
78  argList::validArgs.append("output file");
79  argList::validOptions.insert("inside", "");
80  argList args(argc, argv);
81 
82  fileName surfFileName(args.additionalArgs()[0]);
83  Info<< "Reading surface from " << surfFileName << endl;
84 
85  point visiblePoint(IStringStream(args.additionalArgs()[1])());
86  Info<< "Visible point " << visiblePoint << endl;
87 
88  bool orientInside = args.optionFound("inside");
89 
90  if (orientInside)
91  {
92  Info<< "Orienting surface such that visiblePoint " << visiblePoint
93  << " is inside" << endl;
94  }
95  else
96  {
97  Info<< "Orienting surface such that visiblePoint " << visiblePoint
98  << " is outside" << endl;
99  }
100 
101  fileName outFileName(args.additionalArgs()[2]);
102  Info<< "Writing surface to " << outFileName << endl;
103 
104 
105  // Load surface
106  triSurface surf(surfFileName);
107 
108  //orientedSurface normalSurf(surf, visiblePoint, !orientInside);
109  bool anyFlipped = orientedSurface::orient
110  (
111  surf,
112  visiblePoint,
113  !orientInside
114  );
115 
116  if (anyFlipped)
117  {
118  Info<< "Flipped orientation of (part of) surface." << endl;
119  }
120  else
121  {
122  Info<< "Did not flip orientation of any triangle of surface." << endl;
123  }
124 
125  Info<< "Writing new surface to " << outFileName << endl;
126 
127  surf.write(outFileName);
128 
129  Info << "End\n" << endl;
130 
131  return 0;
132 }
133 
134 
135 // ************************ vim: set sw=4 sts=4 et: ************************ //