From 99efe5f8d89667e0862095ba969c6b5af21159aa Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Tue, 6 Sep 2016 14:57:40 +0200 Subject: [PATCH] BUG: triSurface IO operators are asymmetrical (fixed #225) - Also reported as http://bugs.openfoam.org/view.php?id=2188 --- .../surfaceMeshConvertTesting.C | 12 ++++++++++-- src/triSurface/triSurface/triSurface.C | 9 +++++++++ src/triSurface/triSurface/triSurface.H | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C index d2b887c3e87..1debd6ddc56 100644 --- a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C +++ b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C @@ -97,7 +97,11 @@ int main(int argc, char *argv[]) "surfMesh", "test surfMesh output" ); - argList::addBoolOption("triSurface"); + argList::addBoolOption + ( + "triSurface", + "use triSurface for read/write" + ); argList::addBoolOption ( "unsorted", @@ -164,10 +168,14 @@ int main(int argc, char *argv[]) os << surf; IStringStream is(os.str()); + // both work: triSurface surf2(is); + // OR // is.rewind(); - // is >> surf2; // FAIL: uses List<labelledTri> base class + // triSurface surf2; + // is >> surf2; + // surf2.read(is); // FAIL: private method } diff --git a/src/triSurface/triSurface/triSurface.C b/src/triSurface/triSurface/triSurface.C index 7946ae338ff..5e5bf1feba9 100644 --- a/src/triSurface/triSurface/triSurface.C +++ b/src/triSurface/triSurface/triSurface.C @@ -1108,6 +1108,15 @@ void Foam::triSurface::operator=(const triSurface& ts) // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // +Foam::Istream& Foam::operator>>(Istream& is, triSurface& sm) +{ + sm.clearOut(); + sm.read(is); + sm.setDefaultPatches(); + return is; +} + + Foam::Ostream& Foam::operator<<(Ostream& os, const triSurface& sm) { sm.write(os); diff --git a/src/triSurface/triSurface/triSurface.H b/src/triSurface/triSurface/triSurface.H index 1d8629f3606..527ab181d10 100644 --- a/src/triSurface/triSurface/triSurface.H +++ b/src/triSurface/triSurface/triSurface.H @@ -409,8 +409,9 @@ public: void operator=(const triSurface&); - // Ostream Operator + // IOstream Operators + friend Istream& operator>>(Istream&, triSurface&); friend Ostream& operator<<(Ostream&, const triSurface&); }; -- GitLab