importSurfaceAsSubset.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25  Finds feature edges and corners of a triangulated surface
26 
27 \*---------------------------------------------------------------------------*/
28 
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"
37 #include <cstdlib>
38 #include <sstream>
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 // Main program:
42 using namespace Foam;
43 
44 int main(int argc, char *argv[])
45 {
47  argList::validArgs.clear();
48  argList::validArgs.append("master surface file");
49  argList::validArgs.append("import surface file");
50 
51  argList args(argc, argv);
52 
53  fileName inFileName(args.args()[1]);
54  fileName importFileName(args.args()[2]);
55 
56  triSurf originalSurface(inFileName);
57 
58  triSurf importedSurface(importFileName);
59 
60  triSurfaceImportSurfaceAsSubset importSurf(originalSurface);
61 
62  importSurf.addSurfaceAsSubset(importedSurface, importFileName.lessExt());
63 
64  if( inFileName.ext() == "fms" )
65  {
66  originalSurface.writeSurface(inFileName);
67  }
68  else
69  {
70  fileName newName = inFileName.lessExt();
71  newName.append(".fms");
72  Warning << "Writting surface as " << newName
73  << " to preserve the subset!!" << endl;
74 
75  originalSurface.writeSurface(newName);
76  }
77 
78  Info << "End\n" << endl;
79 
80  return 0;
81 }
82 
83 
84 // ************************************************************************* //
Foam::argList::validArgs
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:143
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::triSurfaceImportSurfaceAsSubset
Definition: triSurfaceImportSurfaceAsSubset.H:52
triSurf.H
Foam::argList::args
const stringList & args() const
Return arguments.
Definition: argListI.H:66
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::Warning
messageStream Warning
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:97
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::fileName::lessExt
fileName lessExt() const
Return file name without extension (part before last .)
Definition: fileName.C:313
main
int main(int argc, char *argv[])
Definition: importSurfaceAsSubset.C:44
triSurfaceImportSurfaceAsSubset.H
OFstream.H
Foam::Info
messageStream Info
argList.H
fileName.H
Foam::triSurfaceImportSurfaceAsSubset::addSurfaceAsSubset
void addSurfaceAsSubset(const triSurf &importSurf, const word &subsetName, const scalar angleTol=5.*M_PI/180.)
Definition: triSurfaceImportSurfaceAsSubset.C:64
IFstream.H
Foam::fileName::ext
word ext() const
Return file name extension (part after last .)
Definition: fileName.C:329
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::triSurf::writeSurface
void writeSurface(const fileName &) const
Definition: triSurf.C:430
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:161
args
Foam::argList args(argc, argv)
Foam::triSurf
Definition: triSurf.H:59