surfaceTransformPoints.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
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  surfaceTransformPoints
26 
27 Description
28  Transform (translate, rotate, scale) a surface.
29 
30 Usage
31  \b surfaceTransformPoints "<transformations>" <input> <output>
32  Supported transformations:
33  - \par translate=<translation vector>
34  Translational transformation by given vector
35  - \par rotate=(<n1 vector> <n2 vector>)
36  Rotational transformation from unit vector n1 to n2
37  - \par Rx=<angle [deg] about x-axis>
38  Rotational transformation by given angle about x-axis
39  - \par Ry=<angle [deg] about y-axis>
40  Rotational transformation by given angle about y-axis
41  - \par Rz=<angle [deg] about z-axis>
42  Rotational transformation by given angle about z-axis
43  - \par Ra=<axis vector> <angle [deg] about axis>
44  Rotational transformation by given angle about given axis
45  - \par scale=<x-y-z scaling vector>
46  Anisotropic scaling by the given vector in the x, y, z
47  coordinate directions
48 
49  Example usage:
50  surfaceTransformPoints \
51  "translate=(-0.586 0 -0.156), \
52  Ry=3.485, \
53  translate=(0.586 0 0.156)" \
54  constant/geometry/w3_orig.stl constant/geometry/w3.stl
55 
56 See also
57  Foam::transformer
58  transformPoints
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #include "argList.H"
63 #include "unitConversion.H"
64 #include "MeshedSurfaces.H"
65 
66 using namespace Foam;
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 int main(int argc, char *argv[])
71 {
72  #include "removeCaseOptions.H"
73 
74  const wordList supportedTransformations
75  (
76  {"translate", "rotate", "Rx", "Ry", "Rz", "Ra", "scale"}
77  );
78 
79  {
80  OStringStream supportedTransformationsStr;
81  supportedTransformationsStr << supportedTransformations << endl;
82 
84  (
85  "Transforms a surface e.g.\n"
86  "surfaceTransformPoints "
87  "\"translate=(-0.586 0 -0.156), "
88  "Ry=3.485, "
89  "translate=(0.586 0 0.156)\" "
90  "surf.stl tranformedSurf.obj\n\n"
91  "Supported transformations " + supportedTransformationsStr.str()
92  );
93  }
94 
96  argList::validArgs.append("transformations");
97  argList::validArgs.append("surface file");
98  argList::validArgs.append("output surface file");
99 
100  argList args(argc, argv);
101 
102  const string transformationString(args[1]);
103  const fileName surfFileName(args[2]);
104  const fileName outFileName(args[3]);
105 
106  #include "createTransforms.H"
107 
108  Info<< "Reading surf from " << surfFileName << " ..." << nl
109  << "Writing surf to " << outFileName << " ..." << endl;
110 
111  meshedSurface surf1(surfFileName);
112  pointField points(surf1.points());
114  surf1.movePoints(points);
115  surf1.write(outFileName);
116 
117  Info<< "End\n" << endl;
118 
119  return 0;
120 }
121 
122 
123 // ************************************************************************* //
transformer transforms
A class for handling file names.
Definition: fileName.H:79
Unit conversion functions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
static void noParallel()
Remove the parallel options.
Definition: argList.C:175
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:153
const pointField & points
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:102
static const char nl
Definition: Ostream.H:260
string str() const
Return the string.
messageStream Info
vector transformPosition(const vector &v) const
Transform the given position.
Definition: transformerI.H:153
static void addNote(const string &)
Add extra notes for the usage information.
Definition: argList.C:159
Foam::argList args(argc, argv)
Output to memory buffer stream.
Definition: OStringStream.H:49
Namespace for OpenFOAM.