1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Reads the AVL's surface mesh
27 \*---------------------------------------------------------------------------*/
30 #include "objectRegistry.H"
33 #include "triSurfModifier.H"
34 #include "triFaceList.H"
35 #include "labelLongList.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 int main(int argc, char *argv[])
44 argList::noParallel();
45 argList::validArgs.clear();
47 argList::validArgs.append("input surface file");
48 argList::validArgs.append("output surface file");
49 argList args(argc, argv);
51 fileName inFileName(args.args()[1]);
52 fileName outFileName(args.args()[2]);
54 if( inFileName.ext() != "flma" )
56 Info << "Cannot convert this mesh" << endl;
60 //- create the surface mesh
62 triSurfModifier tsm(ts);
66 IFstream inFile(inFileName);
71 pointField& points = tsm.pointsAccess();
72 points.setSize(counter);
73 forAll(points, pointI)
75 point& p = points[pointI];
84 geometricSurfacePatchList patches(1);
85 patches[0].name() = "patch";
86 LongList<labelledTri>& triangles = tsm.facetsAccess();
87 triangles.setSize(counter);
88 forAll(triangles, triI)
94 Info << "Facet " << triI << " is not a triangle!!" << endl;
95 Warning << "Cannot convert this surface!" << endl;
99 for(label j=0;j<3;++j)
100 inFile >> triangles[triI][2-j];
102 triangles[triI].region() = 0;
107 forAll(triangles, triI)
110 //- start reading selections
112 for(label selI=0;selI<counter;++selI)
114 //- read selection name
118 //- read selection type
122 //- read selection entries
125 labelLongList entries(size);
126 for(label i=0;i<size;++i)
127 inFile >> entries[i];
129 //- store cell selections
132 Info << "Adding subset " << selName << endl;
133 const label setID = ts.addFacetSubset(selName);
136 ts.addFacetToSubset(setID, entries[i]);
140 //- write the surface
141 ts.writeSurface(outFileName);
143 Info << "End\n" << endl;
147 // ************************************************************************* //