FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "VTKsurfaceFormatCore.H"
00027 #include <OpenFOAM/clock.H>
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
00032 (
00033     Ostream& os,
00034     const pointField& pointLst
00035 )
00036 {
00037     // Write header
00038     os  << "# vtk DataFile Version 2.0" << nl
00039         << "surface written " << clock::dateTime().c_str() << nl
00040         << "ASCII" << nl
00041         << nl
00042         << "DATASET POLYDATA" << nl;
00043 
00044     // Write vertex coords
00045     os  << "POINTS " << pointLst.size() << " float" << nl;
00046     forAll(pointLst, ptI)
00047     {
00048         const point& pt = pointLst[ptI];
00049 
00050         os  << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
00051     }
00052 }
00053 
00054 
00055 void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
00056 (
00057     Ostream& os,
00058     const UList<surfZone>& zoneLst
00059 )
00060 {
00061     label nFaces = 0;
00062     forAll(zoneLst, zoneI)
00063     {
00064         nFaces += zoneLst[zoneI].size();
00065     }
00066 
00067     // Print zone numbers
00068     os  << nl
00069         << "CELL_DATA " << nFaces << nl
00070         << "FIELD attributes 1" << nl
00071         << "zone 1 " << nFaces << " float" << nl;
00072 
00073 
00074     forAll(zoneLst, zoneI)
00075     {
00076         forAll(zoneLst[zoneI], localFaceI)
00077         {
00078             if (localFaceI)
00079             {
00080                 if (localFaceI % 20)
00081                 {
00082                     os << ' ';
00083                 }
00084                 else
00085                 {
00086                     os << nl;
00087                 }
00088             }
00089             os  << zoneI + 1;
00090         }
00091         os  << nl;
00092     }
00093 }
00094 
00095 
00096 void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
00097 (
00098     Ostream& os,
00099     const UList<label>& zoneIds
00100 )
00101 {
00102     // Print zone numbers
00103     os  << nl
00104         << "CELL_DATA " << zoneIds.size() << nl
00105         << "FIELD attributes 1" << nl
00106         << "zone 1 " << zoneIds.size() << " float" << nl;
00107 
00108     forAll(zoneIds, faceI)
00109     {
00110         if (faceI)
00111         {
00112             if (faceI % 20)
00113             {
00114                 os << ' ';
00115             }
00116             else
00117             {
00118                 os << nl;
00119             }
00120         }
00121         os  << zoneIds[faceI] + 1;
00122     }
00123     os  << nl;
00124 }
00125 
00126 
00127 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines