From c8de1c150ddc025809d8766b845ea05ae5db93d9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 10 Nov 2008 20:59:15 +0100 Subject: [PATCH 1/8] foamNew templates: - add static/protected member function subsections - static members up front, constructors/destructors next private/protected/public members next --- bin/foamTemplates/source/foamTemplate.C | 17 +++++++++++------ .../sourceTemplate/foamTemplateTemplate.C | 16 +++++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/bin/foamTemplates/source/foamTemplate.C b/bin/foamTemplates/source/foamTemplate.C index 99bea11c39..fc947cf9b4 100644 --- a/bin/foamTemplates/source/foamTemplate.C +++ b/bin/foamTemplates/source/foamTemplate.C @@ -31,7 +31,7 @@ License const dataType Foam::className::staticData(); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -71,10 +71,16 @@ Foam::className::~className() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // void Foam::className::operator=(const className& rhs) { @@ -87,11 +93,10 @@ void Foam::className::operator=(const className& rhs) } } - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C b/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C index 92038d8199..f0955b92e4 100644 --- a/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C +++ b/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C @@ -32,7 +32,7 @@ template const dataType Foam::ClassName::staticData(); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -84,10 +84,16 @@ Foam::ClassName::~ClassName() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // template void Foam::ClassName::operator= @@ -108,10 +114,10 @@ void Foam::ClassName::operator= } -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // // ************************************************************************* // From d4fcd2d9c433f89cee424c48b749b4bd3300e524 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 11 Nov 2008 22:18:52 +0100 Subject: [PATCH 2/8] surfMesh consistency updates, added read() member throughout etc. --- .../fileFormats/ac3d/AC3DfileFormat.C | 122 ++-- .../fileFormats/ac3d/AC3DfileFormat.H | 5 +- .../fileFormats/ftr/FTRfileFormat.C | 31 +- .../fileFormats/ftr/FTRfileFormat.H | 8 +- .../fileFormats/gts/GTSfileFormat.C | 32 +- .../fileFormats/gts/GTSfileFormat.H | 5 +- .../fileFormats/nas/NASfileFormat.C | 22 +- .../fileFormats/nas/NASfileFormat.H | 3 + .../fileFormats/obj/OBJfileFormat.C | 19 +- .../fileFormats/obj/OBJfileFormat.H | 7 +- .../fileFormats/off/OFFfileFormat.C | 21 +- .../fileFormats/off/OFFfileFormat.H | 7 +- .../fileFormats/smesh/SMESHfileFormat.H | 1 - .../fileFormats/starcd/STARCDfileFormat.C | 27 +- .../fileFormats/starcd/STARCDfileFormat.H | 3 +- .../fileFormats/stl/STLfileFormat.C | 22 +- .../fileFormats/stl/STLfileFormat.H | 9 +- .../fileFormats/stl/STLfileFormatASCII.L | 4 +- .../fileFormats/tri/TRIfileFormat.C | 21 +- .../fileFormats/tri/TRIfileFormat.H | 5 +- src/surfMesh/keyedSurface/keyedSurface.C | 611 +++++++++--------- src/surfMesh/keyedSurface/keyedSurface.H | 72 ++- .../keyedSurface/keyedSurfaceCleanup.C | 4 +- src/surfMesh/meshedSurface/meshedSurface.C | 483 +++++++------- src/surfMesh/meshedSurface/meshedSurface.H | 50 +- .../meshedSurface/meshedSurfaceCleanup.C | 4 +- 26 files changed, 899 insertions(+), 699 deletions(-) diff --git a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C index c3e39b765d..9555f2a4d3 100644 --- a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C +++ b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.C @@ -152,8 +152,7 @@ Foam::string Foam::fileFormats::AC3DfileFormat::cueToOrDie { FatalErrorIn ( - "fileFormats::AC3DfileFormat::AC3DfileFormat" - "(const fileName&)" + "fileFormats::AC3DfileFormat::read(const fileName&)" ) << "Cannot find command " << cmd << " " << errorMsg @@ -164,6 +163,51 @@ Foam::string Foam::fileFormats::AC3DfileFormat::cueToOrDie } +void Foam::fileFormats::AC3DfileFormat::writeHeader +( + Ostream& os, + const List& patchLst +) +{ + // Write with patches as separate objects under "world" object. + // Header is taken over from sample file. + // Defines separate materials for all patches. Recycle colours. + + // Define 8 standard colours as r,g,b components + static scalar colourMap[] = + { + 1, 1, 1, + 1, 0, 0, + 0, 1, 0, + 0, 0, 1, + 1, 1, 0, + 0, 1, 1, + 1, 0, 1, + 0.5, 0.5, 1 + }; + + // Write header. Define materials. + os << "AC3Db" << nl; + + forAll(patchLst, patchI) + { + const word& pName = patchLst[patchI].name(); + + label colourI = patchI % 8; + label colourCompI = 3 * colourI; + + os << "MATERIAL \"" << pName << "Mat\" rgb " + << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1] + << ' ' << colourMap[colourCompI+2] + << " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10" + << " trans 0" + << nl; + } + + os << "OBJECT world" << nl + << "kids " << patchLst.size() << endl; +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -181,14 +225,25 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat : Foam::keyedSurface() { + read(fName,triangulate); +} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fileFormats::AC3DfileFormat::read +( + const fileName& fName, + const bool triangulate +) +{ + clear(); IFstream is(fName); if (!is.good()) { FatalErrorIn ( - "fileFormats::AC3DfileFormat::AC3DfileFormat" - "(const fileName&)" + "fileFormats::AC3DfileFormat::read(const fileName&)" ) << "Cannot read file " << fName << exit(FatalError); @@ -219,8 +274,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat { FatalErrorIn ( - "fileFormats::AC3DfileFormat::AC3DfileFormat" - "(const fileName&)" + "fileFormats::AC3DfileFormat::read(const fileName&)" ) << "Cannot find \"OBJECT world\" in file " << fName << exit(FatalError); @@ -260,8 +314,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat { FatalErrorIn ( - "fileFormats::AC3DfileFormat::AC3DfileFormat" - "(const fileName&)" + "fileFormats::AC3DfileFormat::read(const fileName&)" ) << "Did not read up to \"kids 0\" while reading patch " << patchI << " from file " << fName @@ -289,7 +342,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat WarningIn ( - "fileFormats::AC3DfileFormat::AC3DfileFormat" + "fileFormats::AC3DfileFormat::read" "(const fileName&)" ) << "rot (rotation tensor) command not implemented" @@ -388,8 +441,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat { FatalErrorIn ( - "fileFormats::AC3DfileFormat::AC3DfileFormat" - "(const fileName&)" + "fileFormats::AC3DfileFormat::read(const fileName&)" ) << "Can only read objects without kids." << " Encountered " << nKids << " kids when" @@ -411,54 +463,8 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat setPatches(regionNames); stitchFaces(SMALL); -} - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::fileFormats::AC3DfileFormat::writeHeader -( - Ostream& os, - const List& patchLst -) -{ - // Write with patches as separate objects under "world" object. - // Header is taken over from sample file. - // Defines separate materials for all patches. Recycle colours. - - // Define 8 standard colours as r,g,b components - static scalar colourMap[] = - { - 1, 1, 1, - 1, 0, 0, - 0, 1, 0, - 0, 0, 1, - 1, 1, 0, - 0, 1, 1, - 1, 0, 1, - 0.5, 0.5, 1 - }; - - // Write header. Define materials. - os << "AC3Db" << nl; - - forAll(patchLst, patchI) - { - const word& pName = patchLst[patchI].name(); - - label colourI = patchI % 8; - label colourCompI = 3 * colourI; - - os << "MATERIAL \"" << pName << "Mat\" rgb " - << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1] - << ' ' << colourMap[colourCompI+2] - << " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10" - << " trans 0" - << nl; - } - - os << "OBJECT world" << nl - << "kids " << patchLst.size() << endl; + return true; } diff --git a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H index 49cb6c5733..9ff18bc325 100644 --- a/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H +++ b/src/surfMesh/keyedSurface/fileFormats/ac3d/AC3DfileFormat.H @@ -116,7 +116,7 @@ public: { return autoPtr ( - new AC3DfileFormat(fName, triangulate) + new AC3DfileFormat(fName,triangulate) ); } @@ -124,7 +124,8 @@ public: // Member Functions - // Write + //- Read from file + virtual bool read(const fileName&, const bool triangulate); //- Write keyedSurface static void write(Ostream&, const keyedSurface&); diff --git a/src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C b/src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C index 0ac81d5d46..248e5c2943 100644 --- a/src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C +++ b/src/surfMesh/keyedSurface/fileFormats/ftr/FTRfileFormat.C @@ -25,7 +25,8 @@ License \*---------------------------------------------------------------------------*/ #include "FTRfileFormat.H" -#include "clock.H" +#include "Keyed.H" +#include "triFace.H" #include "IFstream.H" #include "IStringStream.H" #include "addToRunTimeSelectionTable.H" @@ -64,13 +65,26 @@ Foam::fileFormats::FTRfileFormat::FTRfileFormat : Foam::keyedSurface() { + read(fName,true); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fileFormats::FTRfileFormat::read +( + const fileName& fName, + const bool +) +{ + clear(); IFstream is(fName); if (!is.good()) { FatalErrorIn ( - "fileFormats::FTRfileFormat::FTRfileFormat(const fileName&)" + "fileFormats::FTRfileFormat::read(const fileName&)" ) << "Cannot read file " << fName << exit(FatalError); @@ -82,16 +96,17 @@ Foam::fileFormats::FTRfileFormat::FTRfileFormat // transfer to normal list points().transfer(pointLst); - // read face with keys - List readFaces(is); + // read faces with keys + List > readFaces(is); - List faceLst(readFaces.size()); - List