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

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