ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / edgeMesh / edgeMeshIO.C
blob465a2a93cd8d06bf31d419646b5a2ad07bc8cf63
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "edgeMesh.H"
27 #include "boundBox.H"
28 #include "EMESHedgeFormat.H"
30 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
32 Foam::edgeMesh::edgeMesh
34     const fileName& name,
35     const word& ext
38     points_(0),
39     edges_(0),
40     pointEdgesPtr_(NULL)
42     read(name, ext);
46 Foam::edgeMesh::edgeMesh(const fileName& name)
48     points_(0),
49     edges_(0),
50     pointEdgesPtr_(NULL)
52     read(name);
56 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
58 bool Foam::edgeMesh::read(const fileName& name)
60     word ext = name.ext();
61     if (ext == "gz")
62     {
63         fileName unzipName = name.lessExt();
64         return read(unzipName, unzipName.ext());
65     }
66     else
67     {
68         return read(name, ext);
69     }
73 // Read from file in given format
74 bool Foam::edgeMesh::read
76     const fileName& name,
77     const word& ext
80     // read via selector mechanism
81     transfer(New(name, ext)());
82     return true;
86 void Foam::edgeMesh::write
88     const fileName& name,
89     const edgeMesh& mesh
92     if (debug)
93     {
94         Info<< "edgeMesh::write"
95             "(const fileName&, const edgeMesh&) : "
96             "writing to " << name
97             << endl;
98     }
100     const word ext = name.ext();
102     writefileExtensionMemberFunctionTable::iterator mfIter =
103         writefileExtensionMemberFunctionTablePtr_->find(ext);
105     if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
106     {
107         FatalErrorIn
108         (
109             "MeshedSurface::write"
110             "(const fileName&, const MeshedSurface&)"
111         )   << "Unknown file extension " << ext << nl << nl
112             << "Valid types are :" << endl
113             << writefileExtensionMemberFunctionTablePtr_->sortedToc()
114             << exit(FatalError);
115     }
116     else
117     {
118         mfIter()(name, mesh);
119     }
123 void Foam::edgeMesh::writeStats(Ostream& os) const
125     os  << "points      : " << points().size() << nl;
126     os  << "edges       : " << edges().size() << nl;
127     os  << "boundingBox : " << boundBox(this->points()) << endl;
131 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
133 Foam::Ostream& Foam::operator<<(Ostream& os, const edgeMesh& em)
135     fileFormats::EMESHedgeFormat::write(os, em.points_, em.edges_);
137     // Check state of Ostream
138     os.check("Ostream& operator<<(Ostream&, const edgeMesh&)");
140     return os;
144 Foam::Istream& Foam::operator>>(Istream& is, edgeMesh& em)
146     fileFormats::EMESHedgeFormat::read(is, em.points_, em.edges_);
148     em.pointEdgesPtr_.clear();
150     // Check state of Istream
151     is.check("Istream& operator>>(Istream&, edgeMesh&)");
153     return is;
157 // ************************************************************************* //