/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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.
OpenFOAM 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 OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "OFSsurfaceFormat.H"
#include "IFstream.H"
#include "IStringStream.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::fileFormats::OFSsurfaceFormat::OFSsurfaceFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
bool Foam::fileFormats::OFSsurfaceFormat::read
(
const fileName& filename
)
{
this->clear();
IFstream is(filename);
if (!is.good())
{
FatalErrorInFunction
<< "Cannot read file " << filename
<< exit(FatalError);
}
// read surfZones:
is >> this->storedZones();
// read points:
is >> this->storedPoints();
// must triangulate?
if (MeshedSurface::isTri())
{
// read faces as 'face' and transcribe to 'triFace'
List faceLst(is);
MeshedSurface surf
(
move(this->storedPoints()),
move(faceLst),
move(this->storedZones())
);
this->transcribe(surf);
}
else
{
// read faces directly
is >> this->storedFaces();
}
return true;
}
template
bool Foam::fileFormats::OFSsurfaceFormat::read
(
Istream& is,
pointField& pointLst,
List& faceLst,
List& zoneLst
)
{
if (!is.good())
{
FatalErrorInFunction
<< "read error "
<< exit(FatalError);
}
// read surfZones:
is >> zoneLst;
// read points:
is >> pointLst;
// must triangulate?
if (MeshedSurface::isTri())
{
// read faces as 'face' and transcribe to 'triFace'
List origFaces(is);
MeshedSurface origSurf
(
move(pointLst),
move(origFaces),
move(zoneLst)
);
MeshedSurface surf;
surf.transcribe(origSurf);
}
else
{
// read faces directly
is >> faceLst;
}
return true;
}
template
bool Foam::fileFormats::OFSsurfaceFormat::read
(
Istream& is,
MeshedSurface& surf
)
{
surf.clear();
if (!is.good())
{
FatalErrorInFunction
<< "read error "
<< exit(FatalError);
}
pointField pointLst;
List faceLst;
List zoneLst;
read(is, pointLst, faceLst, zoneLst);
surf.reset
(
move(pointLst),
move(faceLst),
move(zoneLst)
);
return true;
}
template
bool Foam::fileFormats::OFSsurfaceFormat::read
(
Istream& is,
UnsortedMeshedSurface& surf
)
{
surf.clear();
MeshedSurface origSurf(is);
surf.transfer(origSurf);
return true;
}
template
void Foam::fileFormats::OFSsurfaceFormat::write
(
const fileName& filename,
const MeshedSurfaceProxy& surf
)
{
const List& faceLst = surf.faces();
const List