mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
surfMesh - more code refactoring
This commit is contained in:
@ -7,18 +7,26 @@ UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||
|
||||
surfaceFormats = surfaceFormats
|
||||
$(surfaceFormats)/surfaceFormatsCore.C
|
||||
|
||||
$(surfaceFormats)/ac3d/AC3DsurfaceFormatCore.C
|
||||
$(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/nas/NASsurfaceFormatCore.C
|
||||
$(surfaceFormats)/nas/NASsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/obj/OBJsurfaceFormatCore.C
|
||||
$(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/off/OFFsurfaceFormatCore.C
|
||||
$(surfaceFormats)/off/OFFsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/smesh/SMESHsurfaceFormatCore.C
|
||||
$(surfaceFormats)/smesh/SMESHsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/starcd/STARCDsurfaceFormatCore.C
|
||||
$(surfaceFormats)/starcd/STARCDsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatCore.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatASCII.L
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatCore.C
|
||||
$(surfaceFormats)/tri/TRIsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/vtk/VTKsurfaceFormatCore.C
|
||||
$(surfaceFormats)/vtk/VTKsurfaceFormatRunTime.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libsurfMesh
|
||||
|
||||
@ -44,20 +44,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
Foam::fileName Foam::MeshedSurface<Face>::triSurfInstance(const Time& d)
|
||||
{
|
||||
return triSurfInstance(d, typeName);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::fileName Foam::MeshedSurface<Face>::triSurfName(const Time& d)
|
||||
{
|
||||
return triSurfName(d, typeName);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::canRead(const word& ext, const bool verbose)
|
||||
{
|
||||
@ -462,7 +448,7 @@ Foam::MeshedSurface<Face>::MeshedSurface(const Time& d)
|
||||
:
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(IFstream(triSurfName(d))());
|
||||
read(IFstream(findMeshName(d))());
|
||||
// setDefaultPatches();
|
||||
}
|
||||
|
||||
@ -845,7 +831,7 @@ bool Foam::MeshedSurface<Face>::read
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::write(const Time& d) const
|
||||
{
|
||||
write(OFstream(triSurfName(d))());
|
||||
write(OFstream(findMeshName(d))());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -141,12 +141,6 @@ public:
|
||||
|
||||
// Static
|
||||
|
||||
//- Name of MeshedSurface directory to use.
|
||||
static fileName triSurfInstance(const Time&);
|
||||
|
||||
//- Name of MeshedSurface directory to use.
|
||||
static fileName triSurfName(const Time&);
|
||||
|
||||
//- Can we read this file format?
|
||||
static bool canRead(const word& ext, const bool verbose=false);
|
||||
|
||||
|
||||
@ -39,20 +39,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
Foam::fileName Foam::UnsortedMeshedSurface<Face>::triSurfInstance(const Time& d)
|
||||
{
|
||||
return triSurfInstance(d, typeName);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::fileName Foam::UnsortedMeshedSurface<Face>::triSurfName(const Time& d)
|
||||
{
|
||||
return triSurfName(d, typeName);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::canRead
|
||||
(
|
||||
@ -442,7 +428,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const Time& d)
|
||||
:
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(IFstream(triSurfName(d))());
|
||||
read(IFstream(findMeshName(d))());
|
||||
}
|
||||
|
||||
|
||||
@ -830,7 +816,7 @@ bool Foam::UnsortedMeshedSurface<Face>::read
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::write(const Time& d) const
|
||||
{
|
||||
write(OFstream(triSurfName(d))());
|
||||
write(OFstream(findMeshName(d))());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -173,12 +173,6 @@ public:
|
||||
|
||||
// Static
|
||||
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName triSurfInstance(const Time&);
|
||||
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName triSurfName(const Time&);
|
||||
|
||||
//- Can we read this file format?
|
||||
static bool canRead(const word& ext, const bool verbose=false);
|
||||
|
||||
|
||||
@ -241,7 +241,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
|
||||
UList<label>& f = static_cast<UList<label>&>(verts);
|
||||
|
||||
if (mustTriangulate)
|
||||
if (mustTriangulate && f.size() > 3)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
@ -298,7 +298,6 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
// transfer to normal lists
|
||||
ParentType::points().transfer(pointLst);
|
||||
ParentType::faces().transfer(faceLst);
|
||||
|
||||
ParentType::regions().transfer(regionLst);
|
||||
|
||||
ParentType::setPatches(regionNames);
|
||||
@ -359,7 +358,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
forAll(patch.localFaces(), faceI)
|
||||
{
|
||||
const face& f = patch.localFaces()[faceI];
|
||||
const Face& f = patch.localFaces()[faceI];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << patchI << nl
|
||||
@ -417,7 +416,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
forAll(patch.localFaces(), faceI)
|
||||
{
|
||||
const face& f = patch.localFaces()[faceI];
|
||||
const Face& f = patch.localFaces()[faceI];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << patchI << nl
|
||||
|
||||
@ -33,17 +33,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::fileFormats::AC3DsurfaceFormatCore::parse(const string& str)
|
||||
{
|
||||
IStringStream ss(str);
|
||||
|
||||
Type t;
|
||||
ss >> t;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fileFormats::AC3DsurfaceFormatCore::readCmd
|
||||
(
|
||||
IFstream& is,
|
||||
|
||||
@ -104,6 +104,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "AC3DsurfaceFormatCoreTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "AC3DsurfaceFormatCore.H"
|
||||
#include "IStringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::fileFormats::AC3DsurfaceFormatCore::parse(const string& s)
|
||||
{
|
||||
IStringStream ss(s);
|
||||
|
||||
Type t;
|
||||
ss >> t;
|
||||
return t;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -31,47 +31,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OBJsurfaceFormat<Face>::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << "v " << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -229,7 +188,7 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
|
||||
UList<label>& f = static_cast<UList<label>&>(dynVertices);
|
||||
|
||||
if (mustTriangulate)
|
||||
if (mustTriangulate && f.size() > 3)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
@ -277,7 +236,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -289,7 +248,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
os << 'f';
|
||||
forAll(f, fp)
|
||||
@ -314,7 +273,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -325,7 +284,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceIndex++];
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
os << 'f';
|
||||
forAll(f, fp)
|
||||
|
||||
@ -42,6 +42,7 @@ SourceFiles
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "OBJsurfaceFormatCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -57,7 +58,8 @@ namespace fileFormats
|
||||
template<class Face>
|
||||
class OBJsurfaceFormat
|
||||
:
|
||||
public UnsortedMeshedSurface<Face>
|
||||
public UnsortedMeshedSurface<Face>,
|
||||
public OBJsurfaceFormatCore
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef OBJsurfaceFormat<Face> ThisType;
|
||||
|
||||
74
src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.C
Normal file
74
src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.C
Normal file
@ -0,0 +1,74 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "OBJsurfaceFormatCore.H"
|
||||
#include "clock.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << nFaces << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << "v " << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << nFaces << "\">" << endl;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
96
src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.H
Normal file
96
src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatCore.H
Normal file
@ -0,0 +1,96 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Class
|
||||
Foam::fileFormats::OBJsurfaceFormatCore
|
||||
|
||||
Description
|
||||
Internal class used by the OBJsurfaceFormat
|
||||
|
||||
SourceFiles
|
||||
OBJsurfaceFormatCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OBJsurfaceFormatCore_H
|
||||
#define OBJsurfaceFormatCore_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AC3DfileFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OBJsurfaceFormatCore
|
||||
{
|
||||
protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write header information with points
|
||||
static void writeHeader
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
OBJsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Destructor
|
||||
|
||||
~OBJsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fileFormats
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -33,52 +33,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OFFsurfaceFormat<Face>::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
os << "OFF" << endl
|
||||
<< "# Geomview OFF file written " << clock::dateTime().c_str() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# nPoints nFaces nEdges" << nl
|
||||
<< pointLst.size() << ' ' << faceLst.size() << ' ' << 0 << nl;
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << pointLst[ptI].x() << ' '
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << " #" << ptI << endl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -188,7 +142,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
||||
|
||||
UList<label>& f = static_cast<UList<label>&>(verts);
|
||||
|
||||
if (mustTriangulate)
|
||||
if (mustTriangulate && f.size() > 3)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
@ -237,7 +191,7 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -273,7 +227,7 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
writeHeader(os, surf.points(), faceLst.size(), patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
|
||||
@ -50,6 +50,7 @@ SourceFiles
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "OFFsurfaceFormatCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -65,7 +66,8 @@ namespace fileFormats
|
||||
template<class Face>
|
||||
class OFFsurfaceFormat
|
||||
:
|
||||
public UnsortedMeshedSurface<Face>
|
||||
public UnsortedMeshedSurface<Face>,
|
||||
public OFFsurfaceFormatCore
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef OFFsurfaceFormat<Face> ThisType;
|
||||
|
||||
78
src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.C
Normal file
78
src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.C
Normal file
@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "OFFsurfaceFormatCore.H"
|
||||
#include "clock.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
os << "OFF" << endl
|
||||
<< "# Geomview OFF file written " << clock::dateTime().c_str() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << nFaces << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# nPoints nFaces nEdges" << nl
|
||||
<< pointLst.size() << ' ' << nFaces << ' ' << 0 << nl;
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << pointLst[ptI].x() << ' '
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << " #" << ptI << endl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << nFaces << "\">" << endl;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
95
src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.H
Normal file
95
src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.H
Normal file
@ -0,0 +1,95 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Class
|
||||
Foam::fileFormats::OFFsurfaceFormatCore
|
||||
|
||||
Description
|
||||
Internal class used by the OFFsurfaceFormat
|
||||
|
||||
SourceFiles
|
||||
OFFsurfaceFormatCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OFFsurfaceFormatCore_H
|
||||
#define OFFsurfaceFormatCore_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OFFsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OFFsurfaceFormatCore
|
||||
{
|
||||
protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write header information with points
|
||||
static void writeHeader
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
OFFsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Destructor
|
||||
~OFFsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fileFormats
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,52 +27,11 @@ License
|
||||
#include "SMESHsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IStringStream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
os << "# tetgen .smesh file written " << clock::dateTime().c_str() << nl;
|
||||
os << "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
os << pointLst.size() << " 3" << nl; // 3: dimensions
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << ptI
|
||||
<< ' ' << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
|
||||
os << faceLst.size() << " 1" << endl; // one attribute: region number
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::writeTail(Ostream& os)
|
||||
{
|
||||
os << "# </faces>" << nl
|
||||
<< nl
|
||||
<< "# no holes or regions:" << nl
|
||||
<< '0' << nl // holes
|
||||
<< '0' << endl; // regions
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -92,7 +51,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
writeHeader(os, surf.points(), faceLst.size());
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -127,14 +86,14 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
writeHeader(os, surf.points(), faceLst.size());
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceIndex++];
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
os << f.size();
|
||||
forAll(f, fp)
|
||||
|
||||
@ -47,6 +47,7 @@ SourceFiles
|
||||
#include "Ostream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "SMESHsurfaceFormatCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -62,7 +63,8 @@ namespace fileFormats
|
||||
template<class Face>
|
||||
class SMESHsurfaceFormat
|
||||
:
|
||||
public UnsortedMeshedSurface<Face>
|
||||
public UnsortedMeshedSurface<Face>,
|
||||
public SMESHsurfaceFormatCore
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef SMESHsurfaceFormat<Face> ThisType;
|
||||
@ -76,9 +78,6 @@ class SMESHsurfaceFormat
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const SMESHsurfaceFormat<Face>&);
|
||||
|
||||
static void writeHead(Ostream&, const pointField&, const List<Face>&);
|
||||
static void writeTail(Ostream&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
72
src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.C
Normal file
72
src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.C
Normal file
@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "SMESHsurfaceFormatCore.H"
|
||||
#include "clock.H"
|
||||
#include "IStringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::SMESHsurfaceFormatCore::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
os << "# tetgen .smesh file written " << clock::dateTime().c_str() << nl;
|
||||
os << "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
os << pointLst.size() << " 3" << nl; // 3: dimensions
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << ptI
|
||||
<< ' ' << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << nFaces << "\">" << endl;
|
||||
|
||||
os << nFaces << " 1" << endl; // one attribute: region number
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::SMESHsurfaceFormatCore::writeTail(Ostream& os)
|
||||
{
|
||||
os << "# </faces>" << nl
|
||||
<< nl
|
||||
<< "# no holes or regions:" << nl
|
||||
<< '0' << nl // holes
|
||||
<< '0' << endl; // regions
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
99
src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.H
Normal file
99
src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.H
Normal file
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Class
|
||||
Foam::fileFormats::SMESHsurfaceFormatCore
|
||||
|
||||
Description
|
||||
Internal class used by the SMESHsurfaceFormat
|
||||
|
||||
SourceFiles
|
||||
SMESHsurfaceFormatCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SMESHsurfaceFormatCore_H
|
||||
#define SMESHsurfaceFormatCore_H
|
||||
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Ostream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SMESHsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class SMESHsurfaceFormatCore
|
||||
{
|
||||
protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write header information with points
|
||||
static void writeHeader
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces
|
||||
);
|
||||
|
||||
//- Write tail information
|
||||
static void writeTail(Ostream&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
SMESHsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Destructor
|
||||
|
||||
~SMESHsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fileFormats
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -31,100 +31,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
//! @cond localscope
|
||||
const int starcdShellShape = 3;
|
||||
const int starcdShellType = 4;
|
||||
//! @endcond localscope
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::STARCDsurfaceFormat<Face>::readHeader
|
||||
(
|
||||
IFstream& is,
|
||||
const word& signature
|
||||
)
|
||||
{
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STARCDsurfaceFormat::readHeader(...)"
|
||||
)
|
||||
<< "cannot read " << signature << " " << is.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
word header;
|
||||
label majorVersion;
|
||||
|
||||
string line;
|
||||
|
||||
is.getLine(line);
|
||||
IStringStream(line)() >> header;
|
||||
|
||||
is.getLine(line);
|
||||
IStringStream(line)() >> majorVersion;
|
||||
|
||||
// add other checks ...
|
||||
if (header != signature)
|
||||
{
|
||||
Info<< "header mismatch " << signature << " " << is.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const char* filetype
|
||||
)
|
||||
{
|
||||
os << "PROSTAR_" << filetype << nl
|
||||
<< 4000
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::writePoints
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst
|
||||
)
|
||||
{
|
||||
writeHeader(os, "VERTEX");
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
os.precision(10);
|
||||
|
||||
// force decimal point for Fortran input
|
||||
os.setf(std::ios::showpoint);
|
||||
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os
|
||||
<< ptI + 1 << " "
|
||||
<< pointLst[ptI].x() << " "
|
||||
<< pointLst[ptI].y() << " "
|
||||
<< pointLst[ptI].z() << nl;
|
||||
}
|
||||
os.flush();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
||||
(
|
||||
@ -136,10 +44,10 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
||||
{
|
||||
os
|
||||
<< cellId // includes 1 offset
|
||||
<< " " << starcdShellShape // 3(shell)
|
||||
<< " " << starcdShellShape_ // 3(shell) shape
|
||||
<< " " << f.size()
|
||||
<< " " << cellTableId
|
||||
<< " " << starcdShellType; // 4(shell)
|
||||
<< " " << starcdShellType_; // 4(shell)
|
||||
|
||||
// primitives have <= 8 vertices, but prevent overrun anyhow
|
||||
// indent following lines for ease of reading
|
||||
@ -189,7 +97,7 @@ Foam::fileFormats::STARCDsurfaceFormat<Face>::STARCDsurfaceFormat
|
||||
:
|
||||
ParentType()
|
||||
{
|
||||
ThisType::read(fName);
|
||||
read(fName);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -312,7 +220,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
isPtr() >> starLabels[i];
|
||||
}
|
||||
|
||||
if (typeId == starcdShellType)
|
||||
if (typeId == starcdShellType_)
|
||||
{
|
||||
// Convert groupID into patchID
|
||||
Map<label>::const_iterator iter =
|
||||
|
||||
@ -47,6 +47,7 @@ SourceFiles
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "STARCDsurfaceFormatCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -62,12 +63,20 @@ namespace fileFormats
|
||||
template<class Face>
|
||||
class STARCDsurfaceFormat
|
||||
:
|
||||
public UnsortedMeshedSurface<Face>
|
||||
public UnsortedMeshedSurface<Face>,
|
||||
public STARCDsurfaceFormatCore
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef STARCDsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Data
|
||||
//- STAR-CD identifier for shell shapes (2d elements)
|
||||
static const int starcdShellShape_ = 3;
|
||||
|
||||
//- STAR-CD identifier for shell type (shells vs. baffles)
|
||||
static const int starcdShellType_ = 4;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -76,13 +85,6 @@ class STARCDsurfaceFormat
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const STARCDsurfaceFormat<Face>&);
|
||||
|
||||
|
||||
static bool readHeader(IFstream&, const word&);
|
||||
|
||||
static void writeHeader(Ostream&, const char* filetype);
|
||||
|
||||
static void writePoints(Ostream&, const pointField&);
|
||||
|
||||
static inline void writeShell
|
||||
(
|
||||
Ostream&,
|
||||
|
||||
126
src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C
Normal file
126
src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C
Normal file
@ -0,0 +1,126 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "STARCDsurfaceFormatCore.H"
|
||||
#include "clock.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IStringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
//! @cond localscope
|
||||
const int starcdShellShape = 3;
|
||||
const int starcdShellType = 4;
|
||||
//! @endcond localscope
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::STARCDsurfaceFormatCore::readHeader
|
||||
(
|
||||
IFstream& is,
|
||||
const word& signature
|
||||
)
|
||||
{
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STARCDsurfaceFormatCore::readHeader(...)"
|
||||
)
|
||||
<< "cannot read " << signature << " " << is.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
word header;
|
||||
label majorVersion;
|
||||
|
||||
string line;
|
||||
|
||||
is.getLine(line);
|
||||
IStringStream(line)() >> header;
|
||||
|
||||
is.getLine(line);
|
||||
IStringStream(line)() >> majorVersion;
|
||||
|
||||
// add other checks ...
|
||||
if (header != signature)
|
||||
{
|
||||
Info<< "header mismatch " << signature << " " << is.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDsurfaceFormatCore::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const char* filetype
|
||||
)
|
||||
{
|
||||
os << "PROSTAR_" << filetype << nl
|
||||
<< 4000
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< " " << 0
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDsurfaceFormatCore::writePoints
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst
|
||||
)
|
||||
{
|
||||
writeHeader(os, "VERTEX");
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
os.precision(10);
|
||||
|
||||
// force decimal point for Fortran input
|
||||
os.setf(std::ios::showpoint);
|
||||
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os
|
||||
<< ptI + 1 << " "
|
||||
<< pointLst[ptI].x() << " "
|
||||
<< pointLst[ptI].y() << " "
|
||||
<< pointLst[ptI].z() << nl;
|
||||
}
|
||||
os.flush();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
95
src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H
Normal file
95
src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.H
Normal file
@ -0,0 +1,95 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Class
|
||||
Foam::fileFormats::STARCDsurfaceFormatCore
|
||||
|
||||
Description
|
||||
Internal class used by the OBJsurfaceFormat
|
||||
|
||||
SourceFiles
|
||||
STARCDsurfaceFormatCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef STARCDsurfaceFormatCore_H
|
||||
#define STARCDsurfaceFormatCore_H
|
||||
|
||||
#include "IFstream.H"
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STARCDsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STARCDsurfaceFormatCore
|
||||
{
|
||||
protected:
|
||||
// Protected Member Functions
|
||||
|
||||
static bool readHeader(IFstream&, const word&);
|
||||
|
||||
static void writeHeader(Ostream&, const char* filetype);
|
||||
|
||||
static void writePoints(Ostream&, const pointField&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
STARCDsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Destructor
|
||||
~STARCDsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fileFormats
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -32,7 +32,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// File extension for 'native' raw format
|
||||
Foam::word Foam::fileFormats::surfaceFormatsCore::meshSubDir("meshedSurface");
|
||||
Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
@ -63,13 +63,13 @@ Foam::fileFormats::surfaceFormatsCore::getLineNoComment
|
||||
|
||||
|
||||
Foam::fileName
|
||||
Foam::fileFormats::surfaceFormatsCore::triSurfInstance
|
||||
Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
(
|
||||
const Time& d,
|
||||
const word& subdirName
|
||||
)
|
||||
{
|
||||
fileName foamName(d.caseName() + ".ofs");
|
||||
fileName foamName(d.caseName() + "." + nativeExt);
|
||||
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
@ -104,13 +104,13 @@ Foam::fileFormats::surfaceFormatsCore::triSurfInstance
|
||||
|
||||
|
||||
Foam::fileName
|
||||
Foam::fileFormats::surfaceFormatsCore::triSurfName
|
||||
Foam::fileFormats::surfaceFormatsCore::findMeshName
|
||||
(
|
||||
const Time& d,
|
||||
const word& subdirName
|
||||
)
|
||||
{
|
||||
fileName foamName(d.caseName() + ".ofs");
|
||||
fileName foamName(d.caseName() + "." + nativeExt);
|
||||
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
@ -146,6 +146,25 @@ Foam::fileFormats::surfaceFormatsCore::triSurfName
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName
|
||||
Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
(
|
||||
const Time& d
|
||||
)
|
||||
{
|
||||
return findMeshInstance(d, meshSubDir);
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName
|
||||
Foam::fileFormats::surfaceFormatsCore::findMeshName
|
||||
(
|
||||
const Time& d
|
||||
)
|
||||
{
|
||||
return findMeshName(d, meshSubDir);
|
||||
}
|
||||
|
||||
// Returns patch info.
|
||||
// Sets faceMap to the indexing according to patch numbers.
|
||||
// Patch numbers start at 0.
|
||||
|
||||
@ -64,6 +64,9 @@ public:
|
||||
|
||||
// Static Data
|
||||
|
||||
//- Return the mesh sub-directory name (usually "meshedSurface")
|
||||
static word meshSubDir;
|
||||
|
||||
//- The file extension corresponding to 'native' surface format
|
||||
static word nativeExt;
|
||||
|
||||
@ -76,10 +79,16 @@ public:
|
||||
static string getLineNoComment(IFstream&);
|
||||
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName triSurfInstance(const Time&, const word& subdirName);
|
||||
static fileName findMeshInstance(const Time&, const word& subdirName);
|
||||
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName triSurfName(const Time&, const word& subdirName);
|
||||
static fileName findMeshName(const Time&, const word& subdirName);
|
||||
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName findMeshInstance(const Time&);
|
||||
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName findMeshName(const Time&);
|
||||
|
||||
//- Determine the sort order from the region list.
|
||||
// Returns patch list and sets faceMap to indices within faceLst
|
||||
|
||||
@ -33,30 +33,14 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHead
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHeaderPolygons
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
os << "# vtk DataFile Version 2.0" << nl
|
||||
<< "surface written " << clock::dateTime().c_str() << nl
|
||||
<< "ASCII" << nl
|
||||
<< nl
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
// Write vertex coords
|
||||
os << "POINTS " << pointLst.size() << " float" << nl;
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << pointLst[ptI].x() << ' '
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << nl;
|
||||
}
|
||||
|
||||
label nNodes = 0;
|
||||
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nNodes += faceLst[faceI].size();
|
||||
@ -68,48 +52,6 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHead
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeTail
|
||||
(
|
||||
Ostream& os,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
label nFaces = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
nFaces += patchLst[patchI].size();
|
||||
}
|
||||
|
||||
// Print region numbers
|
||||
os << nl
|
||||
<< "CELL_DATA " << nFaces << nl
|
||||
<< "FIELD attributes 1" << nl
|
||||
<< "region 1 " << nFaces << " float" << nl;
|
||||
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
if (patchFaceI)
|
||||
{
|
||||
if ((patchFaceI % 20) == 0)
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
os << patchI + 1;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -130,7 +72,8 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
writeHeader(os, surf.points());
|
||||
writeHeaderPolygons(os, faceLst);
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -140,7 +83,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
os << f.size();
|
||||
forAll(f, fp)
|
||||
@ -166,14 +109,15 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
writeHeader(os, surf.points());
|
||||
writeHeaderPolygons(os, faceLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceIndex++];
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
os << f.size();
|
||||
forAll(f, fp)
|
||||
|
||||
@ -40,6 +40,7 @@ SourceFiles
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "VTKsurfaceFormatCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,7 +56,8 @@ namespace fileFormats
|
||||
template<class Face>
|
||||
class VTKsurfaceFormat
|
||||
:
|
||||
public UnsortedMeshedSurface<Face>
|
||||
public UnsortedMeshedSurface<Face>,
|
||||
public VTKsurfaceFormatCore
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef VTKsurfaceFormat<Face> ThisType;
|
||||
@ -63,15 +65,16 @@ class VTKsurfaceFormat
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Write header information about number of polygon points
|
||||
static void writeHeaderPolygons(Ostream&, const List<Face>&);
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
VTKsurfaceFormat(const VTKsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const VTKsurfaceFormat<Face>&);
|
||||
|
||||
static void writeHead(Ostream&, const pointField&, const List<Face>&);
|
||||
static void writeTail(Ostream&, const List<surfGroup>&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
103
src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C
Normal file
103
src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C
Normal file
@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "VTKsurfaceFormatCore.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
os << "# vtk DataFile Version 2.0" << nl
|
||||
<< "surface written " << clock::dateTime().c_str() << nl
|
||||
<< "ASCII" << nl
|
||||
<< nl
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
// Write vertex coords
|
||||
os << "POINTS " << pointLst.size() << " float" << nl;
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << pointLst[ptI].x() << ' '
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
||||
(
|
||||
Ostream& os,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
label nFaces = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
nFaces += patchLst[patchI].size();
|
||||
}
|
||||
|
||||
// Print region numbers
|
||||
os << nl
|
||||
<< "CELL_DATA " << nFaces << nl
|
||||
<< "FIELD attributes 1" << nl
|
||||
<< "region 1 " << nFaces << " float" << nl;
|
||||
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
if (patchFaceI)
|
||||
{
|
||||
if ((patchFaceI % 20) == 0)
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
os << patchI + 1;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
97
src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.H
Normal file
97
src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.H
Normal file
@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Class
|
||||
Foam::fileFormats::VTKsurfaceFormatCore
|
||||
|
||||
Description
|
||||
Internal class used by the VTKsurfaceFormat
|
||||
|
||||
SourceFiles
|
||||
VTKsurfaceFormatCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef VTKsurfaceFormatCore_H
|
||||
#define VTKsurfaceFormatCore_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class VTKsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class VTKsurfaceFormatCore
|
||||
{
|
||||
protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write header information with points
|
||||
static void writeHeader
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&
|
||||
);
|
||||
|
||||
//- Write header information with patch informattion
|
||||
static void writeTail(Ostream&, const List<surfGroup>&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
VTKsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~VTKsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fileFormats
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user