diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C index 9bc86e0cf3..0c60b22ede 100644 --- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C @@ -24,10 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "AC3DsurfaceFormat.H" -#include "clock.H" #include "IStringStream.H" -#include "tensor.H" -#include "primitivePatch.H" +#include "PrimitivePatch.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -254,6 +252,57 @@ bool Foam::fileFormats::AC3DsurfaceFormat::read } +namespace Foam +{ +// file-scope writing of a patch of faces +template +< + class Face, + template class FaceList, + class PointField, + class PointType +> +static void writeZone +( + Ostream& os, + const PrimitivePatch& patch, + const word& name, + const label zoneI +) +{ + // An isolated surface region (patch). + os << "OBJECT poly" << nl + << "name \"" << name << "\"" << nl; + + os << "numvert " << patch.nPoints() << nl; + + forAll(patch.localPoints(), pti) + { + const point& pt = patch.localPoints()[pti]; + + os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl; + } + + os << "numsurf " << patch.size() << nl; + + forAll(patch.localFaces(), facei) + { + const Face& f = patch.localFaces()[facei]; + + os << "SURF 0x20" << nl // polygon + << "mat " << zoneI << nl + << "refs " << f.size() << nl; + + forAll(f, fp) + { + os << f[fp] << " 0 0" << nl; + } + } + + os << "kids 0" << endl; +} +} + template void Foam::fileFormats::AC3DsurfaceFormat::write ( @@ -273,14 +322,6 @@ void Foam::fileFormats::AC3DsurfaceFormat::write const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1); - if (useFaceMap) - { - FatalErrorInFunction - << "output with faceMap is not supported " << filename - << exit(FatalError); - } - - OFstream os(filename); if (!os.good()) { @@ -291,52 +332,42 @@ void Foam::fileFormats::AC3DsurfaceFormat::write writeHeader(os, zones); + if (zones.size() == 1) + { + PrimitivePatch patch + ( + faceLst, pointLst + ); + + writeZone(os, patch, zones[0].name(), 0); + return; + } + forAll(zones, zoneI) { const surfZone& zone = zones[zoneI]; - os << "OBJECT poly" << nl - << "name \"" << zone.name() << "\"\n"; - - // Temporary PrimitivePatch to calculate compact points & faces - // use 'UList' to avoid allocations! - PrimitivePatch patch - ( - SubList + if (useFaceMap) + { + SubList