OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

VTKsurfaceFormatCore.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "VTKsurfaceFormatCore.H"
00028 #include "clock.H"
00029 
00030 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00031 
00032 void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
00033 (
00034     Ostream& os,
00035     const pointField& pointLst
00036 )
00037 {
00038     // Write header
00039     os  << "# vtk DataFile Version 2.0" << nl
00040         << "surface written " << clock::dateTime().c_str() << nl
00041         << "ASCII" << nl
00042         << nl
00043         << "DATASET POLYDATA" << nl;
00044 
00045     // Write vertex coords
00046     os  << "POINTS " << pointLst.size() << " float" << nl;
00047     forAll(pointLst, ptI)
00048     {
00049         const point& pt = pointLst[ptI];
00050 
00051         os  << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
00052     }
00053 }
00054 
00055 
00056 void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
00057 (
00058     Ostream& os,
00059     const UList<surfZone>& zoneLst
00060 )
00061 {
00062     label nFaces = 0;
00063     forAll(zoneLst, zoneI)
00064     {
00065         nFaces += zoneLst[zoneI].size();
00066     }
00067 
00068     // Print zone numbers
00069     os  << nl
00070         << "CELL_DATA " << nFaces << nl
00071         << "FIELD attributes 1" << nl
00072         << "zone 1 " << nFaces << " float" << nl;
00073 
00074 
00075     forAll(zoneLst, zoneI)
00076     {
00077         forAll(zoneLst[zoneI], localFaceI)
00078         {
00079             if (localFaceI)
00080             {
00081                 if (localFaceI % 20)
00082                 {
00083                     os << ' ';
00084                 }
00085                 else
00086                 {
00087                     os << nl;
00088                 }
00089             }
00090             os  << zoneI + 1;
00091         }
00092         os  << nl;
00093     }
00094 }
00095 
00096 
00097 void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
00098 (
00099     Ostream& os,
00100     const UList<label>& zoneIds
00101 )
00102 {
00103     // Print zone numbers
00104     os  << nl
00105         << "CELL_DATA " << zoneIds.size() << nl
00106         << "FIELD attributes 1" << nl
00107         << "zone 1 " << zoneIds.size() << " float" << nl;
00108 
00109     forAll(zoneIds, faceI)
00110     {
00111         if (faceI)
00112         {
00113             if (faceI % 20)
00114             {
00115                 os << ' ';
00116             }
00117             else
00118             {
00119                 os << nl;
00120             }
00121         }
00122         os  << zoneIds[faceI] + 1;
00123     }
00124     os  << nl;
00125 }
00126 
00127 
00128 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd