/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see .
\*---------------------------------------------------------------------------*/
#include "writeFuns.H"
#include "vtkTopo.H"
#if defined(__mips) && !defined(__SICORTEX__)
#include
#include
#endif
// MacOSX
#ifdef __DARWIN_BYTE_ORDER
#if __DARWIN_BYTE_ORDER==__DARWIN_BIG_ENDIAN
#undef LITTLE_ENDIAN
#else
#undef BIG_ENDIAN
#endif
#endif
#if defined(LITTLE_ENDIAN) \
|| defined(_LITTLE_ENDIAN) \
|| defined(__LITTLE_ENDIAN)
# define LITTLEENDIAN 1
#elif defined(BIG_ENDIAN) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN)
# undef LITTLEENDIAN
#else
# error "Cannot find LITTLE_ENDIAN or BIG_ENDIAN symbol defined."
# error "Please add to compilation options"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::writeFuns::swapWord(label& word32)
{
char* mem = reinterpret_cast(&word32);
char a = mem[0];
mem[0] = mem[3];
mem[3] = a;
a = mem[1];
mem[1] = mem[2];
mem[2] = a;
}
void Foam::writeFuns::swapWords(const label nWords, label* words32)
{
for (label i = 0; i < nWords; i++)
{
swapWord(words32[i]);
}
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
List& fField
)
{
if (binary)
{
# ifdef LITTLEENDIAN
swapWords(fField.size(), reinterpret_cast