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/>.
26 \*---------------------------------------------------------------------------*/
28 #include "writeFaceSet.H"
30 #include "writeFuns.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
44 const fileName& fileName
47 const faceList& faces = vMesh.faces();
49 std::ofstream pStream(fileName.c_str());
52 << "# vtk DataFile Version 2.0" << std::endl
53 << set.name() << std::endl;
56 pStream << "BINARY" << std::endl;
60 pStream << "ASCII" << std::endl;
62 pStream << "DATASET POLYDATA" << std::endl;
65 //------------------------------------------------------------------
69 //------------------------------------------------------------------
72 // Construct primitivePatch of faces in faceSet.
74 faceList setFaces(set.size());
75 labelList setFaceLabels(set.size());
80 faceSet::const_iterator iter = set.begin();
85 setFaceLabels[setFaceI] = iter.key();
86 setFaces[setFaceI] = faces[iter.key()];
89 primitiveFacePatch fp(setFaces, vMesh.points());
92 // Write points and faces as polygons
94 pStream << "POINTS " << fp.nPoints() << " float" << std::endl;
96 DynamicList<floatScalar> ptField(3*fp.nPoints());
98 writeFuns::insert(fp.localPoints(), ptField);
100 writeFuns::write(pStream, binary, ptField);
103 label nFaceVerts = 0;
104 const faceList& lf = fp.localFaces();
108 nFaceVerts += lf[faceI].size() + 1;
110 pStream << "POLYGONS " << fp.size() << ' ' << nFaceVerts
113 DynamicList<label> vertLabels(nFaceVerts);
117 const face& f = lf[faceI];
119 vertLabels.append(f.size());
121 writeFuns::insert(f, vertLabels);
123 writeFuns::write(pStream, binary, vertLabels);
126 //-----------------------------------------------------------------
130 //-----------------------------------------------------------------
135 << "CELL_DATA " << fp.size() << std::endl
136 << "FIELD attributes 1" << std::endl;
139 pStream << "faceID 1 " << fp.size() << " int" << std::endl;
141 writeFuns::write(pStream, binary, setFaceLabels);
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 } // End namespace Foam
148 // ************************************************************************* //