1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "VTKsurfaceFormat.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHeaderPolygons
34 const UList<Face>& faceLst
39 forAll(faceLst, faceI)
41 nNodes += faceLst[faceI].size();
45 << "POLYGONS " << faceLst.size() << ' '
46 << faceLst.size() + nNodes << nl;
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 Foam::fileFormats::VTKsurfaceFormat<Face>::VTKsurfaceFormat()
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 void Foam::fileFormats::VTKsurfaceFormat<Face>::write
62 const fileName& filename,
63 const MeshedSurfaceProxy<Face>& surf
66 const pointField& pointLst = surf.points();
67 const List<Face>& faceLst = surf.faces();
68 const List<label>& faceMap = surf.faceMap();
70 const List<surfZone>& zones =
72 surf.surfZones().empty()
73 ? surfaceFormatsCore::oneZone(faceLst)
77 const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
79 OFstream os(filename);
84 "fileFormats::VTKsurfaceFormat::write"
85 "(const fileName&, const MeshedSurfaceProxy<Face>&)"
87 << "Cannot open file for writing " << filename
92 writeHeader(os, pointLst);
93 writeHeaderPolygons(os, faceLst);
98 const surfZone& zone = zones[zoneI];
102 forAll(zone, localFaceI)
104 const Face& f = faceLst[faceMap[faceIndex++]];
116 forAll(zone, localFaceI)
118 const Face& f = faceLst[faceIndex++];
130 writeTail(os, zones);
135 void Foam::fileFormats::VTKsurfaceFormat<Face>::write
137 const fileName& filename,
138 const UnsortedMeshedSurface<Face>& surf
141 OFstream os(filename);
146 "fileFormats::VTKsurfaceFormat::write"
147 "(const fileName&, const UnsortedMeshedSurface<Face>&)"
149 << "Cannot open file for writing " << filename
154 const List<Face>& faceLst = surf.faces();
156 writeHeader(os, surf.points());
157 writeHeaderPolygons(os, faceLst);
159 forAll(faceLst, faceI)
161 const Face& f = faceLst[faceI];
171 writeTail(os, surf.zoneIds());
175 // ************************************************************************* //