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

writeOFF.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 <triSurface/triSurface.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032 
00033 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00034 
00035 void triSurface::writeOFF(const bool writeSorted, Ostream& os) const
00036 {
00037     // Write header
00038     os  << "OFF" << endl
00039         << "# Geomview OFF file" << endl
00040         << "# Regions:" << endl;
00041 
00042     labelList faceMap;
00043     surfacePatchList myPatches(calcPatches(faceMap));
00044 
00045     // Print patch names as comment
00046     forAll(myPatches, patchI)
00047     {
00048         os  << "#     " << patchI << "    "
00049             << myPatches[patchI].name() << endl;
00050     }
00051     os << endl << endl;
00052 
00053     const pointField& ps = points();
00054 
00055     os  << "# nPoints  nTriangles  nEdges" << endl
00056         << ps.size()
00057         << ' ' << size()
00058         << ' ' << nEdges()
00059         << endl << endl;
00060 
00061     // Write vertex coords
00062     forAll(ps, pointi)
00063     {
00064         os  << ps[pointi].x() << ' '
00065             << ps[pointi].y() << ' '
00066             << ps[pointi].z() << " #" << pointi << endl;
00067     }
00068 
00069     os << endl;
00070 
00071     if (writeSorted)
00072     {
00073         label faceIndex = 0;
00074 
00075         forAll(myPatches, patchI)
00076         {
00077             // Print all faces belonging to this patch
00078 
00079             for
00080             (
00081                 label patchFaceI = 0;
00082                 patchFaceI < myPatches[patchI].size();
00083                 patchFaceI++
00084             )
00085             {
00086                 const label faceI = faceMap[faceIndex++];
00087 
00088                 os  << "3 "
00089                     << operator[](faceI)[0] << ' '
00090                     << operator[](faceI)[1] << ' '
00091                     << operator[](faceI)[2] << ' '
00092                     << operator[](faceI).region()
00093                     << endl;
00094             }
00095         }
00096     }
00097     else
00098     {
00099         forAll(*this, faceI)
00100         {
00101             os  << "3 "
00102                 << operator[](faceI)[0] << ' '
00103                 << operator[](faceI)[1] << ' '
00104                 << operator[](faceI)[2] << ' '
00105                 << operator[](faceI).region()
00106                 << endl;
00107         }
00108     }
00109 }
00110 
00111 
00112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00113 
00114 } // End namespace Foam
00115 
00116 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines