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

labelledTriI.H

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 Description
00025 
00026 \*---------------------------------------------------------------------------*/
00027 
00028 #include <OpenFOAM/IOstreams.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 //- Construct null
00038 inline labelledTri::labelledTri()
00039 :
00040     region_(-1)
00041 {}
00042 
00043 
00044 //- Construct from components
00045 inline labelledTri::labelledTri
00046 (
00047     const label A,
00048     const label B,
00049     const label C,
00050     const label region
00051 )
00052 :
00053     triFace(A, B, C),
00054     region_(region)
00055 {}
00056 
00057 
00058 inline labelledTri::labelledTri(Istream& is)
00059 {
00060     operator>>(is, *this);
00061 }
00062 
00063 
00064 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00065 
00066 inline label labelledTri::region() const
00067 {
00068     return region_;
00069 }
00070 
00071 inline label& labelledTri::region()
00072 {
00073     return region_;
00074 }
00075 
00076 
00077 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
00078 
00079 inline Istream& operator>>(Istream& is, labelledTri& t)
00080 {
00081     if (is.format() == IOstream::ASCII)
00082     {
00083         // Read beginning of labelledTri point pair
00084         is.readBegin("labelledTri");
00085 
00086         is  >> static_cast<triFace&>(t) >> t.region_;
00087 
00088         // Read end of labelledTri point pair
00089         is.readEnd("labelledTri");
00090     }
00091     else
00092     {
00093         is.read(reinterpret_cast<char*>(&t), sizeof(labelledTri));
00094     }
00095 
00096     // Check state of Ostream
00097     is.check("Istream& operator>>(Istream&, labelledTri&)");
00098 
00099     return is;
00100 }
00101 
00102 
00103 inline Ostream& operator<<(Ostream& os, const labelledTri& t)
00104 {
00105     if (os.format() == IOstream::ASCII)
00106     {
00107         os  << token::BEGIN_LIST
00108             << static_cast<const triFace&>(t) << token::SPACE << t.region_
00109             << token::END_LIST;
00110     }
00111     else
00112     {
00113         os.write
00114         (
00115             reinterpret_cast<const char*>(&t),
00116             sizeof(labelledTri)
00117         );
00118     }
00119 
00120     // Check state of Ostream
00121     os.check("Ostream& operator<<(Ostream&, const labelledTri&)");
00122 
00123 
00124     return os;
00125 }
00126 
00127 
00128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00129 
00130 } // End namespace Foam
00131 
00132 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines