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 "WRLsurfaceFormat.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::fileFormats::WRLsurfaceFormat<Face>::WRLsurfaceFormat()
39 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 void Foam::fileFormats::WRLsurfaceFormat<Face>::write
44 const fileName& filename,
45 const MeshedSurfaceProxy<Face>& surf
48 const pointField& pointLst = surf.points();
49 const List<Face>& faceLst = surf.faces();
50 const List<label>& faceMap = surf.faceMap();
52 // for no zones, suppress the group name
53 const List<surfZone>& zones =
55 surf.surfZones().empty()
56 ? surfaceFormatsCore::oneZone(faceLst, "")
60 const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
62 OFstream os(filename);
67 "fileFormats::WRLsurfaceFormat::write"
68 "(const fileName&, const MeshedSurfaceProxy<Face>&)"
70 << "Cannot open file for writing " << filename
74 writeHeader(os, pointLst, faceLst.size(), zones);
84 " geometry IndexedFaceSet {\n"
85 " coord Coordinate {\n"
88 // Write vertex coords
91 const point& pt = pointLst[ptI];
93 os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
98 " }\n" // end coord Coordinate
104 const surfZone& zone = zones[zoneI];
108 forAll(zone, localFaceI)
110 const Face& f = faceLst[faceMap[faceIndex++]];
121 forAll(zone, localFaceI)
123 const Face& f = faceLst[faceIndex++];
135 " ]\n" // end coordIndex
136 " }\n" // end geometry IndexedFaceSet
138 " ]\n" // end children
143 // ************************************************************************* //