1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "VTKsurfaceFormat.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHeaderPolygons
35 const UList<Face>& faceLst
40 forAll(faceLst, faceI)
42 nNodes += faceLst[faceI].size();
46 << "POLYGONS " << faceLst.size() << ' '
47 << faceLst.size() + nNodes << nl;
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 Foam::fileFormats::VTKsurfaceFormat<Face>::VTKsurfaceFormat()
58 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61 void Foam::fileFormats::VTKsurfaceFormat<Face>::write
63 const fileName& filename,
64 const MeshedSurfaceProxy<Face>& surf
67 const pointField& pointLst = surf.points();
68 const List<Face>& faceLst = surf.faces();
69 const List<label>& faceMap = surf.faceMap();
71 const List<surfZone>& zones =
73 surf.surfZones().size() > 1
78 const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
80 OFstream os(filename);
85 "fileFormats::VTKsurfaceFormat::write"
86 "(const fileName&, const MeshedSurfaceProxy<Face>&)"
88 << "Cannot open file for writing " << filename
93 writeHeader(os, pointLst);
94 writeHeaderPolygons(os, faceLst);
99 const surfZone& zone = zones[zoneI];
103 forAll(zone, localFaceI)
105 const Face& f = faceLst[faceMap[faceIndex++]];
117 forAll(zone, localFaceI)
119 const Face& f = faceLst[faceIndex++];
131 writeTail(os, zones);
136 void Foam::fileFormats::VTKsurfaceFormat<Face>::write
138 const fileName& filename,
139 const UnsortedMeshedSurface<Face>& surf
142 OFstream os(filename);
147 "fileFormats::VTKsurfaceFormat::write"
148 "(const fileName&, const UnsortedMeshedSurface<Face>&)"
150 << "Cannot open file for writing " << filename
155 const List<Face>& faceLst = surf.faces();
157 writeHeader(os, surf.points());
158 writeHeaderPolygons(os, faceLst);
160 forAll(faceLst, faceI)
162 const Face& f = faceLst[faceI];
172 writeTail(os, surf.zoneIds());
176 // ************************************************************************* //