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 "timeSelector.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "keyedSurface.H"
|
|
||||||
#include "meshedSurface.H"
|
|
||||||
#include "triSurface.H"
|
#include "triSurface.H"
|
||||||
|
|
||||||
|
#include "MeshedSurfaces.H"
|
||||||
|
#include "UnsortedMeshedSurfaces.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -69,7 +70,7 @@ int main(int argc, char *argv[])
|
|||||||
argList::validOptions.insert("clean", "");
|
argList::validOptions.insert("clean", "");
|
||||||
argList::validOptions.insert("scale", "scale");
|
argList::validOptions.insert("scale", "scale");
|
||||||
argList::validOptions.insert("triSurface", "");
|
argList::validOptions.insert("triSurface", "");
|
||||||
argList::validOptions.insert("keyed", "");
|
argList::validOptions.insert("unsorted", "");
|
||||||
# include "setRootCase.H"
|
# include "setRootCase.H"
|
||||||
const stringList& params = args.additionalArgs();
|
const stringList& params = args.additionalArgs();
|
||||||
|
|
||||||
@ -122,9 +123,9 @@ int main(int argc, char *argv[])
|
|||||||
// write sorted by region
|
// write sorted by region
|
||||||
surf.write(exportName, true);
|
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"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,27 +2,23 @@ surfGroup/surfGroup.C
|
|||||||
surfGroup/surfGroupIOList.C
|
surfGroup/surfGroupIOList.C
|
||||||
surfPatchIdentifier/surfPatchIdentifier.C
|
surfPatchIdentifier/surfPatchIdentifier.C
|
||||||
|
|
||||||
keyedSurface/keyedSurface.C
|
MeshedSurface/MeshedSurfaces.C
|
||||||
keyedSurface/keyedSurfaceCleanup.C
|
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||||
keyedSurface/newKeyedSurface.C
|
|
||||||
|
|
||||||
meshedSurface/meshedSurface.C
|
surfaceFormats = surfaceFormats
|
||||||
meshedSurface/meshedSurfaceCleanup.C
|
$(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C
|
||||||
meshedSurface/newMeshedSurface.C
|
$(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C
|
||||||
|
$(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C
|
||||||
fileFormats = keyedSurface/fileFormats
|
$(surfaceFormats)/nas/NASsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/ac3d/AC3DfileFormat.C
|
$(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/ftr/FTRfileFormat.C
|
$(surfaceFormats)/off/OFFsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/gts/GTSfileFormat.C
|
$(surfaceFormats)/smesh/SMESHsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/nas/NASfileFormat.C
|
$(surfaceFormats)/starcd/STARCDsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/obj/OBJfileFormat.C
|
$(surfaceFormats)/stl/STLsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/off/OFFfileFormat.C
|
$(surfaceFormats)/stl/STLsurfaceFormatASCII.L
|
||||||
$(fileFormats)/smesh/SMESHfileFormat.C
|
$(surfaceFormats)/stl/STLsurfaceFormatCore.C
|
||||||
$(fileFormats)/starcd/STARCDfileFormat.C
|
$(surfaceFormats)/tri/TRIsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/stl/STLfileFormat.C
|
$(surfaceFormats)/vtk/VTKsurfaceFormatRunTime.C
|
||||||
$(fileFormats)/stl/STLfileFormatASCII.L
|
|
||||||
$(fileFormats)/tri/TRIfileFormat.C
|
|
||||||
$(fileFormats)/vtk/VTKfileFormat.C
|
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libsurfMesh
|
LIB = $(FOAM_LIBBIN)/libsurfMesh
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,8 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "meshedSurface.H"
|
#include "MeshedSurface.H"
|
||||||
#include "keyedSurface.H"
|
#include "UnsortedMeshedSurface.H"
|
||||||
#include "demandDrivenData.H"
|
#include "demandDrivenData.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
@ -41,27 +41,16 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
defineTypeNameAndDebug(meshedSurface, 0);
|
|
||||||
defineMemberFunctionSelectionTable
|
|
||||||
(
|
|
||||||
meshedSurface,
|
|
||||||
write,
|
|
||||||
fileExtension
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// File extension for 'native' raw format
|
// File extension for 'native' raw format
|
||||||
//! @cond localscope
|
#undef nativeSurfaceExt
|
||||||
const char * const nativeExt = "ofs";
|
#define nativeSurfaceExt "ofs"
|
||||||
//! @endcond localscope
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * 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
|
// Search back through the time directories list to find the time
|
||||||
// closest to and lower than current time
|
// closest to and lower than current time
|
||||||
@ -88,7 +77,7 @@ Foam::fileName Foam::meshedSurface::triSurfInstance(const Time& d)
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " meshedSurface::triSurfInstance(const Time& d)"
|
Pout<< " MeshedSurface::triSurfInstance(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from " << ts[j].name()/typeName
|
<< " from " << ts[j].name()/typeName
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -101,7 +90,7 @@ Foam::fileName Foam::meshedSurface::triSurfInstance(const Time& d)
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " meshedSurface::triSurfInstance(const Time& d)"
|
Pout<< " MeshedSurface::triSurfInstance(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from constant/" << endl;
|
<< " 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
|
// Search back through the time directories list to find the time
|
||||||
// closest to and lower than current time
|
// closest to and lower than current time
|
||||||
@ -141,7 +131,7 @@ Foam::fileName Foam::meshedSurface::triSurfName(const Time& d)
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " meshedSurface::triSurfName(const Time& d)"
|
Pout<< " MeshedSurface::triSurfName(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from " << ts[j].name()/typeName
|
<< " from " << ts[j].name()/typeName
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -154,7 +144,7 @@ Foam::fileName Foam::meshedSurface::triSurfName(const Time& d)
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " meshedSurface::triSurfName(const Time& d)"
|
Pout<< " MeshedSurface::triSurfName(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from constant/" << endl;
|
<< " from constant/" << endl;
|
||||||
}
|
}
|
||||||
@ -162,13 +152,21 @@ Foam::fileName Foam::meshedSurface::triSurfName(const Time& d)
|
|||||||
return d.path()/"constant"/typeName/foamName;
|
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
|
// perhaps sent an entire name
|
||||||
word fExt(ext);
|
word fExt(ext);
|
||||||
@ -180,12 +178,12 @@ bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (fExt == nativeExt)
|
if (fExt == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||||
writefileExtensionMemberFunctionTablePtr_->find(fExt);
|
writefileExtensionMemberFunctionTablePtr_->find(fExt);
|
||||||
|
|
||||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
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;
|
Info<<"Unknown file extension for writing: " << fExt << nl;
|
||||||
// compact output:
|
// compact output:
|
||||||
Info<<"Valid types: ( " << nativeExt;
|
Info<<"Valid types: ( " << nativeSurfaceExt;
|
||||||
forAll(known, i)
|
forAll(known, i)
|
||||||
{
|
{
|
||||||
Info<<" " << known[i];
|
Info<<" " << known[i];
|
||||||
@ -214,36 +212,37 @@ 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 fileName& fName,
|
||||||
const meshedSurface& surf
|
const MeshedSurface& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "meshedSurface::write(const fileName&, const meshedSurface&) : "
|
Info<< "MeshedSurface::write(const fileName&, const MeshedSurface&) : "
|
||||||
"writing meshedSurface to " << fName
|
"writing MeshedSurface to " << fName
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const word ext = fName.ext();
|
const word ext = fName.ext();
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (ext == nativeExt)
|
if (ext == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
surf.write(OFstream(fName)());
|
surf.write(OFstream(fName)());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
|
||||||
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
||||||
|
|
||||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"meshedSurface::write(const fileName&)"
|
"MeshedSurface::write(const fileName&)"
|
||||||
) << "Unknown file extension " << ext << nl << nl
|
) << "Unknown file extension " << ext << nl << nl
|
||||||
<< "Valid types are :" << endl
|
<< "Valid types are :" << endl
|
||||||
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
||||||
@ -251,26 +250,27 @@ void Foam::meshedSurface::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
mfIter()(fName, surf);
|
mfIter()(fName, surf);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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<pointField>& pointLst,
|
||||||
const xfer<List<FaceType> >& faceLst,
|
const xfer<List<Face> >& faceLst,
|
||||||
const xfer<surfGroupList>& patchLst
|
const xfer<surfGroupList>& patchLst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField()),
|
ParentType(List<Face>(), pointField()),
|
||||||
patches_(patchLst)
|
patches_(patchLst)
|
||||||
{
|
{
|
||||||
points().transfer(pointLst());
|
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<pointField>& pointLst,
|
||||||
const xfer<List<FaceType> >& faceLst,
|
const xfer<List<Face> >& faceLst,
|
||||||
const UList<label>& patchSizes,
|
const UList<label>& patchSizes,
|
||||||
const UList<word>& patchNames,
|
const UList<word>& patchNames,
|
||||||
const UList<word>& patchTypes
|
const UList<word>& patchTypes
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField())
|
ParentType(List<Face>(), pointField())
|
||||||
{
|
{
|
||||||
points().transfer(pointLst());
|
points().transfer(pointLst());
|
||||||
faces().transfer(faceLst());
|
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<pointField>& pointLst,
|
||||||
const xfer<List<FaceType> >& faceLst,
|
const xfer<List<Face> >& faceLst,
|
||||||
const UList<label>& regionIds,
|
const UList<label>& regionIds,
|
||||||
const Map<word>& regionNames
|
const Map<word>& regionNames
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField())
|
ParentType(List<Face>(), pointField())
|
||||||
{
|
{
|
||||||
points().transfer(pointLst());
|
points().transfer(pointLst());
|
||||||
faces().transfer(faceLst());
|
faces().transfer(faceLst());
|
||||||
@ -334,10 +336,10 @@ Foam::meshedSurface::meshedSurface
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"meshedSurface::meshedSurface(\n"
|
"MeshedSurface::MeshedSurface(\n"
|
||||||
"(\n"
|
"(\n"
|
||||||
" const xfer<pointField>&,\n"
|
" const xfer<pointField>&,\n"
|
||||||
" const xfer<List<FaceType> >&,\n"
|
" const xfer<List<Face> >&,\n"
|
||||||
" const UList<label>& regionIds,\n"
|
" const UList<label>& regionIds,\n"
|
||||||
" const Map<word>& regionNames\n"
|
" const Map<word>& regionNames\n"
|
||||||
" )\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<pointField>& pointLst,
|
||||||
const xfer<List<FaceType> >& faceLst,
|
const xfer<List<Face> >& faceLst,
|
||||||
const UList<label>& regionIds,
|
const UList<label>& regionIds,
|
||||||
const HashTable<label>& nameToRegionMapping
|
const HashTable<label>& nameToRegionMapping
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField())
|
ParentType(List<Face>(), pointField())
|
||||||
{
|
{
|
||||||
points().transfer(pointLst());
|
points().transfer(pointLst());
|
||||||
faces().transfer(faceLst());
|
faces().transfer(faceLst());
|
||||||
@ -369,10 +372,10 @@ Foam::meshedSurface::meshedSurface
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"meshedSurface::meshedSurface(\n"
|
"MeshedSurface::MeshedSurface(\n"
|
||||||
"(\n"
|
"(\n"
|
||||||
" const xfer<pointField>&,\n"
|
" const xfer<pointField>&,\n"
|
||||||
" const xfer<List<FaceType> >&,\n"
|
" const xfer<List<Face> >&,\n"
|
||||||
" const UList<label>& regionIds,\n"
|
" const UList<label>& regionIds,\n"
|
||||||
" const HashTable<label>& nameToRegionMapping\n"
|
" const HashTable<label>& nameToRegionMapping\n"
|
||||||
" )\n"
|
" )\n"
|
||||||
@ -393,13 +396,14 @@ Foam::meshedSurface::meshedSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::meshedSurface::meshedSurface
|
template<class Face>
|
||||||
|
Foam::MeshedSurface<Face>::MeshedSurface
|
||||||
(
|
(
|
||||||
const polyBoundaryMesh& bMesh,
|
const polyBoundaryMesh& bMesh,
|
||||||
const bool useGlobalPoints
|
const bool useGlobalPoints
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField())
|
ParentType(List<Face>(), pointField())
|
||||||
{
|
{
|
||||||
const polyMesh& mesh = bMesh.mesh();
|
const polyMesh& mesh = bMesh.mesh();
|
||||||
const polyPatchList& bPatches = bMesh;
|
const polyPatchList& bPatches = bMesh;
|
||||||
@ -408,7 +412,7 @@ Foam::meshedSurface::meshedSurface
|
|||||||
// Get patch for all of outside
|
// Get patch for all of outside
|
||||||
primitivePatch allBoundary
|
primitivePatch allBoundary
|
||||||
(
|
(
|
||||||
SubList<FaceType>
|
SubList<Face>
|
||||||
(
|
(
|
||||||
mesh.faces(),
|
mesh.faces(),
|
||||||
mesh.nFaces() - nIntFaces,
|
mesh.nFaces() - nIntFaces,
|
||||||
@ -455,12 +459,12 @@ Foam::meshedSurface::meshedSurface
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// in preparation
|
// in preparation
|
||||||
Foam::meshedSurface::meshedSurface
|
Foam::MeshedSurface<Face>::MeshedSurface
|
||||||
(
|
(
|
||||||
const surfMesh& sMesh
|
const surfMesh& sMesh
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(sMesh.faces()), sMesh.points())
|
ParentType(List<Face>(sMesh.faces()), sMesh.points())
|
||||||
{
|
{
|
||||||
const surfPatchList& sPatches = sMesh.boundaryMesh();
|
const surfPatchList& sPatches = sMesh.boundaryMesh();
|
||||||
|
|
||||||
@ -488,19 +492,20 @@ Foam::meshedSurface::meshedSurface
|
|||||||
#endif
|
#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;
|
labelList faceMap;
|
||||||
surfGroupList patchLst = surf.sortedRegions(faceMap);
|
surfGroupList patchLst = surf.sortedRegions(faceMap);
|
||||||
patches_.transfer(patchLst);
|
patches_.transfer(patchLst);
|
||||||
|
|
||||||
const List<FaceType>& origFaces = surf.faces();
|
const List<Face>& origFaces = surf.faces();
|
||||||
List<FaceType> newFaces(origFaces.size());
|
List<Face> newFaces(origFaces.size());
|
||||||
|
|
||||||
// this is somewhat like ListOps reorder and/or IndirectList
|
// this is somewhat like ListOps reorder and/or IndirectList
|
||||||
forAll(newFaces, faceI)
|
forAll(newFaces, faceI)
|
||||||
@ -512,66 +517,74 @@ Foam::meshedSurface::meshedSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::meshedSurface::meshedSurface
|
template<class Face>
|
||||||
|
Foam::MeshedSurface<Face>::MeshedSurface
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const word& ext,
|
const word& ext
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
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 fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
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))());
|
read(IFstream(triSurfName(d))());
|
||||||
// setDefaultPatches();
|
// 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_)
|
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());
|
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());
|
transfer(surf());
|
||||||
}
|
}
|
||||||
@ -580,13 +593,15 @@ Foam::meshedSurface::meshedSurface(const xfer<meshedSurface>& surf)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::meshedSurface::~meshedSurface()
|
template<class Face>
|
||||||
|
Foam::MeshedSurface<Face>::~MeshedSurface()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::meshedSurface::onePatch()
|
template<class Face>
|
||||||
|
void Foam::MeshedSurface<Face>::onePatch()
|
||||||
{
|
{
|
||||||
// set single default patch
|
// set single default patch
|
||||||
patches_.setSize(1);
|
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,
|
// extra safety, ensure we have at some patches,
|
||||||
// and they cover all the faces
|
// and they cover all the faces
|
||||||
@ -618,7 +634,7 @@ void Foam::meshedSurface::checkPatches()
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"meshedSurface::checkPatches()\n"
|
"MeshedSurface::checkPatches()\n"
|
||||||
)
|
)
|
||||||
<< "more nFaces " << size()
|
<< "more nFaces " << size()
|
||||||
<< " than patches " << count
|
<< " than patches " << count
|
||||||
@ -631,7 +647,7 @@ void Foam::meshedSurface::checkPatches()
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"meshedSurface::checkPatches()\n"
|
"MeshedSurface::checkPatches()\n"
|
||||||
)
|
)
|
||||||
<< "more patches " << count
|
<< "more patches " << count
|
||||||
<< " than nFaces " << size()
|
<< " 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 UList<label>& regionIds,
|
||||||
const Map<word>& regionNames
|
const Map<word>& regionNames
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const List<FaceType>& unsortedFaces = faces();
|
const List<Face>& unsortedFaces = faces();
|
||||||
|
|
||||||
if (!®ionNames || !®ionIds || regionIds.size() == 0)
|
if (!®ionNames || !®ionIds || regionIds.size() == 0)
|
||||||
{
|
{
|
||||||
@ -670,7 +687,7 @@ void Foam::meshedSurface::sortFacesByRegion
|
|||||||
else if (regionIds.size() == unsortedFaces.size())
|
else if (regionIds.size() == unsortedFaces.size())
|
||||||
{
|
{
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
surfGroupList newPatches = keyedSurface::sortedRegions
|
surfGroupList newPatches = UnsortedMeshedSurface<Face>::sortedRegions
|
||||||
(
|
(
|
||||||
regionIds,
|
regionIds,
|
||||||
regionNames,
|
regionNames,
|
||||||
@ -679,7 +696,7 @@ void Foam::meshedSurface::sortFacesByRegion
|
|||||||
patches_.transfer(newPatches);
|
patches_.transfer(newPatches);
|
||||||
|
|
||||||
// this is somewhat like ListOps reorder and/or IndirectList
|
// this is somewhat like ListOps reorder and/or IndirectList
|
||||||
List<FaceType> newFaces(unsortedFaces.size());
|
List<Face> newFaces(unsortedFaces.size());
|
||||||
forAll(newFaces, faceI)
|
forAll(newFaces, faceI)
|
||||||
{
|
{
|
||||||
newFaces[faceI] = unsortedFaces[faceMap[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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::meshedSurface::clear()
|
template<class Face>
|
||||||
|
void Foam::MeshedSurface<Face>::clear()
|
||||||
{
|
{
|
||||||
MeshStorage::clearOut();
|
ParentType::clearOut();
|
||||||
|
|
||||||
points().clear();
|
points().clear();
|
||||||
faces().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
|
// Remove all geometry dependent data
|
||||||
MeshStorage::clearTopology();
|
ParentType::clearTopology();
|
||||||
|
|
||||||
// Adapt for new point position
|
// Adapt for new point position
|
||||||
MeshStorage::movePoints(newPoints);
|
ParentType::movePoints(newPoints);
|
||||||
|
|
||||||
// Copy new points
|
// Copy new points
|
||||||
points() = newPoints;
|
points() = newPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::meshedSurface::scalePoints(const scalar& scaleFactor)
|
template<class Face>
|
||||||
|
void Foam::MeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
|
||||||
{
|
{
|
||||||
// avoid bad scaling
|
// avoid bad scaling
|
||||||
if (scaleFactor > 0 && scaleFactor != 1.0)
|
if (scaleFactor > 0 && scaleFactor != 1.0)
|
||||||
{
|
{
|
||||||
// Remove all geometry dependent data
|
// Remove all geometry dependent data
|
||||||
MeshStorage::clearTopology();
|
ParentType::clearTopology();
|
||||||
|
|
||||||
// Adapt for new point position
|
// Adapt for new point position
|
||||||
MeshStorage::movePoints(pointField());
|
ParentType::movePoints(pointField());
|
||||||
|
|
||||||
points() *= scaleFactor;
|
points() *= scaleFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
template<class Face>
|
||||||
|
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||||
(
|
(
|
||||||
const UList<bool>& include,
|
const UList<bool>& include,
|
||||||
labelList& pointMap,
|
labelList& pointMap,
|
||||||
labelList& faceMap
|
labelList& faceMap
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const pointField& locPoints = localPoints();
|
const pointField& locPoints = ParentType::localPoints();
|
||||||
const List<FaceType>& locFaces = localFaces();
|
const List<Face>& locFaces = ParentType::localFaces();
|
||||||
|
|
||||||
// Fill pointMap, faceMap
|
// Fill pointMap, faceMap
|
||||||
subsetMap(include, pointMap, faceMap);
|
ParentType::subsetMap(include, pointMap, faceMap);
|
||||||
|
|
||||||
// Create compact coordinate list and forward mapping array
|
// Create compact coordinate list and forward mapping array
|
||||||
pointField newPoints(pointMap.size());
|
pointField newPoints(pointMap.size());
|
||||||
@ -792,18 +787,18 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renumber face node labels and compact
|
// Renumber face node labels and compact
|
||||||
List<FaceType> newFaces(faceMap.size());
|
List<Face> newFaces(faceMap.size());
|
||||||
|
|
||||||
forAll(faceMap, faceI)
|
forAll(faceMap, faceI)
|
||||||
{
|
{
|
||||||
// Get old vertex labels
|
// Get old vertex labels
|
||||||
label origFaceI = faceMap[faceI];
|
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
|
// Renumber labels for face
|
||||||
FaceType& f = newFaces[faceI];
|
Face& f = newFaces[faceI];
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
f[fp] = oldToNew[oldFace[fp]];
|
f[fp] = oldToNew[oldFace[fp]];
|
||||||
@ -835,7 +830,7 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// construct a sub-surface
|
// construct a sub-surface
|
||||||
meshedSurface subSurf
|
MeshedSurface subSurf
|
||||||
(
|
(
|
||||||
xferMove(newPoints),
|
xferMove(newPoints),
|
||||||
xferMove(newFaces),
|
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();
|
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();
|
clear();
|
||||||
points().transfer(surf.points());
|
points().transfer(surf.points());
|
||||||
@ -870,8 +873,8 @@ void Foam::meshedSurface::transfer(keyedSurface& surf)
|
|||||||
surf.regions_.clear();
|
surf.regions_.clear();
|
||||||
surf.patches_.clear();
|
surf.patches_.clear();
|
||||||
|
|
||||||
List<FaceType>& oldFaces = surf.faces();
|
List<Face>& oldFaces = surf.faces();
|
||||||
List<FaceType> newFaces(oldFaces.size());
|
List<Face> newFaces(oldFaces.size());
|
||||||
|
|
||||||
// this is somewhat like ListOps reorder and/or IndirectList
|
// this is somewhat like ListOps reorder and/or IndirectList
|
||||||
forAll(newFaces, faceI)
|
forAll(newFaces, faceI)
|
||||||
@ -886,101 +889,74 @@ void Foam::meshedSurface::transfer(keyedSurface& surf)
|
|||||||
|
|
||||||
|
|
||||||
// Read from file in given format
|
// Read from file in given format
|
||||||
bool Foam::meshedSurface::read
|
template<class Face>
|
||||||
|
bool Foam::MeshedSurface<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
const word ext = fName.ext();
|
const word ext = fName.ext();
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (ext == nativeExt)
|
if (ext == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
return read(IFstream(fName)(), triangulate);
|
return read(IFstream(fName)());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use selector mechanism
|
// use selector mechanism
|
||||||
transfer(New(fName, ext, triangulate)());
|
transfer(New(fName, ext)());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read from file in given format
|
// Read from file in given format
|
||||||
bool Foam::meshedSurface::read
|
template<class Face>
|
||||||
|
bool Foam::MeshedSurface<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const word& ext,
|
const word& ext
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (ext == nativeExt)
|
if (ext == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
return read(IFstream(fName)(), triangulate);
|
return read(IFstream(fName)());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use selector mechanism
|
// use selector mechanism
|
||||||
transfer(New(fName, ext, triangulate)());
|
transfer(New(fName, ext)());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::meshedSurface::write(Ostream& os) const
|
template<class Face>
|
||||||
{
|
void Foam::MeshedSurface<Face>::write(const Time& d) 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
|
|
||||||
{
|
{
|
||||||
write(OFstream(triSurfName(d))());
|
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
|
// os << "Faces : " << size() << endl
|
||||||
<< "Edges : " << nEdges() << endl
|
// << "Edges : " << nEdges() << endl
|
||||||
<< "Vertices : " << nPoints() << endl
|
// << "Vertices : " << nPoints() << endl
|
||||||
<< "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
// << "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::meshedSurface::operator=(const meshedSurface& surf)
|
template<class Face>
|
||||||
|
void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
@ -993,13 +969,12 @@ void Foam::meshedSurface::operator=(const meshedSurface& surf)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::meshedSurface
|
Foam::MeshedSurface
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A surface geometry mesh with patch information, not to be confused
|
A surface geometry mesh with patch information, not to be confused
|
||||||
with a similarily named surfaceMesh, which actually refers to
|
with a similarily named surfaceMesh, which actually refers to
|
||||||
the cell faces of a volume mesh!
|
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 without any patch information.
|
||||||
- A set of points and faces with randomly sorted patch information.
|
- A set of points and faces with randomly sorted patch information.
|
||||||
This could arise, for example, from reading external file formats
|
This could arise, for example, from reading external file formats
|
||||||
such as STL, etc.
|
such as STL, etc.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
meshedSurface.C
|
MeshedSurface.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef meshedSurface_H
|
#ifndef MeshedSurface_H
|
||||||
#define meshedSurface_H
|
#define MeshedSurface_H
|
||||||
|
|
||||||
#include "pointField.H"
|
#include "pointField.H"
|
||||||
#include "PrimitivePatchExtra.H"
|
#include "PrimitivePatchExtra.H"
|
||||||
#include "boolList.H"
|
#include "boolList.H"
|
||||||
#include "surfGroupList.H"
|
#include "surfGroupList.H"
|
||||||
#include "face.H"
|
|
||||||
#include "xfer.H"
|
#include "xfer.H"
|
||||||
|
#include "face.H"
|
||||||
|
#include "triFace.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
#include "memberFunctionSelectionTables.H"
|
#include "memberFunctionSelectionTables.H"
|
||||||
|
|
||||||
@ -61,44 +62,38 @@ namespace Foam
|
|||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
class Time;
|
class Time;
|
||||||
class keyedSurface;
|
template<class Face> class MeshedSurface;
|
||||||
class meshedSurface;
|
template<class Face> class UnsortedMeshedSurface;
|
||||||
|
|
||||||
class polyBoundaryMesh;
|
class polyBoundaryMesh;
|
||||||
class surfMesh;
|
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;
|
friend class UnsortedMeshedSurface<Face>;
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Protected Member Data
|
|
||||||
|
|
||||||
//- Typedef for similar code in keyedSurface and meshedSurface
|
|
||||||
typedef face FaceType;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private Member Data
|
//- Private typedefs for convenience
|
||||||
|
typedef MeshedSurface<Face> ThisType;
|
||||||
// Private typedefs
|
|
||||||
|
|
||||||
typedef PrimitivePatchExtra
|
typedef PrimitivePatchExtra
|
||||||
<
|
<
|
||||||
FaceType,
|
Face,
|
||||||
::Foam::List,
|
::Foam::List,
|
||||||
pointField,
|
pointField,
|
||||||
point
|
point
|
||||||
>
|
>
|
||||||
MeshStorage;
|
ParentType;
|
||||||
|
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
@ -118,7 +113,7 @@ private:
|
|||||||
void sortFacesByRegion(const UList<label>&, const Map<word>&);
|
void sortFacesByRegion(const UList<label>&, const Map<word>&);
|
||||||
|
|
||||||
//- Read OpenFOAM Surface format
|
//- Read OpenFOAM Surface format
|
||||||
bool read(Istream&, const bool triangulate=false);
|
bool read(Istream&);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -128,26 +123,26 @@ protected:
|
|||||||
//- Return non-const access to global points
|
//- Return non-const access to global points
|
||||||
pointField& points()
|
pointField& points()
|
||||||
{
|
{
|
||||||
return const_cast<pointField&>(MeshStorage::points());
|
return const_cast<pointField&>(ParentType::points());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return non-const access to the faces
|
//- 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:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
ClassName("meshedSurface");
|
ClassName("MeshedSurface");
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
//- Name of meshedSurface directory to use.
|
//- Name of MeshedSurface directory to use.
|
||||||
static fileName triSurfInstance(const Time&);
|
static fileName triSurfInstance(const Time&);
|
||||||
|
|
||||||
//- Name of meshedSurface directory to use.
|
//- Name of MeshedSurface directory to use.
|
||||||
static fileName triSurfName(const Time&);
|
static fileName triSurfName(const Time&);
|
||||||
|
|
||||||
//- Can we read this file format?
|
//- Can we read this file format?
|
||||||
@ -160,22 +155,22 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
meshedSurface();
|
MeshedSurface();
|
||||||
|
|
||||||
//- Construct by transferring components
|
//- Construct by transferring components
|
||||||
// (points, faces and patches).
|
// (points, faces and patches).
|
||||||
meshedSurface
|
MeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&,
|
const xfer<List<Face> >&,
|
||||||
const xfer<surfGroupList>&
|
const xfer<surfGroupList>&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from points, faces, and patch information
|
//- Construct from points, faces, and patch information
|
||||||
meshedSurface
|
MeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&,
|
const xfer<List<Face> >&,
|
||||||
const UList<label>& patchSizes,
|
const UList<label>& patchSizes,
|
||||||
const UList<word>& patchNames,
|
const UList<word>& patchNames,
|
||||||
const UList<word>& patchTypes
|
const UList<word>& patchTypes
|
||||||
@ -184,88 +179,90 @@ public:
|
|||||||
//- Construct by transferring points, faces.
|
//- Construct by transferring points, faces.
|
||||||
// Sort faces according to regionIds with the names of the regions,
|
// Sort faces according to regionIds with the names of the regions,
|
||||||
// or jsut set a single default patch.
|
// or jsut set a single default patch.
|
||||||
meshedSurface
|
MeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&,
|
const xfer<List<Face> >&,
|
||||||
const UList<label>& regionIds = UList<label>::null(),
|
const UList<label>& regionIds = UList<label>::null(),
|
||||||
const Map<word>& regionNames = Map<word>::null()
|
const Map<word>& regionNames = Map<word>::null()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct by transferring points, faces.
|
//- Construct by transferring points, faces.
|
||||||
// Sort faces according to regionIds with patch-names from hash
|
// Sort faces according to regionIds with patch-names from hash
|
||||||
meshedSurface
|
MeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&,
|
const xfer<List<Face> >&,
|
||||||
const UList<label>& regionIds,
|
const UList<label>& regionIds,
|
||||||
const HashTable<label>& nameToRegionMapping
|
const HashTable<label>& nameToRegionMapping
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from a boundary mesh with local points/faces
|
//- Construct from a boundary mesh with local points/faces
|
||||||
meshedSurface
|
MeshedSurface
|
||||||
(
|
(
|
||||||
const polyBoundaryMesh&,
|
const polyBoundaryMesh&,
|
||||||
const bool globalPoints=false
|
const bool globalPoints=false
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from a keyedSurface
|
//- Construct from a UnsortedMeshedSurface
|
||||||
meshedSurface(const keyedSurface&);
|
MeshedSurface(const UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
//- Construct from a surfMesh
|
//- Construct from a surfMesh
|
||||||
meshedSurface(const surfMesh&);
|
MeshedSurface(const surfMesh&);
|
||||||
|
|
||||||
//- Construct by transferring the contents from a keyedSurface
|
//- Construct by transferring the contents from a UnsortedMeshedSurface
|
||||||
meshedSurface(const xfer<keyedSurface>&);
|
MeshedSurface(const xfer<UnsortedMeshedSurface<Face> >&);
|
||||||
|
|
||||||
//- Construct by transferring the contents from a meshedSurface
|
//- Construct by transferring the contents from a MeshedSurface
|
||||||
meshedSurface(const xfer<meshedSurface>&);
|
MeshedSurface(const xfer<MeshedSurface<Face> >&);
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
meshedSurface
|
MeshedSurface(const fileName&);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const bool triangulate=false
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
meshedSurface
|
MeshedSurface(const fileName&, const word& ext);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const word& ext,
|
|
||||||
const bool triangulate=false
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
meshedSurface(Istream&, const bool triangulate=false);
|
MeshedSurface(Istream&);
|
||||||
|
|
||||||
//- Construct from objectRegistry
|
//- Construct from objectRegistry
|
||||||
meshedSurface(const Time&);
|
MeshedSurface(const Time&);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
meshedSurface(const meshedSurface&);
|
MeshedSurface(const MeshedSurface&);
|
||||||
|
|
||||||
|
// Declare run-time constructor selection table
|
||||||
|
|
||||||
|
declareRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
autoPtr,
|
||||||
|
MeshedSurface,
|
||||||
|
fileExtension,
|
||||||
|
(
|
||||||
|
const fileName& fName
|
||||||
|
),
|
||||||
|
(fName)
|
||||||
|
);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Select constructed from filename (implicit extension)
|
//- Select constructed from filename (implicit extension)
|
||||||
static autoPtr<meshedSurface> New
|
static autoPtr<MeshedSurface> New
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&
|
||||||
const bool triangulate=false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Select constructed from filename (explicit extension)
|
//- Select constructed from filename (explicit extension)
|
||||||
static autoPtr<meshedSurface> New
|
static autoPtr<MeshedSurface> New
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const word&,
|
const word& ext
|
||||||
const bool triangulate=false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
virtual ~meshedSurface();
|
virtual ~MeshedSurface();
|
||||||
|
|
||||||
|
|
||||||
// Member Function Selectors
|
// Member Function Selectors
|
||||||
@ -273,18 +270,18 @@ public:
|
|||||||
declareMemberFunctionSelectionTable
|
declareMemberFunctionSelectionTable
|
||||||
(
|
(
|
||||||
void,
|
void,
|
||||||
meshedSurface,
|
MeshedSurface,
|
||||||
write,
|
write,
|
||||||
fileExtension,
|
fileExtension,
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const meshedSurface& surf
|
const MeshedSurface<Face>& surf
|
||||||
),
|
),
|
||||||
(fName, surf)
|
(fName, surf)
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write to file
|
//- Write to file
|
||||||
static void write(const fileName&, const meshedSurface&);
|
static void write(const fileName&, const MeshedSurface<Face>&);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -300,25 +297,25 @@ public:
|
|||||||
//- Return the number of faces
|
//- Return the number of faces
|
||||||
label nFaces() const
|
label nFaces() const
|
||||||
{
|
{
|
||||||
return MeshStorage::size();
|
return ParentType::size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- The surface size is the number of faces
|
//- The surface size is the number of faces
|
||||||
label size() const
|
label size() const
|
||||||
{
|
{
|
||||||
return MeshStorage::size();
|
return ParentType::size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return const access to global points
|
//- Return const access to global points
|
||||||
const pointField& points() const
|
const pointField& points() const
|
||||||
{
|
{
|
||||||
return MeshStorage::points();
|
return ParentType::points();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return const access to the faces
|
//- 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
|
const surfGroupList& patches() const
|
||||||
@ -358,7 +355,7 @@ public:
|
|||||||
|
|
||||||
//- Return new surface.
|
//- Return new surface.
|
||||||
// Returns pointMap, faceMap from subsetMeshMap
|
// Returns pointMap, faceMap from subsetMeshMap
|
||||||
meshedSurface subsetMesh
|
MeshedSurface subsetMesh
|
||||||
(
|
(
|
||||||
const UList<bool>& include,
|
const UList<bool>& include,
|
||||||
labelList& pointMap,
|
labelList& pointMap,
|
||||||
@ -366,29 +363,20 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Transfer the contents of the argument and annull the argument
|
//- 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
|
//- Transfer the contents of the argument and annull the argument
|
||||||
void transfer(keyedSurface&);
|
void transfer(UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
|
|
||||||
//- Read from file. Chooses reader based on explicit extension
|
//- Read from file. Chooses reader based on explicit extension
|
||||||
bool read
|
bool read(const fileName&, const word& ext);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const word& ext,
|
|
||||||
const bool triangulate=false
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Read from file. Chooses reader based on detected extension
|
//- Read from file. Chooses reader based on detected extension
|
||||||
virtual bool read
|
virtual bool read(const fileName&);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const bool triangulate=false
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
@ -411,11 +399,16 @@ public:
|
|||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
void operator=(const meshedSurface&);
|
void operator=(const MeshedSurface<Face>&);
|
||||||
|
|
||||||
// Ostream Operator
|
// 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
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -24,24 +24,29 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "meshedSurface.H"
|
#include "MeshedSurface.H"
|
||||||
#include "mergePoints.H"
|
#include "mergePoints.H"
|
||||||
#include "triFace.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Remove badly degenerate faces, double faces.
|
// 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)
|
// merge points (already done for STL, TRI)
|
||||||
stitchFaces(SMALL, verbose);
|
stitchFaces(SMALL, verbose);
|
||||||
|
|
||||||
checkFaces(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();
|
pointField& pointLst = points();
|
||||||
|
|
||||||
@ -58,14 +63,14 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "meshedSurface::stitchFaces : Renumbering all faces"
|
Info<< "MeshedSurface::stitchFaces : Renumbering all faces"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the coordinates to the merged ones
|
// Set the coordinates to the merged ones
|
||||||
pointLst.transfer(newPoints);
|
pointLst.transfer(newPoints);
|
||||||
|
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = faces();
|
||||||
|
|
||||||
// ensure we have at some patches, and they cover all the faces
|
// ensure we have at some patches, and they cover all the faces
|
||||||
checkPatches();
|
checkPatches();
|
||||||
@ -83,7 +88,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
label patchEnd = oldFaceI + p.size();
|
label patchEnd = oldFaceI + p.size();
|
||||||
for (; oldFaceI < patchEnd; ++oldFaceI)
|
for (; oldFaceI < patchEnd; ++oldFaceI)
|
||||||
{
|
{
|
||||||
FaceType& f = faceLst[oldFaceI];
|
Face& f = faceLst[oldFaceI];
|
||||||
forAll (f, fp)
|
forAll (f, fp)
|
||||||
{
|
{
|
||||||
f[fp] = pointMap[f[fp]];
|
f[fp] = pointMap[f[fp]];
|
||||||
@ -99,7 +104,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
}
|
}
|
||||||
else if (verbose)
|
else if (verbose)
|
||||||
{
|
{
|
||||||
Pout<< "meshedSurface::stitchFaces : "
|
Pout<< "MeshedSurface::stitchFaces : "
|
||||||
<< "Removing collapsed face " << oldFaceI << endl
|
<< "Removing collapsed face " << oldFaceI << endl
|
||||||
<< " vertices :" << f << endl;
|
<< " vertices :" << f << endl;
|
||||||
}
|
}
|
||||||
@ -113,7 +118,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Pout<< "meshedSurface::stitchFaces : "
|
Pout<< "MeshedSurface::stitchFaces : "
|
||||||
<< "Removed " << faceLst.size() - newFaceI
|
<< "Removed " << faceLst.size() - newFaceI
|
||||||
<< " faces" << endl;
|
<< " faces" << endl;
|
||||||
}
|
}
|
||||||
@ -122,7 +127,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
|
|
||||||
|
|
||||||
// Merging points might have changed geometric factors
|
// Merging points might have changed geometric factors
|
||||||
MeshStorage::clearOut();
|
ParentType::clearOut();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -130,23 +135,24 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
|
|
||||||
|
|
||||||
// Remove badly degenerate faces and double faces.
|
// 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.
|
// Simple check on indices ok.
|
||||||
const label maxPointI = points().size() - 1;
|
const label maxPointI = points().size() - 1;
|
||||||
|
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = faces();
|
||||||
|
|
||||||
// Phase 0: detect badly labelled faces
|
// Phase 0: detect badly labelled faces
|
||||||
forAll (faceLst, faceI)
|
forAll (faceLst, faceI)
|
||||||
{
|
{
|
||||||
const FaceType& f = faceLst[faceI];
|
const Face& f = faceLst[faceI];
|
||||||
|
|
||||||
forAll (f, fp)
|
forAll (f, fp)
|
||||||
{
|
{
|
||||||
if (f[fp] < 0 || f[fp] > maxPointI)
|
if (f[fp] < 0 || f[fp] > maxPointI)
|
||||||
{
|
{
|
||||||
FatalErrorIn("meshedSurface::checkFaces(bool)")
|
FatalErrorIn("MeshedSurface::checkFaces(bool)")
|
||||||
<< "face " << f
|
<< "face " << f
|
||||||
<< " uses point indices outside point range 0.."
|
<< " uses point indices outside point range 0.."
|
||||||
<< maxPointI
|
<< maxPointI
|
||||||
@ -160,7 +166,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
|||||||
|
|
||||||
// Phase 1: find and skip over invalid faces
|
// Phase 1: find and skip over invalid faces
|
||||||
// Phase 2: pack
|
// Phase 2: pack
|
||||||
const labelListList& fFaces = faceFaces();
|
const labelListList& fFaces = ParentType::faceFaces();
|
||||||
|
|
||||||
label oldFaceI = 0;
|
label oldFaceI = 0;
|
||||||
label newFaceI = 0;
|
label newFaceI = 0;
|
||||||
@ -174,7 +180,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
|||||||
label patchEnd = oldFaceI + p.size();
|
label patchEnd = oldFaceI + p.size();
|
||||||
for (; oldFaceI < patchEnd; ++oldFaceI)
|
for (; oldFaceI < patchEnd; ++oldFaceI)
|
||||||
{
|
{
|
||||||
FaceType& f = faceLst[oldFaceI];
|
Face& f = faceLst[oldFaceI];
|
||||||
|
|
||||||
// 'degenerate' face check
|
// 'degenerate' face check
|
||||||
if (f.collapse() >= 3)
|
if (f.collapse() >= 3)
|
||||||
@ -203,7 +209,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"meshedSurface::checkFaces(bool verbose)"
|
"MeshedSurface::checkFaces(bool verbose)"
|
||||||
) << "faces share the same vertices:\n"
|
) << "faces share the same vertices:\n"
|
||||||
<< " face 1 :" << oldFaceI << endl;
|
<< " face 1 :" << oldFaceI << endl;
|
||||||
// printFace(Warning, " ", f, points());
|
// printFace(Warning, " ", f, points());
|
||||||
@ -232,7 +238,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"meshedSurface::checkFaces(bool verbose)"
|
"MeshedSurface::checkFaces(bool verbose)"
|
||||||
) << "face " << oldFaceI
|
) << "face " << oldFaceI
|
||||||
<< " has fewer than three unique vertices:\n";
|
<< " has fewer than three unique vertices:\n";
|
||||||
// printTriangle(Warning, " ", f, points());
|
// printTriangle(Warning, " ", f, points());
|
||||||
@ -249,22 +255,23 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"meshedSurface::checkFaces(bool verbose)"
|
"MeshedSurface::checkFaces(bool verbose)"
|
||||||
) << "Removed " << faceLst.size() - newFaceI
|
) << "Removed " << faceLst.size() - newFaceI
|
||||||
<< " illegal faces." << endl;
|
<< " illegal faces." << endl;
|
||||||
}
|
}
|
||||||
faceLst.setSize(newFaceI);
|
faceLst.setSize(newFaceI);
|
||||||
|
|
||||||
// Topology can change because of renumbering
|
// 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;
|
label nTri = 0;
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = faces();
|
||||||
|
|
||||||
// determine how many triangles are needed
|
// determine how many triangles are needed
|
||||||
forAll (faceLst, faceI)
|
forAll (faceLst, faceI)
|
||||||
@ -278,7 +285,7 @@ Foam::label Foam::meshedSurface::triangulate()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FaceType> newFaces(nTri);
|
List<Face> newFaces(nTri);
|
||||||
|
|
||||||
// note the number of *additional* faces
|
// note the number of *additional* faces
|
||||||
nTri -= faceLst.size();
|
nTri -= faceLst.size();
|
||||||
@ -296,7 +303,7 @@ Foam::label Foam::meshedSurface::triangulate()
|
|||||||
label patchEnd = oldFaceI + p.size();
|
label patchEnd = oldFaceI + p.size();
|
||||||
for (; oldFaceI < patchEnd; ++oldFaceI)
|
for (; oldFaceI < patchEnd; ++oldFaceI)
|
||||||
{
|
{
|
||||||
const FaceType& f = faceLst[oldFaceI];
|
const Face& f = faceLst[oldFaceI];
|
||||||
triFace fTri;
|
triFace fTri;
|
||||||
|
|
||||||
// Do simple face triangulation around f[0].
|
// 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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// all input is indirect via keyedSurface
|
// all input is indirect via UnsortedMeshedSurface
|
||||||
Foam::autoPtr<Foam::meshedSurface>
|
template<class Face>
|
||||||
Foam::meshedSurface::New
|
Foam::autoPtr<Foam::MeshedSurface<Face> >
|
||||||
|
Foam::MeshedSurface<Face>::New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const word& ext,
|
const word& ext
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "meshedSurface::New(const fileName&, const word&, const bool) : "
|
Info<< "MeshedSurface::New(const fileName&, const word&) : "
|
||||||
"constructing meshedSurface"
|
"constructing MeshedSurface"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// created indirectly via keyedSurface
|
// created indirectly via UnsortedMeshedSurface
|
||||||
autoPtr<meshedSurface> surf(new meshedSurface);
|
autoPtr<MeshedSurface<Face> > surf(new MeshedSurface<Face>);
|
||||||
surf().transfer( keyedSurface::New(fName,ext,triangulate)() );
|
surf().transfer( UnsortedMeshedSurface<Face>::New(fName,ext)() );
|
||||||
|
|
||||||
return surf;
|
return surf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
Foam::autoPtr<Foam::meshedSurface>
|
Foam::autoPtr<Foam::MeshedSurface<Face> >
|
||||||
Foam::meshedSurface::New
|
Foam::MeshedSurface<Face>::New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "meshedSurface::New(const fileName&, const bool) : "
|
Info<< "MeshedSurface::New(const fileName&) : "
|
||||||
"constructing meshedSurface"
|
"constructing MeshedSurface"
|
||||||
<< endl;
|
<< 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 "meshedSurface.H"
|
#include "UnsortedMeshedSurface.H"
|
||||||
#include "demandDrivenData.H"
|
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "boundBox.H"
|
#include "boundBox.H"
|
||||||
#include "SortableList.H"
|
|
||||||
#include "polyBoundaryMesh.H"
|
#include "polyBoundaryMesh.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "primitivePatch.H"
|
#include "primitivePatch.H"
|
||||||
@ -39,27 +37,14 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
defineTypeNameAndDebug(keyedSurface, 0);
|
|
||||||
defineRunTimeSelectionTable(keyedSurface, fileExtension);
|
|
||||||
defineMemberFunctionSelectionTable
|
|
||||||
(
|
|
||||||
keyedSurface,
|
|
||||||
write,
|
|
||||||
fileExtension
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// File extension for 'native' raw format
|
// File extension for 'native' raw format
|
||||||
//! @cond localscope
|
#undef nativeSurfaceExt
|
||||||
const char * const nativeExt = "ofs";
|
#define nativeSurfaceExt "ofs"
|
||||||
//! @endcond localscope
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::string Foam::keyedSurface::getLineNoComment(IFstream& is)
|
template<class Face>
|
||||||
|
Foam::string Foam::UnsortedMeshedSurface<Face>::getLineNoComment(IFstream& is)
|
||||||
{
|
{
|
||||||
string line;
|
string line;
|
||||||
do
|
do
|
||||||
@ -71,10 +56,10 @@ Foam::string Foam::keyedSurface::getLineNoComment(IFstream& is)
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
Foam::fileName Foam::keyedSurface::triSurfInstance(const Time& d)
|
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
|
// Search back through the time directories list to find the time
|
||||||
// closest to and lower than current time
|
// closest to and lower than current time
|
||||||
@ -101,7 +86,7 @@ Foam::fileName Foam::keyedSurface::triSurfInstance(const Time& d)
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " keyedSurface::triSurfInstance(const Time& d)"
|
Pout<< " UnsortedMeshedSurface::triSurfInstance(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from " << ts[j].name()/typeName
|
<< " from " << ts[j].name()/typeName
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -114,7 +99,7 @@ Foam::fileName Foam::keyedSurface::triSurfInstance(const Time& d)
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " keyedSurface::triSurfInstance(const Time& d)"
|
Pout<< " UnsortedMeshedSurface::triSurfInstance(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from constant/" << endl;
|
<< " 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
|
// Search back through the time directories list to find the time
|
||||||
// closest to and lower than current time
|
// closest to and lower than current time
|
||||||
@ -154,7 +140,7 @@ Foam::fileName Foam::keyedSurface::triSurfName(const Time& d)
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " keyedSurface::triSurfName(const Time& d)"
|
Pout<< " UnsortedMeshedSurface::triSurfName(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from " << ts[j].name()/typeName
|
<< " from " << ts[j].name()/typeName
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -167,7 +153,7 @@ Foam::fileName Foam::keyedSurface::triSurfName(const Time& d)
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< " keyedSurface::triSurfName(const Time& d)"
|
Pout<< " UnsortedMeshedSurface::triSurfName(const Time& d)"
|
||||||
<< "reading " << foamName
|
<< "reading " << foamName
|
||||||
<< " from constant/" << endl;
|
<< " 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
|
// perhaps sent an entire name
|
||||||
word fExt(ext);
|
word fExt(ext);
|
||||||
@ -188,12 +179,12 @@ bool Foam::keyedSurface::canRead(const word& ext, const bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (fExt == nativeExt)
|
if (fExt == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileExtensionConstructorTable::iterator cstrIter =
|
typename fileExtensionConstructorTable::iterator cstrIter =
|
||||||
fileExtensionConstructorTablePtr_->find(fExt);
|
fileExtensionConstructorTablePtr_->find(fExt);
|
||||||
|
|
||||||
// would be nice to have information about which format this actually is
|
// 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;
|
Info<<"Unknown file extension for reading: " << fExt << nl;
|
||||||
// compact output:
|
// compact output:
|
||||||
Info<<"Valid types: ( " << nativeExt;
|
Info<<"Valid types: ( " << nativeSurfaceExt;
|
||||||
forAll(known, i)
|
forAll(known, i)
|
||||||
{
|
{
|
||||||
Info<<" " << 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
|
// perhaps sent an entire name
|
||||||
word fExt(ext);
|
word fExt(ext);
|
||||||
@ -234,12 +230,12 @@ bool Foam::keyedSurface::canWrite(const word& ext, const bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (fExt == nativeExt)
|
if (fExt == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||||
writefileExtensionMemberFunctionTablePtr_->find(fExt);
|
writefileExtensionMemberFunctionTablePtr_->find(fExt);
|
||||||
|
|
||||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
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;
|
Info<<"Unknown file extension for writing: " << fExt << nl;
|
||||||
// compact output:
|
// compact output:
|
||||||
Info<<"Valid types: ( " << nativeExt;
|
Info<<"Valid types: ( " << nativeSurfaceExt;
|
||||||
forAll(known, i)
|
forAll(known, i)
|
||||||
{
|
{
|
||||||
Info<<" " << known[i];
|
Info<<" " << known[i];
|
||||||
@ -268,36 +264,38 @@ 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 fileName& fName,
|
||||||
const keyedSurface& surf
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "keyedSurface::write(const fileName&, const keyedSurface&) : "
|
Info<< "UnsortedMeshedSurface::write(const fileName&, const UnsortedMeshedSurface&) : "
|
||||||
"writing keyedSurface to " << fName
|
"writing UnsortedMeshedSurface to " << fName
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const word ext = fName.ext();
|
const word ext = fName.ext();
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (ext == nativeExt)
|
if (ext == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
surf.write(OFstream(fName)());
|
surf.write(OFstream(fName)());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
typename writefileExtensionMemberFunctionTable::iterator mfIter =
|
||||||
writefileExtensionMemberFunctionTable::iterator mfIter =
|
|
||||||
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
writefileExtensionMemberFunctionTablePtr_->find(ext);
|
||||||
|
|
||||||
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"keyedSurface::write(const fileName&, const keyedSurface&)"
|
"UnsortedMeshedSurface::write"
|
||||||
|
"(const fileName&, const UnsortedMeshedSurface&)"
|
||||||
) << "Unknown file extension " << ext << nl << nl
|
) << "Unknown file extension " << ext << nl << nl
|
||||||
<< "Valid types are :" << endl
|
<< "Valid types are :" << endl
|
||||||
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
<< writefileExtensionMemberFunctionTablePtr_->toc()
|
||||||
@ -305,14 +303,14 @@ void Foam::keyedSurface::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
mfIter()(fName, surf);
|
mfIter()(fName, surf);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns patch info.
|
// Returns patch info.
|
||||||
// Sets faceMap to the indexing according to patch numbers.
|
// Sets faceMap to the indexing according to patch numbers.
|
||||||
// Patch numbers start at 0.
|
// Patch numbers start at 0.
|
||||||
Foam::surfGroupList Foam::keyedSurface::sortedRegions
|
template<class Face>
|
||||||
|
Foam::surfGroupList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
||||||
(
|
(
|
||||||
const UList<label>& regionLst,
|
const UList<label>& regionLst,
|
||||||
const Map<word>& patchNames,
|
const Map<word>& patchNames,
|
||||||
@ -396,21 +394,23 @@ Foam::surfGroupList Foam::keyedSurface::sortedRegions
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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<pointField>& pointLst,
|
||||||
const xfer<List<face> >& faceLst,
|
const xfer<List<Face> >& faceLst,
|
||||||
const xfer<List<label> >& regionIds,
|
const xfer<List<label> >& regionIds,
|
||||||
const xfer<surfPatchIdentifierList>& patchLst
|
const xfer<surfPatchIdentifierList>& patchLst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField()),
|
ParentType(List<Face>(), pointField()),
|
||||||
regions_(regionIds),
|
regions_(regionIds),
|
||||||
patches_(patchLst)
|
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<pointField>& pointLst,
|
||||||
const xfer<List<face> >& faceLst,
|
const xfer<List<Face> >& faceLst,
|
||||||
const xfer<List<label> >& regionIds,
|
const xfer<List<label> >& regionIds,
|
||||||
const Map<word>& regionNames
|
const Map<word>& regionNames
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField()),
|
ParentType(List<Face>(), pointField()),
|
||||||
regions_(regionIds)
|
regions_(regionIds)
|
||||||
{
|
{
|
||||||
faces().transfer(faceLst());
|
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<pointField>& pointLst,
|
||||||
const xfer<List<face> >& faceLst,
|
const xfer<List<Face> >& faceLst,
|
||||||
const xfer<List<label> >& regionIds,
|
const xfer<List<label> >& regionIds,
|
||||||
const HashTable<label>& labelToRegion
|
const HashTable<label>& labelToRegion
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField()),
|
ParentType(List<Face>(), pointField()),
|
||||||
regions_(regionIds)
|
regions_(regionIds)
|
||||||
{
|
{
|
||||||
points().transfer(pointLst());
|
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<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
|
regions_(faceLst().size(), 0), // single default patch
|
||||||
patches_()
|
patches_()
|
||||||
{
|
{
|
||||||
@ -482,14 +485,15 @@ Foam::keyedSurface::keyedSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
Foam::keyedSurface::keyedSurface
|
template<class Face>
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const polyBoundaryMesh& bMesh,
|
const polyBoundaryMesh& bMesh,
|
||||||
const bool useGlobalPoints
|
const bool useGlobalPoints
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField())
|
ParentType(List<Face>(), pointField())
|
||||||
{
|
{
|
||||||
const polyMesh& mesh = bMesh.mesh();
|
const polyMesh& mesh = bMesh.mesh();
|
||||||
const polyPatchList& bPatches = bMesh;
|
const polyPatchList& bPatches = bMesh;
|
||||||
@ -500,7 +504,7 @@ Foam::keyedSurface::keyedSurface
|
|||||||
// Get patch for all of outside
|
// Get patch for all of outside
|
||||||
primitivePatch allBoundary
|
primitivePatch allBoundary
|
||||||
(
|
(
|
||||||
SubList<face>
|
SubList<Face>
|
||||||
(
|
(
|
||||||
mesh.faces(),
|
mesh.faces(),
|
||||||
mesh.nFaces() - nIntFaces,
|
mesh.nFaces() - nIntFaces,
|
||||||
@ -509,7 +513,7 @@ Foam::keyedSurface::keyedSurface
|
|||||||
mesh.points()
|
mesh.points()
|
||||||
);
|
);
|
||||||
|
|
||||||
List<FaceType> newFaces(allBoundary.size());
|
List<Face> newFaces(allBoundary.size());
|
||||||
List<label> newRegions(allBoundary.size());
|
List<label> newRegions(allBoundary.size());
|
||||||
|
|
||||||
if (useGlobalPoints)
|
if (useGlobalPoints)
|
||||||
@ -524,7 +528,7 @@ Foam::keyedSurface::keyedSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// global or local face addressing
|
// global or local face addressing
|
||||||
const List<face>& bfaces =
|
const List<Face>& bfaces =
|
||||||
(
|
(
|
||||||
useGlobalPoints
|
useGlobalPoints
|
||||||
? allBoundary
|
? allBoundary
|
||||||
@ -554,19 +558,22 @@ Foam::keyedSurface::keyedSurface
|
|||||||
regions_.transfer(newRegions);
|
regions_.transfer(newRegions);
|
||||||
patches_.transfer(newPatches);
|
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();
|
const surfGroupList& patchLst = surf.patches();
|
||||||
|
|
||||||
List<FaceType> newFaces(origFaces.size());
|
List<Face> newFaces(origFaces.size());
|
||||||
List<label> newRegions(origFaces.size());
|
List<label> newRegions(origFaces.size());
|
||||||
List<PatchRegionType> newPatches(patchLst.size());
|
List<PatchRegionType> newPatches(patchLst.size());
|
||||||
|
|
||||||
@ -586,123 +593,106 @@ Foam::keyedSurface::keyedSurface
|
|||||||
regions_.transfer(newRegions);
|
regions_.transfer(newRegions);
|
||||||
patches_.transfer(newPatches);
|
patches_.transfer(newPatches);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
Foam::keyedSurface::keyedSurface
|
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const word& ext,
|
const word& ext
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
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 fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
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))());
|
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_),
|
regions_(surf.regions_),
|
||||||
patches_(surf.patches_)
|
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_(),
|
regions_(),
|
||||||
patches_()
|
patches_()
|
||||||
{
|
{
|
||||||
transfer(surf());
|
transfer(surf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
Foam::keyedSurface::keyedSurface(const xfer<meshedSurface>& surf)
|
template<class Face>
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||||
|
(
|
||||||
|
const xfer<MeshedSurface<Face> >& surf
|
||||||
|
)
|
||||||
:
|
:
|
||||||
MeshStorage(List<FaceType>(), pointField()),
|
ParentType(List<Face>(), pointField()),
|
||||||
regions_(),
|
regions_(),
|
||||||
patches_()
|
patches_()
|
||||||
{
|
{
|
||||||
transfer(surf());
|
transfer(surf());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::keyedSurface::~keyedSurface()
|
template<class Face>
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * 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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * 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);
|
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;
|
label maxPatch = 0;
|
||||||
|
|
||||||
@ -736,8 +727,8 @@ void Foam::keyedSurface::setPatches()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
void Foam::keyedSurface::setPatches
|
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||||
(
|
(
|
||||||
const Map<word>& regionNames,
|
const Map<word>& regionNames,
|
||||||
const label maxPatchHint
|
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
|
const HashTable<label>& groupToPatch
|
||||||
)
|
)
|
||||||
@ -810,16 +802,18 @@ void Foam::keyedSurface::setPatches
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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);
|
regions_.setSize(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::keyedSurface::clear()
|
template<class Face>
|
||||||
|
void Foam::UnsortedMeshedSurface<Face>::clear()
|
||||||
{
|
{
|
||||||
MeshStorage::clearOut();
|
ParentType::clearOut();
|
||||||
|
|
||||||
points().clear();
|
points().clear();
|
||||||
faces().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
|
labelList& faceMap
|
||||||
) const
|
) 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
|
// Remove all geometry dependent data
|
||||||
MeshStorage::clearTopology();
|
ParentType::clearTopology();
|
||||||
|
|
||||||
// Adapt for new point position
|
// Adapt for new point position
|
||||||
MeshStorage::movePoints(newPoints);
|
ParentType::movePoints(newPoints);
|
||||||
|
|
||||||
// Copy new points
|
// Copy new points
|
||||||
points() = newPoints;
|
points() = newPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::keyedSurface::scalePoints(const scalar& scaleFactor)
|
template<class Face>
|
||||||
|
void Foam::UnsortedMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
|
||||||
{
|
{
|
||||||
// avoid bad scaling
|
// avoid bad scaling
|
||||||
if (scaleFactor > 0 && scaleFactor != 1.0)
|
if (scaleFactor > 0 && scaleFactor != 1.0)
|
||||||
{
|
{
|
||||||
// Remove all geometry dependent data
|
// Remove all geometry dependent data
|
||||||
MeshStorage::clearTopology();
|
ParentType::clearTopology();
|
||||||
|
|
||||||
// Adapt for new point position
|
// Adapt for new point position
|
||||||
MeshStorage::movePoints(pointField());
|
ParentType::movePoints(pointField());
|
||||||
|
|
||||||
points() *= scaleFactor;
|
points() *= scaleFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
Foam::keyedSurface Foam::keyedSurface::subsetMesh
|
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||||
(
|
(
|
||||||
const UList<bool>& include,
|
const UList<bool>& include,
|
||||||
labelList& pointMap,
|
labelList& pointMap,
|
||||||
labelList& faceMap
|
labelList& faceMap
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const pointField& locPoints = localPoints();
|
const pointField& locPoints = ParentType::localPoints();
|
||||||
const List<FaceType>& locFaces = localFaces();
|
const List<Face>& locFaces = ParentType::localFaces();
|
||||||
|
|
||||||
// Fill pointMap, faceMap
|
// Fill pointMap, faceMap
|
||||||
subsetMap(include, pointMap, faceMap);
|
ParentType::subsetMap(include, pointMap, faceMap);
|
||||||
|
|
||||||
// Create compact coordinate list and forward mapping array
|
// Create compact coordinate list and forward mapping array
|
||||||
pointField newPoints(pointMap.size());
|
pointField newPoints(pointMap.size());
|
||||||
@ -897,17 +894,17 @@ Foam::keyedSurface Foam::keyedSurface::subsetMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renumber face node labels and compact
|
// Renumber face node labels and compact
|
||||||
List<FaceType> newFaces(faceMap.size());
|
List<Face> newFaces(faceMap.size());
|
||||||
|
|
||||||
forAll(faceMap, faceI)
|
forAll(faceMap, faceI)
|
||||||
{
|
{
|
||||||
// Get old vertex labels
|
// 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
|
// Renumber labels for face
|
||||||
FaceType& f = newFaces[faceI];
|
Face& f = newFaces[faceI];
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
f[fp] = oldToNew[oldFace[fp]];
|
f[fp] = oldToNew[oldFace[fp]];
|
||||||
@ -915,7 +912,7 @@ Foam::keyedSurface Foam::keyedSurface::subsetMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// construct a sub-surface
|
// construct a sub-surface
|
||||||
keyedSurface subSurf;
|
UnsortedMeshedSurface<Face> subSurf;
|
||||||
(
|
(
|
||||||
xferMove(newPoints),
|
xferMove(newPoints),
|
||||||
xferMove(newFaces),
|
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();
|
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();
|
surfGroupList& patchLst = surf.patches();
|
||||||
|
|
||||||
@ -965,125 +971,81 @@ void Foam::keyedSurface::transfer(meshedSurface& surf)
|
|||||||
patchLst.clear();
|
patchLst.clear();
|
||||||
surf.clear();
|
surf.clear();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Read from file in given format
|
// Read from file in given format
|
||||||
bool Foam::keyedSurface::read
|
template<class Face>
|
||||||
|
bool Foam::UnsortedMeshedSurface<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
const word ext = fName.ext();
|
const word ext = fName.ext();
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (ext == nativeExt)
|
if (ext == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
return read(IFstream(fName)(), triangulate);
|
return read(IFstream(fName)());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use selector mechanism
|
// use selector mechanism
|
||||||
transfer(New(fName, ext, triangulate)());
|
transfer(New(fName, ext)());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read from file in given format
|
// Read from file in given format
|
||||||
bool Foam::keyedSurface::read
|
template<class Face>
|
||||||
|
bool Foam::UnsortedMeshedSurface<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const word& ext,
|
const word& ext
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
// handle 'native' format directly
|
// handle 'native' format directly
|
||||||
if (ext == nativeExt)
|
if (ext == nativeSurfaceExt)
|
||||||
{
|
{
|
||||||
return read(IFstream(fName)(), triangulate);
|
return read(IFstream(fName)());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use selector mechanism
|
// use selector mechanism
|
||||||
transfer(New(fName, ext, triangulate)());
|
transfer(New(fName, ext)());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// write (sorted)
|
template<class Face>
|
||||||
void Foam::keyedSurface::write(Ostream& os) const
|
void Foam::UnsortedMeshedSurface<Face>::write(const Time& d) 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
|
|
||||||
{
|
{
|
||||||
write(OFstream(triSurfName(d))());
|
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
|
// os << "Faces : " << size() << endl
|
||||||
<< "Edges : " << nEdges() << endl
|
// << "Edges : " << nEdges() << endl
|
||||||
<< "Vertices : " << nPoints() << endl
|
// << "Vertices : " << nPoints() << endl
|
||||||
<< "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
// << "Bounding Box : " << boundBox(localPoints(), false) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::keyedSurface::operator=(const keyedSurface& surf)
|
template<class Face>
|
||||||
|
void Foam::UnsortedMeshedSurface<Face>::operator=
|
||||||
|
(
|
||||||
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
faces() = surf.faces();
|
faces() = surf.faces();
|
||||||
@ -1097,13 +1059,12 @@ void Foam::keyedSurface::operator=(const keyedSurface& surf)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::keyedSurface
|
Foam::UnsortedMeshedSurface
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A surface geometry mesh, in which the patch information is conveyed by
|
A surface geometry mesh, in which the patch information is conveyed by
|
||||||
@ -40,20 +40,21 @@ See Also
|
|||||||
with independent patch information.
|
with independent patch information.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
keyedSurface.C
|
UnsortedMeshedSurface.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef keyedSurface_H
|
#ifndef UnsortedMeshedSurface_H
|
||||||
#define keyedSurface_H
|
#define UnsortedMeshedSurface_H
|
||||||
|
|
||||||
#include "pointField.H"
|
#include "pointField.H"
|
||||||
#include "PrimitivePatchExtra.H"
|
#include "PrimitivePatchExtra.H"
|
||||||
#include "boolList.H"
|
#include "boolList.H"
|
||||||
#include "surfPatchIdentifierList.H"
|
#include "surfPatchIdentifierList.H"
|
||||||
#include "surfGroupList.H"
|
#include "surfGroupList.H"
|
||||||
#include "face.H"
|
|
||||||
#include "xfer.H"
|
#include "xfer.H"
|
||||||
|
#include "face.H"
|
||||||
|
#include "triFace.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
#include "memberFunctionSelectionTables.H"
|
#include "memberFunctionSelectionTables.H"
|
||||||
|
|
||||||
@ -66,45 +67,45 @@ namespace Foam
|
|||||||
|
|
||||||
class Time;
|
class Time;
|
||||||
class IFstream;
|
class IFstream;
|
||||||
class keyedSurface;
|
template<class Face> class UnsortedMeshedSurface;
|
||||||
class meshedSurface;
|
template<class Face> class MeshedSurface;
|
||||||
|
|
||||||
class polyBoundaryMesh;
|
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:
|
||||||
|
|
||||||
// Protected Member Data
|
// Protected Member Data
|
||||||
|
|
||||||
//- Typedef for similar code in keyedSurface and meshedSurface
|
|
||||||
typedef face FaceType;
|
|
||||||
|
|
||||||
//- Typedef for type holding the region (patch) informationm
|
//- Typedef for type holding the region (patch) informationm
|
||||||
typedef surfPatchIdentifier PatchRegionType;
|
typedef surfPatchIdentifier PatchRegionType;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private typedefs
|
//- Private typedefs for convenience
|
||||||
|
typedef UnsortedMeshedSurface<Face> ThisType;
|
||||||
typedef PrimitivePatchExtra
|
typedef PrimitivePatchExtra
|
||||||
<
|
<
|
||||||
FaceType,
|
Face,
|
||||||
::Foam::List,
|
::Foam::List,
|
||||||
pointField,
|
pointField,
|
||||||
point
|
point
|
||||||
>
|
>
|
||||||
MeshStorage;
|
ParentType;
|
||||||
|
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
@ -118,10 +119,10 @@ private:
|
|||||||
// Private member functions
|
// Private member functions
|
||||||
|
|
||||||
//- Disable setSize with value
|
//- Disable setSize with value
|
||||||
void setSize(const label, const FaceType&);
|
void setSize(const label, const Face&);
|
||||||
|
|
||||||
//- Read OpenFOAM Surface format
|
//- Read OpenFOAM Surface format
|
||||||
bool read(Istream&, const bool triangulate=false);
|
bool read(Istream&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -130,6 +131,7 @@ protected:
|
|||||||
//- Read non-comment line
|
//- Read non-comment line
|
||||||
static string getLineNoComment(IFstream&);
|
static string getLineNoComment(IFstream&);
|
||||||
|
|
||||||
|
|
||||||
// Protected Member functions
|
// Protected Member functions
|
||||||
|
|
||||||
//- Sets default patch names based on the maximum patch number
|
//- Sets default patch names based on the maximum patch number
|
||||||
@ -151,13 +153,13 @@ protected:
|
|||||||
//- Return non-const access to global points
|
//- Return non-const access to global points
|
||||||
pointField& points()
|
pointField& points()
|
||||||
{
|
{
|
||||||
return const_cast<pointField&>(MeshStorage::points());
|
return const_cast<pointField&>(ParentType::points());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return non-const access to the faces
|
//- 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
|
//- Return non-const access to the region Ids
|
||||||
@ -169,14 +171,14 @@ protected:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
ClassName("keyedSurface");
|
TypeName("UnsortedMeshedSurface");
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
//- Name of keyedSurface directory to use.
|
//- Name of UnsortedMeshedSurface directory to use.
|
||||||
static fileName triSurfInstance(const Time&);
|
static fileName triSurfInstance(const Time&);
|
||||||
|
|
||||||
//- Name of keyedSurface directory to use.
|
//- Name of UnsortedMeshedSurface directory to use.
|
||||||
static fileName triSurfName(const Time&);
|
static fileName triSurfName(const Time&);
|
||||||
|
|
||||||
//- Can we read this file format?
|
//- Can we read this file format?
|
||||||
@ -197,120 +199,110 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
keyedSurface();
|
UnsortedMeshedSurface();
|
||||||
|
|
||||||
//- Construct by transferring components
|
//- Construct by transferring components
|
||||||
// (points, faces, region ids, patches).
|
// (points, faces, region ids, patches).
|
||||||
keyedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&,
|
const xfer<List<Face> >&,
|
||||||
const xfer<List<label> >& regionIds,
|
const xfer<List<label> >& regionIds,
|
||||||
const xfer<surfPatchIdentifierList>&
|
const xfer<surfPatchIdentifierList>&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct by transferring points, faces and regionIds
|
//- Construct by transferring points, faces and regionIds
|
||||||
// with region names per map or set to default.
|
// with region names per map or set to default.
|
||||||
keyedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&,
|
const xfer<List<Face> >&,
|
||||||
const xfer<List<label> >& regionIds,
|
const xfer<List<label> >& regionIds,
|
||||||
const Map<word>& regionNames = Map<word>::null()
|
const Map<word>& regionNames = Map<word>::null()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct by transferring points, faces and regionIds
|
//- Construct by transferring points, faces and regionIds
|
||||||
// with patch-names from hash
|
// with patch-names from hash
|
||||||
keyedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&,
|
const xfer<List<Face> >&,
|
||||||
const xfer<List<label> >& regionIds,
|
const xfer<List<label> >& regionIds,
|
||||||
const HashTable<label>& labelToRegion
|
const HashTable<label>& labelToRegion
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct by transferring points, faces.
|
//- Construct by transferring points, faces.
|
||||||
// Set single default patch.
|
// Set single default patch.
|
||||||
keyedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const xfer<pointField>&,
|
const xfer<pointField>&,
|
||||||
const xfer<List<face> >&
|
const xfer<List<Face> >&
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if 0
|
||||||
//- Construct from a boundary mesh with local points/faces
|
//- Construct from a boundary mesh with local points/faces
|
||||||
keyedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const polyBoundaryMesh&,
|
const polyBoundaryMesh&,
|
||||||
const bool globalPoints=false
|
const bool globalPoints=false
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
//- Construct from a meshedSurface
|
//- Construct from a meshedSurface
|
||||||
keyedSurface(const meshedSurface&);
|
UnsortedMeshedSurface(const MeshedSurface<Face>&);
|
||||||
|
|
||||||
//- Construct by transferring the contents from a keyedSurface
|
//- Construct by transferring the contents from a UnsortedMeshedSurface
|
||||||
keyedSurface(const xfer<keyedSurface>&);
|
UnsortedMeshedSurface(const xfer<UnsortedMeshedSurface<Face> >&);
|
||||||
|
|
||||||
//- Construct by transferring the contents from a meshedSurface
|
//- 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)
|
//- Construct from file name (uses extension to determine type)
|
||||||
keyedSurface
|
UnsortedMeshedSurface(const fileName&);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const bool triangulate=false
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
keyedSurface
|
UnsortedMeshedSurface(const fileName&, const word&);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const word&,
|
|
||||||
const bool triangulate=false
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
keyedSurface(Istream&, const bool triangulate=false);
|
UnsortedMeshedSurface(Istream&);
|
||||||
|
|
||||||
//- Construct from objectRegistry
|
//- Construct from objectRegistry
|
||||||
keyedSurface(const Time&);
|
UnsortedMeshedSurface(const Time&);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
keyedSurface(const keyedSurface&);
|
UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
// Declare run-time constructor selection table
|
// Declare run-time constructor selection table
|
||||||
|
|
||||||
declareRunTimeSelectionTable
|
declareRunTimeSelectionTable
|
||||||
(
|
(
|
||||||
autoPtr,
|
autoPtr,
|
||||||
keyedSurface,
|
UnsortedMeshedSurface,
|
||||||
fileExtension,
|
fileExtension,
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
),
|
),
|
||||||
(fName, triangulate)
|
(fName)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Select constructed from filename (implicit extension)
|
//- Select constructed from filename (implicit extension)
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface> New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName&
|
||||||
const bool triangulate=false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Select constructed from filename (explicit extension)
|
//- Select constructed from filename (explicit extension)
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface> New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName&,
|
||||||
const word& ext,
|
const word& ext
|
||||||
const bool triangulate=false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
virtual ~keyedSurface();
|
virtual ~UnsortedMeshedSurface();
|
||||||
|
|
||||||
|
|
||||||
// Member Function Selectors
|
// Member Function Selectors
|
||||||
@ -318,18 +310,18 @@ public:
|
|||||||
declareMemberFunctionSelectionTable
|
declareMemberFunctionSelectionTable
|
||||||
(
|
(
|
||||||
void,
|
void,
|
||||||
keyedSurface,
|
UnsortedMeshedSurface,
|
||||||
write,
|
write,
|
||||||
fileExtension,
|
fileExtension,
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const keyedSurface& surf
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
),
|
),
|
||||||
(fName, surf)
|
(fName, surf)
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write to file
|
//- Write to file
|
||||||
static void write(const fileName&, const keyedSurface&);
|
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -345,13 +337,13 @@ public:
|
|||||||
//- Return the number of faces
|
//- Return the number of faces
|
||||||
label nFaces() const
|
label nFaces() const
|
||||||
{
|
{
|
||||||
return MeshStorage::size();
|
return ParentType::size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- The surface size is the number of faces
|
//- The surface size is the number of faces
|
||||||
label size() const
|
label size() const
|
||||||
{
|
{
|
||||||
return MeshStorage::size();
|
return ParentType::size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Reset size of face and region list
|
//- Reset size of face and region list
|
||||||
@ -360,13 +352,13 @@ public:
|
|||||||
//- Return const access to global points
|
//- Return const access to global points
|
||||||
const pointField& points() const
|
const pointField& points() const
|
||||||
{
|
{
|
||||||
return MeshStorage::points();
|
return ParentType::points();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return const access to the faces
|
//- 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
|
//- Return const access to the regions
|
||||||
@ -415,7 +407,7 @@ public:
|
|||||||
|
|
||||||
//- Return new surface. Returns pointMap, faceMap from
|
//- Return new surface. Returns pointMap, faceMap from
|
||||||
// subsetMeshMap
|
// subsetMeshMap
|
||||||
keyedSurface subsetMesh
|
UnsortedMeshedSurface subsetMesh
|
||||||
(
|
(
|
||||||
const UList<bool>& include,
|
const UList<bool>& include,
|
||||||
labelList& pointMap,
|
labelList& pointMap,
|
||||||
@ -423,27 +415,18 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Transfer the contents of the argument and annull the argument
|
//- 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
|
//- Transfer the contents of the argument and annull the argument
|
||||||
void transfer(meshedSurface&);
|
void transfer(MeshedSurface<Face>&);
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
|
|
||||||
//- Read from file. Chooses reader based on explicit extension
|
//- Read from file. Chooses reader based on explicit extension
|
||||||
bool read
|
bool read(const fileName&, const word& ext);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const word& ext,
|
|
||||||
const bool triangulate
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Read from file. Chooses reader based on detected extension
|
//- Read from file. Chooses reader based on detected extension
|
||||||
virtual bool read
|
virtual bool read(const fileName&);
|
||||||
(
|
|
||||||
const fileName&,
|
|
||||||
const bool triangulate=false
|
|
||||||
);
|
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
@ -465,13 +448,17 @@ public:
|
|||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
void operator=(const keyedSurface&);
|
void operator=(const UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operator
|
// Ostream Operator
|
||||||
|
|
||||||
// friend Istream& operator>>(Istream&, keyedSurface&);
|
friend Ostream& operator<<
|
||||||
friend Ostream& operator<<(Ostream&, const keyedSurface&);
|
<Face>
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -482,6 +469,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "UnsortedMeshedSurface.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -24,24 +24,29 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "keyedSurface.H"
|
#include "UnsortedMeshedSurface.H"
|
||||||
#include "mergePoints.H"
|
#include "mergePoints.H"
|
||||||
#include "triFace.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Remove badly degenerate faces, double faces.
|
// 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)
|
// merge points (already done for STL, TRI)
|
||||||
stitchFaces(SMALL, verbose);
|
stitchFaces(SMALL, verbose);
|
||||||
|
|
||||||
checkFaces(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();
|
pointField& pointLst = points();
|
||||||
|
|
||||||
@ -58,20 +63,20 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "keyedSurface::stitchFaces : Renumbering all faces"
|
Info<< "UnsortedMeshedSurface::stitchFaces : Renumbering all faces"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the coordinates to the merged ones
|
// Set the coordinates to the merged ones
|
||||||
pointLst.transfer(newPoints);
|
pointLst.transfer(newPoints);
|
||||||
|
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = faces();
|
||||||
|
|
||||||
// Reset the point labels to the unique points array
|
// Reset the point labels to the unique points array
|
||||||
label newFaceI = 0;
|
label newFaceI = 0;
|
||||||
forAll (faceLst, faceI)
|
forAll (faceLst, faceI)
|
||||||
{
|
{
|
||||||
FaceType& f = faceLst[faceI];
|
Face& f = faceLst[faceI];
|
||||||
forAll (f, fp)
|
forAll (f, fp)
|
||||||
{
|
{
|
||||||
f[fp] = pointMap[f[fp]];
|
f[fp] = pointMap[f[fp]];
|
||||||
@ -88,7 +93,7 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
}
|
}
|
||||||
else if (verbose)
|
else if (verbose)
|
||||||
{
|
{
|
||||||
Pout<< "keyedSurface::stitchFaces : "
|
Pout<< "UnsortedMeshedSurface::stitchFaces : "
|
||||||
<< "Removing collapsed face " << faceI << endl
|
<< "Removing collapsed face " << faceI << endl
|
||||||
<< " vertices :" << f << endl;
|
<< " vertices :" << f << endl;
|
||||||
}
|
}
|
||||||
@ -98,7 +103,7 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Pout<< "keyedSurface::stitchFaces : "
|
Pout<< "UnsortedMeshedSurface::stitchFaces : "
|
||||||
<< "Removed " << faceLst.size() - newFaceI
|
<< "Removed " << faceLst.size() - newFaceI
|
||||||
<< " faces" << endl;
|
<< " faces" << endl;
|
||||||
}
|
}
|
||||||
@ -107,30 +112,31 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Merging points might have changed geometric factors
|
// Merging points might have changed geometric factors
|
||||||
MeshStorage::clearOut();
|
ParentType::clearOut();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove badly degenerate faces and double faces.
|
// 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.
|
// Simple check on indices ok.
|
||||||
const label maxPointI = points().size() - 1;
|
const label maxPointI = points().size() - 1;
|
||||||
|
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = faces();
|
||||||
|
|
||||||
// Phase 0: detect badly labelled faces
|
// Phase 0: detect badly labelled faces
|
||||||
forAll (faceLst, faceI)
|
forAll (faceLst, faceI)
|
||||||
{
|
{
|
||||||
const FaceType& f = faceLst[faceI];
|
const Face& f = faceLst[faceI];
|
||||||
|
|
||||||
forAll (f, fp)
|
forAll (f, fp)
|
||||||
{
|
{
|
||||||
if (f[fp] < 0 || f[fp] > maxPointI)
|
if (f[fp] < 0 || f[fp] > maxPointI)
|
||||||
{
|
{
|
||||||
FatalErrorIn("keyedSurface::checkFaces(bool)")
|
FatalErrorIn("UnsortedMeshedSurface::checkFaces(bool)")
|
||||||
<< "face " << f
|
<< "face " << f
|
||||||
<< " uses point indices outside point range 0.."
|
<< " uses point indices outside point range 0.."
|
||||||
<< maxPointI
|
<< maxPointI
|
||||||
@ -142,12 +148,12 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
|||||||
// Phase 1: mark invalid faces
|
// Phase 1: mark invalid faces
|
||||||
// Phase 1: pack
|
// Phase 1: pack
|
||||||
// Done to keep numbering constant in phase 1
|
// Done to keep numbering constant in phase 1
|
||||||
const labelListList& fFaces = faceFaces();
|
const labelListList& fFaces = ParentType::faceFaces();
|
||||||
label newFaceI = 0;
|
label newFaceI = 0;
|
||||||
|
|
||||||
forAll (faceLst, faceI)
|
forAll (faceLst, faceI)
|
||||||
{
|
{
|
||||||
FaceType& f = faceLst[faceI];
|
Face& f = faceLst[faceI];
|
||||||
|
|
||||||
// avoid degenerate faces
|
// avoid degenerate faces
|
||||||
if (f.collapse() >= 3)
|
if (f.collapse() >= 3)
|
||||||
@ -176,7 +182,7 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"keyedSurface::checkFaces(bool verbose)"
|
"UnsortedMeshedSurface::checkFaces(bool verbose)"
|
||||||
) << "faces share the same vertices:\n"
|
) << "faces share the same vertices:\n"
|
||||||
<< " face 1 :" << faceI << endl;
|
<< " face 1 :" << faceI << endl;
|
||||||
// printFace(Warning, " ", f, points());
|
// printFace(Warning, " ", f, points());
|
||||||
@ -206,7 +212,7 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"keyedSurface::checkFaces(bool verbose)"
|
"UnsortedMeshedSurface::checkFaces(bool verbose)"
|
||||||
) << "face " << faceI
|
) << "face " << faceI
|
||||||
<< " does not at least three unique vertices:\n";
|
<< " does not at least three unique vertices:\n";
|
||||||
// printFace(Warning, " ", f, points());
|
// printFace(Warning, " ", f, points());
|
||||||
@ -219,7 +225,7 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"keyedSurface::checkFaces(bool verbose)"
|
"UnsortedMeshedSurface::checkFaces(bool verbose)"
|
||||||
) << "Removed " << faceLst.size() - newFaceI
|
) << "Removed " << faceLst.size() - newFaceI
|
||||||
<< " illegal faces." << endl;
|
<< " illegal faces." << endl;
|
||||||
}
|
}
|
||||||
@ -227,15 +233,16 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
|||||||
regions_.setSize(newFaceI);
|
regions_.setSize(newFaceI);
|
||||||
|
|
||||||
// Topology can change because of renumbering
|
// 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;
|
label nTri = 0;
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = faces();
|
||||||
|
|
||||||
// determine how many triangles are needed
|
// determine how many triangles are needed
|
||||||
forAll (faceLst, faceI)
|
forAll (faceLst, faceI)
|
||||||
@ -249,7 +256,7 @@ Foam::label Foam::keyedSurface::triangulate()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FaceType> newFaces(nTri);
|
List<Face> newFaces(nTri);
|
||||||
List<label> newRegions(nTri);
|
List<label> newRegions(nTri);
|
||||||
|
|
||||||
// note the number of *additional* faces
|
// note the number of *additional* faces
|
||||||
@ -259,7 +266,7 @@ Foam::label Foam::keyedSurface::triangulate()
|
|||||||
label newFaceI = 0;
|
label newFaceI = 0;
|
||||||
forAll (faceLst, faceI)
|
forAll (faceLst, faceI)
|
||||||
{
|
{
|
||||||
const FaceType& f = faceLst[faceI];
|
const Face& f = faceLst[faceI];
|
||||||
triFace fTri;
|
triFace fTri;
|
||||||
|
|
||||||
// Do simple face triangulation around f[0].
|
// 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 "UnsortedMeshedSurface.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
Foam::autoPtr<Foam::keyedSurface>
|
template<class Face>
|
||||||
Foam::keyedSurface::New
|
Foam::autoPtr<Foam::UnsortedMeshedSurface<Face> >
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const word& ext,
|
const word& ext
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "keyedSurface::New"
|
Info<< "UnsortedMeshedSurface<Face>::New"
|
||||||
"(const fileName&, const word&, const bool) : "
|
"(const fileName&, const word&) : "
|
||||||
"constructing keyedSurface"
|
"constructing UnsortedMeshedSurface"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileExtensionConstructorTable::iterator cstrIter =
|
typename fileExtensionConstructorTable::iterator cstrIter =
|
||||||
fileExtensionConstructorTablePtr_->find(ext);
|
fileExtensionConstructorTablePtr_->find(ext);
|
||||||
|
|
||||||
if (cstrIter == fileExtensionConstructorTablePtr_->end())
|
if (cstrIter == fileExtensionConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"keyedSurface::New(const fileName&, const word&, const bool) : "
|
"UnsortedMeshedSurface<Face>::New"
|
||||||
"constructing keyedSurface"
|
"(const fileName&, const word&) : "
|
||||||
|
"constructing UnsortedMeshedSurface"
|
||||||
) << "Unknown file extension " << ext << nl << nl
|
) << "Unknown file extension " << ext << nl << nl
|
||||||
<< "Valid types are :" << nl
|
<< "Valid types are :" << nl
|
||||||
<< fileExtensionConstructorTablePtr_->toc()
|
<< fileExtensionConstructorTablePtr_->toc()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return autoPtr<keyedSurface>(cstrIter()(fName, triangulate));
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
|
(
|
||||||
|
cstrIter()(fName)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::autoPtr<Foam::keyedSurface>
|
template<class Face>
|
||||||
Foam::keyedSurface::New
|
Foam::autoPtr<Foam::UnsortedMeshedSurface<Face> >
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word ext = fName.ext();
|
const word ext = fName.ext();
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "keyedSurface::New(const fileName&, const bool) : "
|
Info<< "UnsortedMeshedSurface<Face>::New"
|
||||||
"constructing keyedSurface"
|
"(const fileName&) : "
|
||||||
|
"constructing UnsortedMeshedSurface"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +93,7 @@ Foam::keyedSurface::New
|
|||||||
// return New(unzipName, unzipName.ext(), ext);
|
// 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 "AC3DsurfaceFormat.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "clock.H"
|
#include "clock.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "tensor.H"
|
#include "tensor.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "primitivePatch.H"
|
#include "primitivePatch.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * 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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Type Foam::fileFormats::AC3DfileFormat::parse(const string& str)
|
Type Foam::fileFormats::AC3DsurfaceFormat<Face>::parse(const string& str)
|
||||||
{
|
{
|
||||||
IStringStream ss(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,
|
IFstream& is,
|
||||||
string& cmd,
|
string& cmd,
|
||||||
@ -111,7 +76,8 @@ bool Foam::fileFormats::AC3DfileFormat::readCmd
|
|||||||
|
|
||||||
// Read up to line starting with cmd. Sets args to rest of line.
|
// Read up to line starting with cmd. Sets args to rest of line.
|
||||||
// Returns true if found, false if stream is not good anymore.
|
// 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,
|
IFstream& is,
|
||||||
const string& cmd,
|
const string& cmd,
|
||||||
@ -140,7 +106,8 @@ bool Foam::fileFormats::AC3DfileFormat::cueTo
|
|||||||
|
|
||||||
|
|
||||||
// Similar to cueTo(), but throws error if cmd not found
|
// 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,
|
IFstream& is,
|
||||||
const string& cmd,
|
const string& cmd,
|
||||||
@ -152,7 +119,7 @@ Foam::string Foam::fileFormats::AC3DfileFormat::cueToOrDie
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot find command " << cmd
|
<< "Cannot find command " << cmd
|
||||||
<< " " << errorMsg
|
<< " " << 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,
|
Ostream& os,
|
||||||
const List<surfGroup>& patchLst
|
const List<surfGroup>& patchLst
|
||||||
@ -211,39 +179,50 @@ void Foam::fileFormats::AC3DfileFormat::writeHeader
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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 fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName,triangulate);
|
read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::AC3DfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
IFstream is(fName);
|
|
||||||
|
|
||||||
|
// triangulation required?
|
||||||
|
bool mustTriangulate = false;
|
||||||
|
{
|
||||||
|
Face f;
|
||||||
|
if (f.max_size() == 3)
|
||||||
|
{
|
||||||
|
mustTriangulate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IFstream is(fName);
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << fName
|
<< "Cannot read file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -259,8 +238,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DfileFormat::AC3DfileFormat"
|
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||||
"(const fileName&)"
|
|
||||||
)
|
)
|
||||||
<< "When reading AC3D file " << fName
|
<< "When reading AC3D file " << fName
|
||||||
<< " read header " << line << " with version "
|
<< " read header " << line << " with version "
|
||||||
@ -274,7 +252,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot find \"OBJECT world\" in file " << fName
|
<< "Cannot find \"OBJECT world\" in file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -288,7 +266,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
label patchVertOffset = 0;
|
label patchVertOffset = 0;
|
||||||
|
|
||||||
DynamicList<point> pointLst;
|
DynamicList<point> pointLst;
|
||||||
DynamicList<FaceType> faceLst;
|
DynamicList<Face> faceLst;
|
||||||
DynamicList<label> regionLst;
|
DynamicList<label> regionLst;
|
||||||
|
|
||||||
// patchId => patchName
|
// patchId => patchName
|
||||||
@ -314,7 +292,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Did not read up to \"kids 0\" while reading patch "
|
<< "Did not read up to \"kids 0\" while reading patch "
|
||||||
<< patchI << " from file " << fName
|
<< patchI << " from file " << fName
|
||||||
@ -342,7 +320,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
|
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DfileFormat::read"
|
"fileFormats::AC3DsurfaceFormat::read"
|
||||||
"(const fileName&)"
|
"(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "rot (rotation tensor) command not implemented"
|
<< "rot (rotation tensor) command not implemented"
|
||||||
@ -395,14 +373,16 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
|
|
||||||
label nVert = parse<int>(args);
|
label nVert = parse<int>(args);
|
||||||
|
|
||||||
face verts(nVert);
|
List<label> verts(nVert);
|
||||||
forAll(verts, vertI)
|
forAll(verts, vertI)
|
||||||
{
|
{
|
||||||
is.getLine(line);
|
is.getLine(line);
|
||||||
verts[vertI] = parse<int>(line) + patchVertOffset;
|
verts[vertI] = parse<int>(line) + patchVertOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (triangulate && verts.size() > 3)
|
UList<label>& f = static_cast<UList<label>&>(verts);
|
||||||
|
|
||||||
|
if (mustTriangulate)
|
||||||
{
|
{
|
||||||
triFace fTri;
|
triFace fTri;
|
||||||
|
|
||||||
@ -423,7 +403,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
faceLst.append(verts);
|
faceLst.append(Face(f));
|
||||||
regionLst.append(patchI);
|
regionLst.append(patchI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,7 +421,7 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DfileFormat::read(const fileName&)"
|
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Can only read objects without kids."
|
<< "Can only read objects without kids."
|
||||||
<< " Encountered " << nKids << " kids when"
|
<< " Encountered " << nKids << " kids when"
|
||||||
@ -457,21 +437,22 @@ bool Foam::fileFormats::AC3DfileFormat::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points().transfer(pointLst);
|
ParentType::points().transfer(pointLst);
|
||||||
faces().transfer(faceLst);
|
ParentType::faces().transfer(faceLst);
|
||||||
regions().transfer(regionLst);
|
|
||||||
|
|
||||||
setPatches(regionNames);
|
ParentType::regions().transfer(regionLst);
|
||||||
stitchFaces(SMALL);
|
|
||||||
|
|
||||||
|
ParentType::setPatches(regionNames);
|
||||||
|
ParentType::stitchFaces(SMALL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::AC3DfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const keyedSurface& surf
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
@ -500,7 +481,7 @@ void Foam::fileFormats::AC3DfileFormat::write
|
|||||||
labelList pMap;
|
labelList pMap;
|
||||||
labelList fMap;
|
labelList fMap;
|
||||||
|
|
||||||
keyedSurface patch = surf.subsetMesh
|
ParentType patch = surf.subsetMesh
|
||||||
(
|
(
|
||||||
include, pMap, fMap
|
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,
|
Ostream& os,
|
||||||
const meshedSurface& surf
|
const MeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<FaceType>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfGroup>& patchLst = surf.patches();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
writeHeader(os, patchLst);
|
writeHeader(os, patchLst);
|
||||||
@ -555,15 +537,11 @@ void Foam::fileFormats::AC3DfileFormat::write
|
|||||||
os << "OBJECT poly" << nl
|
os << "OBJECT poly" << nl
|
||||||
<< "name \"" << p.name() << '"' << endl;
|
<< "name \"" << p.name() << '"' << endl;
|
||||||
|
|
||||||
// Temporary primitivePatch to calculate compact points & faces
|
// Temporary PrimitivePatch to calculate compact points & faces
|
||||||
primitivePatch patch
|
// use 'UList' to avoid allocations!
|
||||||
(
|
PrimitivePatch<Face, UList, const pointField&> patch
|
||||||
SubList<face>
|
|
||||||
(
|
(
|
||||||
faceLst,
|
faceLst,
|
||||||
p.start(),
|
|
||||||
p.size()
|
|
||||||
),
|
|
||||||
pointLst
|
pointLst
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::AC3DfileFormat
|
Foam::fileFormats::AC3DsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of reading/writing AC3D format.
|
Provide a means of reading/writing AC3D format.
|
||||||
@ -39,13 +39,13 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef AC3DfileFormat_H
|
#ifndef AC3DsurfaceFormat_H
|
||||||
#define AC3DfileFormat_H
|
#define AC3DsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "keyedSurface.H"
|
#include "MeshedSurface.H"
|
||||||
#include "meshedSurface.H"
|
#include "UnsortedMeshedSurface.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -54,16 +54,18 @@ namespace Foam
|
|||||||
namespace fileFormats
|
namespace fileFormats
|
||||||
{
|
{
|
||||||
|
|
||||||
class AC3DfileFormat;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class AC3DfileFormat Declaration
|
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
|
// Private Member Functions
|
||||||
|
|
||||||
@ -90,57 +92,76 @@ class AC3DfileFormat
|
|||||||
static void writeHeader(Ostream&, const List<surfGroup>&);
|
static void writeHeader(Ostream&, const List<surfGroup>&);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
AC3DfileFormat(const AC3DfileFormat&);
|
AC3DsurfaceFormat(const AC3DsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const AC3DfileFormat&);
|
void operator=(const AC3DsurfaceFormat<Face>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
AC3DfileFormat();
|
AC3DsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
AC3DfileFormat(const fileName&, const bool triangulate=false);
|
AC3DsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return surface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=false
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new AC3DfileFormat(fName,triangulate)
|
new AC3DsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~AC3DsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- Read from file
|
||||||
virtual bool read(const fileName&, const bool triangulate);
|
virtual bool read(const fileName&);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const keyedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(const fileName& fName, const keyedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(Ostream&, const meshedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const MeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName& fName, const meshedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const MeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
@ -161,6 +182,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "AC3DsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#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 "Keyed.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
namespace fileFormats
|
|
||||||
{
|
|
||||||
|
|
||||||
addNamedToRunTimeSelectionTable
|
|
||||||
(
|
|
||||||
keyedSurface,
|
|
||||||
FTRfileFormat,
|
|
||||||
fileExtension,
|
|
||||||
ftr
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
template<class Face>
|
||||||
Foam::fileFormats::FTRfileFormat::FTRfileFormat()
|
Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat()
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::fileFormats::FTRfileFormat::FTRfileFormat
|
template<class Face>
|
||||||
|
Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName,true);
|
ThisType::read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::FTRfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
IFstream is(fName);
|
|
||||||
|
|
||||||
|
IFstream is(fName);
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::FTRfileFormat::read(const fileName&)"
|
"fileFormats::FTRsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << fName
|
<< "Cannot read file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -94,12 +75,12 @@ bool Foam::fileFormats::FTRfileFormat::read
|
|||||||
List<point> pointLst(is);
|
List<point> pointLst(is);
|
||||||
|
|
||||||
// transfer to normal list
|
// transfer to normal list
|
||||||
points().transfer(pointLst);
|
ParentType::points().transfer(pointLst);
|
||||||
|
|
||||||
// read faces with keys
|
// read faces with keys
|
||||||
List<Keyed<triFace> > readFaces(is);
|
List<Keyed<triFace> > readFaces(is);
|
||||||
|
|
||||||
List<FaceType> faceLst(readFaces.size());
|
List<Face> faceLst(readFaces.size());
|
||||||
List<label> regionLst(readFaces.size());
|
List<label> regionLst(readFaces.size());
|
||||||
|
|
||||||
// disentangle faces/keys - already triangulated
|
// disentangle faces/keys - already triangulated
|
||||||
@ -110,8 +91,8 @@ bool Foam::fileFormats::FTRfileFormat::read
|
|||||||
regionLst[faceI] = readFaces[faceI].key();
|
regionLst[faceI] = readFaces[faceI].key();
|
||||||
}
|
}
|
||||||
|
|
||||||
faces().transfer(faceLst);
|
ParentType::faces().transfer(faceLst);
|
||||||
regions().transfer(regionLst);
|
ParentType::regions().transfer(regionLst);
|
||||||
|
|
||||||
Map<word> regionNames;
|
Map<word> regionNames;
|
||||||
forAll(readPatches, patchI)
|
forAll(readPatches, patchI)
|
||||||
@ -119,8 +100,7 @@ bool Foam::fileFormats::FTRfileFormat::read
|
|||||||
regionNames.insert(patchI, readPatches[patchI].name());
|
regionNames.insert(patchI, readPatches[patchI].name());
|
||||||
}
|
}
|
||||||
|
|
||||||
setPatches(regionNames, readPatches.size() - 1);
|
ParentType::setPatches(regionNames, readPatches.size() - 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,22 +23,22 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::FTRfileFormat
|
Foam::fileFormats::FTRsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Reading of Foam Trisurface Format
|
Reading of Foam Trisurface Format
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
FTRfileFormat.C
|
FTRsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef FTRfileFormat_H
|
#ifndef FTRsurfaceFormat_H
|
||||||
#define FTRfileFormat_H
|
#define FTRsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "IFstream.H"
|
||||||
#include "OFstream.H"
|
#include "MeshedSurface.H"
|
||||||
#include "keyedSurface.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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
FTRfileFormat(const FTRfileFormat&);
|
FTRsurfaceFormat(const FTRsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const FTRfileFormat&);
|
void operator=(const FTRsurfaceFormat<Face>&);
|
||||||
|
|
||||||
|
|
||||||
//- read compatibility for ftr format
|
//- read compatibility for ftr format
|
||||||
@ -93,30 +97,36 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
FTRfileFormat();
|
FTRsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
FTRfileFormat(const fileName&, const bool triangulate=false);
|
FTRsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return surface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=false
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new FTRfileFormat(fName,true)
|
new FTRsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~FTRsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- 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
|
#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 "GTSsurfaceFormat.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "clock.H"
|
#include "clock.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "tensor.H"
|
|
||||||
#include "primitivePatch.H"
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * 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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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 fileName& fName
|
||||||
const bool
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName,true);
|
read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::GTSfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
IFstream is(fName);
|
|
||||||
|
|
||||||
|
IFstream is(fName);
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << fName
|
<< "Cannot read file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read header
|
// Read header
|
||||||
string line = getLineNoComment(is);
|
string line = ParentType::getLineNoComment(is);
|
||||||
|
|
||||||
label nPoints, nEdges, nElems;
|
label nPoints, nEdges, nElems;
|
||||||
{
|
{
|
||||||
@ -126,9 +89,9 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
|
|
||||||
|
|
||||||
// write directly into the lists:
|
// write directly into the lists:
|
||||||
pointField& pointLst = points();
|
pointField& pointLst = ParentType::points();
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = ParentType::faces();
|
||||||
List<label>& regionLst = regions();
|
List<label>& regionLst = ParentType::regions();
|
||||||
|
|
||||||
pointLst.setSize(nPoints);
|
pointLst.setSize(nPoints);
|
||||||
faceLst.setSize(nElems);
|
faceLst.setSize(nElems);
|
||||||
@ -139,7 +102,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
forAll(pointLst, pointI)
|
forAll(pointLst, pointI)
|
||||||
{
|
{
|
||||||
scalar x, y, z;
|
scalar x, y, z;
|
||||||
line = getLineNoComment(is);
|
line = ParentType::getLineNoComment(is);
|
||||||
{
|
{
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
lineStream
|
lineStream
|
||||||
@ -154,7 +117,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
forAll(edges, edgei)
|
forAll(edges, edgei)
|
||||||
{
|
{
|
||||||
label beg, end;
|
label beg, end;
|
||||||
line = getLineNoComment(is);
|
line = ParentType::getLineNoComment(is);
|
||||||
{
|
{
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
lineStream
|
lineStream
|
||||||
@ -171,7 +134,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
label e0Label, e1Label, e2Label;
|
label e0Label, e1Label, e2Label;
|
||||||
label regionI = 0;
|
label regionI = 0;
|
||||||
|
|
||||||
line = getLineNoComment(is);
|
line = ParentType::getLineNoComment(is);
|
||||||
{
|
{
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
lineStream
|
lineStream
|
||||||
@ -206,7 +169,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Edges 0 and 1 of triangle " << faceI
|
<< "Edges 0 and 1 of triangle " << faceI
|
||||||
<< " do not share a point.\n"
|
<< " do not share a point.\n"
|
||||||
@ -223,7 +186,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Edges 1 and 2 of triangle " << faceI
|
<< "Edges 1 and 2 of triangle " << faceI
|
||||||
<< " do not share a point.\n"
|
<< " do not share a point.\n"
|
||||||
@ -238,7 +201,7 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::GTSfileFormat::read(const fileName&)"
|
"fileFormats::GTSsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Edges of triangle " << faceI
|
<< "Edges of triangle " << faceI
|
||||||
<< " reference more than three points.\n"
|
<< " reference more than three points.\n"
|
||||||
@ -252,28 +215,32 @@ bool Foam::fileFormats::GTSfileFormat::read
|
|||||||
regionLst[faceI] = regionI;
|
regionLst[faceI] = regionI;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPatches(maxPatch);
|
ParentType::setPatches(maxPatch);
|
||||||
// stitchFaces(SMALL);
|
// ParentType::stitchFaces(SMALL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::GTSfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const keyedSurface& surf
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
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
|
// It is too annoying to triangulate on-the-fly
|
||||||
// just issue a warning and get out
|
// just issue a warning and get out
|
||||||
|
//
|
||||||
|
if (faceLst.size() && faceLst[0].max_size() != 3)
|
||||||
|
{
|
||||||
label nNonTris = 0;
|
label nNonTris = 0;
|
||||||
forAll(faceLst, faceI)
|
forAll(faceLst, faceI)
|
||||||
{
|
{
|
||||||
if (faceLst[faceI].size() > 3)
|
if (faceLst[faceI].size() != 3)
|
||||||
{
|
{
|
||||||
++nNonTris;
|
++nNonTris;
|
||||||
}
|
}
|
||||||
@ -283,13 +250,15 @@ void Foam::fileFormats::GTSfileFormat::write
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::GTSfileFormat::write"
|
"fileFormats::GTSsurfaceFormat::write"
|
||||||
"(Ostream&, const keyedSurface&)"
|
"(Ostream&, const UnsortedMeshedSurfaces<Face>&)"
|
||||||
)
|
)
|
||||||
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
||||||
<< " non-triangulated faces - not writing!" << endl;
|
<< " non-triangulated faces - not writing!" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||||
@ -352,22 +321,28 @@ void Foam::fileFormats::GTSfileFormat::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::GTSfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const meshedSurface& surf
|
const MeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<FaceType>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfGroup>& patchLst = surf.patches();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
|
|
||||||
|
// check if output triangulation would be required
|
||||||
// It is too annoying to triangulate on-the-fly
|
// It is too annoying to triangulate on-the-fly
|
||||||
// just issue a warning and get out
|
// just issue a warning and get out
|
||||||
|
//
|
||||||
|
if (faceLst.size() && faceLst[0].max_size() != 3)
|
||||||
|
{
|
||||||
label nNonTris = 0;
|
label nNonTris = 0;
|
||||||
forAll(faceLst, faceI)
|
forAll(faceLst, faceI)
|
||||||
{
|
{
|
||||||
if (faceLst[faceI].size() > 3)
|
if (faceLst[faceI].size() != 3)
|
||||||
{
|
{
|
||||||
++nNonTris;
|
++nNonTris;
|
||||||
}
|
}
|
||||||
@ -375,16 +350,16 @@ void Foam::fileFormats::GTSfileFormat::write
|
|||||||
|
|
||||||
if (nNonTris)
|
if (nNonTris)
|
||||||
{
|
{
|
||||||
WarningIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::GTSfileFormat::write"
|
"fileFormats::GTSsurfaceFormat::write"
|
||||||
"(Ostream&, const meshedSurface&)"
|
"(Ostream&, const MeshedSurface<Face>&)"
|
||||||
)
|
)
|
||||||
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
<< "Surface has " << nNonTris << "/" << faceLst.size()
|
||||||
<< " non-triangulated faces - not writing!" << endl;
|
<< " non-triangulated faces - not writing!" << endl;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Write header, print patch names as comment
|
// Write header, print patch names as comment
|
||||||
os << "# GTS file" << nl
|
os << "# GTS file" << nl
|
||||||
@ -23,23 +23,23 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::GTSfileFormat
|
Foam::fileFormats::GTSsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of reading/writing GTS format.
|
Provide a means of reading/writing GTS format.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
GTSfileFormat.C
|
GTSsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef GTSfileFormat_H
|
#ifndef GTSsurfaceFormat_H
|
||||||
#define GTSfileFormat_H
|
#define GTSsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "keyedSurface.H"
|
#include "MeshedSurface.H"
|
||||||
#include "meshedSurface.H"
|
#include "UnsortedMeshedSurface.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -48,71 +48,90 @@ namespace Foam
|
|||||||
namespace fileFormats
|
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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
GTSfileFormat(const GTSfileFormat&);
|
GTSsurfaceFormat(const GTSsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const GTSfileFormat&);
|
void operator=(const GTSsurfaceFormat<Face>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
GTSfileFormat();
|
GTSsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
GTSfileFormat(const fileName&, const bool triangulate=true);
|
GTSsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return surface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=true
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new GTSfileFormat(fName,true)
|
new GTSsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
virtual ~GTSsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- Read from file
|
||||||
virtual bool read(const fileName&, const bool triangulate);
|
virtual bool read(const fileName&);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const keyedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(const fileName& fName, const keyedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(Ostream&, const meshedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const MeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName& fName, const meshedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const MeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
@ -133,6 +152,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "GTSsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#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 "NASsurfaceFormat.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "clock.H"
|
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * 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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
// Do weird things to extract number
|
// 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("+-");
|
size_t expSign = s.find_last_of("+-");
|
||||||
|
|
||||||
@ -103,40 +61,51 @@ Foam::scalar Foam::fileFormats::NASfileFormat::parseNASCoord(const string& s)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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 fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName,triangulate);
|
ThisType::read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::NASfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
IFstream is(fName);
|
|
||||||
|
|
||||||
|
// triangulation required?
|
||||||
|
bool mustTriangulate = false;
|
||||||
|
{
|
||||||
|
Face f;
|
||||||
|
if (f.max_size() == 3)
|
||||||
|
{
|
||||||
|
mustTriangulate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IFstream is(fName);
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::NASfileFormat::read(const fileName&)"
|
"fileFormats::NASsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << fName
|
<< "Cannot read file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -145,7 +114,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
DynamicList<point> pointLst;
|
DynamicList<point> pointLst;
|
||||||
// Nastran index of points
|
// Nastran index of points
|
||||||
DynamicList<label> pointId;
|
DynamicList<label> pointId;
|
||||||
DynamicList<FaceType> faceLst;
|
DynamicList<Face> faceLst;
|
||||||
DynamicList<label> regionLst;
|
DynamicList<label> regionLst;
|
||||||
HashTable<label> groupToPatch;
|
HashTable<label> groupToPatch;
|
||||||
|
|
||||||
@ -307,6 +276,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
else if (cmd == "CQUAD4")
|
else if (cmd == "CQUAD4")
|
||||||
{
|
{
|
||||||
face fQuad(4);
|
face fQuad(4);
|
||||||
|
UList<label>& f = static_cast<UList<label>&>(fQuad);
|
||||||
|
|
||||||
label groupId = readLabel(IStringStream(line.substr(16,8))());
|
label groupId = readLabel(IStringStream(line.substr(16,8))());
|
||||||
fQuad[0] = readLabel(IStringStream(line.substr(24,8))());
|
fQuad[0] = readLabel(IStringStream(line.substr(24,8))());
|
||||||
@ -329,19 +299,19 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
patchI = iter();
|
patchI = iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (triangulate)
|
if (mustTriangulate)
|
||||||
{
|
{
|
||||||
triFace fTri;
|
triFace fTri;
|
||||||
|
|
||||||
// simple face triangulation about f[0].
|
// simple face triangulation about f[0].
|
||||||
// cannot use face::triangulation since points are incomplete
|
// cannot use face::triangulation since points are incomplete
|
||||||
fTri[0] = fQuad[0];
|
fTri[0] = f[0];
|
||||||
for (label fp1 = 1; fp1 < fQuad.size() - 1; fp1++)
|
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[1] = f[fp1];
|
||||||
fTri[2] = fQuad[fp2];
|
fTri[2] = f[fp2];
|
||||||
|
|
||||||
faceLst.append(fTri);
|
faceLst.append(fTri);
|
||||||
regionLst.append(patchI);
|
regionLst.append(patchI);
|
||||||
@ -349,7 +319,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
faceLst.append(fQuad);
|
faceLst.append(Face(f));
|
||||||
regionLst.append(patchI);
|
regionLst.append(patchI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,7 +361,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::NASfileFormat::read(const fileName&)"
|
"fileFormats::NASsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Expected continuation symbol '*' when reading GRID*"
|
<< "Expected continuation symbol '*' when reading GRID*"
|
||||||
<< " (double precision coordinate) output" << nl
|
<< " (double precision coordinate) output" << nl
|
||||||
@ -420,8 +390,8 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
|
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points().transfer(pointLst);
|
ParentType::points().transfer(pointLst);
|
||||||
regions().transfer(regionLst);
|
ParentType::regions().transfer(regionLst);
|
||||||
|
|
||||||
pointId.shrink();
|
pointId.shrink();
|
||||||
faceLst.shrink();
|
faceLst.shrink();
|
||||||
@ -439,7 +409,7 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
// Relabel faces
|
// Relabel faces
|
||||||
forAll(faceLst, i)
|
forAll(faceLst, i)
|
||||||
{
|
{
|
||||||
face& f = faceLst[i];
|
Face& f = faceLst[i];
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
f[fp] = nasToFoamPoint[f[fp]];
|
f[fp] = nasToFoamPoint[f[fp]];
|
||||||
@ -461,10 +431,9 @@ bool Foam::fileFormats::NASfileFormat::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
faces().transfer(faceLst);
|
ParentType::faces().transfer(faceLst);
|
||||||
|
|
||||||
setPatches(regionNames);
|
|
||||||
|
|
||||||
|
ParentType::setPatches(regionNames);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::NASfileFormat
|
Foam::fileFormats::NASsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Nastran surface reader.
|
Nastran surface reader.
|
||||||
@ -37,17 +37,17 @@ Description
|
|||||||
@endverbatim
|
@endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
NASfileFormat.C
|
NASsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef NASfileFormat_H
|
#ifndef NASsurfaceFormat_H
|
||||||
#define NASfileFormat_H
|
#define NASsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.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
|
// Private Member Functions
|
||||||
|
|
||||||
@ -71,42 +75,44 @@ class NASfileFormat
|
|||||||
static scalar parseNASCoord(const string&);
|
static scalar parseNASCoord(const string&);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
NASfileFormat(const NASfileFormat&);
|
NASsurfaceFormat(const NASsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const NASfileFormat&);
|
void operator=(const NASsurfaceFormat<Face>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
NASfileFormat();
|
NASsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
NASfileFormat(const fileName&, const bool triangulate=false);
|
NASsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return surface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=false
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new NASfileFormat(fName,triangulate)
|
new NASsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~NASsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from a file
|
//- 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
|
#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 "OBJsurfaceFormat.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "clock.H"
|
#include "clock.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fileFormats::OBJfileFormat::writeHead
|
template<class Face>
|
||||||
|
void Foam::fileFormats::OBJsurfaceFormat<Face>::writeHead
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const List<FaceType>& faceLst,
|
const List<Face>& faceLst,
|
||||||
const List<surfGroup>& patchLst
|
const List<surfGroup>& patchLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -111,47 +74,58 @@ void Foam::fileFormats::OBJfileFormat::writeHead
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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 fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName,triangulate);
|
ThisType::read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::OBJfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
IFstream is(fName);
|
|
||||||
|
|
||||||
|
// triangulation required?
|
||||||
|
bool mustTriangulate = false;
|
||||||
|
{
|
||||||
|
Face f;
|
||||||
|
if (f.max_size() == 3)
|
||||||
|
{
|
||||||
|
mustTriangulate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IFstream is(fName);
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::OBJfileFormat::read(const fileName&)"
|
"fileFormats::OBJsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << fName
|
<< "Cannot read file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicList<point> pointLst;
|
DynamicList<point> pointLst;
|
||||||
DynamicList<FaceType> faceLst;
|
DynamicList<Face> faceLst;
|
||||||
DynamicList<label> regionLst;
|
DynamicList<label> regionLst;
|
||||||
HashTable<label> groupToPatch;
|
HashTable<label> groupToPatch;
|
||||||
|
|
||||||
@ -161,13 +135,13 @@ bool Foam::fileFormats::OBJfileFormat::read
|
|||||||
|
|
||||||
while (is.good())
|
while (is.good())
|
||||||
{
|
{
|
||||||
string line = getLineNoComment(is);
|
string line = ParentType::getLineNoComment(is);
|
||||||
|
|
||||||
// handle continuations
|
// handle continuations
|
||||||
if (line[line.size()-1] == '\\')
|
if (line[line.size()-1] == '\\')
|
||||||
{
|
{
|
||||||
line.substr(0, line.size()-1);
|
line.substr(0, line.size()-1);
|
||||||
line += getLineNoComment(is);
|
line += ParentType::getLineNoComment(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read first word
|
// Read first word
|
||||||
@ -253,9 +227,9 @@ bool Foam::fileFormats::OBJfileFormat::read
|
|||||||
}
|
}
|
||||||
dynVertices.shrink();
|
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;
|
triFace fTri;
|
||||||
|
|
||||||
@ -275,30 +249,30 @@ bool Foam::fileFormats::OBJfileFormat::read
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
faceLst.append(f);
|
faceLst.append(Face(f));
|
||||||
regionLst.append(groupID);
|
regionLst.append(groupID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points().transfer(pointLst);
|
ParentType::points().transfer(pointLst);
|
||||||
faces().transfer(faceLst);
|
ParentType::faces().transfer(faceLst);
|
||||||
regions().transfer(regionLst);
|
ParentType::regions().transfer(regionLst);
|
||||||
|
|
||||||
setPatches(groupToPatch);
|
|
||||||
|
|
||||||
|
ParentType::setPatches(groupToPatch);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::OBJfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const keyedSurface& surf
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const List<FaceType>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
|
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfGroup> patchLst = surf.sortedRegions(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,
|
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();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
writeHead(os, surf.points(), faceLst, patchLst);
|
writeHead(os, surf.points(), faceLst, patchLst);
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::OBJfileFormat
|
Foam::fileFormats::OBJsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of reading/writing Alias/Wavefront OBJ format.
|
Provide a means of reading/writing Alias/Wavefront OBJ format.
|
||||||
@ -31,17 +31,17 @@ Description
|
|||||||
Does not handle negative face indices.
|
Does not handle negative face indices.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
OBJfileFormat.C
|
OBJsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef OBJfileFormat_H
|
#ifndef OBJsurfaceFormat_H
|
||||||
#define OBJfileFormat_H
|
#define OBJsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
OBJfileFormat(const OBJfileFormat&);
|
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const OBJfileFormat&);
|
void operator=(const OBJsurfaceFormat<Face>&);
|
||||||
|
|
||||||
static void writeHead
|
static void writeHead
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const List<FaceType>&,
|
const List<Face>&,
|
||||||
const List<surfGroup>&
|
const List<surfGroup>&
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -80,47 +84,66 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
OBJfileFormat();
|
OBJsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
OBJfileFormat(const fileName&, const bool triangulate=false);
|
OBJsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return surface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=false
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new OBJfileFormat(fName,triangulate)
|
new OBJsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~OBJsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- Read from file
|
||||||
virtual bool read(const fileName&, const bool triangulate);
|
virtual bool read(const fileName&);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const keyedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(const fileName& fName, const keyedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(Ostream&, const meshedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const MeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName& fName, const meshedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const MeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
@ -141,6 +164,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "OBJsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#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 "OFFsurfaceFormat.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "clock.H"
|
#include "clock.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * 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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fileFormats::OFFfileFormat::writeHead
|
template<class Face>
|
||||||
|
void Foam::fileFormats::OFFsurfaceFormat<Face>::writeHead
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const List<FaceType>& faceLst,
|
const List<Face>& faceLst,
|
||||||
const List<surfGroup>& patchLst
|
const List<surfGroup>& patchLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -116,52 +81,63 @@ void Foam::fileFormats::OFFfileFormat::writeHead
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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 fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName,triangulate);
|
ThisType::read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::OFFfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
IFstream is(fName);
|
|
||||||
|
|
||||||
|
// triangulation required?
|
||||||
|
bool mustTriangulate = false;
|
||||||
|
{
|
||||||
|
Face f;
|
||||||
|
if (f.max_size() == 3)
|
||||||
|
{
|
||||||
|
mustTriangulate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IFstream is(fName);
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::OFFfileFormat::read(const fileName&)"
|
"fileFormats::OFFsurfaceFormat<Face>::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << fName
|
<< "Cannot read file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read header
|
// Read header
|
||||||
string hdr = getLineNoComment(is);
|
string hdr = ParentType::getLineNoComment(is);
|
||||||
if (hdr != "OFF")
|
if (hdr != "OFF")
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::OFFfileFormat::read(const fileName&)"
|
"fileFormats::OFFsurfaceFormat<Face>::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "OFF file " << fName << " does not start with 'OFF'"
|
<< "OFF file " << fName << " does not start with 'OFF'"
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -171,7 +147,7 @@ bool Foam::fileFormats::OFFfileFormat::read
|
|||||||
// get dimensions
|
// get dimensions
|
||||||
label nPoints, nEdges, nElems;
|
label nPoints, nEdges, nElems;
|
||||||
|
|
||||||
string line = getLineNoComment(is);
|
string line = ParentType::getLineNoComment(is);
|
||||||
{
|
{
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
lineStream >> nPoints >> nElems >> nEdges;
|
lineStream >> nPoints >> nElems >> nEdges;
|
||||||
@ -182,7 +158,7 @@ bool Foam::fileFormats::OFFfileFormat::read
|
|||||||
forAll(pointLst, pointI)
|
forAll(pointLst, pointI)
|
||||||
{
|
{
|
||||||
scalar x, y, z;
|
scalar x, y, z;
|
||||||
line = getLineNoComment(is);
|
line = ParentType::getLineNoComment(is);
|
||||||
{
|
{
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
lineStream >> x >> y >> z;
|
lineStream >> x >> y >> z;
|
||||||
@ -192,25 +168,27 @@ bool Foam::fileFormats::OFFfileFormat::read
|
|||||||
|
|
||||||
// Read faces - ignore optional region information
|
// Read faces - ignore optional region information
|
||||||
// use a DynamicList for possible on-the-fly triangulation
|
// use a DynamicList for possible on-the-fly triangulation
|
||||||
DynamicList<FaceType> faceLst(nElems);
|
DynamicList<Face> faceLst(nElems);
|
||||||
|
|
||||||
forAll(faceLst, faceI)
|
forAll(faceLst, faceI)
|
||||||
{
|
{
|
||||||
line = getLineNoComment(is);
|
line = ParentType::getLineNoComment(is);
|
||||||
{
|
{
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
|
|
||||||
label nVerts;
|
label nVerts;
|
||||||
lineStream >> 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;
|
triFace fTri;
|
||||||
|
|
||||||
@ -229,31 +207,32 @@ bool Foam::fileFormats::OFFfileFormat::read
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
faceLst.append(f);
|
faceLst.append(Face(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points().transfer(pointLst);
|
ParentType::points().transfer(pointLst);
|
||||||
faces().transfer(faceLst);
|
ParentType::faces().transfer(faceLst);
|
||||||
|
|
||||||
// no region information
|
// no region information
|
||||||
regions().setSize(size());
|
ParentType::regions().setSize(ThisType::size());
|
||||||
regions() = 0;
|
ParentType::regions() = 0;
|
||||||
|
|
||||||
setPatches(0);
|
ParentType::setPatches(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::OFFfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const keyedSurface& surf
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const List<FaceType>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
|
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||||
@ -267,7 +246,7 @@ void Foam::fileFormats::OFFfileFormat::write
|
|||||||
|
|
||||||
forAll(patchLst[patchI], patchFaceI)
|
forAll(patchLst[patchI], patchFaceI)
|
||||||
{
|
{
|
||||||
const face& f = faceLst[faceMap[faceIndex++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
|
|
||||||
os << f.size();
|
os << f.size();
|
||||||
forAll(f, fp)
|
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,
|
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();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
writeHead(os, surf.points(), faceLst, patchLst);
|
writeHead(os, surf.points(), faceLst, patchLst);
|
||||||
@ -302,7 +282,7 @@ void Foam::fileFormats::OFFfileFormat::write
|
|||||||
|
|
||||||
forAll(patchLst[patchI], patchFaceI)
|
forAll(patchLst[patchI], patchFaceI)
|
||||||
{
|
{
|
||||||
const face& f = faceLst[faceIndex++];
|
const Face& f = faceLst[faceIndex++];
|
||||||
|
|
||||||
os << f.size();
|
os << f.size();
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::OFFfileFormat
|
Foam::fileFormats::OFFsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of reading/writing Geomview OFF polyList format.
|
Provide a means of reading/writing Geomview OFF polyList format.
|
||||||
@ -43,13 +43,13 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef OFFfileFormat_H
|
#ifndef OFFsurfaceFormat_H
|
||||||
#define OFFfileFormat_H
|
#define OFFsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
OFFfileFormat(const OFFfileFormat&);
|
OFFsurfaceFormat(const OFFsurfaceFormat&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const OFFfileFormat&);
|
void operator=(const OFFsurfaceFormat&);
|
||||||
|
|
||||||
static void writeHead
|
static void writeHead
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const List<FaceType>&,
|
const List<Face>&,
|
||||||
const List<surfGroup>&
|
const List<surfGroup>&
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -87,47 +92,64 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
OFFfileFormat();
|
OFFsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
OFFfileFormat(const fileName&, const bool triangulate=false);
|
OFFsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return surface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=false
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new OFFfileFormat(fName,triangulate)
|
new OFFsurfaceFormat(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
virtual ~OFFsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- Read from file
|
||||||
virtual bool read(const fileName&, const bool triangulate);
|
virtual bool read(const fileName&);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const keyedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(const fileName& fName, const keyedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(Ostream&, const meshedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const MeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName& fName, const meshedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const MeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
@ -148,6 +170,11 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "OFFsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#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 "clock.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
namespace fileFormats
|
|
||||||
{
|
|
||||||
|
|
||||||
addNamedToMemberFunctionSelectionTable
|
|
||||||
(
|
|
||||||
keyedSurface,
|
|
||||||
SMESHfileFormat,
|
|
||||||
write,
|
|
||||||
fileExtension,
|
|
||||||
smesh
|
|
||||||
);
|
|
||||||
|
|
||||||
addNamedToMemberFunctionSelectionTable
|
|
||||||
(
|
|
||||||
meshedSurface,
|
|
||||||
SMESHfileFormat,
|
|
||||||
write,
|
|
||||||
fileExtension,
|
|
||||||
smesh
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
void Foam::fileFormats::SMESHfileFormat::writeHead
|
void Foam::fileFormats::SMESHsurfaceFormat<Face>::writeHead
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const List<face>& faceLst
|
const List<Face>& faceLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Write header
|
// 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
|
os << "# </faces>" << nl
|
||||||
<< nl
|
<< nl
|
||||||
@ -100,21 +75,22 @@ void Foam::fileFormats::SMESHfileFormat::writeTail(Ostream& os)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileFormats::SMESHfileFormat::SMESHfileFormat()
|
template<class Face>
|
||||||
|
Foam::fileFormats::SMESHsurfaceFormat<Face>::SMESHsurfaceFormat()
|
||||||
:
|
:
|
||||||
keyedSurface()
|
ParentType()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void
|
template<class Face>
|
||||||
Foam::fileFormats::SMESHfileFormat::write
|
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
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);
|
writeHead(os, surf.points(), faceLst);
|
||||||
|
|
||||||
@ -126,7 +102,7 @@ Foam::fileFormats::SMESHfileFormat::write
|
|||||||
{
|
{
|
||||||
forAll(patchLst[patchI], patchFaceI)
|
forAll(patchLst[patchI], patchFaceI)
|
||||||
{
|
{
|
||||||
const face& f = faceLst[faceMap[faceIndex++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
|
|
||||||
os << f.size();
|
os << f.size();
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
@ -141,14 +117,14 @@ Foam::fileFormats::SMESHfileFormat::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
template<class Face>
|
||||||
Foam::fileFormats::SMESHfileFormat::write
|
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
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();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
writeHead(os, surf.points(), faceLst);
|
writeHead(os, surf.points(), faceLst);
|
||||||
@ -172,5 +148,4 @@ Foam::fileFormats::SMESHfileFormat::write
|
|||||||
writeTail(os);
|
writeTail(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::SMESHfileFormat
|
Foam::fileFormats::SMESHsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of writing tetgen SMESH format.
|
Provide a means of writing tetgen SMESH format.
|
||||||
@ -35,18 +35,18 @@ See Also
|
|||||||
http://tetgen.berlios.de/fformats.smesh.html
|
http://tetgen.berlios.de/fformats.smesh.html
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
SMESHfileFormat.C
|
SMESHsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef SMESHfileFormat_H
|
#ifndef SMESHsurfaceFormat_H
|
||||||
#define SMESHfileFormat_H
|
#define SMESHsurfaceFormat_H
|
||||||
|
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "Ostream.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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
SMESHfileFormat(const SMESHfileFormat&);
|
SMESHsurfaceFormat(const SMESHsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- 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&);
|
static void writeTail(Ostream&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -81,28 +84,48 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
SMESHfileFormat();
|
SMESHsurfaceFormat();
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~SMESHsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const keyedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const meshedSurface&);
|
static void write
|
||||||
|
(
|
||||||
//- Write keyedSurface
|
const fileName& fName,
|
||||||
static void write(const fileName& fName, const keyedSurface& surf)
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName& fName, const meshedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const MeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write MeshedSurface
|
||||||
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const MeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
@ -123,6 +146,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "SMESHsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#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 "clock.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * 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
|
//! @cond localscope
|
||||||
const int starcdShellShape = 3;
|
const int starcdShellShape = 3;
|
||||||
@ -74,7 +39,8 @@ const int starcdShellType = 4;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDfileFormat::readHeader
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::STARCDsurfaceFormat<Face>::readHeader
|
||||||
(
|
(
|
||||||
IFstream& is,
|
IFstream& is,
|
||||||
const word& signature
|
const word& signature
|
||||||
@ -84,7 +50,7 @@ bool Foam::fileFormats::STARCDfileFormat::readHeader
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::STARCDfileFormat::readHeader(...)"
|
"fileFormats::STARCDsurfaceFormat::readHeader(...)"
|
||||||
)
|
)
|
||||||
<< "cannot read " << signature << " " << is.name()
|
<< "cannot read " << signature << " " << is.name()
|
||||||
<< abort(FatalError);
|
<< 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,
|
Ostream& os,
|
||||||
const char* filetype
|
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,
|
Ostream& os,
|
||||||
const pointField& pointLst
|
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,
|
Ostream& os,
|
||||||
const face& f,
|
const Face& f,
|
||||||
const label cellId,
|
const label cellId,
|
||||||
const label cellTableId
|
const label cellTableId
|
||||||
)
|
)
|
||||||
@ -192,9 +161,10 @@ inline void Foam::fileFormats::STARCDfileFormat::writeShell
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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 fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName, triangulate);
|
ThisType::read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
|
|
||||||
|
// triangulation required?
|
||||||
|
bool mustTriangulate = false;
|
||||||
|
{
|
||||||
|
Face f;
|
||||||
|
if (f.max_size() == 3)
|
||||||
|
{
|
||||||
|
mustTriangulate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fileName baseName = fName.lessExt();
|
fileName baseName = fName.lessExt();
|
||||||
autoPtr<IFstream> isPtr;
|
autoPtr<IFstream> isPtr;
|
||||||
@ -250,7 +231,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::STARCDfileFormat::read(const fileName&)"
|
"fileFormats::STARCDsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << (baseName + ".vrt")
|
<< "Cannot read file " << (baseName + ".vrt")
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -271,7 +252,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points().transfer(pointLst);
|
ParentType::points().transfer(pointLst);
|
||||||
|
|
||||||
// Build inverse mapping (index to point)
|
// Build inverse mapping (index to point)
|
||||||
pointId.shrink();
|
pointId.shrink();
|
||||||
@ -283,7 +264,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
|||||||
pointId.clear();
|
pointId.clear();
|
||||||
|
|
||||||
|
|
||||||
DynamicList<face> faceLst;
|
DynamicList<Face> faceLst;
|
||||||
DynamicList<label> regionLst;
|
DynamicList<label> regionLst;
|
||||||
|
|
||||||
// From face cellTableId to patchId
|
// From face cellTableId to patchId
|
||||||
@ -300,7 +281,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::STARCDfileFormat::read(const fileName&)"
|
"fileFormats::STARCDsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << (baseName + ".cel")
|
<< "Cannot read file " << (baseName + ".cel")
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -356,20 +337,27 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
|||||||
starLabels[i] = mapToFoamPointId[starLabels[i]];
|
starLabels[i] = mapToFoamPointId[starLabels[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (triangulate && nLabels > 3)
|
if (mustTriangulate && nLabels > 3)
|
||||||
{
|
{
|
||||||
face f
|
face f
|
||||||
(
|
(
|
||||||
SubList<label>(starLabels, nLabels)
|
SubList<label>(starLabels, nLabels)
|
||||||
);
|
);
|
||||||
|
|
||||||
faceList triFaces(f.nTriangles(points()));
|
faceList triFaces(f.nTriangles(ParentType::points()));
|
||||||
label nTri = 0;
|
label nTri = 0;
|
||||||
f.triangles(points(), nTri, triFaces);
|
f.triangles(ParentType::points(), nTri, triFaces);
|
||||||
|
|
||||||
forAll(triFaces, faceI)
|
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);
|
regionLst.append(patchI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -377,7 +365,7 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
|||||||
{
|
{
|
||||||
faceLst.append
|
faceLst.append
|
||||||
(
|
(
|
||||||
face(SubList<label>(starLabels, nLabels))
|
Face(SubList<label>(starLabels, nLabels))
|
||||||
);
|
);
|
||||||
regionLst.append(patchI);
|
regionLst.append(patchI);
|
||||||
}
|
}
|
||||||
@ -398,22 +386,23 @@ bool Foam::fileFormats::STARCDfileFormat::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
faces().transfer(faceLst);
|
ParentType::faces().transfer(faceLst);
|
||||||
regions().transfer(regionLst);
|
ParentType::regions().transfer(regionLst);
|
||||||
|
|
||||||
setPatches(regionNames);
|
ParentType::setPatches(regionNames);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::STARCDfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
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();
|
fileName baseName = fName.lessExt();
|
||||||
autoPtr<OFstream> osPtr;
|
autoPtr<OFstream> osPtr;
|
||||||
@ -436,7 +425,7 @@ void Foam::fileFormats::STARCDfileFormat::write
|
|||||||
|
|
||||||
forAll(patch, patchFaceI)
|
forAll(patch, patchFaceI)
|
||||||
{
|
{
|
||||||
const face& f = faceLst[faceMap[faceIndex++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
|
|
||||||
writeShell(osPtr(), f, faceIndex, patchI + 1);
|
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 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();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
|
|
||||||
@ -471,7 +461,7 @@ void Foam::fileFormats::STARCDfileFormat::write
|
|||||||
|
|
||||||
forAll(patch, patchFaceI)
|
forAll(patch, patchFaceI)
|
||||||
{
|
{
|
||||||
const face& f = faceLst[faceIndex++];
|
const Face& f = faceLst[faceIndex++];
|
||||||
writeShell(osPtr(), f, faceIndex, patchI + 1);
|
writeShell(osPtr(), f, faceIndex, patchI + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::STARCDfileFormat
|
Foam::fileFormats::STARCDsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Read/write the surface shells from pro-STAR vrt/cel files.
|
Read/write the surface shells from pro-STAR vrt/cel files.
|
||||||
@ -35,19 +35,18 @@ See Also
|
|||||||
Foam::meshReaders::STARCD
|
Foam::meshReaders::STARCD
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
STARCDfileFormat.C
|
STARCDsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef STARCDfileFormat_H
|
#ifndef STARCDsurfaceFormat_H
|
||||||
#define STARCDfileFormat_H
|
#define STARCDsurfaceFormat_H
|
||||||
|
|
||||||
#include "STLtriangle.H"
|
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
STARCDfileFormat(const STARCDfileFormat&);
|
STARCDsurfaceFormat(const STARCDsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const STARCDfileFormat&);
|
void operator=(const STARCDsurfaceFormat<Face>&);
|
||||||
|
|
||||||
|
|
||||||
static bool readHeader(IFstream&, const word&);
|
static bool readHeader(IFstream&, const word&);
|
||||||
@ -84,7 +86,7 @@ class STARCDfileFormat
|
|||||||
static inline void writeShell
|
static inline void writeShell
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const face&,
|
const Face&,
|
||||||
const label cellId,
|
const label cellId,
|
||||||
const label cellTableId
|
const label cellTableId
|
||||||
);
|
);
|
||||||
@ -94,43 +96,45 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
STARCDfileFormat();
|
STARCDsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
STARCDfileFormat(const fileName&, const bool triangulate=true);
|
STARCDsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return keyedSurface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=true
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new STARCDfileFormat(fName, triangulate)
|
new STARCDsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
virtual ~STARCDsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- Read from file
|
||||||
virtual bool read(const fileName&, const bool triangulate);
|
virtual bool read(const fileName&);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(const fileName&, const keyedSurface&);
|
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName&, const meshedSurface&);
|
static void write(const fileName&, const MeshedSurface<Face>&);
|
||||||
|
|
||||||
//- Write to Ostream as one large file - not really useful
|
//- Write to Ostream as one large file - not really useful
|
||||||
virtual void write(Ostream&) const
|
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
|
#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
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::STLfileFormat
|
Foam::fileFormats::STLsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of reading/writing STL files (ASCII and binary).
|
Provide a means of reading/writing STL files (ASCII and binary).
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
STLfileFormat.C
|
STLsurfaceFormat.C
|
||||||
STLfileFormatASCII.L
|
STLsurfaceFormatASCII.L
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef STLfileFormat_H
|
#ifndef STLsurfaceFormat_H
|
||||||
#define STLfileFormat_H
|
#define STLsurfaceFormat_H
|
||||||
|
|
||||||
#include "STLtriangle.H"
|
#include "STLsurfaceFormatCore.H"
|
||||||
#include "IFstream.H"
|
#include "MeshedSurface.H"
|
||||||
#include "Ostream.H"
|
#include "UnsortedMeshedSurface.H"
|
||||||
#include "OFstream.H"
|
|
||||||
#include "keyedSurface.H"
|
|
||||||
#include "meshedSurface.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
|
// Private data
|
||||||
static const int headerSize=80;
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
STLfileFormat(const STLfileFormat&);
|
STLsurfaceFormat(const STLsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const STLfileFormat&);
|
void operator=(const STLsurfaceFormat<Face>&);
|
||||||
|
|
||||||
bool readASCII(IFstream&, const off_t);
|
//- Write Face in ASCII
|
||||||
bool readBINARY(IFstream&, const off_t);
|
|
||||||
|
|
||||||
static bool detectBINARY(const fileName&);
|
|
||||||
|
|
||||||
//- write face in ASCII
|
|
||||||
static inline void writeShell
|
static inline void writeShell
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const face&,
|
const Face&,
|
||||||
const vector& norm
|
const vector& norm
|
||||||
);
|
);
|
||||||
|
|
||||||
//- write face in BINARY
|
//- Write Face in BINARY
|
||||||
static inline void writeShell
|
static inline void writeShell
|
||||||
(
|
(
|
||||||
ostream&,
|
ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const face&,
|
const Face&,
|
||||||
const vector&,
|
const vector&,
|
||||||
const label patchI
|
const label patchI
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Write keySurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void writeASCII(Ostream&, const keyedSurface&);
|
static void writeASCII(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void writeBINARY(ostream&, const keyedSurface&);
|
static void writeBINARY(ostream&, const UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void writeASCII(Ostream&, const meshedSurface&);
|
static void writeASCII(Ostream&, const MeshedSurface<Face>&);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void writeBINARY(ostream&, const meshedSurface&);
|
static void writeBINARY(ostream&, const MeshedSurface<Face>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
STLfileFormat();
|
STLsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
STLfileFormat(const fileName&, const bool triangulate=true);
|
STLsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return keyedSurface
|
||||||
static autoPtr<keyedSurface> New
|
//- Read file and return surface
|
||||||
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=true
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new STLfileFormat(fName,true)
|
new STLsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
virtual ~STLsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- 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
|
// 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
|
// 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
|
//- Write object (only ASCII output)
|
||||||
static void write(Ostream&, const meshedSurface&);
|
|
||||||
|
|
||||||
//- Write meshedSurface
|
|
||||||
static void write(const fileName&, const meshedSurface&);
|
|
||||||
|
|
||||||
//- Write object
|
|
||||||
virtual void write(Ostream& os) const
|
virtual void write(Ostream& os) const
|
||||||
{
|
{
|
||||||
write(os, *this);
|
write(os, *this);
|
||||||
@ -171,6 +183,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "STLsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -32,8 +32,7 @@ License
|
|||||||
------ local definitions
|
------ local definitions
|
||||||
\* ------------------------------------------------------------------------ */
|
\* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#include "STLfileFormat.H"
|
#include "STLsurfaceFormatCore.H"
|
||||||
#include "triFace.H"
|
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- region names
|
//- region names
|
||||||
const HashTable<label>& groupToPatch() const
|
HashTable<label>& groupToPatch()
|
||||||
{
|
{
|
||||||
return groupToPatch_;
|
return groupToPatch_;
|
||||||
}
|
}
|
||||||
@ -360,7 +359,7 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
|||||||
yy_pop_state();
|
yy_pop_state();
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::STLfileFormat::readASCII(const fileName&)"
|
"fileFormats::STLsurfaceFormatCore::readASCII(const fileName&)"
|
||||||
) << "while " << stateNames[YY_START] << " on line " << lineNo_ << nl
|
) << "while " << stateNames[YY_START] << " on line " << lineNo_ << nl
|
||||||
<< " expected " << stateExpects[YY_START]
|
<< " expected " << stateExpects[YY_START]
|
||||||
<< " but found '" << startError_.c_str() << YYText() << "'"
|
<< " but found '" << startError_.c_str() << YYText() << "'"
|
||||||
@ -379,14 +378,13 @@ endsolid {space}("endsolid"|"ENDSOLID")({some_space}{word})*
|
|||||||
//
|
//
|
||||||
// member function
|
// member function
|
||||||
//
|
//
|
||||||
bool
|
bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
|
||||||
Foam::fileFormats::STLfileFormat::readASCII
|
|
||||||
(
|
(
|
||||||
IFstream& ifs,
|
IFstream& ifs,
|
||||||
const off_t fileSize
|
const off_t fileSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
binary_ = false;
|
||||||
|
|
||||||
// Create the lexer with the approximate number of vertices in the STL
|
// Create the lexer with the approximate number of vertices in the STL
|
||||||
// from the file size
|
// from the file size
|
||||||
@ -394,32 +392,12 @@ Foam::fileFormats::STLfileFormat::readASCII
|
|||||||
while (lexer.lex() != 0) {}
|
while (lexer.lex() != 0) {}
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points().transfer(lexer.points());
|
points_.transfer(lexer.points());
|
||||||
regions().transfer(lexer.facets());
|
regions_.transfer(lexer.facets());
|
||||||
|
groupToPatch_.transfer(lexer.groupToPatch());
|
||||||
// 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);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ *\
|
/* ------------------------------------------------------------------------ *\
|
||||||
------ End of STLfileFormatASCII.L
|
------ 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 "TRIsurfaceFormat.H"
|
||||||
#include "triFace.H"
|
|
||||||
#include "clock.H"
|
#include "clock.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * 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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
inline void Foam::fileFormats::TRIfileFormat::writeShell
|
template<class Face>
|
||||||
|
inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const face& f,
|
const Face& f,
|
||||||
const label patchI
|
const label patchI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -99,40 +64,41 @@ inline void Foam::fileFormats::TRIfileFormat::writeShell
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * 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 fileName& fName
|
||||||
const bool
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{
|
{
|
||||||
read(fName, true);
|
read(fName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fileFormats::TRIfileFormat::read
|
template<class Face>
|
||||||
|
bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
clear();
|
ParentType::clear();
|
||||||
IFstream is(fName);
|
|
||||||
|
|
||||||
|
IFstream is(fName);
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::TRIfileFormat::read(const fileName&)"
|
"fileFormats::TRIsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Cannot read file " << fName
|
<< "Cannot read file " << fName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -150,13 +116,13 @@ bool Foam::fileFormats::TRIfileFormat::read
|
|||||||
|
|
||||||
while (is.good())
|
while (is.good())
|
||||||
{
|
{
|
||||||
string line = getLineNoComment(is);
|
string line = ParentType::getLineNoComment(is);
|
||||||
|
|
||||||
// handle continuations ?
|
// handle continuations ?
|
||||||
// if (line[line.size()-1] == '\\')
|
// if (line[line.size()-1] == '\\')
|
||||||
// {
|
// {
|
||||||
// line.substr(0, line.size()-1);
|
// line.substr(0, line.size()-1);
|
||||||
// line += getLineNoComment(is);
|
// line += ParentType::getLineNoComment(is);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
@ -224,12 +190,12 @@ bool Foam::fileFormats::TRIfileFormat::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transfer to normal list
|
// transfer to normal list
|
||||||
points().transfer(pointLst);
|
ParentType::points().transfer(pointLst);
|
||||||
regions().transfer(regionLst);
|
ParentType::regions().transfer(regionLst);
|
||||||
|
|
||||||
// make our triangles directly
|
// make our triangles directly
|
||||||
List<FaceType>& faceLst = faces();
|
List<Face>& faceLst = ParentType::faces();
|
||||||
faceLst.setSize(regions().size());
|
faceLst.setSize(ParentType::regions().size());
|
||||||
|
|
||||||
label ptI = 0;
|
label ptI = 0;
|
||||||
forAll(faceLst, faceI)
|
forAll(faceLst, faceI)
|
||||||
@ -243,21 +209,21 @@ bool Foam::fileFormats::TRIfileFormat::read
|
|||||||
faceLst[faceI] = fTri;
|
faceLst[faceI] = fTri;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPatches(groupToPatch);
|
ParentType::setPatches(groupToPatch);
|
||||||
stitchFaces(SMALL);
|
ParentType::stitchFaces(SMALL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::TRIfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const keyedSurface& surf
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
|
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||||
@ -267,21 +233,22 @@ void Foam::fileFormats::TRIfileFormat::write
|
|||||||
{
|
{
|
||||||
forAll(patchLst[patchI], patchFaceI)
|
forAll(patchLst[patchI], patchFaceI)
|
||||||
{
|
{
|
||||||
const face& f = faceLst[faceMap[faceIndex++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
writeShell(os, pointLst, f, patchI);
|
writeShell(os, pointLst, f, patchI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileFormats::TRIfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const meshedSurface& surf
|
const MeshedSurface<Face>& surf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfGroup>& patchLst = surf.patches();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
@ -289,7 +256,7 @@ void Foam::fileFormats::TRIfileFormat::write
|
|||||||
{
|
{
|
||||||
forAll(patchLst[patchI], patchFaceI)
|
forAll(patchLst[patchI], patchFaceI)
|
||||||
{
|
{
|
||||||
const face& f = faceLst[faceIndex++];
|
const Face& f = faceLst[faceIndex++];
|
||||||
writeShell(os, pointLst, f, patchI);
|
writeShell(os, pointLst, f, patchI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,23 +23,23 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::TRIfileFormat
|
Foam::fileFormats::TRIsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of reading/writing .tri format.
|
Provide a means of reading/writing .tri format.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
TRIfileFormat.C
|
TRIsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef TRIfileFormat_H
|
#ifndef TRIsurfaceFormat_H
|
||||||
#define TRIfileFormat_H
|
#define TRIsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
TRIfileFormat(const TRIfileFormat&);
|
TRIsurfaceFormat(const TRIsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const TRIfileFormat&);
|
void operator=(const TRIsurfaceFormat<Face>&);
|
||||||
|
|
||||||
static inline void writeShell
|
static inline void writeShell
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const face&,
|
const Face&,
|
||||||
const label patchI
|
const label patchI
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -78,47 +82,64 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
TRIfileFormat();
|
TRIsurfaceFormat();
|
||||||
|
|
||||||
//- Construct from file name
|
//- Construct from file name
|
||||||
TRIfileFormat(const fileName&, const bool triangulate=true);
|
TRIsurfaceFormat(const fileName&);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Read file and return keyedSurface
|
//- Read file and return surface
|
||||||
static autoPtr<keyedSurface> New
|
static autoPtr<UnsortedMeshedSurface<Face> > New
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName
|
||||||
const bool triangulate=true
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return autoPtr<keyedSurface>
|
return autoPtr<UnsortedMeshedSurface<Face> >
|
||||||
(
|
(
|
||||||
new TRIfileFormat(fName,true)
|
new TRIsurfaceFormat<Face>(fName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
virtual ~TRIsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read from file
|
//- Read from file
|
||||||
virtual bool read(const fileName&, const bool triangulate);
|
virtual bool read(const fileName&);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const keyedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(const fileName& fName, const keyedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(Ostream&, const meshedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const MeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName& fName, const meshedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const MeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
@ -139,6 +160,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "TRIsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#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 "clock.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
#include "addToMemberFunctionSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
namespace fileFormats
|
|
||||||
{
|
|
||||||
|
|
||||||
addNamedToMemberFunctionSelectionTable
|
|
||||||
(
|
|
||||||
keyedSurface,
|
|
||||||
VTKfileFormat,
|
|
||||||
write,
|
|
||||||
fileExtension,
|
|
||||||
vtk
|
|
||||||
);
|
|
||||||
|
|
||||||
addNamedToMemberFunctionSelectionTable
|
|
||||||
(
|
|
||||||
meshedSurface,
|
|
||||||
VTKfileFormat,
|
|
||||||
write,
|
|
||||||
fileExtension,
|
|
||||||
vtk
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
template<class Face>
|
||||||
void Foam::fileFormats::VTKfileFormat::writeHead
|
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHead
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const List<face>& faceLst
|
const List<Face>& faceLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Write header
|
// 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,
|
Ostream& os,
|
||||||
const List<surfGroup>& patchLst
|
const List<surfGroup>& patchLst
|
||||||
@ -139,21 +112,23 @@ void Foam::fileFormats::VTKfileFormat::writeTail
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileFormats::VTKfileFormat::VTKfileFormat()
|
template<class Face>
|
||||||
|
Foam::fileFormats::VTKsurfaceFormat<Face>::VTKsurfaceFormat()
|
||||||
:
|
:
|
||||||
Foam::keyedSurface()
|
ParentType()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fileFormats::VTKfileFormat::write
|
template<class Face>
|
||||||
|
void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||||
(
|
(
|
||||||
Ostream& os,
|
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);
|
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,
|
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();
|
const List<surfGroup>& patchLst = surf.patches();
|
||||||
|
|
||||||
writeHead(os, surf.points(), faceLst);
|
writeHead(os, surf.points(), faceLst);
|
||||||
@ -23,23 +23,23 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fileFormats::VTKfileFormat
|
Foam::fileFormats::VTKsurfaceFormat
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of writing VTK legacy format.
|
Provide a means of writing VTK legacy format.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
VTKfileFormat.C
|
VTKsurfaceFormat.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef VTKfileFormat_H
|
#ifndef VTKsurfaceFormat_H
|
||||||
#define VTKfileFormat_H
|
#define VTKsurfaceFormat_H
|
||||||
|
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "OFstream.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
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
VTKfileFormat(const VTKfileFormat&);
|
VTKsurfaceFormat(const VTKsurfaceFormat<Face>&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- 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>&);
|
static void writeTail(Ostream&, const List<surfGroup>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -73,30 +77,49 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
VTKfileFormat();
|
VTKsurfaceFormat();
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~VTKsurfaceFormat()
|
||||||
|
{}
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(Ostream&, const keyedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const UnsortedMeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write keyedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
static void write(const fileName& fName, const keyedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const UnsortedMeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(Ostream&, const meshedSurface&);
|
static void write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const MeshedSurface<Face>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Write meshedSurface
|
//- Write MeshedSurface
|
||||||
static void write(const fileName& fName, const meshedSurface& surf)
|
static void write
|
||||||
|
(
|
||||||
|
const fileName& fName,
|
||||||
|
const MeshedSurface<Face>& surf
|
||||||
|
)
|
||||||
{
|
{
|
||||||
write(OFstream(fName)(), surf);
|
write(OFstream(fName)(), surf);
|
||||||
}
|
}
|
||||||
@ -117,6 +140,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "VTKsurfaceFormat.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#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