From 9705520e246ebd9586c6e123dfb25d79eaea33f7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 5 Nov 2008 02:25:19 +0100 Subject: [PATCH] surfMesh changes - read 'ftr' triSurface format - added 'ofs' (OpenFOAM Surface) as new all-in-one surface format candidate - trying to get some sanity into the surface patch classes, but called it 'surfGroup' (for now) to avoid conflict with existing 'surfacePatch' - add read() member like Mattijs suggested --- src/surfMesh/Make/files | 5 + .../fileFormats/ac3d/AC3DfileFormat.C | 28 +-- .../fileFormats/ac3d/AC3DfileFormat.H | 2 +- .../fileFormats/ftr/FTRfileFormat.C | 110 +++++++++ .../fileFormats/ftr/FTRfileFormat.H | 131 +++++++++++ .../fileFormats/gts/GTSfileFormat.C | 6 +- .../fileFormats/nas/NASfileFormat.C | 13 +- .../fileFormats/obj/OBJfileFormat.C | 15 +- .../fileFormats/obj/OBJfileFormat.H | 2 +- .../fileFormats/off/OFFfileFormat.C | 19 +- .../fileFormats/off/OFFfileFormat.H | 2 +- .../fileFormats/smesh/SMESHfileFormat.C | 4 +- .../fileFormats/starcd/STARCDfileFormat.C | 13 +- .../fileFormats/stl/STLfileFormat.C | 20 +- .../fileFormats/tri/TRIfileFormat.C | 9 +- .../fileFormats/vtk/VTKfileFormat.C | 6 +- .../fileFormats/vtk/VTKfileFormat.H | 2 +- src/surfMesh/keyedSurface/keyedSurface.C | 216 ++++++++++------- src/surfMesh/keyedSurface/keyedSurface.H | 221 ++++++++++-------- src/surfMesh/meshedSurface/meshedSurface.C | 125 +++++----- src/surfMesh/meshedSurface/meshedSurface.H | 46 ++-- .../meshedSurface/meshedSurfaceCleanup.C | 24 +- src/surfMesh/surfGroup/surfGroup.C | 166 +++++++++++++ src/surfMesh/surfGroup/surfGroup.H | 187 +++++++++++++++ src/surfMesh/surfGroup/surfGroupIOList.C | 152 ++++++++++++ src/surfMesh/surfGroup/surfGroupIOList.H | 117 ++++++++++ src/surfMesh/surfGroup/surfGroupList.H | 55 +++++ .../surfPatchIdentifier/surfPatchIdentifier.C | 139 +++++++++++ .../surfPatchIdentifier/surfPatchIdentifier.H | 171 ++++++++++++++ .../surfPatchIdentifierList.H | 55 +++++ 30 files changed, 1728 insertions(+), 333 deletions(-) create mode 100644 src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C create mode 100644 src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.H create mode 100644 src/surfMesh/surfGroup/surfGroup.C create mode 100644 src/surfMesh/surfGroup/surfGroup.H create mode 100644 src/surfMesh/surfGroup/surfGroupIOList.C create mode 100644 src/surfMesh/surfGroup/surfGroupIOList.H create mode 100644 src/surfMesh/surfGroup/surfGroupList.H create mode 100644 src/surfMesh/surfPatchIdentifier/surfPatchIdentifier.C create mode 100644 src/surfMesh/surfPatchIdentifier/surfPatchIdentifier.H create mode 100644 src/surfMesh/surfPatchIdentifier/surfPatchIdentifierList.H diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index 2bf476cb72..def352062d 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -1,3 +1,7 @@ +surfGroup/surfGroup.C +surfGroup/surfGroupIOList.C +surfPatchIdentifier/surfPatchIdentifier.C + keyedSurface/keyedSurface.C keyedSurface/keyedSurfaceCleanup.C keyedSurface/newKeyedSurface.C @@ -8,6 +12,7 @@ meshedSurface/newMeshedSurface.C fileFormats = keyedSurface/fileFormats $(fileFormats)/ac3d/AC3DfileFormat.C +$(fileFormats)/ftr/FTRfileFormat.C $(fileFormats)/gts/GTSfileFormat.C $(fileFormats)/nas/NASfileFormat.C $(fileFormats)/obj/OBJfileFormat.C diff --git a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C index 0aa3f7d84f..2fd4b9e3ca 100644 --- a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C +++ b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C @@ -257,10 +257,10 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat if (!readCmd(is, cmd, args)) { FatalErrorIn - ( - "fileFormats::AC3DfileFormat::AC3DfileFormat" - "(const fileName&)" - ) + ( + "fileFormats::AC3DfileFormat::AC3DfileFormat" + "(const fileName&)" + ) << "Did not read up to \"kids 0\" while reading patch " << patchI << " from file " << fName << exit(FatalError); @@ -417,7 +417,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat void Foam::fileFormats::AC3DfileFormat::writeHeader ( Ostream& os, - const List& patchLst + const List& patchLst ) { // Write with patches as separate objects under "world" object. @@ -467,22 +467,22 @@ void Foam::fileFormats::AC3DfileFormat::write ) { labelList faceMap; - List patchLst = surf.sortedRegions(faceMap); + List patchLst = surf.sortedRegions(faceMap); writeHeader(os, patchLst); label faceIndex = 0; forAll(patchLst, patchI) { - const surfacePatch& sp = patchLst[patchI]; + const surfGroup& p = patchLst[patchI]; os << "OBJECT poly" << nl - << "name \"" << sp.name() << '"' << endl; + << "name \"" << p.name() << '"' << endl; // Create patch with only patch faces included for ease of addressing boolList include(surf.size(), false); - forAll(sp, patchFaceI) + forAll(p, patchFaceI) { const label faceI = faceMap[faceIndex++]; @@ -536,16 +536,16 @@ void Foam::fileFormats::AC3DfileFormat::write { const pointField& pointLst = surf.points(); const List& faceLst = surf.faces(); - const List& patchLst = surf.patches(); + const List& patchLst = surf.patches(); writeHeader(os, patchLst); forAll(patchLst, patchI) { - const surfacePatch& sp = patchLst[patchI]; + const surfGroup& p = patchLst[patchI]; os << "OBJECT poly" << nl - << "name \"" << sp.name() << '"' << endl; + << "name \"" << p.name() << '"' << endl; // Temporary primitivePatch to calculate compact points & faces primitivePatch patch @@ -553,8 +553,8 @@ void Foam::fileFormats::AC3DfileFormat::write SubList ( faceLst, - sp.start(), - sp.size() + p.start(), + p.size() ), pointLst ); diff --git a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H index 286f17c284..49cb6c5733 100644 --- a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H +++ b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H @@ -87,7 +87,7 @@ class AC3DfileFormat ); //- Write header with materials - static void writeHeader(Ostream&, const List&); + static void writeHeader(Ostream&, const List&); //- Disallow default bitwise copy construct AC3DfileFormat(const AC3DfileFormat&); diff --git a/src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C b/src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C new file mode 100644 index 0000000000..0ac81d5d46 --- /dev/null +++ b/src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C @@ -0,0 +1,110 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "FTRfileFormat.H" +#include "clock.H" +#include "IFstream.H" +#include "IStringStream.H" +#include "addToRunTimeSelectionTable.H" +#include "addToMemberFunctionSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +namespace Foam +{ +namespace fileFormats +{ + +addNamedToRunTimeSelectionTable +( + keyedSurface, + FTRfileFormat, + fileExtension, + ftr +); + +} +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fileFormats::FTRfileFormat::FTRfileFormat() +: + Foam::keyedSurface() +{} + + +Foam::fileFormats::FTRfileFormat::FTRfileFormat +( + const fileName& fName, + const bool triangulate +) +: + Foam::keyedSurface() +{ + IFstream is(fName); + + if (!is.good()) + { + FatalErrorIn + ( + "fileFormats::FTRfileFormat::FTRfileFormat(const fileName&)" + ) + << "Cannot read file " << fName + << exit(FatalError); + } + + List readPatches(is); + List pointLst(is); + + // transfer to normal list + points().transfer(pointLst); + + // read face with keys + List readFaces(is); + + List faceLst(readFaces.size()); + List