1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ensightFile.H"
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 bool Foam::ensightFile::allowUndef_ = false;
32 Foam::scalar Foam::ensightFile::undefValue_ = Foam::floatScalarVGREAT;
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 Foam::ensightFile::ensightFile
38 const fileName& pathname,
39 IOstream::streamFormat format
42 OFstream(pathname, ios_base::out|ios_base::trunc, format)
44 // ascii formatting specs
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 Foam::ensightFile::~ensightFile()
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 bool Foam::ensightFile::allowUndef()
68 bool Foam::ensightFile::allowUndef(bool value)
70 bool old = allowUndef_;
76 Foam::scalar Foam::ensightFile::undefValue(const scalar& value)
81 scalar old = undefValue_;
87 Foam::Ostream& Foam::ensightFile::write
93 stream().write(buf, count);
98 Foam::Ostream& Foam::ensightFile::write(const string& value)
102 for (string::size_type i = 0; i < 80; ++i)
107 string::size_type n = value.size();
113 for (string::size_type i = 0; i < n; ++i)
118 if (format() == IOstream::BINARY)
122 reinterpret_cast<char const *>(buf),
135 Foam::Ostream& Foam::ensightFile::write(const label& value)
137 if (format() == IOstream::BINARY)
139 unsigned int ivalue(value);
143 reinterpret_cast<char const *>(&ivalue),
157 Foam::Ostream& Foam::ensightFile::write
160 const label fieldWidth
163 if (format() == IOstream::BINARY)
165 unsigned int ivalue(value);
169 reinterpret_cast<char const *>(&ivalue),
175 stream().width(fieldWidth);
183 Foam::Ostream& Foam::ensightFile::write(const scalar& value)
185 if (format() == IOstream::BINARY)
191 reinterpret_cast<char const *>(&fvalue),
205 void Foam::ensightFile::newline()
207 if (format() == IOstream::ASCII)
214 Foam::Ostream& Foam::ensightFile::writeUndef()
221 Foam::Ostream& Foam::ensightFile::writeKeyword(const string& key)
225 write(key + " undef");
239 Foam::Ostream& Foam::ensightFile::writeBinaryHeader()
241 if (format() == IOstream::BINARY)
250 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
252 Foam::string Foam::ensightFile::mask()
254 char buf[16] = "********";
259 Foam::string Foam::ensightFile::subDir(const label n)
263 sprintf(buf, "%08d", n);
268 // ************************************************************************* //