mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Templated meshedSurface/keyedSurface -> MeshedSurface/UnsortedMeshedSurface
- neither class names, nor the typedefs for the <face> and <triFace>
instances are really decided
This commit is contained in:
@ -52,10 +52,11 @@ Note
|
||||
#include "timeSelector.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "UnsortedMeshedSurfaces.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -69,7 +70,7 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("clean", "");
|
||||
argList::validOptions.insert("scale", "scale");
|
||||
argList::validOptions.insert("triSurface", "");
|
||||
argList::validOptions.insert("keyed", "");
|
||||
argList::validOptions.insert("unsorted", "");
|
||||
# include "setRootCase.H"
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
@ -122,9 +123,9 @@ int main(int argc, char *argv[])
|
||||
// write sorted by region
|
||||
surf.write(exportName, true);
|
||||
}
|
||||
else if (args.options().found("keyed"))
|
||||
else if (args.options().found("unsorted"))
|
||||
{
|
||||
keyedSurface surf(importName);
|
||||
unsortedMeshedSurface surf(importName);
|
||||
|
||||
if (args.options().found("clean"))
|
||||
{
|
||||
|
||||
@ -2,27 +2,23 @@ surfGroup/surfGroup.C
|
||||
surfGroup/surfGroupIOList.C
|
||||
surfPatchIdentifier/surfPatchIdentifier.C
|
||||
|
||||
keyedSurface/keyedSurface.C
|
||||
keyedSurface/keyedSurfaceCleanup.C
|
||||
keyedSurface/newKeyedSurface.C
|
||||
MeshedSurface/MeshedSurfaces.C
|
||||
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||
|
||||
meshedSurface/meshedSurface.C
|
||||
meshedSurface/meshedSurfaceCleanup.C
|
||||
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
|
||||
$(fileFormats)/off/OFFfileFormat.C
|
||||
$(fileFormats)/smesh/SMESHfileFormat.C
|
||||
$(fileFormats)/starcd/STARCDfileFormat.C
|
||||
$(fileFormats)/stl/STLfileFormat.C
|
||||
$(fileFormats)/stl/STLfileFormatASCII.L
|
||||
$(fileFormats)/tri/TRIfileFormat.C
|
||||
$(fileFormats)/vtk/VTKfileFormat.C
|
||||
surfaceFormats = surfaceFormats
|
||||
$(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/nas/NASsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/off/OFFsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/smesh/SMESHsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/starcd/STARCDsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatASCII.L
|
||||
$(surfaceFormats)/stl/STLsurfaceFormatCore.C
|
||||
$(surfaceFormats)/tri/TRIsurfaceFormatRunTime.C
|
||||
$(surfaceFormats)/vtk/VTKsurfaceFormatRunTime.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libsurfMesh
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshedSurface.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
@ -41,27 +41,16 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(meshedSurface, 0);
|
||||
defineMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
write,
|
||||
fileExtension
|
||||
);
|
||||
}
|
||||
|
||||
// File extension for 'native' raw format
|
||||
//! @cond localscope
|
||||
const char * const nativeExt = "ofs";
|
||||
//! @endcond localscope
|
||||
// File extension for 'native' raw format
|
||||
#undef nativeSurfaceExt
|
||||
#define nativeSurfaceExt "ofs"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::meshedSurface::triSurfInstance(const Time& d)
|
||||
template<class Face>
|
||||
Foam::fileName Foam::MeshedSurface<Face>::triSurfInstance(const Time& d)
|
||||
{
|
||||
fileName foamName(d.caseName() + "." + nativeExt);
|
||||
fileName foamName(d.caseName() + "." + nativeSurfaceExt);
|
||||
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
@ -88,7 +77,7 @@ Foam::fileName Foam::meshedSurface::triSurfInstance(const Time& d)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " meshedSurface::triSurfInstance(const Time& d)"
|
||||
Pout<< " MeshedSurface::triSurfInstance(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from " << ts[j].name()/typeName
|
||||
<< endl;
|
||||
@ -101,7 +90,7 @@ Foam::fileName Foam::meshedSurface::triSurfInstance(const Time& d)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " meshedSurface::triSurfInstance(const Time& d)"
|
||||
Pout<< " MeshedSurface::triSurfInstance(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from constant/" << endl;
|
||||
}
|
||||
@ -110,9 +99,10 @@ Foam::fileName Foam::meshedSurface::triSurfInstance(const Time& d)
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::meshedSurface::triSurfName(const Time& d)
|
||||
template<class Face>
|
||||
Foam::fileName Foam::MeshedSurface<Face>::triSurfName(const Time& d)
|
||||
{
|
||||
fileName foamName(d.caseName() + "." + nativeExt);
|
||||
fileName foamName(d.caseName() + "." + nativeSurfaceExt);
|
||||
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
@ -141,7 +131,7 @@ Foam::fileName Foam::meshedSurface::triSurfName(const Time& d)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " meshedSurface::triSurfName(const Time& d)"
|
||||
Pout<< " MeshedSurface::triSurfName(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from " << ts[j].name()/typeName
|
||||
<< endl;
|
||||
@ -154,7 +144,7 @@ Foam::fileName Foam::meshedSurface::triSurfName(const Time& d)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " meshedSurface::triSurfName(const Time& d)"
|
||||
Pout<< " MeshedSurface::triSurfName(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from constant/" << endl;
|
||||
}
|
||||
@ -162,13 +152,21 @@ Foam::fileName Foam::meshedSurface::triSurfName(const Time& d)
|
||||
return d.path()/"constant"/typeName/foamName;
|
||||
}
|
||||
|
||||
bool Foam::meshedSurface::canRead(const word& ext, const bool verbose)
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::canRead(const word& ext, const bool verbose)
|
||||
{
|
||||
return keyedSurface::canRead(ext, verbose);
|
||||
// handle 'native' format directly
|
||||
if (ext == nativeSurfaceExt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return UnsortedMeshedSurface<Face>::canRead(ext, verbose);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::canWrite(const word& ext, const bool verbose)
|
||||
{
|
||||
// perhaps sent an entire name
|
||||
word fExt(ext);
|
||||
@ -180,12 +178,12 @@ bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
|
||||
}
|
||||
|
||||
// handle 'native' format directly
|
||||
if (fExt == nativeExt)
|
||||
if (fExt == nativeSurfaceExt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
writefileExtensionMemberFunctionTablePtr_->find(fExt);
|
||||
|
||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||
@ -199,7 +197,7 @@ bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
|
||||
|
||||
Info<<"Unknown file extension for writing: " << fExt << nl;
|
||||
// compact output:
|
||||
Info<<"Valid types: ( " << nativeExt;
|
||||
Info<<"Valid types: ( " << nativeSurfaceExt;
|
||||
forAll(known, i)
|
||||
{
|
||||
Info<<" " << known[i];
|
||||
@ -214,63 +212,65 @@ bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::write
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface& surf
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "meshedSurface::write(const fileName&, const meshedSurface&) : "
|
||||
"writing meshedSurface to " << fName
|
||||
Info<< "MeshedSurface::write(const fileName&, const MeshedSurface&) : "
|
||||
"writing MeshedSurface to " << fName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'native' format directly
|
||||
if (ext == nativeExt)
|
||||
if (ext == nativeSurfaceExt)
|
||||
{
|
||||
surf.write(OFstream(fName)());
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
||||
|
||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||
{
|
||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
||||
|
||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshedSurface::write(const fileName&)"
|
||||
) << "Unknown file extension " << ext << nl << nl
|
||||
<< "Valid types are :" << endl
|
||||
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
mfIter()(fName, surf);
|
||||
FatalErrorIn
|
||||
(
|
||||
"MeshedSurface::write(const fileName&)"
|
||||
) << "Unknown file extension " << ext << nl << nl
|
||||
<< "Valid types are :" << endl
|
||||
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
mfIter()(fName, surf);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::meshedSurface::meshedSurface()
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface()
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<FaceType> >& faceLst,
|
||||
const xfer<List<Face> >& faceLst,
|
||||
const xfer<surfGroupList>& patchLst
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
patches_(patchLst)
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
@ -278,16 +278,17 @@ Foam::meshedSurface::meshedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<FaceType> >& faceLst,
|
||||
const xfer<List<Face> >& faceLst,
|
||||
const UList<label>& patchSizes,
|
||||
const UList<word>& patchNames,
|
||||
const UList<word>& patchTypes
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
@ -312,15 +313,16 @@ Foam::meshedSurface::meshedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<FaceType> >& faceLst,
|
||||
const xfer<List<Face> >& faceLst,
|
||||
const UList<label>& regionIds,
|
||||
const Map<word>& regionNames
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
@ -334,10 +336,10 @@ Foam::meshedSurface::meshedSurface
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshedSurface::meshedSurface(\n"
|
||||
"MeshedSurface::MeshedSurface(\n"
|
||||
"(\n"
|
||||
" const xfer<pointField>&,\n"
|
||||
" const xfer<List<FaceType> >&,\n"
|
||||
" const xfer<List<Face> >&,\n"
|
||||
" const UList<label>& regionIds,\n"
|
||||
" const Map<word>& regionNames\n"
|
||||
" )\n"
|
||||
@ -352,15 +354,16 @@ Foam::meshedSurface::meshedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<FaceType> >& faceLst,
|
||||
const xfer<List<Face> >& faceLst,
|
||||
const UList<label>& regionIds,
|
||||
const HashTable<label>& nameToRegionMapping
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
@ -369,10 +372,10 @@ Foam::meshedSurface::meshedSurface
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshedSurface::meshedSurface(\n"
|
||||
"MeshedSurface::MeshedSurface(\n"
|
||||
"(\n"
|
||||
" const xfer<pointField>&,\n"
|
||||
" const xfer<List<FaceType> >&,\n"
|
||||
" const xfer<List<Face> >&,\n"
|
||||
" const UList<label>& regionIds,\n"
|
||||
" const HashTable<label>& nameToRegionMapping\n"
|
||||
" )\n"
|
||||
@ -393,13 +396,14 @@ Foam::meshedSurface::meshedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const polyBoundaryMesh& bMesh,
|
||||
const bool useGlobalPoints
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
const polyMesh& mesh = bMesh.mesh();
|
||||
const polyPatchList& bPatches = bMesh;
|
||||
@ -408,7 +412,7 @@ Foam::meshedSurface::meshedSurface
|
||||
// Get patch for all of outside
|
||||
primitivePatch allBoundary
|
||||
(
|
||||
SubList<FaceType>
|
||||
SubList<Face>
|
||||
(
|
||||
mesh.faces(),
|
||||
mesh.nFaces() - nIntFaces,
|
||||
@ -455,12 +459,12 @@ Foam::meshedSurface::meshedSurface
|
||||
|
||||
#if 0
|
||||
// in preparation
|
||||
Foam::meshedSurface::meshedSurface
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const surfMesh& sMesh
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(sMesh.faces()), sMesh.points())
|
||||
ParentType(List<Face>(sMesh.faces()), sMesh.points())
|
||||
{
|
||||
const surfPatchList& sPatches = sMesh.boundaryMesh();
|
||||
|
||||
@ -488,19 +492,20 @@ Foam::meshedSurface::meshedSurface
|
||||
#endif
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), surf.points())
|
||||
ParentType(List<Face>(), surf.points())
|
||||
{
|
||||
labelList faceMap;
|
||||
surfGroupList patchLst = surf.sortedRegions(faceMap);
|
||||
patches_.transfer(patchLst);
|
||||
|
||||
const List<FaceType>& origFaces = surf.faces();
|
||||
List<FaceType> newFaces(origFaces.size());
|
||||
const List<Face>& origFaces = surf.faces();
|
||||
List<Face> newFaces(origFaces.size());
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
forAll(newFaces, faceI)
|
||||
@ -512,66 +517,74 @@ Foam::meshedSurface::meshedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const fileName& fName,
|
||||
const word& ext,
|
||||
const bool triangulate
|
||||
const word& ext
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(fName, ext, triangulate);
|
||||
read(fName, ext);
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(fName, fName.ext(), triangulate);
|
||||
read(fName, fName.ext());
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface(Istream& is, const bool triangulate)
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(Istream& is)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(is, triangulate);
|
||||
read(is);
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface(const Time& d)
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(const Time& d)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(IFstream(triSurfName(d))());
|
||||
// setDefaultPatches();
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface(const meshedSurface& surf)
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
|
||||
:
|
||||
MeshStorage(surf.faces(), surf.points()),
|
||||
ParentType(surf.faces(), surf.points()),
|
||||
patches_(surf.patches_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface(const xfer<keyedSurface>& surf)
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const xfer<UnsortedMeshedSurface<Face> >& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
transfer(surf());
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface(const xfer<meshedSurface>& surf)
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(const xfer<MeshedSurface>& surf)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
transfer(surf());
|
||||
}
|
||||
@ -580,13 +593,15 @@ Foam::meshedSurface::meshedSurface(const xfer<meshedSurface>& surf)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::meshedSurface::~meshedSurface()
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::~MeshedSurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::meshedSurface::onePatch()
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::onePatch()
|
||||
{
|
||||
// set single default patch
|
||||
patches_.setSize(1);
|
||||
@ -600,7 +615,8 @@ void Foam::meshedSurface::onePatch()
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::checkPatches()
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::checkPatches()
|
||||
{
|
||||
// extra safety, ensure we have at some patches,
|
||||
// and they cover all the faces
|
||||
@ -618,7 +634,7 @@ void Foam::meshedSurface::checkPatches()
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"meshedSurface::checkPatches()\n"
|
||||
"MeshedSurface::checkPatches()\n"
|
||||
)
|
||||
<< "more nFaces " << size()
|
||||
<< " than patches " << count
|
||||
@ -631,7 +647,7 @@ void Foam::meshedSurface::checkPatches()
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshedSurface::checkPatches()\n"
|
||||
"MeshedSurface::checkPatches()\n"
|
||||
)
|
||||
<< "more patches " << count
|
||||
<< " than nFaces " << size()
|
||||
@ -655,13 +671,14 @@ void Foam::meshedSurface::checkPatches()
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::sortFacesByRegion
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::sortFacesByRegion
|
||||
(
|
||||
const UList<label>& regionIds,
|
||||
const Map<word>& regionNames
|
||||
)
|
||||
{
|
||||
const List<FaceType>& unsortedFaces = faces();
|
||||
const List<Face>& unsortedFaces = faces();
|
||||
|
||||
if (!®ionNames || !®ionIds || regionIds.size() == 0)
|
||||
{
|
||||
@ -670,7 +687,7 @@ void Foam::meshedSurface::sortFacesByRegion
|
||||
else if (regionIds.size() == unsortedFaces.size())
|
||||
{
|
||||
labelList faceMap;
|
||||
surfGroupList newPatches = keyedSurface::sortedRegions
|
||||
surfGroupList newPatches = UnsortedMeshedSurface<Face>::sortedRegions
|
||||
(
|
||||
regionIds,
|
||||
regionNames,
|
||||
@ -679,7 +696,7 @@ void Foam::meshedSurface::sortFacesByRegion
|
||||
patches_.transfer(newPatches);
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
List<FaceType> newFaces(unsortedFaces.size());
|
||||
List<Face> newFaces(unsortedFaces.size());
|
||||
forAll(newFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = unsortedFaces[faceMap[faceI]];
|
||||
@ -691,40 +708,15 @@ void Foam::meshedSurface::sortFacesByRegion
|
||||
}
|
||||
|
||||
|
||||
// Read surf grouping, points, faces directly from Istream
|
||||
bool Foam::meshedSurface::read(Istream& is, const bool doTriangulate)
|
||||
{
|
||||
List<surfGroup> patchLst(is);
|
||||
is >> points() >> faces();
|
||||
|
||||
// copy patch info:
|
||||
patches_.setSize(patchLst.size());
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
patches_[patchI] = surfGroup
|
||||
(
|
||||
patchLst[patchI],
|
||||
patchI
|
||||
);
|
||||
}
|
||||
|
||||
if (doTriangulate)
|
||||
{
|
||||
triangulate();
|
||||
}
|
||||
|
||||
return is.good();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::meshedSurface::clear()
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::clear()
|
||||
{
|
||||
MeshStorage::clearOut();
|
||||
ParentType::clearOut();
|
||||
|
||||
points().clear();
|
||||
faces().clear();
|
||||
@ -732,47 +724,50 @@ void Foam::meshedSurface::clear()
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::movePoints(const pointField& newPoints)
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints)
|
||||
{
|
||||
// Remove all geometry dependent data
|
||||
MeshStorage::clearTopology();
|
||||
ParentType::clearTopology();
|
||||
|
||||
// Adapt for new point position
|
||||
MeshStorage::movePoints(newPoints);
|
||||
ParentType::movePoints(newPoints);
|
||||
|
||||
// Copy new points
|
||||
points() = newPoints;
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::scalePoints(const scalar& scaleFactor)
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
|
||||
{
|
||||
// avoid bad scaling
|
||||
if (scaleFactor > 0 && scaleFactor != 1.0)
|
||||
{
|
||||
// Remove all geometry dependent data
|
||||
MeshStorage::clearTopology();
|
||||
ParentType::clearTopology();
|
||||
|
||||
// Adapt for new point position
|
||||
MeshStorage::movePoints(pointField());
|
||||
ParentType::movePoints(pointField());
|
||||
|
||||
points() *= scaleFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const
|
||||
{
|
||||
const pointField& locPoints = localPoints();
|
||||
const List<FaceType>& locFaces = localFaces();
|
||||
const pointField& locPoints = ParentType::localPoints();
|
||||
const List<Face>& locFaces = ParentType::localFaces();
|
||||
|
||||
// Fill pointMap, faceMap
|
||||
subsetMap(include, pointMap, faceMap);
|
||||
ParentType::subsetMap(include, pointMap, faceMap);
|
||||
|
||||
// Create compact coordinate list and forward mapping array
|
||||
pointField newPoints(pointMap.size());
|
||||
@ -792,18 +787,18 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
||||
}
|
||||
|
||||
// Renumber face node labels and compact
|
||||
List<FaceType> newFaces(faceMap.size());
|
||||
List<Face> newFaces(faceMap.size());
|
||||
|
||||
forAll(faceMap, faceI)
|
||||
{
|
||||
// Get old vertex labels
|
||||
label origFaceI = faceMap[faceI];
|
||||
const FaceType& oldFace = locFaces[origFaceI];
|
||||
const Face& oldFace = locFaces[origFaceI];
|
||||
|
||||
newFaces[faceI] = FaceType(oldFace);
|
||||
newFaces[faceI] = Face(oldFace);
|
||||
|
||||
// Renumber labels for face
|
||||
FaceType& f = newFaces[faceI];
|
||||
Face& f = newFaces[faceI];
|
||||
forAll(f, fp)
|
||||
{
|
||||
f[fp] = oldToNew[oldFace[fp]];
|
||||
@ -835,7 +830,7 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
||||
}
|
||||
|
||||
// construct a sub-surface
|
||||
meshedSurface subSurf
|
||||
MeshedSurface subSurf
|
||||
(
|
||||
xferMove(newPoints),
|
||||
xferMove(newFaces),
|
||||
@ -846,7 +841,11 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::transfer(meshedSurface& surf)
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::transfer
|
||||
(
|
||||
MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
clear();
|
||||
|
||||
@ -858,7 +857,11 @@ void Foam::meshedSurface::transfer(meshedSurface& surf)
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::transfer(keyedSurface& surf)
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::transfer
|
||||
(
|
||||
UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
clear();
|
||||
points().transfer(surf.points());
|
||||
@ -870,8 +873,8 @@ void Foam::meshedSurface::transfer(keyedSurface& surf)
|
||||
surf.regions_.clear();
|
||||
surf.patches_.clear();
|
||||
|
||||
List<FaceType>& oldFaces = surf.faces();
|
||||
List<FaceType> newFaces(oldFaces.size());
|
||||
List<Face>& oldFaces = surf.faces();
|
||||
List<Face> newFaces(oldFaces.size());
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
forAll(newFaces, faceI)
|
||||
@ -886,101 +889,74 @@ void Foam::meshedSurface::transfer(keyedSurface& surf)
|
||||
|
||||
|
||||
// Read from file in given format
|
||||
bool Foam::meshedSurface::read
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'native' format directly
|
||||
if (ext == nativeExt)
|
||||
if (ext == nativeSurfaceExt)
|
||||
{
|
||||
return read(IFstream(fName)(), triangulate);
|
||||
return read(IFstream(fName)());
|
||||
}
|
||||
else
|
||||
{
|
||||
// use selector mechanism
|
||||
transfer(New(fName, ext, triangulate)());
|
||||
transfer(New(fName, ext)());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read from file in given format
|
||||
bool Foam::meshedSurface::read
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const word& ext,
|
||||
const bool triangulate
|
||||
const word& ext
|
||||
)
|
||||
{
|
||||
clear();
|
||||
|
||||
// handle 'native' format directly
|
||||
if (ext == nativeExt)
|
||||
if (ext == nativeSurfaceExt)
|
||||
{
|
||||
return read(IFstream(fName)(), triangulate);
|
||||
return read(IFstream(fName)());
|
||||
}
|
||||
else
|
||||
{
|
||||
// use selector mechanism
|
||||
transfer(New(fName, ext, triangulate)());
|
||||
transfer(New(fName, ext)());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::write(Ostream& os) const
|
||||
{
|
||||
// just emit some information until we get a nice IOobject
|
||||
IOobject::writeBanner(os);
|
||||
os << "// OpenFOAM Surface format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||
<< "// regions:" << nl
|
||||
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
forAll(patches_, patchI)
|
||||
{
|
||||
patches_[patchI].writeDict(os);
|
||||
}
|
||||
os << decrIndent << token::END_LIST << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Note: Write with global point numbering
|
||||
os << "\n// points:" << nl << points() << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
os << "\n// faces:" << nl << faces() << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("meshedSurface::write(Ostream&)");
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::write(const Time& d) const
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::write(const Time& d) const
|
||||
{
|
||||
write(OFstream(triSurfName(d))());
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshedSurface::writeStats(Ostream& os) const
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::writeStats(Ostream& os) const
|
||||
{
|
||||
os << "Faces : " << size() << endl
|
||||
<< "Edges : " << nEdges() << endl
|
||||
<< "Vertices : " << nPoints() << endl
|
||||
<< "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
||||
// os << "Faces : " << size() << endl
|
||||
// << "Edges : " << nEdges() << endl
|
||||
// << "Vertices : " << nPoints() << endl
|
||||
// << "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::meshedSurface::operator=(const meshedSurface& surf)
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
|
||||
{
|
||||
clear();
|
||||
|
||||
@ -993,13 +969,12 @@ void Foam::meshedSurface::operator=(const meshedSurface& surf)
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const meshedSurface& surf)
|
||||
{
|
||||
surf.write(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "MeshedSurfaceCleanup.C"
|
||||
#include "MeshedSurfaceIO.C"
|
||||
#include "MeshedSurfaceNew.C"
|
||||
|
||||
#undef nativeSurfaceExt
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,33 +23,34 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::meshedSurface
|
||||
Foam::MeshedSurface
|
||||
|
||||
Description
|
||||
A surface geometry mesh with patch information, not to be confused
|
||||
with a similarily named surfaceMesh, which actually refers to
|
||||
the cell faces of a volume mesh!
|
||||
|
||||
The meshedSurface is intended to surfaces from a variety of sources.
|
||||
The MeshedSurface is intended to surfaces from a variety of sources.
|
||||
- A set of points and faces without any patch information.
|
||||
- A set of points and faces with randomly sorted patch information.
|
||||
This could arise, for example, from reading external file formats
|
||||
such as STL, etc.
|
||||
|
||||
SourceFiles
|
||||
meshedSurface.C
|
||||
MeshedSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef meshedSurface_H
|
||||
#define meshedSurface_H
|
||||
#ifndef MeshedSurface_H
|
||||
#define MeshedSurface_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "PrimitivePatchExtra.H"
|
||||
#include "boolList.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "face.H"
|
||||
#include "xfer.H"
|
||||
#include "face.H"
|
||||
#include "triFace.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "memberFunctionSelectionTables.H"
|
||||
|
||||
@ -61,44 +62,38 @@ namespace Foam
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class Time;
|
||||
class keyedSurface;
|
||||
class meshedSurface;
|
||||
template<class Face> class MeshedSurface;
|
||||
template<class Face> class UnsortedMeshedSurface;
|
||||
|
||||
class polyBoundaryMesh;
|
||||
class surfMesh;
|
||||
|
||||
Ostream& operator<<(Ostream&, const meshedSurface&);
|
||||
template<class Face>
|
||||
Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class meshedSurface Declaration
|
||||
Class MeshedSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class meshedSurface
|
||||
template<class Face>
|
||||
class MeshedSurface
|
||||
:
|
||||
public PrimitivePatchExtra<face, ::Foam::List, pointField, point>
|
||||
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point>
|
||||
{
|
||||
friend class keyedSurface;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Data
|
||||
|
||||
//- Typedef for similar code in keyedSurface and meshedSurface
|
||||
typedef face FaceType;
|
||||
friend class UnsortedMeshedSurface<Face>;
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Data
|
||||
|
||||
// Private typedefs
|
||||
|
||||
//- Private typedefs for convenience
|
||||
typedef MeshedSurface<Face> ThisType;
|
||||
typedef PrimitivePatchExtra
|
||||
<
|
||||
FaceType,
|
||||
Face,
|
||||
::Foam::List,
|
||||
pointField,
|
||||
point
|
||||
>
|
||||
MeshStorage;
|
||||
ParentType;
|
||||
|
||||
// Private Member Data
|
||||
|
||||
@ -118,7 +113,7 @@ private:
|
||||
void sortFacesByRegion(const UList<label>&, const Map<word>&);
|
||||
|
||||
//- Read OpenFOAM Surface format
|
||||
bool read(Istream&, const bool triangulate=false);
|
||||
bool read(Istream&);
|
||||
|
||||
|
||||
protected:
|
||||
@ -128,26 +123,26 @@ protected:
|
||||
//- Return non-const access to global points
|
||||
pointField& points()
|
||||
{
|
||||
return const_cast<pointField&>(MeshStorage::points());
|
||||
return const_cast<pointField&>(ParentType::points());
|
||||
}
|
||||
|
||||
//- Return non-const access to the faces
|
||||
List<FaceType>& faces()
|
||||
List<Face>& faces()
|
||||
{
|
||||
return static_cast<List<FaceType> &>(*this);
|
||||
return static_cast<List<Face> &>(*this);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("meshedSurface");
|
||||
ClassName("MeshedSurface");
|
||||
|
||||
// Static
|
||||
|
||||
//- Name of meshedSurface directory to use.
|
||||
//- Name of MeshedSurface directory to use.
|
||||
static fileName triSurfInstance(const Time&);
|
||||
|
||||
//- Name of meshedSurface directory to use.
|
||||
//- Name of MeshedSurface directory to use.
|
||||
static fileName triSurfName(const Time&);
|
||||
|
||||
//- Can we read this file format?
|
||||
@ -160,22 +155,22 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
meshedSurface();
|
||||
MeshedSurface();
|
||||
|
||||
//- Construct by transferring components
|
||||
// (points, faces and patches).
|
||||
meshedSurface
|
||||
MeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<Face> >&,
|
||||
const xfer<surfGroupList>&
|
||||
);
|
||||
|
||||
//- Construct from points, faces, and patch information
|
||||
meshedSurface
|
||||
MeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<Face> >&,
|
||||
const UList<label>& patchSizes,
|
||||
const UList<word>& patchNames,
|
||||
const UList<word>& patchTypes
|
||||
@ -184,88 +179,90 @@ public:
|
||||
//- Construct by transferring points, faces.
|
||||
// Sort faces according to regionIds with the names of the regions,
|
||||
// or jsut set a single default patch.
|
||||
meshedSurface
|
||||
MeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<Face> >&,
|
||||
const UList<label>& regionIds = UList<label>::null(),
|
||||
const Map<word>& regionNames = Map<word>::null()
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces.
|
||||
// Sort faces according to regionIds with patch-names from hash
|
||||
meshedSurface
|
||||
MeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<Face> >&,
|
||||
const UList<label>& regionIds,
|
||||
const HashTable<label>& nameToRegionMapping
|
||||
);
|
||||
|
||||
//- Construct from a boundary mesh with local points/faces
|
||||
meshedSurface
|
||||
MeshedSurface
|
||||
(
|
||||
const polyBoundaryMesh&,
|
||||
const bool globalPoints=false
|
||||
);
|
||||
|
||||
//- Construct from a keyedSurface
|
||||
meshedSurface(const keyedSurface&);
|
||||
//- Construct from a UnsortedMeshedSurface
|
||||
MeshedSurface(const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
//- Construct from a surfMesh
|
||||
meshedSurface(const surfMesh&);
|
||||
MeshedSurface(const surfMesh&);
|
||||
|
||||
//- Construct by transferring the contents from a keyedSurface
|
||||
meshedSurface(const xfer<keyedSurface>&);
|
||||
//- Construct by transferring the contents from a UnsortedMeshedSurface
|
||||
MeshedSurface(const xfer<UnsortedMeshedSurface<Face> >&);
|
||||
|
||||
//- Construct by transferring the contents from a meshedSurface
|
||||
meshedSurface(const xfer<meshedSurface>&);
|
||||
//- Construct by transferring the contents from a MeshedSurface
|
||||
MeshedSurface(const xfer<MeshedSurface<Face> >&);
|
||||
|
||||
//- Construct from file name (uses extension to determine type)
|
||||
meshedSurface
|
||||
(
|
||||
const fileName&,
|
||||
const bool triangulate=false
|
||||
);
|
||||
MeshedSurface(const fileName&);
|
||||
|
||||
//- Construct from file name (uses extension to determine type)
|
||||
meshedSurface
|
||||
(
|
||||
const fileName&,
|
||||
const word& ext,
|
||||
const bool triangulate=false
|
||||
);
|
||||
MeshedSurface(const fileName&, const word& ext);
|
||||
|
||||
//- Construct from Istream
|
||||
meshedSurface(Istream&, const bool triangulate=false);
|
||||
MeshedSurface(Istream&);
|
||||
|
||||
//- Construct from objectRegistry
|
||||
meshedSurface(const Time&);
|
||||
MeshedSurface(const Time&);
|
||||
|
||||
//- Construct as copy
|
||||
meshedSurface(const meshedSurface&);
|
||||
MeshedSurface(const MeshedSurface&);
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
MeshedSurface,
|
||||
fileExtension,
|
||||
(
|
||||
const fileName& fName
|
||||
),
|
||||
(fName)
|
||||
);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from filename (implicit extension)
|
||||
static autoPtr<meshedSurface> New
|
||||
static autoPtr<MeshedSurface> New
|
||||
(
|
||||
const fileName&,
|
||||
const bool triangulate=false
|
||||
const fileName&
|
||||
);
|
||||
|
||||
//- Select constructed from filename (explicit extension)
|
||||
static autoPtr<meshedSurface> New
|
||||
static autoPtr<MeshedSurface> New
|
||||
(
|
||||
const fileName&,
|
||||
const word&,
|
||||
const bool triangulate=false
|
||||
const word& ext
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~meshedSurface();
|
||||
virtual ~MeshedSurface();
|
||||
|
||||
|
||||
// Member Function Selectors
|
||||
@ -273,18 +270,18 @@ public:
|
||||
declareMemberFunctionSelectionTable
|
||||
(
|
||||
void,
|
||||
meshedSurface,
|
||||
MeshedSurface,
|
||||
write,
|
||||
fileExtension,
|
||||
(
|
||||
const fileName& fName,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
),
|
||||
(fName, surf)
|
||||
);
|
||||
|
||||
//- Write to file
|
||||
static void write(const fileName&, const meshedSurface&);
|
||||
static void write(const fileName&, const MeshedSurface<Face>&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -300,25 +297,25 @@ public:
|
||||
//- Return the number of faces
|
||||
label nFaces() const
|
||||
{
|
||||
return MeshStorage::size();
|
||||
return ParentType::size();
|
||||
}
|
||||
|
||||
//- The surface size is the number of faces
|
||||
label size() const
|
||||
{
|
||||
return MeshStorage::size();
|
||||
return ParentType::size();
|
||||
}
|
||||
|
||||
//- Return const access to global points
|
||||
const pointField& points() const
|
||||
{
|
||||
return MeshStorage::points();
|
||||
return ParentType::points();
|
||||
}
|
||||
|
||||
//- Return const access to the faces
|
||||
const List<FaceType>& faces() const
|
||||
const List<Face>& faces() const
|
||||
{
|
||||
return static_cast<const List<FaceType> &>(*this);
|
||||
return static_cast<const List<Face> &>(*this);
|
||||
}
|
||||
|
||||
const surfGroupList& patches() const
|
||||
@ -358,7 +355,7 @@ public:
|
||||
|
||||
//- Return new surface.
|
||||
// Returns pointMap, faceMap from subsetMeshMap
|
||||
meshedSurface subsetMesh
|
||||
MeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
labelList& pointMap,
|
||||
@ -366,29 +363,20 @@ public:
|
||||
) const;
|
||||
|
||||
//- Transfer the contents of the argument and annull the argument
|
||||
void transfer(meshedSurface&);
|
||||
void transfer(MeshedSurface<Face>&);
|
||||
|
||||
//- Transfer the contents of the argument and annull the argument
|
||||
void transfer(keyedSurface&);
|
||||
void transfer(UnsortedMeshedSurface<Face>&);
|
||||
|
||||
|
||||
// Read
|
||||
|
||||
//- Read from file. Chooses reader based on explicit extension
|
||||
bool read
|
||||
(
|
||||
const fileName&,
|
||||
const word& ext,
|
||||
const bool triangulate=false
|
||||
);
|
||||
bool read(const fileName&, const word& ext);
|
||||
|
||||
|
||||
//- Read from file. Chooses reader based on detected extension
|
||||
virtual bool read
|
||||
(
|
||||
const fileName&,
|
||||
const bool triangulate=false
|
||||
);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
|
||||
// Write
|
||||
@ -411,11 +399,16 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
void operator=(const meshedSurface&);
|
||||
void operator=(const MeshedSurface<Face>&);
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const meshedSurface&);
|
||||
friend Ostream& operator<<
|
||||
<Face>
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -425,6 +418,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "MeshedSurface.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,24 +24,29 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "mergePoints.H"
|
||||
#include "triFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Remove badly degenerate faces, double faces.
|
||||
void Foam::meshedSurface::cleanup(const bool verbose)
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::cleanup(const bool verbose)
|
||||
{
|
||||
// merge points (already done for STL, TRI)
|
||||
stitchFaces(SMALL, verbose);
|
||||
|
||||
checkFaces(verbose);
|
||||
checkEdges(verbose);
|
||||
ParentType::checkEdges(verbose);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::stitchFaces
|
||||
(
|
||||
const scalar tol,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
pointField& pointLst = points();
|
||||
|
||||
@ -58,14 +63,14 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "meshedSurface::stitchFaces : Renumbering all faces"
|
||||
Info<< "MeshedSurface::stitchFaces : Renumbering all faces"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Set the coordinates to the merged ones
|
||||
pointLst.transfer(newPoints);
|
||||
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<Face>& faceLst = faces();
|
||||
|
||||
// ensure we have at some patches, and they cover all the faces
|
||||
checkPatches();
|
||||
@ -83,7 +88,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
label patchEnd = oldFaceI + p.size();
|
||||
for (; oldFaceI < patchEnd; ++oldFaceI)
|
||||
{
|
||||
FaceType& f = faceLst[oldFaceI];
|
||||
Face& f = faceLst[oldFaceI];
|
||||
forAll (f, fp)
|
||||
{
|
||||
f[fp] = pointMap[f[fp]];
|
||||
@ -99,7 +104,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
}
|
||||
else if (verbose)
|
||||
{
|
||||
Pout<< "meshedSurface::stitchFaces : "
|
||||
Pout<< "MeshedSurface::stitchFaces : "
|
||||
<< "Removing collapsed face " << oldFaceI << endl
|
||||
<< " vertices :" << f << endl;
|
||||
}
|
||||
@ -113,7 +118,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
Pout<< "meshedSurface::stitchFaces : "
|
||||
Pout<< "MeshedSurface::stitchFaces : "
|
||||
<< "Removed " << faceLst.size() - newFaceI
|
||||
<< " faces" << endl;
|
||||
}
|
||||
@ -122,7 +127,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
|
||||
|
||||
// Merging points might have changed geometric factors
|
||||
MeshStorage::clearOut();
|
||||
ParentType::clearOut();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -130,23 +135,24 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
|
||||
|
||||
// Remove badly degenerate faces and double faces.
|
||||
void Foam::meshedSurface::checkFaces(const bool verbose)
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::checkFaces(const bool verbose)
|
||||
{
|
||||
// Simple check on indices ok.
|
||||
const label maxPointI = points().size() - 1;
|
||||
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<Face>& faceLst = faces();
|
||||
|
||||
// Phase 0: detect badly labelled faces
|
||||
forAll (faceLst, faceI)
|
||||
{
|
||||
const FaceType& f = faceLst[faceI];
|
||||
const Face& f = faceLst[faceI];
|
||||
|
||||
forAll (f, fp)
|
||||
{
|
||||
if (f[fp] < 0 || f[fp] > maxPointI)
|
||||
{
|
||||
FatalErrorIn("meshedSurface::checkFaces(bool)")
|
||||
FatalErrorIn("MeshedSurface::checkFaces(bool)")
|
||||
<< "face " << f
|
||||
<< " uses point indices outside point range 0.."
|
||||
<< maxPointI
|
||||
@ -160,7 +166,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
||||
|
||||
// Phase 1: find and skip over invalid faces
|
||||
// Phase 2: pack
|
||||
const labelListList& fFaces = faceFaces();
|
||||
const labelListList& fFaces = ParentType::faceFaces();
|
||||
|
||||
label oldFaceI = 0;
|
||||
label newFaceI = 0;
|
||||
@ -174,7 +180,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
||||
label patchEnd = oldFaceI + p.size();
|
||||
for (; oldFaceI < patchEnd; ++oldFaceI)
|
||||
{
|
||||
FaceType& f = faceLst[oldFaceI];
|
||||
Face& f = faceLst[oldFaceI];
|
||||
|
||||
// 'degenerate' face check
|
||||
if (f.collapse() >= 3)
|
||||
@ -203,7 +209,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"meshedSurface::checkFaces(bool verbose)"
|
||||
"MeshedSurface::checkFaces(bool verbose)"
|
||||
) << "faces share the same vertices:\n"
|
||||
<< " face 1 :" << oldFaceI << endl;
|
||||
// printFace(Warning, " ", f, points());
|
||||
@ -232,7 +238,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"meshedSurface::checkFaces(bool verbose)"
|
||||
"MeshedSurface::checkFaces(bool verbose)"
|
||||
) << "face " << oldFaceI
|
||||
<< " has fewer than three unique vertices:\n";
|
||||
// printTriangle(Warning, " ", f, points());
|
||||
@ -249,22 +255,23 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"meshedSurface::checkFaces(bool verbose)"
|
||||
"MeshedSurface::checkFaces(bool verbose)"
|
||||
) << "Removed " << faceLst.size() - newFaceI
|
||||
<< " illegal faces." << endl;
|
||||
}
|
||||
faceLst.setSize(newFaceI);
|
||||
|
||||
// Topology can change because of renumbering
|
||||
MeshStorage::clearOut();
|
||||
ParentType::clearOut();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::meshedSurface::triangulate()
|
||||
template<class Face>
|
||||
Foam::label Foam::MeshedSurface<Face>::triangulate()
|
||||
{
|
||||
label nTri = 0;
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<Face>& faceLst = faces();
|
||||
|
||||
// determine how many triangles are needed
|
||||
forAll (faceLst, faceI)
|
||||
@ -278,7 +285,7 @@ Foam::label Foam::meshedSurface::triangulate()
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<FaceType> newFaces(nTri);
|
||||
List<Face> newFaces(nTri);
|
||||
|
||||
// note the number of *additional* faces
|
||||
nTri -= faceLst.size();
|
||||
@ -296,7 +303,7 @@ Foam::label Foam::meshedSurface::triangulate()
|
||||
label patchEnd = oldFaceI + p.size();
|
||||
for (; oldFaceI < patchEnd; ++oldFaceI)
|
||||
{
|
||||
const FaceType& f = faceLst[oldFaceI];
|
||||
const Face& f = faceLst[oldFaceI];
|
||||
triFace fTri;
|
||||
|
||||
// Do simple face triangulation around f[0].
|
||||
125
src/surfMesh/MeshedSurface/MeshedSurfaceIO.C
Normal file
125
src/surfMesh/MeshedSurface/MeshedSurfaceIO.C
Normal file
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Read surf grouping, points, faces directly from Istream
|
||||
template<class Face>
|
||||
bool Foam::MeshedSurface<Face>::read(Istream& is)
|
||||
{
|
||||
clear();
|
||||
|
||||
// triangulation required?
|
||||
bool mustTriangulate = false;
|
||||
{
|
||||
Face f;
|
||||
if (f.max_size() == 3)
|
||||
{
|
||||
mustTriangulate = true;
|
||||
}
|
||||
}
|
||||
|
||||
List<surfGroup> patchLst(is);
|
||||
|
||||
// copy and set the indices
|
||||
patches_.setSize(patchLst.size());
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
patches_[patchI] = surfGroup
|
||||
(
|
||||
patchLst[patchI],
|
||||
patchI
|
||||
);
|
||||
}
|
||||
|
||||
// read points:
|
||||
is >> points();
|
||||
|
||||
// read faces:
|
||||
// TODO - specialization to triangulate on-the-fly
|
||||
if (mustTriangulate)
|
||||
{
|
||||
is >> faces();
|
||||
}
|
||||
else
|
||||
{
|
||||
is >> faces();
|
||||
}
|
||||
|
||||
return is.good();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::write(Ostream& os) const
|
||||
{
|
||||
// just emit some information until we get a nice IOobject
|
||||
IOobject::writeBanner(os);
|
||||
os << "// OpenFOAM Surface format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||
<< "// regions:" << nl
|
||||
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
forAll(patches_, patchI)
|
||||
{
|
||||
patches_[patchI].writeDict(os);
|
||||
}
|
||||
os << decrIndent << token::END_LIST << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Note: Write with global point numbering
|
||||
os << "\n// points:" << nl << points() << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
os << "\n// faces:" << nl << faces() << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("MeshedSurface::write(Ostream&)");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
surf.write(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,50 +24,49 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// all input is indirect via keyedSurface
|
||||
Foam::autoPtr<Foam::meshedSurface>
|
||||
Foam::meshedSurface::New
|
||||
// all input is indirect via UnsortedMeshedSurface
|
||||
template<class Face>
|
||||
Foam::autoPtr<Foam::MeshedSurface<Face> >
|
||||
Foam::MeshedSurface<Face>::New
|
||||
(
|
||||
const fileName& fName,
|
||||
const word& ext,
|
||||
const bool triangulate
|
||||
const word& ext
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "meshedSurface::New(const fileName&, const word&, const bool) : "
|
||||
"constructing meshedSurface"
|
||||
Info<< "MeshedSurface::New(const fileName&, const word&) : "
|
||||
"constructing MeshedSurface"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// created indirectly via keyedSurface
|
||||
autoPtr<meshedSurface> surf(new meshedSurface);
|
||||
surf().transfer( keyedSurface::New(fName,ext,triangulate)() );
|
||||
// created indirectly via UnsortedMeshedSurface
|
||||
autoPtr<MeshedSurface<Face> > surf(new MeshedSurface<Face>);
|
||||
surf().transfer( UnsortedMeshedSurface<Face>::New(fName,ext)() );
|
||||
|
||||
return surf;
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::meshedSurface>
|
||||
Foam::meshedSurface::New
|
||||
template<class Face>
|
||||
Foam::autoPtr<Foam::MeshedSurface<Face> >
|
||||
Foam::MeshedSurface<Face>::New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "meshedSurface::New(const fileName&, const bool) : "
|
||||
"constructing meshedSurface"
|
||||
Info<< "MeshedSurface::New(const fileName&) : "
|
||||
"constructing MeshedSurface"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return New(fName, fName.ext(), triangulate);
|
||||
return New(fName, fName.ext());
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
48
src/surfMesh/MeshedSurface/MeshedSurfaces.C
Normal file
48
src/surfMesh/MeshedSurface/MeshedSurfaces.C
Normal file
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "MeshedSurfaces.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
#define makeMeshedSurface(surfaceType) \
|
||||
defineNamedTemplateTypeNameAndDebug(surfaceType, 0); \
|
||||
defineTemplateMemberFunctionSelectionTable(surfaceType,write,fileExtension); \
|
||||
defineTemplateRunTimeSelectionTable(surfaceType, fileExtension);
|
||||
|
||||
makeMeshedSurface(meshedSurface)
|
||||
makeMeshedSurface(triMeshedSurface)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
35
src/surfMesh/MeshedSurface/MeshedSurfaces.H
Normal file
35
src/surfMesh/MeshedSurface/MeshedSurfaces.H
Normal file
@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MeshedSurfaces_H
|
||||
#define MeshedSurfaces_H
|
||||
|
||||
#include "MeshedSurface.H"
|
||||
#include "MeshedSurfacesFwd.H"
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
53
src/surfMesh/MeshedSurface/MeshedSurfacesFwd.H
Normal file
53
src/surfMesh/MeshedSurface/MeshedSurfacesFwd.H
Normal file
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MeshedSurfacesFwd_H
|
||||
#define MeshedSurfacesFwd_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class face;
|
||||
class triFace;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face> class MeshedSurface;
|
||||
|
||||
typedef MeshedSurface<face> meshedSurface;
|
||||
typedef MeshedSurface<triFace> triMeshedSurface;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,14 +24,12 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
#include "boundBox.H"
|
||||
#include "SortableList.H"
|
||||
#include "polyBoundaryMesh.H"
|
||||
#include "polyMesh.H"
|
||||
#include "primitivePatch.H"
|
||||
@ -39,27 +37,14 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(keyedSurface, 0);
|
||||
defineRunTimeSelectionTable(keyedSurface, fileExtension);
|
||||
defineMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
write,
|
||||
fileExtension
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// File extension for 'native' raw format
|
||||
//! @cond localscope
|
||||
const char * const nativeExt = "ofs";
|
||||
//! @endcond localscope
|
||||
// File extension for 'native' raw format
|
||||
#undef nativeSurfaceExt
|
||||
#define nativeSurfaceExt "ofs"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::string Foam::keyedSurface::getLineNoComment(IFstream& is)
|
||||
template<class Face>
|
||||
Foam::string Foam::UnsortedMeshedSurface<Face>::getLineNoComment(IFstream& is)
|
||||
{
|
||||
string line;
|
||||
do
|
||||
@ -71,10 +56,10 @@ Foam::string Foam::keyedSurface::getLineNoComment(IFstream& is)
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::keyedSurface::triSurfInstance(const Time& d)
|
||||
template<class Face>
|
||||
Foam::fileName Foam::UnsortedMeshedSurface<Face>::triSurfInstance(const Time& d)
|
||||
{
|
||||
fileName foamName(d.caseName() + "." + nativeExt);
|
||||
fileName foamName(d.caseName() + "." + nativeSurfaceExt);
|
||||
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
@ -101,7 +86,7 @@ Foam::fileName Foam::keyedSurface::triSurfInstance(const Time& d)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " keyedSurface::triSurfInstance(const Time& d)"
|
||||
Pout<< " UnsortedMeshedSurface::triSurfInstance(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from " << ts[j].name()/typeName
|
||||
<< endl;
|
||||
@ -114,7 +99,7 @@ Foam::fileName Foam::keyedSurface::triSurfInstance(const Time& d)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " keyedSurface::triSurfInstance(const Time& d)"
|
||||
Pout<< " UnsortedMeshedSurface::triSurfInstance(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from constant/" << endl;
|
||||
}
|
||||
@ -123,9 +108,10 @@ Foam::fileName Foam::keyedSurface::triSurfInstance(const Time& d)
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::keyedSurface::triSurfName(const Time& d)
|
||||
template<class Face>
|
||||
Foam::fileName Foam::UnsortedMeshedSurface<Face>::triSurfName(const Time& d)
|
||||
{
|
||||
fileName foamName(d.caseName() + "." + nativeExt);
|
||||
fileName foamName(d.caseName() + "." + nativeSurfaceExt);
|
||||
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
@ -154,7 +140,7 @@ Foam::fileName Foam::keyedSurface::triSurfName(const Time& d)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " keyedSurface::triSurfName(const Time& d)"
|
||||
Pout<< " UnsortedMeshedSurface::triSurfName(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from " << ts[j].name()/typeName
|
||||
<< endl;
|
||||
@ -167,7 +153,7 @@ Foam::fileName Foam::keyedSurface::triSurfName(const Time& d)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " keyedSurface::triSurfName(const Time& d)"
|
||||
Pout<< " UnsortedMeshedSurface::triSurfName(const Time& d)"
|
||||
<< "reading " << foamName
|
||||
<< " from constant/" << endl;
|
||||
}
|
||||
@ -176,7 +162,12 @@ Foam::fileName Foam::keyedSurface::triSurfName(const Time& d)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::keyedSurface::canRead(const word& ext, const bool verbose)
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::canRead
|
||||
(
|
||||
const word& ext,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
// perhaps sent an entire name
|
||||
word fExt(ext);
|
||||
@ -188,12 +179,12 @@ bool Foam::keyedSurface::canRead(const word& ext, const bool verbose)
|
||||
}
|
||||
|
||||
// handle 'native' format directly
|
||||
if (fExt == nativeExt)
|
||||
if (fExt == nativeSurfaceExt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
fileExtensionConstructorTable::iterator cstrIter =
|
||||
typename fileExtensionConstructorTable::iterator cstrIter =
|
||||
fileExtensionConstructorTablePtr_->find(fExt);
|
||||
|
||||
// would be nice to have information about which format this actually is
|
||||
@ -208,7 +199,7 @@ bool Foam::keyedSurface::canRead(const word& ext, const bool verbose)
|
||||
|
||||
Info<<"Unknown file extension for reading: " << fExt << nl;
|
||||
// compact output:
|
||||
Info<<"Valid types: ( " << nativeExt;
|
||||
Info<<"Valid types: ( " << nativeSurfaceExt;
|
||||
forAll(known, i)
|
||||
{
|
||||
Info<<" " << known[i];
|
||||
@ -222,7 +213,12 @@ bool Foam::keyedSurface::canRead(const word& ext, const bool verbose)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::keyedSurface::canWrite(const word& ext, const bool verbose)
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::canWrite
|
||||
(
|
||||
const word& ext,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
// perhaps sent an entire name
|
||||
word fExt(ext);
|
||||
@ -234,12 +230,12 @@ bool Foam::keyedSurface::canWrite(const word& ext, const bool verbose)
|
||||
}
|
||||
|
||||
// handle 'native' format directly
|
||||
if (fExt == nativeExt)
|
||||
if (fExt == nativeSurfaceExt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
writefileExtensionMemberFunctionTablePtr_->find(fExt);
|
||||
|
||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||
@ -253,7 +249,7 @@ bool Foam::keyedSurface::canWrite(const word& ext, const bool verbose)
|
||||
|
||||
Info<<"Unknown file extension for writing: " << fExt << nl;
|
||||
// compact output:
|
||||
Info<<"Valid types: ( " << nativeExt;
|
||||
Info<<"Valid types: ( " << nativeSurfaceExt;
|
||||
forAll(known, i)
|
||||
{
|
||||
Info<<" " << known[i];
|
||||
@ -268,51 +264,53 @@ bool Foam::keyedSurface::canWrite(const word& ext, const bool verbose)
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::write
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "keyedSurface::write(const fileName&, const keyedSurface&) : "
|
||||
"writing keyedSurface to " << fName
|
||||
Info<< "UnsortedMeshedSurface::write(const fileName&, const UnsortedMeshedSurface&) : "
|
||||
"writing UnsortedMeshedSurface to " << fName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'native' format directly
|
||||
if (ext == nativeExt)
|
||||
if (ext == nativeSurfaceExt)
|
||||
{
|
||||
surf.write(OFstream(fName)());
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
||||
|
||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||
{
|
||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
||||
|
||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"keyedSurface::write(const fileName&, const keyedSurface&)"
|
||||
) << "Unknown file extension " << ext << nl << nl
|
||||
<< "Valid types are :" << endl
|
||||
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
mfIter()(fName, surf);
|
||||
FatalErrorIn
|
||||
(
|
||||
"UnsortedMeshedSurface::write"
|
||||
"(const fileName&, const UnsortedMeshedSurface&)"
|
||||
) << "Unknown file extension " << ext << nl << nl
|
||||
<< "Valid types are :" << endl
|
||||
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
mfIter()(fName, surf);
|
||||
}
|
||||
|
||||
|
||||
// Returns patch info.
|
||||
// Sets faceMap to the indexing according to patch numbers.
|
||||
// Patch numbers start at 0.
|
||||
Foam::surfGroupList Foam::keyedSurface::sortedRegions
|
||||
template<class Face>
|
||||
Foam::surfGroupList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
||||
(
|
||||
const UList<label>& regionLst,
|
||||
const Map<word>& patchNames,
|
||||
@ -396,21 +394,23 @@ Foam::surfGroupList Foam::keyedSurface::sortedRegions
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::keyedSurface::keyedSurface()
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface()
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<face> >& faceLst,
|
||||
const xfer<List<Face> >& faceLst,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const xfer<surfPatchIdentifierList>& patchLst
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
regions_(regionIds),
|
||||
patches_(patchLst)
|
||||
{
|
||||
@ -419,15 +419,16 @@ Foam::keyedSurface::keyedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<face> >& faceLst,
|
||||
const xfer<List<Face> >& faceLst,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const Map<word>& regionNames
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
regions_(regionIds)
|
||||
{
|
||||
faces().transfer(faceLst());
|
||||
@ -446,15 +447,16 @@ Foam::keyedSurface::keyedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<face> >& faceLst,
|
||||
const xfer<List<Face> >& faceLst,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const HashTable<label>& labelToRegion
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
regions_(regionIds)
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
@ -465,13 +467,14 @@ Foam::keyedSurface::keyedSurface
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<face> >& faceLst
|
||||
const xfer<List<Face> >& faceLst
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
regions_(faceLst().size(), 0), // single default patch
|
||||
patches_()
|
||||
{
|
||||
@ -482,14 +485,15 @@ Foam::keyedSurface::keyedSurface
|
||||
}
|
||||
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
#if 0
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const polyBoundaryMesh& bMesh,
|
||||
const bool useGlobalPoints
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
const polyMesh& mesh = bMesh.mesh();
|
||||
const polyPatchList& bPatches = bMesh;
|
||||
@ -500,7 +504,7 @@ Foam::keyedSurface::keyedSurface
|
||||
// Get patch for all of outside
|
||||
primitivePatch allBoundary
|
||||
(
|
||||
SubList<face>
|
||||
SubList<Face>
|
||||
(
|
||||
mesh.faces(),
|
||||
mesh.nFaces() - nIntFaces,
|
||||
@ -509,8 +513,8 @@ Foam::keyedSurface::keyedSurface
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
List<FaceType> newFaces(allBoundary.size());
|
||||
List<label> newRegions(allBoundary.size());
|
||||
List<Face> newFaces(allBoundary.size());
|
||||
List<label> newRegions(allBoundary.size());
|
||||
|
||||
if (useGlobalPoints)
|
||||
{
|
||||
@ -524,7 +528,7 @@ Foam::keyedSurface::keyedSurface
|
||||
}
|
||||
|
||||
// global or local face addressing
|
||||
const List<face>& bfaces =
|
||||
const List<Face>& bfaces =
|
||||
(
|
||||
useGlobalPoints
|
||||
? allBoundary
|
||||
@ -554,20 +558,23 @@ Foam::keyedSurface::keyedSurface
|
||||
regions_.transfer(newRegions);
|
||||
patches_.transfer(newPatches);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
#if 0
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), surf.points())
|
||||
ParentType(List<Face>(), surf.points())
|
||||
{
|
||||
const List<face>& origFaces = surf.faces();
|
||||
const List<Face>& origFaces = surf.faces();
|
||||
const surfGroupList& patchLst = surf.patches();
|
||||
|
||||
List<FaceType> newFaces(origFaces.size());
|
||||
List<label> newRegions(origFaces.size());
|
||||
List<Face> newFaces(origFaces.size());
|
||||
List<label> newRegions(origFaces.size());
|
||||
List<PatchRegionType> newPatches(patchLst.size());
|
||||
|
||||
label faceIndex = 0;
|
||||
@ -586,123 +593,106 @@ Foam::keyedSurface::keyedSurface
|
||||
regions_.transfer(newRegions);
|
||||
patches_.transfer(newPatches);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const fileName& fName,
|
||||
const word& ext,
|
||||
const bool triangulate
|
||||
const word& ext
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(fName, ext, triangulate);
|
||||
read(fName, ext);
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(fName, fName.ext(), triangulate);
|
||||
read(fName, fName.ext());
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface(Istream& is, const bool triangulate)
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(is, triangulate);
|
||||
read(is);
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface(const Time& d)
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const Time& d)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(IFstream(triSurfName(d))());
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface(const keyedSurface& surf)
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(surf.faces(), surf.points()),
|
||||
ParentType(surf.faces(), surf.points()),
|
||||
regions_(surf.regions_),
|
||||
patches_(surf.patches_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface(const xfer<keyedSurface>& surf)
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<UnsortedMeshedSurface<Face> >& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
regions_(),
|
||||
patches_()
|
||||
{
|
||||
transfer(surf());
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface(const xfer<meshedSurface>& surf)
|
||||
#if 0
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<MeshedSurface<Face> >& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
regions_(),
|
||||
patches_()
|
||||
{
|
||||
transfer(surf());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::keyedSurface::~keyedSurface()
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// Read surf grouping, points, faces directly from Istream
|
||||
bool Foam::keyedSurface::read(Istream& is, const bool doTriangulate)
|
||||
{
|
||||
clear();
|
||||
|
||||
List<surfGroup> patchLst(is);
|
||||
is >> points() >> faces();
|
||||
|
||||
patches_.setSize(patchLst.size());
|
||||
regions_.setSize(size());
|
||||
|
||||
// copy patch info and set regions:
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
patches_[patchI] = PatchRegionType
|
||||
(
|
||||
patchLst[patchI],
|
||||
patchI
|
||||
);
|
||||
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
regions_[faceIndex++] = patchI;
|
||||
}
|
||||
}
|
||||
|
||||
if (doTriangulate)
|
||||
{
|
||||
triangulate();
|
||||
}
|
||||
|
||||
return is.good();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::keyedSurface::setPatches(const label maxPatch)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches(const label maxPatch)
|
||||
{
|
||||
patches_.setSize(maxPatch+1);
|
||||
|
||||
@ -717,7 +707,8 @@ void Foam::keyedSurface::setPatches(const label maxPatch)
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::setPatches()
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches()
|
||||
{
|
||||
label maxPatch = 0;
|
||||
|
||||
@ -736,8 +727,8 @@ void Foam::keyedSurface::setPatches()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::keyedSurface::setPatches
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
(
|
||||
const Map<word>& regionNames,
|
||||
const label maxPatchHint
|
||||
@ -786,7 +777,8 @@ void Foam::keyedSurface::setPatches
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::setPatches
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
(
|
||||
const HashTable<label>& groupToPatch
|
||||
)
|
||||
@ -810,16 +802,18 @@ void Foam::keyedSurface::setPatches
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::keyedSurface::setSize(const label s)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
|
||||
{
|
||||
MeshStorage::setSize(s);
|
||||
ParentType::setSize(s);
|
||||
regions_.setSize(s);
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::clear()
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::clear()
|
||||
{
|
||||
MeshStorage::clearOut();
|
||||
ParentType::clearOut();
|
||||
|
||||
points().clear();
|
||||
faces().clear();
|
||||
@ -828,7 +822,8 @@ void Foam::keyedSurface::clear()
|
||||
}
|
||||
|
||||
|
||||
Foam::surfGroupList Foam::keyedSurface::sortedRegions
|
||||
template<class Face>
|
||||
Foam::surfGroupList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
||||
(
|
||||
labelList& faceMap
|
||||
) const
|
||||
@ -844,48 +839,50 @@ Foam::surfGroupList Foam::keyedSurface::sortedRegions
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::movePoints(const pointField& newPoints)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::movePoints(const pointField& newPoints)
|
||||
{
|
||||
// Remove all geometry dependent data
|
||||
MeshStorage::clearTopology();
|
||||
ParentType::clearTopology();
|
||||
|
||||
// Adapt for new point position
|
||||
MeshStorage::movePoints(newPoints);
|
||||
ParentType::movePoints(newPoints);
|
||||
|
||||
// Copy new points
|
||||
points() = newPoints;
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::scalePoints(const scalar& scaleFactor)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
|
||||
{
|
||||
// avoid bad scaling
|
||||
if (scaleFactor > 0 && scaleFactor != 1.0)
|
||||
{
|
||||
// Remove all geometry dependent data
|
||||
MeshStorage::clearTopology();
|
||||
ParentType::clearTopology();
|
||||
|
||||
// Adapt for new point position
|
||||
MeshStorage::movePoints(pointField());
|
||||
ParentType::movePoints(pointField());
|
||||
|
||||
points() *= scaleFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Foam::keyedSurface Foam::keyedSurface::subsetMesh
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const
|
||||
{
|
||||
const pointField& locPoints = localPoints();
|
||||
const List<FaceType>& locFaces = localFaces();
|
||||
const pointField& locPoints = ParentType::localPoints();
|
||||
const List<Face>& locFaces = ParentType::localFaces();
|
||||
|
||||
// Fill pointMap, faceMap
|
||||
subsetMap(include, pointMap, faceMap);
|
||||
ParentType::subsetMap(include, pointMap, faceMap);
|
||||
|
||||
// Create compact coordinate list and forward mapping array
|
||||
pointField newPoints(pointMap.size());
|
||||
@ -897,17 +894,17 @@ Foam::keyedSurface Foam::keyedSurface::subsetMesh
|
||||
}
|
||||
|
||||
// Renumber face node labels and compact
|
||||
List<FaceType> newFaces(faceMap.size());
|
||||
List<Face> newFaces(faceMap.size());
|
||||
|
||||
forAll(faceMap, faceI)
|
||||
{
|
||||
// Get old vertex labels
|
||||
const FaceType& oldFace = locFaces[faceMap[faceI]];
|
||||
const Face& oldFace = locFaces[faceMap[faceI]];
|
||||
|
||||
newFaces[faceI] = FaceType(oldFace);
|
||||
newFaces[faceI] = Face(oldFace);
|
||||
|
||||
// Renumber labels for face
|
||||
FaceType& f = newFaces[faceI];
|
||||
Face& f = newFaces[faceI];
|
||||
forAll(f, fp)
|
||||
{
|
||||
f[fp] = oldToNew[oldFace[fp]];
|
||||
@ -915,7 +912,7 @@ Foam::keyedSurface Foam::keyedSurface::subsetMesh
|
||||
}
|
||||
|
||||
// construct a sub-surface
|
||||
keyedSurface subSurf;
|
||||
UnsortedMeshedSurface<Face> subSurf;
|
||||
(
|
||||
xferMove(newPoints),
|
||||
xferMove(newFaces),
|
||||
@ -926,7 +923,11 @@ Foam::keyedSurface Foam::keyedSurface::subsetMesh
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::transfer(keyedSurface& surf)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::transfer
|
||||
(
|
||||
UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
clear();
|
||||
|
||||
@ -939,7 +940,12 @@ void Foam::keyedSurface::transfer(keyedSurface& surf)
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::transfer(meshedSurface& surf)
|
||||
#if 0
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::transfer
|
||||
(
|
||||
MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
surfGroupList& patchLst = surf.patches();
|
||||
|
||||
@ -965,125 +971,81 @@ void Foam::keyedSurface::transfer(meshedSurface& surf)
|
||||
patchLst.clear();
|
||||
surf.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Read from file in given format
|
||||
bool Foam::keyedSurface::read
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'native' format directly
|
||||
if (ext == nativeExt)
|
||||
if (ext == nativeSurfaceExt)
|
||||
{
|
||||
return read(IFstream(fName)(), triangulate);
|
||||
return read(IFstream(fName)());
|
||||
}
|
||||
else
|
||||
{
|
||||
// use selector mechanism
|
||||
transfer(New(fName, ext, triangulate)());
|
||||
transfer(New(fName, ext)());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read from file in given format
|
||||
bool Foam::keyedSurface::read
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const word& ext,
|
||||
const bool triangulate
|
||||
const word& ext
|
||||
)
|
||||
{
|
||||
clear();
|
||||
|
||||
// handle 'native' format directly
|
||||
if (ext == nativeExt)
|
||||
if (ext == nativeSurfaceExt)
|
||||
{
|
||||
return read(IFstream(fName)(), triangulate);
|
||||
return read(IFstream(fName)());
|
||||
}
|
||||
else
|
||||
{
|
||||
// use selector mechanism
|
||||
transfer(New(fName, ext, triangulate)());
|
||||
transfer(New(fName, ext)());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write (sorted)
|
||||
void Foam::keyedSurface::write(Ostream& os) const
|
||||
{
|
||||
const List<face>& faceLst = faces();
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = sortedRegions(faceMap);
|
||||
|
||||
// just emit some information until we get a nice IOobject
|
||||
IOobject::writeBanner(os);
|
||||
os << "// OpenFOAM Surface format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||
<< "// regions:" << nl
|
||||
<< patchLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
patchLst[patchI].writeDict(os);
|
||||
}
|
||||
os << decrIndent << token::END_LIST << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Note: Write with global point numbering
|
||||
os << "\n// points:" << nl << points() << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
os << "\n// faces:" << nl;
|
||||
os << faceLst.size() << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
os << f << nl;
|
||||
}
|
||||
}
|
||||
os << token::END_LIST << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("meshedSurface::write(Ostream&)");
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::write(const Time& d) const
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::write(const Time& d) const
|
||||
{
|
||||
write(OFstream(triSurfName(d))());
|
||||
}
|
||||
|
||||
|
||||
void Foam::keyedSurface::writeStats(Ostream& os) const
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::writeStats(Ostream& os) const
|
||||
{
|
||||
os << "Faces : " << size() << endl
|
||||
<< "Edges : " << nEdges() << endl
|
||||
<< "Vertices : " << nPoints() << endl
|
||||
<< "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
||||
// os << "Faces : " << size() << endl
|
||||
// << "Edges : " << nEdges() << endl
|
||||
// << "Vertices : " << nPoints() << endl
|
||||
// << "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::keyedSurface::operator=(const keyedSurface& surf)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::operator=
|
||||
(
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
clear();
|
||||
faces() = surf.faces();
|
||||
@ -1097,13 +1059,12 @@ void Foam::keyedSurface::operator=(const keyedSurface& surf)
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const keyedSurface& surf)
|
||||
{
|
||||
surf.write(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "UnsortedMeshedSurfaceCleanup.C"
|
||||
#include "UnsortedMeshedSurfaceIO.C"
|
||||
#include "UnsortedMeshedSurfaceNew.C"
|
||||
|
||||
#undef nativeSurfaceExt
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::keyedSurface
|
||||
Foam::UnsortedMeshedSurface
|
||||
|
||||
Description
|
||||
A surface geometry mesh, in which the patch information is conveyed by
|
||||
@ -40,20 +40,21 @@ See Also
|
||||
with independent patch information.
|
||||
|
||||
SourceFiles
|
||||
keyedSurface.C
|
||||
UnsortedMeshedSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef keyedSurface_H
|
||||
#define keyedSurface_H
|
||||
#ifndef UnsortedMeshedSurface_H
|
||||
#define UnsortedMeshedSurface_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "PrimitivePatchExtra.H"
|
||||
#include "boolList.H"
|
||||
#include "surfPatchIdentifierList.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "face.H"
|
||||
#include "xfer.H"
|
||||
#include "face.H"
|
||||
#include "triFace.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "memberFunctionSelectionTables.H"
|
||||
|
||||
@ -66,45 +67,45 @@ namespace Foam
|
||||
|
||||
class Time;
|
||||
class IFstream;
|
||||
class keyedSurface;
|
||||
class meshedSurface;
|
||||
template<class Face> class UnsortedMeshedSurface;
|
||||
template<class Face> class MeshedSurface;
|
||||
|
||||
class polyBoundaryMesh;
|
||||
|
||||
Ostream& operator<<(Ostream&, const keyedSurface&);
|
||||
template<class Face>
|
||||
Ostream& operator<<(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class keyedSurface Declaration
|
||||
Class UnsortedMeshedSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class keyedSurface
|
||||
template<class Face>
|
||||
class UnsortedMeshedSurface
|
||||
:
|
||||
public PrimitivePatchExtra<face, ::Foam::List, pointField, point>
|
||||
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point>
|
||||
{
|
||||
friend class meshedSurface;
|
||||
friend class MeshedSurface<Face>;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Data
|
||||
|
||||
//- Typedef for similar code in keyedSurface and meshedSurface
|
||||
typedef face FaceType;
|
||||
|
||||
//- Typedef for type holding the region (patch) informationm
|
||||
typedef surfPatchIdentifier PatchRegionType;
|
||||
|
||||
private:
|
||||
|
||||
// Private typedefs
|
||||
|
||||
//- Private typedefs for convenience
|
||||
typedef UnsortedMeshedSurface<Face> ThisType;
|
||||
typedef PrimitivePatchExtra
|
||||
<
|
||||
FaceType,
|
||||
Face,
|
||||
::Foam::List,
|
||||
pointField,
|
||||
point
|
||||
>
|
||||
MeshStorage;
|
||||
ParentType;
|
||||
|
||||
// Private Member Data
|
||||
|
||||
@ -118,10 +119,10 @@ private:
|
||||
// Private member functions
|
||||
|
||||
//- Disable setSize with value
|
||||
void setSize(const label, const FaceType&);
|
||||
void setSize(const label, const Face&);
|
||||
|
||||
//- Read OpenFOAM Surface format
|
||||
bool read(Istream&, const bool triangulate=false);
|
||||
bool read(Istream&);
|
||||
|
||||
protected:
|
||||
|
||||
@ -130,6 +131,7 @@ protected:
|
||||
//- Read non-comment line
|
||||
static string getLineNoComment(IFstream&);
|
||||
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
//- Sets default patch names based on the maximum patch number
|
||||
@ -151,13 +153,13 @@ protected:
|
||||
//- Return non-const access to global points
|
||||
pointField& points()
|
||||
{
|
||||
return const_cast<pointField&>(MeshStorage::points());
|
||||
return const_cast<pointField&>(ParentType::points());
|
||||
}
|
||||
|
||||
//- Return non-const access to the faces
|
||||
List<FaceType>& faces()
|
||||
List<Face>& faces()
|
||||
{
|
||||
return static_cast<List<FaceType> &>(*this);
|
||||
return static_cast<List<Face> &>(*this);
|
||||
}
|
||||
|
||||
//- Return non-const access to the region Ids
|
||||
@ -169,14 +171,14 @@ protected:
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("keyedSurface");
|
||||
TypeName("UnsortedMeshedSurface");
|
||||
|
||||
// Static
|
||||
|
||||
//- Name of keyedSurface directory to use.
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName triSurfInstance(const Time&);
|
||||
|
||||
//- Name of keyedSurface directory to use.
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName triSurfName(const Time&);
|
||||
|
||||
//- Can we read this file format?
|
||||
@ -197,120 +199,110 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
keyedSurface();
|
||||
UnsortedMeshedSurface();
|
||||
|
||||
//- Construct by transferring components
|
||||
// (points, faces, region ids, patches).
|
||||
keyedSurface
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<Face> >&,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const xfer<surfPatchIdentifierList>&
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces and regionIds
|
||||
// with region names per map or set to default.
|
||||
keyedSurface
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<Face> >&,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const Map<word>& regionNames = Map<word>::null()
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces and regionIds
|
||||
// with patch-names from hash
|
||||
keyedSurface
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<Face> >&,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const HashTable<label>& labelToRegion
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces.
|
||||
// Set single default patch.
|
||||
keyedSurface
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&
|
||||
const xfer<List<Face> >&
|
||||
);
|
||||
|
||||
#if 0
|
||||
//- Construct from a boundary mesh with local points/faces
|
||||
keyedSurface
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const polyBoundaryMesh&,
|
||||
const bool globalPoints=false
|
||||
);
|
||||
#endif
|
||||
|
||||
//- Construct from a meshedSurface
|
||||
keyedSurface(const meshedSurface&);
|
||||
UnsortedMeshedSurface(const MeshedSurface<Face>&);
|
||||
|
||||
//- Construct by transferring the contents from a keyedSurface
|
||||
keyedSurface(const xfer<keyedSurface>&);
|
||||
//- Construct by transferring the contents from a UnsortedMeshedSurface
|
||||
UnsortedMeshedSurface(const xfer<UnsortedMeshedSurface<Face> >&);
|
||||
|
||||
//- Construct by transferring the contents from a meshedSurface
|
||||
keyedSurface(const xfer<meshedSurface>&);
|
||||
UnsortedMeshedSurface(const xfer<MeshedSurface<Face> >&);
|
||||
|
||||
//- Construct from file name (uses extension to determine type)
|
||||
keyedSurface
|
||||
(
|
||||
const fileName&,
|
||||
const bool triangulate=false
|
||||
);
|
||||
UnsortedMeshedSurface(const fileName&);
|
||||
|
||||
//- Construct from file name (uses extension to determine type)
|
||||
keyedSurface
|
||||
(
|
||||
const fileName&,
|
||||
const word&,
|
||||
const bool triangulate=false
|
||||
);
|
||||
UnsortedMeshedSurface(const fileName&, const word&);
|
||||
|
||||
//- Construct from Istream
|
||||
keyedSurface(Istream&, const bool triangulate=false);
|
||||
UnsortedMeshedSurface(Istream&);
|
||||
|
||||
//- Construct from objectRegistry
|
||||
keyedSurface(const Time&);
|
||||
UnsortedMeshedSurface(const Time&);
|
||||
|
||||
//- Construct as copy
|
||||
keyedSurface(const keyedSurface&);
|
||||
UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
keyedSurface,
|
||||
UnsortedMeshedSurface,
|
||||
fileExtension,
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
),
|
||||
(fName, triangulate)
|
||||
(fName)
|
||||
);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from filename (implicit extension)
|
||||
static autoPtr<keyedSurface> New
|
||||
static autoPtr<UnsortedMeshedSurface> New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=false
|
||||
const fileName&
|
||||
);
|
||||
|
||||
//- Select constructed from filename (explicit extension)
|
||||
static autoPtr<keyedSurface> New
|
||||
static autoPtr<UnsortedMeshedSurface> New
|
||||
(
|
||||
const fileName& fName,
|
||||
const word& ext,
|
||||
const bool triangulate=false
|
||||
const fileName&,
|
||||
const word& ext
|
||||
);
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~keyedSurface();
|
||||
virtual ~UnsortedMeshedSurface();
|
||||
|
||||
|
||||
// Member Function Selectors
|
||||
@ -318,18 +310,18 @@ public:
|
||||
declareMemberFunctionSelectionTable
|
||||
(
|
||||
void,
|
||||
keyedSurface,
|
||||
UnsortedMeshedSurface,
|
||||
write,
|
||||
fileExtension,
|
||||
(
|
||||
const fileName& fName,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
),
|
||||
(fName, surf)
|
||||
);
|
||||
|
||||
//- Write to file
|
||||
static void write(const fileName&, const keyedSurface&);
|
||||
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -345,13 +337,13 @@ public:
|
||||
//- Return the number of faces
|
||||
label nFaces() const
|
||||
{
|
||||
return MeshStorage::size();
|
||||
return ParentType::size();
|
||||
}
|
||||
|
||||
//- The surface size is the number of faces
|
||||
label size() const
|
||||
{
|
||||
return MeshStorage::size();
|
||||
return ParentType::size();
|
||||
}
|
||||
|
||||
//- Reset size of face and region list
|
||||
@ -360,13 +352,13 @@ public:
|
||||
//- Return const access to global points
|
||||
const pointField& points() const
|
||||
{
|
||||
return MeshStorage::points();
|
||||
return ParentType::points();
|
||||
}
|
||||
|
||||
//- Return const access to the faces
|
||||
const List<FaceType>& faces() const
|
||||
const List<Face>& faces() const
|
||||
{
|
||||
return static_cast<const List<FaceType> &>(*this);
|
||||
return static_cast<const List<Face> &>(*this);
|
||||
}
|
||||
|
||||
//- Return const access to the regions
|
||||
@ -415,7 +407,7 @@ public:
|
||||
|
||||
//- Return new surface. Returns pointMap, faceMap from
|
||||
// subsetMeshMap
|
||||
keyedSurface subsetMesh
|
||||
UnsortedMeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
labelList& pointMap,
|
||||
@ -423,27 +415,18 @@ public:
|
||||
) const;
|
||||
|
||||
//- Transfer the contents of the argument and annull the argument
|
||||
void transfer(keyedSurface&);
|
||||
void transfer(UnsortedMeshedSurface<Face>&);
|
||||
|
||||
//- Transfer the contents of the argument and annull the argument
|
||||
void transfer(meshedSurface&);
|
||||
void transfer(MeshedSurface<Face>&);
|
||||
|
||||
// Read
|
||||
|
||||
//- Read from file. Chooses reader based on explicit extension
|
||||
bool read
|
||||
(
|
||||
const fileName&,
|
||||
const word& ext,
|
||||
const bool triangulate
|
||||
);
|
||||
bool read(const fileName&, const word& ext);
|
||||
|
||||
//- Read from file. Chooses reader based on detected extension
|
||||
virtual bool read
|
||||
(
|
||||
const fileName&,
|
||||
const bool triangulate=false
|
||||
);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
// Write
|
||||
|
||||
@ -465,13 +448,17 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
void operator=(const keyedSurface&);
|
||||
void operator=(const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
// friend Istream& operator>>(Istream&, keyedSurface&);
|
||||
friend Ostream& operator<<(Ostream&, const keyedSurface&);
|
||||
friend Ostream& operator<<
|
||||
<Face>
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@ -482,6 +469,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "UnsortedMeshedSurface.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,24 +24,29 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "keyedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "mergePoints.H"
|
||||
#include "triFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Remove badly degenerate faces, double faces.
|
||||
void Foam::keyedSurface::cleanup(const bool verbose)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::cleanup(const bool verbose)
|
||||
{
|
||||
// merge points (already done for STL, TRI)
|
||||
stitchFaces(SMALL, verbose);
|
||||
|
||||
checkFaces(verbose);
|
||||
checkEdges(verbose);
|
||||
ParentType::checkEdges(verbose);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::stitchFaces
|
||||
(
|
||||
const scalar tol,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
pointField& pointLst = points();
|
||||
|
||||
@ -58,20 +63,20 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "keyedSurface::stitchFaces : Renumbering all faces"
|
||||
Info<< "UnsortedMeshedSurface::stitchFaces : Renumbering all faces"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Set the coordinates to the merged ones
|
||||
pointLst.transfer(newPoints);
|
||||
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<Face>& faceLst = faces();
|
||||
|
||||
// Reset the point labels to the unique points array
|
||||
label newFaceI = 0;
|
||||
forAll (faceLst, faceI)
|
||||
{
|
||||
FaceType& f = faceLst[faceI];
|
||||
Face& f = faceLst[faceI];
|
||||
forAll (f, fp)
|
||||
{
|
||||
f[fp] = pointMap[f[fp]];
|
||||
@ -88,7 +93,7 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
}
|
||||
else if (verbose)
|
||||
{
|
||||
Pout<< "keyedSurface::stitchFaces : "
|
||||
Pout<< "UnsortedMeshedSurface::stitchFaces : "
|
||||
<< "Removing collapsed face " << faceI << endl
|
||||
<< " vertices :" << f << endl;
|
||||
}
|
||||
@ -98,7 +103,7 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
Pout<< "keyedSurface::stitchFaces : "
|
||||
Pout<< "UnsortedMeshedSurface::stitchFaces : "
|
||||
<< "Removed " << faceLst.size() - newFaceI
|
||||
<< " faces" << endl;
|
||||
}
|
||||
@ -107,30 +112,31 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
}
|
||||
|
||||
// Merging points might have changed geometric factors
|
||||
MeshStorage::clearOut();
|
||||
ParentType::clearOut();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Remove badly degenerate faces and double faces.
|
||||
void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::checkFaces(const bool verbose)
|
||||
{
|
||||
// Simple check on indices ok.
|
||||
const label maxPointI = points().size() - 1;
|
||||
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<Face>& faceLst = faces();
|
||||
|
||||
// Phase 0: detect badly labelled faces
|
||||
forAll (faceLst, faceI)
|
||||
{
|
||||
const FaceType& f = faceLst[faceI];
|
||||
const Face& f = faceLst[faceI];
|
||||
|
||||
forAll (f, fp)
|
||||
{
|
||||
if (f[fp] < 0 || f[fp] > maxPointI)
|
||||
{
|
||||
FatalErrorIn("keyedSurface::checkFaces(bool)")
|
||||
FatalErrorIn("UnsortedMeshedSurface::checkFaces(bool)")
|
||||
<< "face " << f
|
||||
<< " uses point indices outside point range 0.."
|
||||
<< maxPointI
|
||||
@ -142,12 +148,12 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
// Phase 1: mark invalid faces
|
||||
// Phase 1: pack
|
||||
// Done to keep numbering constant in phase 1
|
||||
const labelListList& fFaces = faceFaces();
|
||||
const labelListList& fFaces = ParentType::faceFaces();
|
||||
label newFaceI = 0;
|
||||
|
||||
forAll (faceLst, faceI)
|
||||
{
|
||||
FaceType& f = faceLst[faceI];
|
||||
Face& f = faceLst[faceI];
|
||||
|
||||
// avoid degenerate faces
|
||||
if (f.collapse() >= 3)
|
||||
@ -176,7 +182,7 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"keyedSurface::checkFaces(bool verbose)"
|
||||
"UnsortedMeshedSurface::checkFaces(bool verbose)"
|
||||
) << "faces share the same vertices:\n"
|
||||
<< " face 1 :" << faceI << endl;
|
||||
// printFace(Warning, " ", f, points());
|
||||
@ -206,7 +212,7 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"keyedSurface::checkFaces(bool verbose)"
|
||||
"UnsortedMeshedSurface::checkFaces(bool verbose)"
|
||||
) << "face " << faceI
|
||||
<< " does not at least three unique vertices:\n";
|
||||
// printFace(Warning, " ", f, points());
|
||||
@ -219,7 +225,7 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"keyedSurface::checkFaces(bool verbose)"
|
||||
"UnsortedMeshedSurface::checkFaces(bool verbose)"
|
||||
) << "Removed " << faceLst.size() - newFaceI
|
||||
<< " illegal faces." << endl;
|
||||
}
|
||||
@ -227,15 +233,16 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
regions_.setSize(newFaceI);
|
||||
|
||||
// Topology can change because of renumbering
|
||||
MeshStorage::clearOut();
|
||||
ParentType::clearOut();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::keyedSurface::triangulate()
|
||||
template<class Face>
|
||||
Foam::label Foam::UnsortedMeshedSurface<Face>::triangulate()
|
||||
{
|
||||
label nTri = 0;
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<Face>& faceLst = faces();
|
||||
|
||||
// determine how many triangles are needed
|
||||
forAll (faceLst, faceI)
|
||||
@ -249,8 +256,8 @@ Foam::label Foam::keyedSurface::triangulate()
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<FaceType> newFaces(nTri);
|
||||
List<label> newRegions(nTri);
|
||||
List<Face> newFaces(nTri);
|
||||
List<label> newRegions(nTri);
|
||||
|
||||
// note the number of *additional* faces
|
||||
nTri -= faceLst.size();
|
||||
@ -259,7 +266,7 @@ Foam::label Foam::keyedSurface::triangulate()
|
||||
label newFaceI = 0;
|
||||
forAll (faceLst, faceI)
|
||||
{
|
||||
const FaceType& f = faceLst[faceI];
|
||||
const Face& f = faceLst[faceI];
|
||||
triFace fTri;
|
||||
|
||||
// Do simple face triangulation around f[0].
|
||||
153
src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceIO.C
Normal file
153
src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceIO.C
Normal file
@ -0,0 +1,153 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Read surf grouping, points, faces directly from Istream
|
||||
template<class Face>
|
||||
bool Foam::UnsortedMeshedSurface<Face>::read(Istream& is)
|
||||
{
|
||||
clear();
|
||||
|
||||
// triangulation required?
|
||||
bool mustTriangulate = false;
|
||||
{
|
||||
Face f;
|
||||
if (f.max_size() == 3)
|
||||
{
|
||||
mustTriangulate = true;
|
||||
}
|
||||
}
|
||||
|
||||
List<surfGroup> patchLst(is);
|
||||
// read points:
|
||||
is >> points();
|
||||
|
||||
|
||||
// read faces:
|
||||
// TODO - specialization to triangulate on-the-fly
|
||||
if (mustTriangulate)
|
||||
{
|
||||
is >> faces();
|
||||
}
|
||||
else
|
||||
{
|
||||
is >> faces();
|
||||
}
|
||||
|
||||
patches_.setSize(patchLst.size());
|
||||
regions_.setSize(size());
|
||||
|
||||
// copy patch info and set regions:
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
patches_[patchI] = PatchRegionType
|
||||
(
|
||||
patchLst[patchI],
|
||||
patchI
|
||||
);
|
||||
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
regions_[faceIndex++] = patchI;
|
||||
}
|
||||
}
|
||||
|
||||
return is.good();
|
||||
}
|
||||
|
||||
|
||||
// write (sorted)
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
|
||||
{
|
||||
const List<Face>& faceLst = faces();
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = sortedRegions(faceMap);
|
||||
|
||||
// just emit some information until we get a nice IOobject
|
||||
IOobject::writeBanner(os);
|
||||
os << "// OpenFOAM Surface format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||
<< "// regions:" << nl
|
||||
<< patchLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
patchLst[patchI].writeDict(os);
|
||||
}
|
||||
os << decrIndent << token::END_LIST << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Note: Write with global point numbering
|
||||
os << "\n// points:" << nl << points() << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
os << "\n// faces:" << nl;
|
||||
os << faceLst.size() << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
os << f << nl;
|
||||
}
|
||||
}
|
||||
os << token::END_LIST << nl;
|
||||
|
||||
IOobject::writeDivider(os);
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("meshedSurface::write(Ostream&)");
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
surf.write(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,60 +24,64 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "keyedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::keyedSurface>
|
||||
Foam::keyedSurface::New
|
||||
template<class Face>
|
||||
Foam::autoPtr<Foam::UnsortedMeshedSurface<Face> >
|
||||
Foam::UnsortedMeshedSurface<Face>::New
|
||||
(
|
||||
const fileName& fName,
|
||||
const word& ext,
|
||||
const bool triangulate
|
||||
const word& ext
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "keyedSurface::New"
|
||||
"(const fileName&, const word&, const bool) : "
|
||||
"constructing keyedSurface"
|
||||
Info<< "UnsortedMeshedSurface<Face>::New"
|
||||
"(const fileName&, const word&) : "
|
||||
"constructing UnsortedMeshedSurface"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
fileExtensionConstructorTable::iterator cstrIter =
|
||||
typename fileExtensionConstructorTable::iterator cstrIter =
|
||||
fileExtensionConstructorTablePtr_->find(ext);
|
||||
|
||||
if (cstrIter == fileExtensionConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"keyedSurface::New(const fileName&, const word&, const bool) : "
|
||||
"constructing keyedSurface"
|
||||
"UnsortedMeshedSurface<Face>::New"
|
||||
"(const fileName&, const word&) : "
|
||||
"constructing UnsortedMeshedSurface"
|
||||
) << "Unknown file extension " << ext << nl << nl
|
||||
<< "Valid types are :" << nl
|
||||
<< fileExtensionConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<keyedSurface>(cstrIter()(fName, triangulate));
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
cstrIter()(fName)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::keyedSurface>
|
||||
Foam::keyedSurface::New
|
||||
template<class Face>
|
||||
Foam::autoPtr<Foam::UnsortedMeshedSurface<Face> >
|
||||
Foam::UnsortedMeshedSurface<Face>::New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
const word ext = fName.ext();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "keyedSurface::New(const fileName&, const bool) : "
|
||||
"constructing keyedSurface"
|
||||
Info<< "UnsortedMeshedSurface<Face>::New"
|
||||
"(const fileName&) : "
|
||||
"constructing UnsortedMeshedSurface"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -89,7 +93,7 @@ Foam::keyedSurface::New
|
||||
// return New(unzipName, unzipName.ext(), ext);
|
||||
// }
|
||||
|
||||
return New(fName, ext, triangulate);
|
||||
return New(fName, ext);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
48
src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
Normal file
48
src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
Normal file
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "UnsortedMeshedSurfaces.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
#define makeUnsortedMeshedSurface(surfaceType) \
|
||||
defineNamedTemplateTypeNameAndDebug(surfaceType, 0); \
|
||||
defineTemplateRunTimeSelectionTable(surfaceType, fileExtension); \
|
||||
defineTemplateMemberFunctionSelectionTable(surfaceType,write,fileExtension);
|
||||
|
||||
makeUnsortedMeshedSurface(unsortedMeshedSurface)
|
||||
makeUnsortedMeshedSurface(triUnsortedMeshedSurface)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
35
src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaces.H
Normal file
35
src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaces.H
Normal file
@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef UnsortedMeshedSurfaces_H
|
||||
#define UnsortedMeshedSurfaces_H
|
||||
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "UnsortedMeshedSurfacesFwd.H"
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef UnsortedMeshedSurfacesFwd_H
|
||||
#define UnsortedMeshedSurfacesFwd_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
class face;
|
||||
class triFace;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face> class UnsortedMeshedSurface;
|
||||
|
||||
typedef UnsortedMeshedSurface<face> unsortedMeshedSurface;
|
||||
typedef UnsortedMeshedSurface<triFace> triUnsortedMeshedSurface;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,611 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "STLfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "OSspecific.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
STLfileFormat,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
STLfileFormat,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
STLfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
STLfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
STLfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
STLfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// check binary by getting the header and number of facets
|
||||
// this seems to work better than the old token-based method
|
||||
// - some programs (eg, pro-STAR) have 'solid' as the first word in
|
||||
// the binary header.
|
||||
// - using wordToken can cause an abort if non-word (binary) content
|
||||
// is detected ... this is not exactly what we want.
|
||||
bool Foam::fileFormats::STLfileFormat::detectBINARY
|
||||
(
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
off_t fileSize = Foam::size(fName);
|
||||
|
||||
IFstream ifs(fName, IOstream::BINARY);
|
||||
istream& is = ifs.stdStream();
|
||||
|
||||
// Read the STL header
|
||||
char header[headerSize];
|
||||
is.read(header, headerSize);
|
||||
|
||||
// Check that stream is OK, if not this may be an ASCII file
|
||||
if (!is.good())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the number of triangles in the STl file
|
||||
// (note: read as int so we can check whether >2^31)
|
||||
int nTris;
|
||||
is.read(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
// Check that stream is OK and number of triangles is positive,
|
||||
// if not this maybe an ASCII file
|
||||
//
|
||||
// Also compare the file size with that expected from the number of tris
|
||||
// If the comparison is not sensible then it may be an ASCII file
|
||||
if
|
||||
(
|
||||
!is
|
||||
|| nTris < 0
|
||||
|| nTris < (fileSize - headerSize)/50
|
||||
|| nTris > (fileSize - headerSize)/25
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// looks like it might be BINARY
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#undef DEBUG_STLBINARY
|
||||
|
||||
bool Foam::fileFormats::STLfileFormat::readBINARY
|
||||
(
|
||||
IFstream& ifs,
|
||||
const off_t fileSize
|
||||
)
|
||||
{
|
||||
clear();
|
||||
|
||||
istream& is = ifs.stdStream();
|
||||
|
||||
// Read the STL header
|
||||
char header[headerSize];
|
||||
is.read(header, headerSize);
|
||||
|
||||
// Check that stream is OK, if not this may be an ASCII file
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STLfileFormat::readBINARY(Istream&)"
|
||||
)
|
||||
<< "problem reading header, perhaps file is not binary "
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Read the number of triangles in the STl file
|
||||
// (note: read as int so we can check whether >2^31)
|
||||
int nTris;
|
||||
is.read(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
// Check that stream is OK and number of triangles is positive,
|
||||
// if not this maybe an ASCII file
|
||||
//
|
||||
// Also compare the file size with that expected from the number of tris
|
||||
// If the comparison is not sensible then it may be an ASCII file
|
||||
if
|
||||
(
|
||||
!is
|
||||
|| nTris < 0
|
||||
|| nTris < (fileSize - headerSize)/50
|
||||
|| nTris > (fileSize - headerSize)/25
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STLfileFormat::readBINARY(Istream&)"
|
||||
)
|
||||
<< "problem reading number of triangles, perhaps file is not binary"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
Info<< "# " << nTris << " facets" << endl;
|
||||
label prevRegion = -1;
|
||||
#endif
|
||||
|
||||
|
||||
// write directly into the lists:
|
||||
pointField& pointLst = points();
|
||||
List<face>& faceLst = faces();
|
||||
List<label>& regionLst = regions();
|
||||
|
||||
pointLst.setSize(3*nTris);
|
||||
faceLst.setSize(nTris);
|
||||
regionLst.setSize(nTris);
|
||||
|
||||
label maxRegionId = 0;
|
||||
|
||||
label pointI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
// Read an STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
|
||||
// Set the rawPoints to the vertices of the STL triangle
|
||||
// and set the point labels of the face
|
||||
|
||||
pointLst[pointI] = stlTri.a();
|
||||
fTri[0] = pointI++;
|
||||
|
||||
pointLst[pointI] = stlTri.b();
|
||||
fTri[1] = pointI++;
|
||||
|
||||
pointLst[pointI] = stlTri.c();
|
||||
fTri[2] = pointI++;
|
||||
|
||||
faceLst[faceI] = fTri;
|
||||
|
||||
// interprete colour as a region
|
||||
regionLst[faceI] = stlTri.region();
|
||||
|
||||
if (maxRegionId < stlTri.region())
|
||||
{
|
||||
maxRegionId = stlTri.region();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
if
|
||||
(
|
||||
prevRegion != stlTri.region()
|
||||
)
|
||||
{
|
||||
if (prevRegion != -1)
|
||||
{
|
||||
Info<< "endsolid region" << prevRegion << nl;
|
||||
}
|
||||
prevRegion = stlTri.region();
|
||||
|
||||
Info<< "solid region" << prevRegion << nl;
|
||||
}
|
||||
|
||||
Info<< " facet normal " << stlTri.normal() << nl;
|
||||
Info<< " outer loop" << nl;
|
||||
Info<< " vertex " << stlTri.a() << nl;
|
||||
Info<< " vertex " << stlTri.b() << nl;
|
||||
Info<< " vertex " << stlTri.c() << nl;
|
||||
Info<< " outer loop" << nl;
|
||||
Info<< " endfacet" << endl;
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG_STLBINARY
|
||||
Info<< "endsolid region" << prevRegion << nl;
|
||||
#endif
|
||||
|
||||
setPatches(maxRegionId);
|
||||
stitchFaces(SMALL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::fileFormats::STLfileFormat::writeShell
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const face& f,
|
||||
const vector& norm
|
||||
)
|
||||
{
|
||||
// simple triangulation about f[0].
|
||||
// better triangulation should have been done before
|
||||
const point& p0 = pointLst[f[0]];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||
{
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
const point& p1 = pointLst[f[fp1]];
|
||||
const point& p2 = pointLst[f[fp2]];
|
||||
|
||||
// write STL triangle
|
||||
os << " facet normal "
|
||||
<< norm.x() << ' ' << norm.y() << ' ' << norm.z() << nl
|
||||
<< " outer loop\n"
|
||||
<< " vertex "
|
||||
<< p0.x() << ' ' << p0.y() << ' ' << p0.z() << nl
|
||||
<< " vertex "
|
||||
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl
|
||||
<< " vertex "
|
||||
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << nl
|
||||
<< " endloop\n"
|
||||
<< " endfacet" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::fileFormats::STLfileFormat::writeShell
|
||||
(
|
||||
ostream& os,
|
||||
const pointField& pointLst,
|
||||
const face& f,
|
||||
const vector& norm,
|
||||
const label patchI
|
||||
)
|
||||
{
|
||||
// simple triangulation about f[0].
|
||||
// better triangulation should have been done before
|
||||
const point& p0 = pointLst[f[0]];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||
{
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
STLtriangle stlTri
|
||||
(
|
||||
norm,
|
||||
p0,
|
||||
pointLst[f[fp1]],
|
||||
pointLst[f[fp2]],
|
||||
patchI
|
||||
);
|
||||
|
||||
stlTri.write(os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// write sorted:
|
||||
void Foam::fileFormats::STLfileFormat::writeASCII
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const label faceI = faceMap[faceIndex++];
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// write sorted:
|
||||
void Foam::fileFormats::STLfileFormat::writeASCII
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
// force triangulation, but just do the cheapest form possible
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const label faceI = faceIndex++;
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write unsorted:
|
||||
void Foam::fileFormats::STLfileFormat::writeBINARY
|
||||
(
|
||||
ostream& os,
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
// Write the STL header
|
||||
string header("STL binary file", headerSize);
|
||||
|
||||
// clear possible trailing junk
|
||||
for (label i = header.size(); i < headerSize; ++i)
|
||||
{
|
||||
header[i] = 0;
|
||||
}
|
||||
os.write(header.c_str(), headerSize);
|
||||
|
||||
// force triangulation, but just do the cheapest form possible
|
||||
unsigned int nTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nTris += faceLst[faceI].size() - 2;
|
||||
}
|
||||
|
||||
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
// always write unsorted
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
writeShell
|
||||
(
|
||||
os,
|
||||
pointLst,
|
||||
faceLst[faceI],
|
||||
normLst[faceI],
|
||||
regionLst[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STLfileFormat::writeBINARY
|
||||
(
|
||||
ostream& os,
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
// Write the STL header
|
||||
string header("STL binary file", headerSize);
|
||||
os.write(header.c_str(), headerSize);
|
||||
|
||||
// force triangulation, but just do the cheapest form possible
|
||||
|
||||
unsigned int nTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nTris += faceLst[faceI].size() - 2;
|
||||
}
|
||||
|
||||
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
writeShell
|
||||
(
|
||||
os,
|
||||
pointLst,
|
||||
faceLst[faceIndex],
|
||||
normLst[faceIndex],
|
||||
patchI
|
||||
);
|
||||
|
||||
++faceIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLfileFormat::STLfileFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileFormats::STLfileFormat::STLfileFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
{
|
||||
read(fName, true);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
bool Foam::fileFormats::STLfileFormat::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool
|
||||
)
|
||||
{
|
||||
off_t fileSize = Foam::size(fName);
|
||||
|
||||
// auto-detect ascii/binary
|
||||
if (detectBINARY(fName))
|
||||
{
|
||||
return readBINARY(IFstream(fName, IOstream::BINARY)(), fileSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return readASCII(IFstream(fName)(), fileSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STLfileFormat::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
writeASCII(os, surf);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STLfileFormat::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
writeASCII(os, surf);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STLfileFormat::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'stlb' as binary directly
|
||||
if (ext == "stlb")
|
||||
{
|
||||
std::ofstream ofs(fName.c_str(), std::ios::binary);
|
||||
writeBINARY(ofs, surf);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeASCII(OFstream(fName)(), surf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STLfileFormat::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'stlb' as binary directly
|
||||
if (ext == "stlb")
|
||||
{
|
||||
std::ofstream ofs(fName.c_str(), std::ios::binary);
|
||||
writeBINARY(ofs, surf);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeASCII(OFstream(fName)(), surf);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,56 +24,20 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "AC3DfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "AC3DsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "tensor.H"
|
||||
#include "triFace.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
AC3DfileFormat,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
AC3DfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
AC3DfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
template<class Type>
|
||||
Type Foam::fileFormats::AC3DfileFormat::parse(const string& str)
|
||||
Type Foam::fileFormats::AC3DsurfaceFormat<Face>::parse(const string& str)
|
||||
{
|
||||
IStringStream ss(str);
|
||||
|
||||
@ -83,7 +47,8 @@ Type Foam::fileFormats::AC3DfileFormat::parse(const string& str)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fileFormats::AC3DfileFormat::readCmd
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::AC3DsurfaceFormat<Face>::readCmd
|
||||
(
|
||||
IFstream& is,
|
||||
string& cmd,
|
||||
@ -111,7 +76,8 @@ bool Foam::fileFormats::AC3DfileFormat::readCmd
|
||||
|
||||
// Read up to line starting with cmd. Sets args to rest of line.
|
||||
// Returns true if found, false if stream is not good anymore.
|
||||
bool Foam::fileFormats::AC3DfileFormat::cueTo
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::AC3DsurfaceFormat<Face>::cueTo
|
||||
(
|
||||
IFstream& is,
|
||||
const string& cmd,
|
||||
@ -140,7 +106,8 @@ bool Foam::fileFormats::AC3DfileFormat::cueTo
|
||||
|
||||
|
||||
// Similar to cueTo(), but throws error if cmd not found
|
||||
Foam::string Foam::fileFormats::AC3DfileFormat::cueToOrDie
|
||||
template<class Face>
|
||||
Foam::string Foam::fileFormats::AC3DsurfaceFormat<Face>::cueToOrDie
|
||||
(
|
||||
IFstream& is,
|
||||
const string& cmd,
|
||||
@ -152,7 +119,7 @@ Foam::string Foam::fileFormats::AC3DfileFormat::cueToOrDie
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot find command " << cmd
|
||||
<< " " << errorMsg
|
||||
@ -163,7 +130,8 @@ Foam::string Foam::fileFormats::AC3DfileFormat::cueToOrDie
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::AC3DfileFormat::writeHeader
|
||||
template<class Face>
|
||||
void Foam::fileFormats::AC3DsurfaceFormat<Face>::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const List<surfGroup>& patchLst
|
||||
@ -211,39 +179,50 @@ void Foam::fileFormats::AC3DfileFormat::writeHeader
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::AC3DfileFormat::AC3DfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::AC3DsurfaceFormat<Face>::AC3DsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
|
||||
template<class Face>
|
||||
Foam::fileFormats::AC3DsurfaceFormat<Face>::AC3DsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName,triangulate);
|
||||
read(fName);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::AC3DfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
IFstream is(fName);
|
||||
ParentType::clear();
|
||||
|
||||
// triangulation required?
|
||||
bool mustTriangulate = false;
|
||||
{
|
||||
Face f;
|
||||
if (f.max_size() == 3)
|
||||
{
|
||||
mustTriangulate = true;
|
||||
}
|
||||
}
|
||||
|
||||
IFstream is(fName);
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << fName
|
||||
<< exit(FatalError);
|
||||
@ -259,8 +238,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"fileFormats::AC3DfileFormat::AC3DfileFormat"
|
||||
"(const fileName&)"
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "When reading AC3D file " << fName
|
||||
<< " read header " << line << " with version "
|
||||
@ -274,7 +252,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot find \"OBJECT world\" in file " << fName
|
||||
<< exit(FatalError);
|
||||
@ -287,9 +265,9 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
// Start of vertices for object/patch
|
||||
label patchVertOffset = 0;
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<FaceType> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<Face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
|
||||
// patchId => patchName
|
||||
Map<word> regionNames;
|
||||
@ -314,7 +292,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Did not read up to \"kids 0\" while reading patch "
|
||||
<< patchI << " from file " << fName
|
||||
@ -342,7 +320,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
|
||||
WarningIn
|
||||
(
|
||||
"fileFormats::AC3DfileFormat::read"
|
||||
"fileFormats::AC3DsurfaceFormat::read"
|
||||
"(const fileName&)"
|
||||
)
|
||||
<< "rot (rotation tensor) command not implemented"
|
||||
@ -395,14 +373,16 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
|
||||
label nVert = parse<int>(args);
|
||||
|
||||
face verts(nVert);
|
||||
List<label> verts(nVert);
|
||||
forAll(verts, vertI)
|
||||
{
|
||||
is.getLine(line);
|
||||
verts[vertI] = parse<int>(line) + patchVertOffset;
|
||||
}
|
||||
|
||||
if (triangulate && verts.size() > 3)
|
||||
UList<label>& f = static_cast<UList<label>&>(verts);
|
||||
|
||||
if (mustTriangulate)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
@ -423,7 +403,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(verts);
|
||||
faceLst.append(Face(f));
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
@ -441,7 +421,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Can only read objects without kids."
|
||||
<< " Encountered " << nKids << " kids when"
|
||||
@ -457,21 +437,22 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
||||
}
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
regions().transfer(regionLst);
|
||||
ParentType::points().transfer(pointLst);
|
||||
ParentType::faces().transfer(faceLst);
|
||||
|
||||
setPatches(regionNames);
|
||||
stitchFaces(SMALL);
|
||||
ParentType::regions().transfer(regionLst);
|
||||
|
||||
ParentType::setPatches(regionNames);
|
||||
ParentType::stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::AC3DfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
labelList faceMap;
|
||||
@ -500,7 +481,7 @@ void Foam::fileFormats::AC3DfileFormat::write
|
||||
labelList pMap;
|
||||
labelList fMap;
|
||||
|
||||
keyedSurface patch = surf.subsetMesh
|
||||
ParentType patch = surf.subsetMesh
|
||||
(
|
||||
include, pMap, fMap
|
||||
);
|
||||
@ -536,14 +517,15 @@ void Foam::fileFormats::AC3DfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::AC3DfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHeader(os, patchLst);
|
||||
@ -555,15 +537,11 @@ void Foam::fileFormats::AC3DfileFormat::write
|
||||
os << "OBJECT poly" << nl
|
||||
<< "name \"" << p.name() << '"' << endl;
|
||||
|
||||
// Temporary primitivePatch to calculate compact points & faces
|
||||
primitivePatch patch
|
||||
// Temporary PrimitivePatch to calculate compact points & faces
|
||||
// use 'UList' to avoid allocations!
|
||||
PrimitivePatch<Face, UList, const pointField&> patch
|
||||
(
|
||||
SubList<face>
|
||||
(
|
||||
faceLst,
|
||||
p.start(),
|
||||
p.size()
|
||||
),
|
||||
faceLst,
|
||||
pointLst
|
||||
);
|
||||
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::AC3DfileFormat
|
||||
Foam::fileFormats::AC3DsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing AC3D format.
|
||||
@ -39,13 +39,13 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef AC3DfileFormat_H
|
||||
#define AC3DfileFormat_H
|
||||
#ifndef AC3DsurfaceFormat_H
|
||||
#define AC3DsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -54,16 +54,18 @@ namespace Foam
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
class AC3DfileFormat;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AC3DfileFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class AC3DfileFormat
|
||||
template<class Face>
|
||||
class AC3DsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef AC3DsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -90,57 +92,76 @@ class AC3DfileFormat
|
||||
static void writeHeader(Ostream&, const List<surfGroup>&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
AC3DfileFormat(const AC3DfileFormat&);
|
||||
AC3DsurfaceFormat(const AC3DsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const AC3DfileFormat&);
|
||||
void operator=(const AC3DsurfaceFormat<Face>&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
AC3DfileFormat();
|
||||
AC3DsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
AC3DfileFormat(const fileName&, const bool triangulate=false);
|
||||
AC3DsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=false
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new AC3DfileFormat(fName,triangulate)
|
||||
new AC3DsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~AC3DsurfaceFormat()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName& fName, const keyedSurface& surf)
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName& fName, const meshedSurface& surf)
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
@ -161,6 +182,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "AC3DsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
99
src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatRunTime.C
Normal file
99
src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatRunTime.C
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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "AC3DsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
AC3DsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
ac
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,67 +24,48 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "FTRfileFormat.H"
|
||||
#include "FTRsurfaceFormat.H"
|
||||
#include "Keyed.H"
|
||||
#include "triFace.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()
|
||||
template<class Face>
|
||||
Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileFormats::FTRfileFormat::FTRfileFormat
|
||||
template<class Face>
|
||||
Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName,true);
|
||||
ThisType::read(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::FTRfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
IFstream is(fName);
|
||||
ParentType::clear();
|
||||
|
||||
IFstream is(fName);
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::FTRfileFormat::read(const fileName&)"
|
||||
"fileFormats::FTRsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << fName
|
||||
<< exit(FatalError);
|
||||
@ -94,13 +75,13 @@ bool Foam::fileFormats::FTRfileFormat::read
|
||||
List<point> pointLst(is);
|
||||
|
||||
// transfer to normal list
|
||||
points().transfer(pointLst);
|
||||
ParentType::points().transfer(pointLst);
|
||||
|
||||
// read faces with keys
|
||||
List<Keyed<triFace> > readFaces(is);
|
||||
|
||||
List<FaceType> faceLst(readFaces.size());
|
||||
List<label> regionLst(readFaces.size());
|
||||
List<Face> faceLst(readFaces.size());
|
||||
List<label> regionLst(readFaces.size());
|
||||
|
||||
// disentangle faces/keys - already triangulated
|
||||
forAll(readFaces, faceI)
|
||||
@ -110,8 +91,8 @@ bool Foam::fileFormats::FTRfileFormat::read
|
||||
regionLst[faceI] = readFaces[faceI].key();
|
||||
}
|
||||
|
||||
faces().transfer(faceLst);
|
||||
regions().transfer(regionLst);
|
||||
ParentType::faces().transfer(faceLst);
|
||||
ParentType::regions().transfer(regionLst);
|
||||
|
||||
Map<word> regionNames;
|
||||
forAll(readPatches, patchI)
|
||||
@ -119,8 +100,7 @@ bool Foam::fileFormats::FTRfileFormat::read
|
||||
regionNames.insert(patchI, readPatches[patchI].name());
|
||||
}
|
||||
|
||||
setPatches(regionNames, readPatches.size() - 1);
|
||||
|
||||
ParentType::setPatches(regionNames, readPatches.size() - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -23,22 +23,22 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::FTRfileFormat
|
||||
Foam::fileFormats::FTRsurfaceFormat
|
||||
|
||||
Description
|
||||
Reading of Foam Trisurface Format
|
||||
|
||||
SourceFiles
|
||||
FTRfileFormat.C
|
||||
FTRsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FTRfileFormat_H
|
||||
#define FTRfileFormat_H
|
||||
#ifndef FTRsurfaceFormat_H
|
||||
#define FTRsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "IFstream.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -48,21 +48,25 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FTRfileFormat Declaration
|
||||
Class FTRsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class FTRfileFormat
|
||||
template<class Face>
|
||||
class FTRsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef FTRsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
FTRfileFormat(const FTRfileFormat&);
|
||||
FTRsurfaceFormat(const FTRsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const FTRfileFormat&);
|
||||
void operator=(const FTRsurfaceFormat<Face>&);
|
||||
|
||||
|
||||
//- read compatibility for ftr format
|
||||
@ -93,30 +97,36 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
FTRfileFormat();
|
||||
FTRsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
FTRfileFormat(const fileName&, const bool triangulate=false);
|
||||
FTRsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=false
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new FTRfileFormat(fName,true)
|
||||
new FTRsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~FTRsurfaceFormat()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
};
|
||||
|
||||
@ -128,6 +138,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "FTRsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
59
src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormatRunTime.C
Normal file
59
src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormatRunTime.C
Normal file
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "FTRsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
FTRsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
ftr
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
FTRsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
ftr
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,96 +24,59 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GTSfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "GTSsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "tensor.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
GTSfileFormat,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
GTSfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
GTSfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::GTSfileFormat::GTSfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::GTSsurfaceFormat<Face>::GTSsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
Foam::fileFormats::GTSfileFormat::GTSfileFormat
|
||||
|
||||
template<class Face>
|
||||
Foam::fileFormats::GTSsurfaceFormat<Face>::GTSsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName,true);
|
||||
read(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::GTSfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
IFstream is(fName);
|
||||
ParentType::clear();
|
||||
|
||||
IFstream is(fName);
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
||||
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << fName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Read header
|
||||
string line = getLineNoComment(is);
|
||||
string line = ParentType::getLineNoComment(is);
|
||||
|
||||
label nPoints, nEdges, nElems;
|
||||
{
|
||||
@ -126,9 +89,9 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
|
||||
|
||||
// write directly into the lists:
|
||||
pointField& pointLst = points();
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<label>& regionLst = regions();
|
||||
pointField& pointLst = ParentType::points();
|
||||
List<Face>& faceLst = ParentType::faces();
|
||||
List<label>& regionLst = ParentType::regions();
|
||||
|
||||
pointLst.setSize(nPoints);
|
||||
faceLst.setSize(nElems);
|
||||
@ -139,7 +102,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
forAll(pointLst, pointI)
|
||||
{
|
||||
scalar x, y, z;
|
||||
line = getLineNoComment(is);
|
||||
line = ParentType::getLineNoComment(is);
|
||||
{
|
||||
IStringStream lineStream(line);
|
||||
lineStream
|
||||
@ -154,7 +117,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
forAll(edges, edgei)
|
||||
{
|
||||
label beg, end;
|
||||
line = getLineNoComment(is);
|
||||
line = ParentType::getLineNoComment(is);
|
||||
{
|
||||
IStringStream lineStream(line);
|
||||
lineStream
|
||||
@ -171,7 +134,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
label e0Label, e1Label, e2Label;
|
||||
label regionI = 0;
|
||||
|
||||
line = getLineNoComment(is);
|
||||
line = ParentType::getLineNoComment(is);
|
||||
{
|
||||
IStringStream lineStream(line);
|
||||
lineStream
|
||||
@ -206,7 +169,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
||||
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Edges 0 and 1 of triangle " << faceI
|
||||
<< " do not share a point.\n"
|
||||
@ -223,7 +186,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
||||
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Edges 1 and 2 of triangle " << faceI
|
||||
<< " do not share a point.\n"
|
||||
@ -238,7 +201,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
||||
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Edges of triangle " << faceI
|
||||
<< " reference more than three points.\n"
|
||||
@ -252,44 +215,50 @@ bool Foam::fileFormats::GTSfileFormat::read
|
||||
regionLst[faceI] = regionI;
|
||||
}
|
||||
|
||||
setPatches(maxPatch);
|
||||
// stitchFaces(SMALL);
|
||||
|
||||
ParentType::setPatches(maxPatch);
|
||||
// ParentType::stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::GTSfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
// check if output triangulation would be required
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
// just issue a warning and get out
|
||||
label nNonTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
//
|
||||
if (faceLst.size() && faceLst[0].max_size() != 3)
|
||||
{
|
||||
if (faceLst[faceI].size() > 3)
|
||||
label nNonTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
++nNonTris;
|
||||
if (faceLst[faceI].size() != 3)
|
||||
{
|
||||
++nNonTris;
|
||||
}
|
||||
}
|
||||
|
||||
if (nNonTris)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::GTSsurfaceFormat::write"
|
||||
"(Ostream&, const UnsortedMeshedSurfaces<Face>&)"
|
||||
)
|
||||
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
||||
<< " non-triangulated faces - not writing!" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (nNonTris)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::GTSfileFormat::write"
|
||||
"(Ostream&, const keyedSurface&)"
|
||||
)
|
||||
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
||||
<< " non-triangulated faces - not writing!" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -352,38 +321,44 @@ void Foam::fileFormats::GTSfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::GTSfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
|
||||
// check if output triangulation would be required
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
// just issue a warning and get out
|
||||
label nNonTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
//
|
||||
if (faceLst.size() && faceLst[0].max_size() != 3)
|
||||
{
|
||||
if (faceLst[faceI].size() > 3)
|
||||
label nNonTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
++nNonTris;
|
||||
if (faceLst[faceI].size() != 3)
|
||||
{
|
||||
++nNonTris;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nNonTris)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"fileFormats::GTSfileFormat::write"
|
||||
"(Ostream&, const meshedSurface&)"
|
||||
)
|
||||
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
||||
<< " non-triangulated faces - not writing!" << endl;
|
||||
|
||||
return;
|
||||
if (nNonTris)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::GTSsurfaceFormat::write"
|
||||
"(Ostream&, const MeshedSurface<Face>&)"
|
||||
)
|
||||
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
||||
<< " non-triangulated faces - not writing!" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Write header, print patch names as comment
|
||||
@ -23,23 +23,23 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::GTSfileFormat
|
||||
Foam::fileFormats::GTSsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing GTS format.
|
||||
|
||||
SourceFiles
|
||||
GTSfileFormat.C
|
||||
GTSsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef GTSfileFormat_H
|
||||
#define GTSfileFormat_H
|
||||
#ifndef GTSsurfaceFormat_H
|
||||
#define GTSsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -48,71 +48,90 @@ namespace Foam
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
class GTSfileFormat;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class GTSfileFormat Declaration
|
||||
Class GTSsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class GTSfileFormat
|
||||
template<class Face>
|
||||
class GTSsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef GTSsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
GTSfileFormat(const GTSfileFormat&);
|
||||
GTSsurfaceFormat(const GTSsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const GTSfileFormat&);
|
||||
void operator=(const GTSsurfaceFormat<Face>&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
GTSfileFormat();
|
||||
GTSsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
GTSfileFormat(const fileName&, const bool triangulate=true);
|
||||
GTSsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=true
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new GTSfileFormat(fName,true)
|
||||
new GTSsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
virtual ~GTSsurfaceFormat()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName& fName, const keyedSurface& surf)
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName& fName, const meshedSurface& surf)
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
@ -133,6 +152,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "GTSsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
98
src/surfMesh/surfaceFormats/gts/GTSsurfaceFormatRunTime.C
Normal file
98
src/surfMesh/surfaceFormats/gts/GTSsurfaceFormatRunTime.C
Normal file
@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "GTSsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
GTSsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
gts
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,63 +24,21 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "NASfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "NASsurfaceFormat.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
// .bdf (Bulk Data Format)
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
NASfileFormat,
|
||||
fileExtension,
|
||||
bdf
|
||||
);
|
||||
|
||||
// .nas (Nastran)
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
NASfileFormat,
|
||||
fileExtension,
|
||||
nas
|
||||
);
|
||||
|
||||
// addNamedToMemberFunctionSelectionTable
|
||||
// (
|
||||
// keyedSurface,
|
||||
// NASfileFormat,
|
||||
// write,
|
||||
// fileExtension,
|
||||
// nas
|
||||
// );
|
||||
//
|
||||
// addNamedToMemberFunctionSelectionTable
|
||||
// (
|
||||
// meshedSurface,
|
||||
// NASfileFormat,
|
||||
// write,
|
||||
// fileExtension,
|
||||
// nas
|
||||
// );
|
||||
|
||||
}
|
||||
}
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// Do weird things to extract number
|
||||
Foam::scalar Foam::fileFormats::NASfileFormat::parseNASCoord(const string& s)
|
||||
template<class Face>
|
||||
Foam::scalar Foam::fileFormats::NASsurfaceFormat<Face>::parseNASCoord
|
||||
(
|
||||
const string& s
|
||||
)
|
||||
{
|
||||
size_t expSign = s.find_last_of("+-");
|
||||
|
||||
@ -103,51 +61,62 @@ Foam::scalar Foam::fileFormats::NASfileFormat::parseNASCoord(const string& s)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::NASfileFormat::NASfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::NASsurfaceFormat<Face>::NASsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
template<class Face>
|
||||
Foam::fileFormats::NASsurfaceFormat<Face>::NASsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName,triangulate);
|
||||
ThisType::read(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::NASfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
IFstream is(fName);
|
||||
ParentType::clear();
|
||||
|
||||
// triangulation required?
|
||||
bool mustTriangulate = false;
|
||||
{
|
||||
Face f;
|
||||
if (f.max_size() == 3)
|
||||
{
|
||||
mustTriangulate = true;
|
||||
}
|
||||
}
|
||||
|
||||
IFstream is(fName);
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::NASfileFormat::read(const fileName&)"
|
||||
"fileFormats::NASsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << fName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<point> pointLst;
|
||||
// Nastran index of points
|
||||
DynamicList<label> pointId;
|
||||
DynamicList<FaceType> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
DynamicList<label> pointId;
|
||||
DynamicList<Face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
|
||||
// From face groupId to patchId
|
||||
Map<label> groupIdToPatchId;
|
||||
@ -307,6 +276,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
||||
else if (cmd == "CQUAD4")
|
||||
{
|
||||
face fQuad(4);
|
||||
UList<label>& f = static_cast<UList<label>&>(fQuad);
|
||||
|
||||
label groupId = readLabel(IStringStream(line.substr(16,8))());
|
||||
fQuad[0] = readLabel(IStringStream(line.substr(24,8))());
|
||||
@ -329,19 +299,19 @@ bool Foam::fileFormats::NASfileFormat::read
|
||||
patchI = iter();
|
||||
}
|
||||
|
||||
if (triangulate)
|
||||
if (mustTriangulate)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
// simple face triangulation about f[0].
|
||||
// cannot use face::triangulation since points are incomplete
|
||||
fTri[0] = fQuad[0];
|
||||
for (label fp1 = 1; fp1 < fQuad.size() - 1; fp1++)
|
||||
fTri[0] = f[0];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
|
||||
{
|
||||
label fp2 = (fp1 + 1) % fQuad.size();
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
fTri[1] = fQuad[fp1];
|
||||
fTri[2] = fQuad[fp2];
|
||||
fTri[1] = f[fp1];
|
||||
fTri[2] = f[fp2];
|
||||
|
||||
faceLst.append(fTri);
|
||||
regionLst.append(patchI);
|
||||
@ -349,7 +319,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(fQuad);
|
||||
faceLst.append(Face(f));
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
@ -391,7 +361,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::NASfileFormat::read(const fileName&)"
|
||||
"fileFormats::NASsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Expected continuation symbol '*' when reading GRID*"
|
||||
<< " (double precision coordinate) output" << nl
|
||||
@ -420,8 +390,8 @@ bool Foam::fileFormats::NASfileFormat::read
|
||||
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
regions().transfer(regionLst);
|
||||
ParentType::points().transfer(pointLst);
|
||||
ParentType::regions().transfer(regionLst);
|
||||
|
||||
pointId.shrink();
|
||||
faceLst.shrink();
|
||||
@ -439,7 +409,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
||||
// Relabel faces
|
||||
forAll(faceLst, i)
|
||||
{
|
||||
face& f = faceLst[i];
|
||||
Face& f = faceLst[i];
|
||||
forAll(f, fp)
|
||||
{
|
||||
f[fp] = nasToFoamPoint[f[fp]];
|
||||
@ -461,10 +431,9 @@ bool Foam::fileFormats::NASfileFormat::read
|
||||
}
|
||||
|
||||
// transfer to normal lists
|
||||
faces().transfer(faceLst);
|
||||
|
||||
setPatches(regionNames);
|
||||
ParentType::faces().transfer(faceLst);
|
||||
|
||||
ParentType::setPatches(regionNames);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::NASfileFormat
|
||||
Foam::fileFormats::NASsurfaceFormat
|
||||
|
||||
Description
|
||||
Nastran surface reader.
|
||||
@ -37,17 +37,17 @@ Description
|
||||
@endverbatim
|
||||
|
||||
SourceFiles
|
||||
NASfileFormat.C
|
||||
NASsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NASfileFormat_H
|
||||
#define NASfileFormat_H
|
||||
#ifndef NASsurfaceFormat_H
|
||||
#define NASsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -57,13 +57,17 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class NASfileFormat Declaration
|
||||
Class NASsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class NASfileFormat
|
||||
template<class Face>
|
||||
class NASsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef NASsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -71,42 +75,44 @@ class NASfileFormat
|
||||
static scalar parseNASCoord(const string&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
NASfileFormat(const NASfileFormat&);
|
||||
NASsurfaceFormat(const NASsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const NASfileFormat&);
|
||||
void operator=(const NASsurfaceFormat<Face>&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
NASfileFormat();
|
||||
NASsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
NASfileFormat(const fileName&, const bool triangulate=false);
|
||||
NASsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=false
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new NASfileFormat(fName,triangulate)
|
||||
new NASsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~NASsurfaceFormat()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from a file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
};
|
||||
|
||||
@ -118,6 +124,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "NASsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
78
src/surfMesh/surfaceFormats/nas/NASsurfaceFormatRunTime.C
Normal file
78
src/surfMesh/surfaceFormats/nas/NASsurfaceFormatRunTime.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 "NASsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
// .bdf (Bulk Data Format)
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
NASsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
bdf
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
NASsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
bdf
|
||||
);
|
||||
|
||||
// .nas (Nastran)
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
NASsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
nas
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
NASsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
nas
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,56 +24,19 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OBJfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "OBJsurfaceFormat.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,
|
||||
OBJfileFormat,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
OBJfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
OBJfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::OBJfileFormat::writeHead
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OBJsurfaceFormat<Face>::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<FaceType>& faceLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
@ -111,47 +74,58 @@ void Foam::fileFormats::OBJfileFormat::writeHead
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::OBJfileFormat::OBJfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::OBJsurfaceFormat<Face>::OBJsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
template<class Face>
|
||||
Foam::fileFormats::OBJsurfaceFormat<Face>::OBJsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName,triangulate);
|
||||
ThisType::read(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::OBJfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
IFstream is(fName);
|
||||
ParentType::clear();
|
||||
|
||||
// triangulation required?
|
||||
bool mustTriangulate = false;
|
||||
{
|
||||
Face f;
|
||||
if (f.max_size() == 3)
|
||||
{
|
||||
mustTriangulate = true;
|
||||
}
|
||||
}
|
||||
|
||||
IFstream is(fName);
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::OBJfileFormat::read(const fileName&)"
|
||||
"fileFormats::OBJsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << fName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<FaceType> faceLst;
|
||||
DynamicList<Face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
|
||||
@ -161,13 +135,13 @@ bool Foam::fileFormats::OBJfileFormat::read
|
||||
|
||||
while (is.good())
|
||||
{
|
||||
string line = getLineNoComment(is);
|
||||
string line = ParentType::getLineNoComment(is);
|
||||
|
||||
// handle continuations
|
||||
if (line[line.size()-1] == '\\')
|
||||
{
|
||||
line.substr(0, line.size()-1);
|
||||
line += getLineNoComment(is);
|
||||
line += ParentType::getLineNoComment(is);
|
||||
}
|
||||
|
||||
// Read first word
|
||||
@ -253,9 +227,9 @@ bool Foam::fileFormats::OBJfileFormat::read
|
||||
}
|
||||
dynVertices.shrink();
|
||||
|
||||
FaceType f(SubList<label>(dynVertices, dynVertices.size()));
|
||||
UList<label>& f = static_cast<UList<label>&>(dynVertices);
|
||||
|
||||
if (triangulate && f.size() > 3)
|
||||
if (mustTriangulate)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
@ -275,30 +249,30 @@ bool Foam::fileFormats::OBJfileFormat::read
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(f);
|
||||
faceLst.append(Face(f));
|
||||
regionLst.append(groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
regions().transfer(regionLst);
|
||||
|
||||
setPatches(groupToPatch);
|
||||
ParentType::points().transfer(pointLst);
|
||||
ParentType::faces().transfer(faceLst);
|
||||
ParentType::regions().transfer(regionLst);
|
||||
|
||||
ParentType::setPatches(groupToPatch);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::OBJfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -330,13 +304,14 @@ void Foam::fileFormats::OBJfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::OBJfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::OBJfileFormat
|
||||
Foam::fileFormats::OBJsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing Alias/Wavefront OBJ format.
|
||||
@ -31,17 +31,17 @@ Description
|
||||
Does not handle negative face indices.
|
||||
|
||||
SourceFiles
|
||||
OBJfileFormat.C
|
||||
OBJsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OBJfileFormat_H
|
||||
#define OBJfileFormat_H
|
||||
#ifndef OBJsurfaceFormat_H
|
||||
#define OBJsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,27 +51,31 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OBJfileFormat Declaration
|
||||
Class OBJsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OBJfileFormat
|
||||
template<class Face>
|
||||
class OBJsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef OBJsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OBJfileFormat(const OBJfileFormat&);
|
||||
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const OBJfileFormat&);
|
||||
void operator=(const OBJsurfaceFormat<Face>&);
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<FaceType>&,
|
||||
const List<Face>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
@ -80,47 +84,66 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
OBJfileFormat();
|
||||
OBJsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
OBJfileFormat(const fileName&, const bool triangulate=false);
|
||||
OBJsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=false
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new OBJfileFormat(fName,triangulate)
|
||||
new OBJsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~OBJsurfaceFormat()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName& fName, const keyedSurface& surf)
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName& fName, const meshedSurface& surf)
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
@ -141,6 +164,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "OBJsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
99
src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatRunTime.C
Normal file
99
src/surfMesh/surfaceFormats/obj/OBJsurfaceFormatRunTime.C
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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OBJsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OBJsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OBJsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OBJsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OBJsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
OBJsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
OBJsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
obj
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,56 +24,21 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OFFfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "OFFsurfaceFormat.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,
|
||||
OFFfileFormat,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
OFFfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
OFFfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::OFFfileFormat::writeHead
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OFFsurfaceFormat<Face>::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<FaceType>& faceLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
@ -116,52 +81,63 @@ void Foam::fileFormats::OFFfileFormat::writeHead
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::OFFfileFormat::OFFfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::OFFsurfaceFormat<Face>::OFFsurfaceFormat()
|
||||
:
|
||||
keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileFormats::OFFfileFormat::OFFfileFormat
|
||||
template<class Face>
|
||||
Foam::fileFormats::OFFsurfaceFormat<Face>::OFFsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName,triangulate);
|
||||
ThisType::read(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::OFFfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
IFstream is(fName);
|
||||
ParentType::clear();
|
||||
|
||||
// triangulation required?
|
||||
bool mustTriangulate = false;
|
||||
{
|
||||
Face f;
|
||||
if (f.max_size() == 3)
|
||||
{
|
||||
mustTriangulate = true;
|
||||
}
|
||||
}
|
||||
|
||||
IFstream is(fName);
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::OFFfileFormat::read(const fileName&)"
|
||||
"fileFormats::OFFsurfaceFormat<Face>::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << fName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Read header
|
||||
string hdr = getLineNoComment(is);
|
||||
string hdr = ParentType::getLineNoComment(is);
|
||||
if (hdr != "OFF")
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::OFFfileFormat::read(const fileName&)"
|
||||
"fileFormats::OFFsurfaceFormat<Face>::read(const fileName&)"
|
||||
)
|
||||
<< "OFF file " << fName << " does not start with 'OFF'"
|
||||
<< exit(FatalError);
|
||||
@ -171,7 +147,7 @@ bool Foam::fileFormats::OFFfileFormat::read
|
||||
// get dimensions
|
||||
label nPoints, nEdges, nElems;
|
||||
|
||||
string line = getLineNoComment(is);
|
||||
string line = ParentType::getLineNoComment(is);
|
||||
{
|
||||
IStringStream lineStream(line);
|
||||
lineStream >> nPoints >> nElems >> nEdges;
|
||||
@ -182,7 +158,7 @@ bool Foam::fileFormats::OFFfileFormat::read
|
||||
forAll(pointLst, pointI)
|
||||
{
|
||||
scalar x, y, z;
|
||||
line = getLineNoComment(is);
|
||||
line = ParentType::getLineNoComment(is);
|
||||
{
|
||||
IStringStream lineStream(line);
|
||||
lineStream >> x >> y >> z;
|
||||
@ -192,25 +168,27 @@ bool Foam::fileFormats::OFFfileFormat::read
|
||||
|
||||
// Read faces - ignore optional region information
|
||||
// use a DynamicList for possible on-the-fly triangulation
|
||||
DynamicList<FaceType> faceLst(nElems);
|
||||
DynamicList<Face> faceLst(nElems);
|
||||
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
line = getLineNoComment(is);
|
||||
line = ParentType::getLineNoComment(is);
|
||||
{
|
||||
IStringStream lineStream(line);
|
||||
|
||||
label nVerts;
|
||||
lineStream >> nVerts;
|
||||
|
||||
face f(nVerts);
|
||||
List<label> verts(nVerts);
|
||||
|
||||
forAll(f, fp)
|
||||
forAll(verts, vertI)
|
||||
{
|
||||
lineStream >> f[fp];
|
||||
lineStream >> verts[vertI];
|
||||
}
|
||||
|
||||
if (triangulate && f.size() > 3)
|
||||
UList<label>& f = static_cast<UList<label>&>(verts);
|
||||
|
||||
if (mustTriangulate)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
@ -229,31 +207,32 @@ bool Foam::fileFormats::OFFfileFormat::read
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(f);
|
||||
faceLst.append(Face(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
ParentType::points().transfer(pointLst);
|
||||
ParentType::faces().transfer(faceLst);
|
||||
|
||||
// no region information
|
||||
regions().setSize(size());
|
||||
regions() = 0;
|
||||
ParentType::regions().setSize(ThisType::size());
|
||||
ParentType::regions() = 0;
|
||||
|
||||
setPatches(0);
|
||||
ParentType::setPatches(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::OFFfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -267,7 +246,7 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
os << f.size();
|
||||
forAll(f, fp)
|
||||
@ -284,13 +263,14 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::OFFfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
@ -302,7 +282,7 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceIndex++];
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
os << f.size();
|
||||
forAll(f, fp)
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::OFFfileFormat
|
||||
Foam::fileFormats::OFFsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing Geomview OFF polyList format.
|
||||
@ -43,13 +43,13 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OFFfileFormat_H
|
||||
#define OFFfileFormat_H
|
||||
#ifndef OFFsurfaceFormat_H
|
||||
#define OFFsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -59,26 +59,31 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OFFfileFormat Declaration
|
||||
Class OFFsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OFFfileFormat
|
||||
template<class Face>
|
||||
class OFFsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef OFFsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OFFfileFormat(const OFFfileFormat&);
|
||||
OFFsurfaceFormat(const OFFsurfaceFormat&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const OFFfileFormat&);
|
||||
void operator=(const OFFsurfaceFormat&);
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<FaceType>&,
|
||||
const List<Face>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
@ -87,47 +92,64 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
OFFfileFormat();
|
||||
OFFsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
OFFfileFormat(const fileName&, const bool triangulate=false);
|
||||
OFFsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=false
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new OFFfileFormat(fName,triangulate)
|
||||
new OFFsurfaceFormat(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
virtual ~OFFsurfaceFormat()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName& fName, const keyedSurface& surf)
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName& fName, const meshedSurface& surf)
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
@ -148,6 +170,11 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "OFFsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
99
src/surfMesh/surfaceFormats/off/OFFsurfaceFormatRunTime.C
Normal file
99
src/surfMesh/surfaceFormats/off/OFFsurfaceFormatRunTime.C
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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OFFsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OFFsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OFFsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OFFsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
OFFsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
OFFsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
OFFsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
off
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,47 +24,21 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SMESHfileFormat.H"
|
||||
#include "SMESHsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IStringStream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
SMESHfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
SMESHfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::fileFormats::SMESHfileFormat::writeHead
|
||||
template<class Face>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst
|
||||
const List<Face>& faceLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
@ -88,7 +62,8 @@ void Foam::fileFormats::SMESHfileFormat::writeHead
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::SMESHfileFormat::writeTail(Ostream& os)
|
||||
template<class Face>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::writeTail(Ostream& os)
|
||||
{
|
||||
os << "# </faces>" << nl
|
||||
<< nl
|
||||
@ -100,21 +75,22 @@ void Foam::fileFormats::SMESHfileFormat::writeTail(Ostream& os)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::SMESHfileFormat::SMESHfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::SMESHsurfaceFormat<Face>::SMESHsurfaceFormat()
|
||||
:
|
||||
keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::fileFormats::SMESHfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
|
||||
@ -126,7 +102,7 @@ Foam::fileFormats::SMESHfileFormat::write
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
os << f.size();
|
||||
forAll(f, fp)
|
||||
@ -141,14 +117,14 @@ Foam::fileFormats::SMESHfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Foam::fileFormats::SMESHfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
@ -172,5 +148,4 @@ Foam::fileFormats::SMESHfileFormat::write
|
||||
writeTail(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::SMESHfileFormat
|
||||
Foam::fileFormats::SMESHsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of writing tetgen SMESH format.
|
||||
@ -35,18 +35,18 @@ See Also
|
||||
http://tetgen.berlios.de/fformats.smesh.html
|
||||
|
||||
SourceFiles
|
||||
SMESHfileFormat.C
|
||||
SMESHsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SMESHfileFormat_H
|
||||
#define SMESHfileFormat_H
|
||||
#ifndef SMESHsurfaceFormat_H
|
||||
#define SMESHsurfaceFormat_H
|
||||
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Ostream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -56,24 +56,27 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SMESHfileFormat Declaration
|
||||
Class SMESHsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class SMESHfileFormat
|
||||
template<class Face>
|
||||
class SMESHsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
// Private data
|
||||
//- Private typedefs for convenience
|
||||
typedef SMESHsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
SMESHfileFormat(const SMESHfileFormat&);
|
||||
SMESHsurfaceFormat(const SMESHsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const SMESHfileFormat&);
|
||||
void operator=(const SMESHsurfaceFormat<Face>&);
|
||||
|
||||
static void writeHead(Ostream&, const pointField&, const List<face>&);
|
||||
static void writeHead(Ostream&, const pointField&, const List<Face>&);
|
||||
static void writeTail(Ostream&);
|
||||
|
||||
public:
|
||||
@ -81,28 +84,48 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
SMESHfileFormat();
|
||||
SMESHsurfaceFormat();
|
||||
|
||||
// Selectors
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~SMESHsurfaceFormat()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName& fName, const keyedSurface& surf)
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName& fName, const meshedSurface& surf)
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
@ -123,6 +146,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "SMESHsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "SMESHsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
SMESHsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
SMESHsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
SMESHsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
SMESHsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
smesh
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,47 +24,12 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STARCDfileFormat.H"
|
||||
#include "STARCDsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IStringStream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
STARCDfileFormat,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
STARCDfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
STARCDfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//! @cond localscope
|
||||
const int starcdShellShape = 3;
|
||||
@ -74,7 +39,8 @@ const int starcdShellType = 4;
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::STARCDfileFormat::readHeader
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::STARCDsurfaceFormat<Face>::readHeader
|
||||
(
|
||||
IFstream& is,
|
||||
const word& signature
|
||||
@ -84,7 +50,7 @@ bool Foam::fileFormats::STARCDfileFormat::readHeader
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STARCDfileFormat::readHeader(...)"
|
||||
"fileFormats::STARCDsurfaceFormat::readHeader(...)"
|
||||
)
|
||||
<< "cannot read " << signature << " " << is.name()
|
||||
<< abort(FatalError);
|
||||
@ -112,7 +78,8 @@ bool Foam::fileFormats::STARCDfileFormat::readHeader
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDfileFormat::writeHeader
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const char* filetype
|
||||
@ -131,7 +98,8 @@ void Foam::fileFormats::STARCDfileFormat::writeHeader
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDfileFormat::writePoints
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::writePoints
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst
|
||||
@ -157,10 +125,11 @@ void Foam::fileFormats::STARCDfileFormat::writePoints
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::fileFormats::STARCDfileFormat::writeShell
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
||||
(
|
||||
Ostream& os,
|
||||
const face& f,
|
||||
const Face& f,
|
||||
const label cellId,
|
||||
const label cellTableId
|
||||
)
|
||||
@ -192,9 +161,10 @@ inline void Foam::fileFormats::STARCDfileFormat::writeShell
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STARCDfileFormat::STARCDfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::STARCDsurfaceFormat<Face>::STARCDsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
@ -211,27 +181,38 @@ Body:
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
Foam::fileFormats::STARCDfileFormat::STARCDfileFormat
|
||||
template<class Face>
|
||||
Foam::fileFormats::STARCDsurfaceFormat<Face>::STARCDsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName, triangulate);
|
||||
ThisType::read(fName);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
bool Foam::fileFormats::STARCDfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
ParentType::clear();
|
||||
|
||||
// triangulation required?
|
||||
bool mustTriangulate = false;
|
||||
{
|
||||
Face f;
|
||||
if (f.max_size() == 3)
|
||||
{
|
||||
mustTriangulate = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fileName baseName = fName.lessExt();
|
||||
autoPtr<IFstream> isPtr;
|
||||
@ -250,7 +231,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STARCDfileFormat::read(const fileName&)"
|
||||
"fileFormats::STARCDsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << (baseName + ".vrt")
|
||||
<< exit(FatalError);
|
||||
@ -271,7 +252,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
||||
}
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
ParentType::points().transfer(pointLst);
|
||||
|
||||
// Build inverse mapping (index to point)
|
||||
pointId.shrink();
|
||||
@ -283,7 +264,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
||||
pointId.clear();
|
||||
|
||||
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<Face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
|
||||
// From face cellTableId to patchId
|
||||
@ -300,7 +281,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STARCDfileFormat::read(const fileName&)"
|
||||
"fileFormats::STARCDsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << (baseName + ".cel")
|
||||
<< exit(FatalError);
|
||||
@ -356,20 +337,27 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
||||
starLabels[i] = mapToFoamPointId[starLabels[i]];
|
||||
}
|
||||
|
||||
if (triangulate && nLabels > 3)
|
||||
if (mustTriangulate && nLabels > 3)
|
||||
{
|
||||
face f
|
||||
(
|
||||
SubList<label>(starLabels, nLabels)
|
||||
);
|
||||
|
||||
faceList triFaces(f.nTriangles(points()));
|
||||
faceList triFaces(f.nTriangles(ParentType::points()));
|
||||
label nTri = 0;
|
||||
f.triangles(points(), nTri, triFaces);
|
||||
f.triangles(ParentType::points(), nTri, triFaces);
|
||||
|
||||
forAll(triFaces, faceI)
|
||||
{
|
||||
faceLst.append(triFaces[faceI]);
|
||||
// a triangle, but not yet a triFace
|
||||
faceLst.append
|
||||
(
|
||||
triFace
|
||||
(
|
||||
static_cast<UList<label>&>(triFaces[faceI])
|
||||
)
|
||||
);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
@ -377,7 +365,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
||||
{
|
||||
faceLst.append
|
||||
(
|
||||
face(SubList<label>(starLabels, nLabels))
|
||||
Face(SubList<label>(starLabels, nLabels))
|
||||
);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
@ -398,22 +386,23 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
||||
}
|
||||
|
||||
// transfer to normal lists
|
||||
faces().transfer(faceLst);
|
||||
regions().transfer(regionLst);
|
||||
ParentType::faces().transfer(faceLst);
|
||||
ParentType::regions().transfer(regionLst);
|
||||
|
||||
setPatches(regionNames);
|
||||
ParentType::setPatches(regionNames);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
fileName baseName = fName.lessExt();
|
||||
autoPtr<OFstream> osPtr;
|
||||
@ -436,7 +425,7 @@ void Foam::fileFormats::STARCDfileFormat::write
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
writeShell(osPtr(), f, faceIndex, patchI + 1);
|
||||
}
|
||||
@ -444,13 +433,14 @@ void Foam::fileFormats::STARCDfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
|
||||
@ -471,7 +461,7 @@ void Foam::fileFormats::STARCDfileFormat::write
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceIndex++];
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
writeShell(osPtr(), f, faceIndex, patchI + 1);
|
||||
}
|
||||
}
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::STARCDfileFormat
|
||||
Foam::fileFormats::STARCDsurfaceFormat
|
||||
|
||||
Description
|
||||
Read/write the surface shells from pro-STAR vrt/cel files.
|
||||
@ -35,19 +35,18 @@ See Also
|
||||
Foam::meshReaders::STARCD
|
||||
|
||||
SourceFiles
|
||||
STARCDfileFormat.C
|
||||
STARCDsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef STARCDfileFormat_H
|
||||
#define STARCDfileFormat_H
|
||||
#ifndef STARCDsurfaceFormat_H
|
||||
#define STARCDsurfaceFormat_H
|
||||
|
||||
#include "STLtriangle.H"
|
||||
#include "IFstream.H"
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -57,22 +56,25 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STARCDfileFormat Declaration
|
||||
Class STARCDsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STARCDfileFormat
|
||||
template<class Face>
|
||||
class STARCDsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
// Private data
|
||||
//- Private typedefs for convenience
|
||||
typedef STARCDsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
STARCDfileFormat(const STARCDfileFormat&);
|
||||
STARCDsurfaceFormat(const STARCDsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const STARCDfileFormat&);
|
||||
void operator=(const STARCDsurfaceFormat<Face>&);
|
||||
|
||||
|
||||
static bool readHeader(IFstream&, const word&);
|
||||
@ -84,7 +86,7 @@ class STARCDfileFormat
|
||||
static inline void writeShell
|
||||
(
|
||||
Ostream&,
|
||||
const face&,
|
||||
const Face&,
|
||||
const label cellId,
|
||||
const label cellTableId
|
||||
);
|
||||
@ -94,43 +96,45 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
STARCDfileFormat();
|
||||
STARCDsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
STARCDfileFormat(const fileName&, const bool triangulate=true);
|
||||
STARCDsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=true
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new STARCDfileFormat(fName, triangulate)
|
||||
new STARCDsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
virtual ~STARCDsurfaceFormat()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void write(const fileName&, const MeshedSurface<Face>&);
|
||||
|
||||
//- Write to Ostream as one large file - not really useful
|
||||
virtual void write(Ostream&) const
|
||||
{
|
||||
notImplemented("fileFormats::STARCDfileFormat::write(Ostream&)");
|
||||
notImplemented("fileFormats::STARCDsurfaceFormat::write(Ostream&)");
|
||||
}
|
||||
|
||||
};
|
||||
@ -143,6 +147,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "STARCDsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STARCDsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STARCDsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STARCDsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STARCDsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STARCDsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STARCDsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STARCDsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
inp
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
386
src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.C
Normal file
386
src/surfMesh/surfaceFormats/stl/STLsurfaceFormat.C
Normal file
@ -0,0 +1,386 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "STLsurfaceFormat.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const Face& f,
|
||||
const vector& norm
|
||||
)
|
||||
{
|
||||
// simple triangulation about f[0].
|
||||
// better triangulation should have been done before
|
||||
const point& p0 = pointLst[f[0]];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||
{
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
const point& p1 = pointLst[f[fp1]];
|
||||
const point& p2 = pointLst[f[fp2]];
|
||||
|
||||
// write STL triangle
|
||||
os << " facet normal "
|
||||
<< norm.x() << ' ' << norm.y() << ' ' << norm.z() << nl
|
||||
<< " outer loop\n"
|
||||
<< " vertex "
|
||||
<< p0.x() << ' ' << p0.y() << ' ' << p0.z() << nl
|
||||
<< " vertex "
|
||||
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl
|
||||
<< " vertex "
|
||||
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << nl
|
||||
<< " endloop\n"
|
||||
<< " endfacet" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
(
|
||||
ostream& os,
|
||||
const pointField& pointLst,
|
||||
const Face& f,
|
||||
const vector& norm,
|
||||
const label patchI
|
||||
)
|
||||
{
|
||||
// simple triangulation about f[0].
|
||||
// better triangulation should have been done before
|
||||
const point& p0 = pointLst[f[0]];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||
{
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
STLtriangle stlTri
|
||||
(
|
||||
norm,
|
||||
p0,
|
||||
pointLst[f[fp1]],
|
||||
pointLst[f[fp2]],
|
||||
patchI
|
||||
);
|
||||
|
||||
stlTri.write(os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write sorted:
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
|
||||
(
|
||||
Ostream& os,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const label faceI = faceMap[faceIndex++];
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// write sorted:
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
|
||||
(
|
||||
Ostream& os,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
// force triangulation, but just do the cheapest form possible
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
const label faceI = faceIndex++;
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write unsorted:
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
(
|
||||
ostream& os,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
// Write the STL header
|
||||
STLsurfaceFormatCore::writeHeaderBINARY(os);
|
||||
|
||||
// force triangulation, but just do the cheapest form possible
|
||||
unsigned int nTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nTris += faceLst[faceI].size() - 2;
|
||||
}
|
||||
|
||||
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
// always write unsorted
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
writeShell
|
||||
(
|
||||
os,
|
||||
pointLst,
|
||||
faceLst[faceI],
|
||||
normLst[faceI],
|
||||
regionLst[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
(
|
||||
ostream& os,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
// Write the STL header
|
||||
STLsurfaceFormatCore::writeHeaderBINARY(os);
|
||||
|
||||
// force triangulation, but just do the cheapest form possible
|
||||
unsigned int nTris = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nTris += faceLst[faceI].size() - 2;
|
||||
}
|
||||
|
||||
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
writeShell
|
||||
(
|
||||
os,
|
||||
pointLst,
|
||||
faceLst[faceIndex],
|
||||
normLst[faceIndex],
|
||||
patchI
|
||||
);
|
||||
|
||||
++faceIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
Foam::fileFormats::STLsurfaceFormat<Face>::STLsurfaceFormat()
|
||||
:
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::fileFormats::STLsurfaceFormat<Face>::STLsurfaceFormat
|
||||
(
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
ParentType()
|
||||
{
|
||||
ThisType::read(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
ParentType::clear();
|
||||
|
||||
// read in the values
|
||||
STLsurfaceFormatCore reader(fName);
|
||||
|
||||
pointField& pointLst = ParentType::points();
|
||||
List<Face>& faceLst = ParentType::faces();
|
||||
List<label>& regionLst = ParentType::regions();
|
||||
|
||||
// transfer
|
||||
pointLst.transfer(reader.points());
|
||||
regionLst.transfer(reader.regions());
|
||||
|
||||
// assemble the faces:
|
||||
faceLst.setSize(regionLst.size());
|
||||
|
||||
label ptI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
fTri[0] = ptI++;
|
||||
fTri[1] = ptI++;
|
||||
fTri[2] = ptI++;
|
||||
|
||||
faceLst[faceI] = fTri;
|
||||
}
|
||||
|
||||
if (reader.binary())
|
||||
{
|
||||
ParentType::setPatches(reader.maxRegionId());
|
||||
}
|
||||
else
|
||||
{
|
||||
ParentType::setPatches(reader.groupToPatch());
|
||||
}
|
||||
|
||||
ParentType::stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
writeASCII(os, surf);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
writeASCII(os, surf);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'stlb' as binary directly
|
||||
if (ext == "stlb")
|
||||
{
|
||||
std::ofstream ofs(fName.c_str(), std::ios::binary);
|
||||
writeBINARY(ofs, surf);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeASCII(OFstream(fName)(), surf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const word ext = fName.ext();
|
||||
|
||||
// handle 'stlb' as binary directly
|
||||
if (ext == "stlb")
|
||||
{
|
||||
std::ofstream ofs(fName.c_str(), std::ios::binary);
|
||||
writeBINARY(ofs, surf);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeASCII(OFstream(fName)(), surf);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,26 +23,23 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::STLfileFormat
|
||||
Foam::fileFormats::STLsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing STL files (ASCII and binary).
|
||||
|
||||
SourceFiles
|
||||
STLfileFormat.C
|
||||
STLfileFormatASCII.L
|
||||
STLsurfaceFormat.C
|
||||
STLsurfaceFormatASCII.L
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef STLfileFormat_H
|
||||
#define STLfileFormat_H
|
||||
#ifndef STLsurfaceFormat_H
|
||||
#define STLsurfaceFormat_H
|
||||
|
||||
#include "STLtriangle.H"
|
||||
#include "IFstream.H"
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "STLsurfaceFormatCore.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -52,110 +49,125 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STLfileFormat Declaration
|
||||
Class STLsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STLfileFormat
|
||||
template<class Face>
|
||||
class STLsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
// Private data
|
||||
//- Private typedefs for convenience
|
||||
typedef STLsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
//- The number of bytes in the STL binary header
|
||||
static const int headerSize=80;
|
||||
// Private data
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
STLfileFormat(const STLfileFormat&);
|
||||
STLsurfaceFormat(const STLsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const STLfileFormat&);
|
||||
void operator=(const STLsurfaceFormat<Face>&);
|
||||
|
||||
bool readASCII(IFstream&, const off_t);
|
||||
bool readBINARY(IFstream&, const off_t);
|
||||
|
||||
static bool detectBINARY(const fileName&);
|
||||
|
||||
//- write face in ASCII
|
||||
//- Write Face in ASCII
|
||||
static inline void writeShell
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const face&,
|
||||
const Face&,
|
||||
const vector& norm
|
||||
);
|
||||
|
||||
//- write face in BINARY
|
||||
//- Write Face in BINARY
|
||||
static inline void writeShell
|
||||
(
|
||||
ostream&,
|
||||
const pointField&,
|
||||
const face&,
|
||||
const Face&,
|
||||
const vector&,
|
||||
const label patchI
|
||||
);
|
||||
|
||||
|
||||
//- Write keySurface
|
||||
static void writeASCII(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void writeASCII(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void writeBINARY(ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void writeBINARY(ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void writeASCII(Ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void writeASCII(Ostream&, const MeshedSurface<Face>&);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void writeBINARY(ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void writeBINARY(ostream&, const MeshedSurface<Face>&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
STLfileFormat();
|
||||
STLsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
STLfileFormat(const fileName&, const bool triangulate=true);
|
||||
STLsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=true
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new STLfileFormat(fName,true)
|
||||
new STLsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
virtual ~STLsurfaceFormat()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write keyedSurface
|
||||
//- Write UnsortedMeshedSurface (as ASCII)
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface (as ASCII)
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface
|
||||
// The ASCII output is sorted by patch, the binary output is unsorted
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write keyedSurface
|
||||
//- Write MeshedSurface
|
||||
// The ASCII output is sorted by patch, the binary output is unsorted
|
||||
static void write(const fileName&, const keyedSurface&);
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName&, const meshedSurface&);
|
||||
|
||||
//- Write object
|
||||
//- Write object (only ASCII output)
|
||||
virtual void write(Ostream& os) const
|
||||
{
|
||||
write(os, *this);
|
||||
@ -171,6 +183,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "STLsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -32,8 +32,7 @@ License
|
||||
------ local definitions
|
||||
\* ------------------------------------------------------------------------ */
|
||||
|
||||
#include "STLfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "STLsurfaceFormatCore.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -111,7 +110,7 @@ public:
|
||||
}
|
||||
|
||||
//- region names
|
||||
const HashTable<label>& groupToPatch() const
|
||||
HashTable<label>& groupToPatch()
|
||||
{
|
||||
return groupToPatch_;
|
||||
}
|
||||
@ -360,7 +359,7 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
yy_pop_state();
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STLfileFormat::readASCII(const fileName&)"
|
||||
"fileFormats::STLsurfaceFormatCore::readASCII(const fileName&)"
|
||||
) << "while " << stateNames[YY_START] << " on line " << lineNo_ << nl
|
||||
<< " expected " << stateExpects[YY_START]
|
||||
<< " but found '" << startError_.c_str() << YYText() << "'"
|
||||
@ -379,14 +378,13 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
||||
//
|
||||
// member function
|
||||
//
|
||||
bool
|
||||
Foam::fileFormats::STLfileFormat::readASCII
|
||||
bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
|
||||
(
|
||||
IFstream& ifs,
|
||||
const off_t fileSize
|
||||
)
|
||||
{
|
||||
clear();
|
||||
binary_ = false;
|
||||
|
||||
// Create the lexer with the approximate number of vertices in the STL
|
||||
// from the file size
|
||||
@ -394,32 +392,12 @@ Foam::fileFormats::STLfileFormat::readASCII
|
||||
while (lexer.lex() != 0) {}
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(lexer.points());
|
||||
regions().transfer(lexer.facets());
|
||||
|
||||
// make our triangles directly
|
||||
List<FaceType>& faceLst = faces();
|
||||
faceLst.setSize(regions().size());
|
||||
|
||||
label ptI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
triFace fTri;
|
||||
|
||||
fTri[0] = ptI++;
|
||||
fTri[1] = ptI++;
|
||||
fTri[2] = ptI++;
|
||||
|
||||
faceLst[faceI] = fTri;
|
||||
}
|
||||
|
||||
setPatches(lexer.groupToPatch());
|
||||
stitchFaces(SMALL);
|
||||
|
||||
points_.transfer(lexer.points());
|
||||
regions_.transfer(lexer.facets());
|
||||
groupToPatch_.transfer(lexer.groupToPatch());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------ *\
|
||||
------ End of STLfileFormatASCII.L
|
||||
\* ------------------------------------------------------------------------ */
|
||||
236
src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C
Normal file
236
src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C
Normal file
@ -0,0 +1,236 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "STLsurfaceFormatCore.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
#undef DEBUG_STLBINARY
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// check binary by getting the header and number of facets
|
||||
// this seems to work better than the old token-based method
|
||||
// - some programs (eg, pro-STAR) have 'solid' as the first word in
|
||||
// the binary header.
|
||||
// - using wordToken can cause an abort if non-word (binary) content
|
||||
// is detected ... this is not exactly what we want.
|
||||
int Foam::fileFormats::STLsurfaceFormatCore::detectBINARY
|
||||
(
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
off_t fileSize = Foam::size(fName);
|
||||
|
||||
IFstream ifs(fName, IOstream::BINARY);
|
||||
istream& is = ifs.stdStream();
|
||||
|
||||
// Read the STL header
|
||||
char header[headerSize];
|
||||
is.read(header, headerSize);
|
||||
|
||||
// Check that stream is OK, if not this may be an ASCII file
|
||||
if (!is.good())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read the number of triangles in the STl file
|
||||
// (note: read as int so we can check whether >2^31)
|
||||
int nTris;
|
||||
is.read(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
// Check that stream is OK and number of triangles is positive,
|
||||
// if not this may be an ASCII file
|
||||
//
|
||||
// Also compare the file size with that expected from the number of tris
|
||||
// If the comparison is not sensible then it may be an ASCII file
|
||||
if
|
||||
(
|
||||
!is
|
||||
|| nTris < 0
|
||||
|| nTris < (fileSize - headerSize)/50
|
||||
|| nTris > (fileSize - headerSize)/25
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// looks like it might be BINARY, return number of triangles
|
||||
return nTris;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
||||
(
|
||||
IFstream& ifs,
|
||||
const off_t fileSize
|
||||
)
|
||||
{
|
||||
binary_ = true;
|
||||
istream& is = ifs.stdStream();
|
||||
|
||||
// Read the STL header
|
||||
char header[headerSize];
|
||||
is.read(header, headerSize);
|
||||
|
||||
// Check that stream is OK, if not this may be an ASCII file
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STLsurfaceFormatCore::readBINARY(IFstream&)"
|
||||
)
|
||||
<< "problem reading header, perhaps file is not binary "
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Read the number of triangles in the STl file
|
||||
// (note: read as int so we can check whether >2^31)
|
||||
int nTris;
|
||||
is.read(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
// Check that stream is OK and number of triangles is positive,
|
||||
// if not this maybe an ASCII file
|
||||
//
|
||||
// Also compare the file size with that expected from the number of tris
|
||||
// If the comparison is not sensible then it may be an ASCII file
|
||||
if
|
||||
(
|
||||
!is
|
||||
|| nTris < 0
|
||||
|| nTris < (fileSize - headerSize)/50
|
||||
|| nTris > (fileSize - headerSize)/25
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::STLsurfaceFormatCore::readBINARY(IFstream&)"
|
||||
)
|
||||
<< "problem reading number of triangles, perhaps file is not binary"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
Info<< "# " << nTris << " facets" << endl;
|
||||
label prevRegion = -1;
|
||||
#endif
|
||||
|
||||
points_.setSize(3*nTris);
|
||||
regions_.setSize(nTris);
|
||||
|
||||
label ptI = 0;
|
||||
forAll(regions_, faceI)
|
||||
{
|
||||
// Read an STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
|
||||
// transcript the vertices of the STL triangle -> points
|
||||
points_[ptI++] = stlTri.a();
|
||||
points_[ptI++] = stlTri.b();
|
||||
points_[ptI++] = stlTri.c();
|
||||
|
||||
// interprete colour as a region
|
||||
regions_[faceI] = stlTri.region();
|
||||
if (maxRegionId_ < stlTri.region())
|
||||
{
|
||||
maxRegionId_ = stlTri.region();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
if (prevRegion != stlTri.region())
|
||||
{
|
||||
if (prevRegion != -1)
|
||||
{
|
||||
Info<< "endsolid region" << prevRegion << nl;
|
||||
}
|
||||
prevRegion = stlTri.region();
|
||||
|
||||
Info<< "solid region" << prevRegion << nl;
|
||||
}
|
||||
|
||||
Info<< " facet normal " << stlTri.normal() << nl;
|
||||
Info<< " outer loop" << nl;
|
||||
Info<< " vertex " << stlTri.a() << nl;
|
||||
Info<< " vertex " << stlTri.b() << nl;
|
||||
Info<< " vertex " << stlTri.c() << nl;
|
||||
Info<< " outer loop" << nl;
|
||||
Info<< " endfacet" << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
|
||||
(
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
binary_(false),
|
||||
points_(0),
|
||||
regions_(0),
|
||||
maxRegionId_(0),
|
||||
groupToPatch_(0)
|
||||
{
|
||||
off_t fileSize = Foam::size(fName);
|
||||
|
||||
// auto-detect ascii/binary
|
||||
if (detectBINARY(fName))
|
||||
{
|
||||
readBINARY(IFstream(fName, IOstream::BINARY)(), fileSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
readASCII(IFstream(fName)(), fileSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::STLsurfaceFormatCore::~STLsurfaceFormatCore()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::STLsurfaceFormatCore::writeHeaderBINARY(ostream& os)
|
||||
{
|
||||
// Write the STL header, avoid possible trailing junk
|
||||
string header("STL binary file", headerSize);
|
||||
for (label i = header.size(); i < headerSize; ++i)
|
||||
{
|
||||
header[i] = 0;
|
||||
}
|
||||
os.write(header.c_str(), headerSize);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
173
src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.H
Normal file
173
src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.H
Normal file
@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::STLsurfaceFormatCore
|
||||
|
||||
Description
|
||||
Internal class used by the STLsurfaceFormat
|
||||
|
||||
SourceFiles
|
||||
STLsurfaceFormatCore.C
|
||||
STLsurfaceFormatASCII.L
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef STLsurfaceFormatCore_H
|
||||
#define STLsurfaceFormatCore_H
|
||||
|
||||
#include "STLtriangle.H"
|
||||
#include "triFace.H"
|
||||
#include "IFstream.H"
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STLsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STLsurfaceFormatCore
|
||||
{
|
||||
// Private Data
|
||||
|
||||
bool binary_;
|
||||
|
||||
//- The points supporting the facets
|
||||
pointField points_;
|
||||
|
||||
//- The regions associated with the faces
|
||||
List<label> regions_;
|
||||
|
||||
label maxRegionId_;
|
||||
|
||||
HashTable<label> groupToPatch_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
STLsurfaceFormatCore(const STLsurfaceFormatCore&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const STLsurfaceFormatCore&);
|
||||
|
||||
//- Determine the file type
|
||||
static int detectBINARY(const fileName&);
|
||||
|
||||
//- Read ASCII, set groupToPatch
|
||||
bool readASCII(IFstream&, const off_t);
|
||||
|
||||
//- Read BINARY, set maxRegionId
|
||||
bool readBINARY(IFstream&, const off_t);
|
||||
|
||||
public:
|
||||
|
||||
// Static Data
|
||||
|
||||
//- The number of bytes in the STL binary header
|
||||
static const int headerSize = 80;
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Write "STL binary file" to stream
|
||||
static void writeHeaderBINARY(ostream&);
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Read from file, filling in the information
|
||||
STLsurfaceFormatCore
|
||||
(
|
||||
const fileName&
|
||||
);
|
||||
|
||||
// Destructor
|
||||
~STLsurfaceFormatCore();
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- File was detected to be STL binary
|
||||
bool binary() const
|
||||
{
|
||||
return binary_;
|
||||
}
|
||||
|
||||
//- The number of facets is the number of regions
|
||||
label size() const
|
||||
{
|
||||
return regions_.size();
|
||||
}
|
||||
|
||||
//- Flush all values
|
||||
void clear()
|
||||
{
|
||||
points_.clear();
|
||||
regions_.clear();
|
||||
groupToPatch_.clear();
|
||||
}
|
||||
|
||||
//- Return full access to the faces
|
||||
pointField& points()
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- Return full access to the regions
|
||||
List<label>& regions()
|
||||
{
|
||||
return regions_;
|
||||
}
|
||||
|
||||
//- The max regionId when reading binary files
|
||||
label maxRegionId() const
|
||||
{
|
||||
return maxRegionId_;
|
||||
}
|
||||
|
||||
//- The group/patch information when reading ASCII files
|
||||
const HashTable<label>& groupToPatch() const
|
||||
{
|
||||
return groupToPatch_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fileFormats
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
154
src/surfMesh/surfaceFormats/stl/STLsurfaceFormatRunTime.C
Normal file
154
src/surfMesh/surfaceFormats/stl/STLsurfaceFormatRunTime.C
Normal file
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "STLsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
stl
|
||||
);
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
STLsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
stlb
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,57 +24,22 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "TRIfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "TRIsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "IStringStream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
TRIfileFormat,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
TRIfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
TRIfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::fileFormats::TRIfileFormat::writeShell
|
||||
template<class Face>
|
||||
inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const face& f,
|
||||
const Face& f,
|
||||
const label patchI
|
||||
)
|
||||
{
|
||||
@ -99,40 +64,41 @@ inline void Foam::fileFormats::TRIfileFormat::writeShell
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::TRIfileFormat::TRIfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::TRIsurfaceFormat<Face>::TRIsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileFormats::TRIfileFormat::TRIfileFormat
|
||||
template<class Face>
|
||||
Foam::fileFormats::TRIsurfaceFormat<Face>::TRIsurfaceFormat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{
|
||||
read(fName, true);
|
||||
read(fName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fileFormats::TRIfileFormat::read
|
||||
template<class Face>
|
||||
bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
clear();
|
||||
IFstream is(fName);
|
||||
ParentType::clear();
|
||||
|
||||
IFstream is(fName);
|
||||
if (!is.good())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::TRIfileFormat::read(const fileName&)"
|
||||
"fileFormats::TRIsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Cannot read file " << fName
|
||||
<< exit(FatalError);
|
||||
@ -150,13 +116,13 @@ bool Foam::fileFormats::TRIfileFormat::read
|
||||
|
||||
while (is.good())
|
||||
{
|
||||
string line = getLineNoComment(is);
|
||||
string line = ParentType::getLineNoComment(is);
|
||||
|
||||
// handle continuations ?
|
||||
// if (line[line.size()-1] == '\\')
|
||||
// {
|
||||
// line.substr(0, line.size()-1);
|
||||
// line += getLineNoComment(is);
|
||||
// line += ParentType::getLineNoComment(is);
|
||||
// }
|
||||
|
||||
IStringStream lineStream(line);
|
||||
@ -224,12 +190,12 @@ bool Foam::fileFormats::TRIfileFormat::read
|
||||
}
|
||||
|
||||
// transfer to normal list
|
||||
points().transfer(pointLst);
|
||||
regions().transfer(regionLst);
|
||||
ParentType::points().transfer(pointLst);
|
||||
ParentType::regions().transfer(regionLst);
|
||||
|
||||
// make our triangles directly
|
||||
List<FaceType>& faceLst = faces();
|
||||
faceLst.setSize(regions().size());
|
||||
List<Face>& faceLst = ParentType::faces();
|
||||
faceLst.setSize(ParentType::regions().size());
|
||||
|
||||
label ptI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
@ -243,21 +209,21 @@ bool Foam::fileFormats::TRIfileFormat::read
|
||||
faceLst[faceI] = fTri;
|
||||
}
|
||||
|
||||
setPatches(groupToPatch);
|
||||
stitchFaces(SMALL);
|
||||
|
||||
ParentType::setPatches(groupToPatch);
|
||||
ParentType::stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::TRIfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -267,21 +233,22 @@ void Foam::fileFormats::TRIfileFormat::write
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceMap[faceIndex++]];
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
writeShell(os, pointLst, f, patchI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::TRIfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
label faceIndex = 0;
|
||||
@ -289,7 +256,7 @@ void Foam::fileFormats::TRIfileFormat::write
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
const face& f = faceLst[faceIndex++];
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
writeShell(os, pointLst, f, patchI);
|
||||
}
|
||||
}
|
||||
@ -23,23 +23,23 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::TRIfileFormat
|
||||
Foam::fileFormats::TRIsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing .tri format.
|
||||
|
||||
SourceFiles
|
||||
TRIfileFormat.C
|
||||
TRIsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef TRIfileFormat_H
|
||||
#define TRIfileFormat_H
|
||||
#ifndef TRIsurfaceFormat_H
|
||||
#define TRIsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,27 +49,31 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class TRIfileFormat Declaration
|
||||
Class TRIsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class TRIfileFormat
|
||||
template<class Face>
|
||||
class TRIsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef TRIsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
TRIfileFormat(const TRIfileFormat&);
|
||||
TRIsurfaceFormat(const TRIsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TRIfileFormat&);
|
||||
void operator=(const TRIsurfaceFormat<Face>&);
|
||||
|
||||
static inline void writeShell
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const face&,
|
||||
const Face&,
|
||||
const label patchI
|
||||
);
|
||||
|
||||
@ -78,47 +82,64 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
TRIfileFormat();
|
||||
TRIsurfaceFormat();
|
||||
|
||||
//- Construct from file name
|
||||
TRIfileFormat(const fileName&, const bool triangulate=true);
|
||||
TRIsurfaceFormat(const fileName&);
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Read file and return keyedSurface
|
||||
static autoPtr<keyedSurface> New
|
||||
//- Read file and return surface
|
||||
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool triangulate=true
|
||||
const fileName& fName
|
||||
)
|
||||
{
|
||||
return autoPtr<keyedSurface>
|
||||
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||
(
|
||||
new TRIfileFormat(fName,true)
|
||||
new TRIsurfaceFormat<Face>(fName)
|
||||
);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
virtual ~TRIsurfaceFormat()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&, const bool triangulate);
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName& fName, const keyedSurface& surf)
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName& fName, const meshedSurface& surf)
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
@ -139,6 +160,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "TRIsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
99
src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatRunTime.C
Normal file
99
src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatRunTime.C
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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "TRIsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
face,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
addNamedTemplatedToRunTimeSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
triFace,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
TRIsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
tri
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,48 +24,20 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "VTKfileFormat.H"
|
||||
#include "VTKsurfaceFormat.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
keyedSurface,
|
||||
VTKfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
addNamedToMemberFunctionSelectionTable
|
||||
(
|
||||
meshedSurface,
|
||||
VTKfileFormat,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::VTKfileFormat::writeHead
|
||||
template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst
|
||||
const List<Face>& faceLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
@ -96,7 +68,8 @@ void Foam::fileFormats::VTKfileFormat::writeHead
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::VTKfileFormat::writeTail
|
||||
template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeTail
|
||||
(
|
||||
Ostream& os,
|
||||
const List<surfGroup>& patchLst
|
||||
@ -139,21 +112,23 @@ void Foam::fileFormats::VTKfileFormat::writeTail
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::VTKfileFormat::VTKfileFormat()
|
||||
template<class Face>
|
||||
Foam::fileFormats::VTKsurfaceFormat<Face>::VTKsurfaceFormat()
|
||||
:
|
||||
Foam::keyedSurface()
|
||||
ParentType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::VTKfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
|
||||
@ -181,13 +156,14 @@ void Foam::fileFormats::VTKfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::VTKfileFormat::write
|
||||
template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurface& surf
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
@ -23,23 +23,23 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fileFormats::VTKfileFormat
|
||||
Foam::fileFormats::VTKsurfaceFormat
|
||||
|
||||
Description
|
||||
Provide a means of writing VTK legacy format.
|
||||
|
||||
SourceFiles
|
||||
VTKfileFormat.C
|
||||
VTKsurfaceFormat.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef VTKfileFormat_H
|
||||
#define VTKfileFormat_H
|
||||
#ifndef VTKsurfaceFormat_H
|
||||
#define VTKsurfaceFormat_H
|
||||
|
||||
#include "Ostream.H"
|
||||
#include "OFstream.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,23 +49,27 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class VTKfileFormat Declaration
|
||||
Class VTKsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class VTKfileFormat
|
||||
template<class Face>
|
||||
class VTKsurfaceFormat
|
||||
:
|
||||
public keyedSurface
|
||||
public UnsortedMeshedSurface<Face>
|
||||
{
|
||||
//- Private typedefs for convenience
|
||||
typedef VTKsurfaceFormat<Face> ThisType;
|
||||
typedef UnsortedMeshedSurface<Face> ParentType;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
VTKfileFormat(const VTKfileFormat&);
|
||||
VTKsurfaceFormat(const VTKsurfaceFormat<Face>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const VTKfileFormat&);
|
||||
void operator=(const VTKsurfaceFormat<Face>&);
|
||||
|
||||
static void writeHead(Ostream&, const pointField&, const List<face>&);
|
||||
static void writeHead(Ostream&, const pointField&, const List<Face>&);
|
||||
static void writeTail(Ostream&, const List<surfGroup>&);
|
||||
|
||||
public:
|
||||
@ -73,30 +77,49 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
VTKfileFormat();
|
||||
VTKsurfaceFormat();
|
||||
|
||||
// Selectors
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~VTKsurfaceFormat()
|
||||
{}
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(Ostream&, const keyedSurface&);
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const UnsortedMeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write keyedSurface
|
||||
static void write(const fileName& fName, const keyedSurface& surf)
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(Ostream&, const meshedSurface&);
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write meshedSurface
|
||||
static void write(const fileName& fName, const meshedSurface& surf)
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
const fileName& fName,
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
write(OFstream(fName)(), surf);
|
||||
}
|
||||
@ -117,6 +140,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "VTKsurfaceFormat.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
81
src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatRunTime.C
Normal file
81
src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatRunTime.C
Normal file
@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "VTKsurfaceFormat.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
namespace fileFormats
|
||||
{
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
VTKsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
UnsortedMeshedSurface,
|
||||
VTKsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
VTKsurfaceFormat,
|
||||
face,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
addNamedTemplatedToMemberFunctionSelectionTable
|
||||
(
|
||||
MeshedSurface,
|
||||
VTKsurfaceFormat,
|
||||
triFace,
|
||||
write,
|
||||
fileExtension,
|
||||
vtk
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user