Commit a5179ff4 authored by Mark Olesen's avatar Mark Olesen
Browse files

surfMesh changes

 - use new HashSet capabilities and sortedOrder function
 - make STL format a MeshedSurface instead of an UnsortedMeshedSurface for
   better (MeshedSurface) reader efficiency
parent e3c70a83
......@@ -29,7 +29,6 @@ License
#include "IFstream.H"
#include "OFstream.H"
#include "Time.H"
#include "SortableList.H"
#include "ListOps.H"
#include "polyBoundaryMesh.H"
#include "polyMesh.H"
......@@ -42,38 +41,14 @@ License
template<class Face>
Foam::wordHashSet Foam::MeshedSurface<Face>::readTypes()
{
wordHashSet known(2*fileExtensionConstructorTablePtr_->size());
forAllIter
(
typename fileExtensionConstructorTable::iterator,
*fileExtensionConstructorTablePtr_,
iter
)
{
known.insert(iter.key());
}
return known;
return wordHashSet(*fileExtensionConstructorTablePtr_);
}
template<class Face>
Foam::wordHashSet Foam::MeshedSurface<Face>::writeTypes()
{
wordHashSet supported(2*writefileExtensionMemberFunctionTablePtr_->size());
forAllIter
(
typename writefileExtensionMemberFunctionTable::iterator,
*writefileExtensionMemberFunctionTablePtr_,
iter
)
{
supported.insert(iter.key());
}
return supported;
return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
}
......@@ -91,11 +66,16 @@ bool Foam::MeshedSurface<Face>::canReadType
{
return true;
}
wordHashSet available = readTypes();
available += SiblingType::readTypes();
return checkSupport(available, ext, verbose, "reading");
else
{
return checkSupport
(
readTypes() | SiblingType::readTypes(),
ext,
verbose,
"reading"
);
}
}
......@@ -141,8 +121,9 @@ void Foam::MeshedSurface<Face>::write
{
if (debug)
{
Info<< "MeshedSurface::write(const fileName&, const MeshedSurface&) : "
"writing MeshedSurface to " << fName
Info<< "MeshedSurface::write"
"(const fileName&, const MeshedSurface&) : "
"writing to " << fName
<< endl;
}
......
......@@ -69,7 +69,7 @@ Foam::MeshedSurface<Face>::New
(
"MeshedSurface<Face>::New"
"(const fileName&, const word&) : "
"constructing UnsortedMeshedSurface"
"constructing MeshedSurface"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << nl
<< supported
......
......@@ -29,11 +29,8 @@ License
#include "IFstream.H"
#include "OFstream.H"
#include "Time.H"
#include "boundBox.H"
#include "polyBoundaryMesh.H"
#include "polyMesh.H"
#include "primitivePatch.H"
#include "SortableList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -42,38 +39,14 @@ License
template<class Face>
Foam::wordHashSet Foam::UnsortedMeshedSurface<Face>::readTypes()
{
wordHashSet supported(2*fileExtensionConstructorTablePtr_->size());
forAllIter
(
typename fileExtensionConstructorTable::iterator,
*fileExtensionConstructorTablePtr_,
iter
)
{
supported.insert(iter.key());
}
return supported;
return wordHashSet(*fileExtensionConstructorTablePtr_);
}
template<class Face>
Foam::wordHashSet Foam::UnsortedMeshedSurface<Face>::writeTypes()
{
wordHashSet supported(2*writefileExtensionMemberFunctionTablePtr_->size());
forAllIter
(
typename writefileExtensionMemberFunctionTable::iterator,
*writefileExtensionMemberFunctionTablePtr_,
iter
)
{
supported.insert(iter.key());
}
return supported;
return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
}
......@@ -89,11 +62,16 @@ bool Foam::UnsortedMeshedSurface<Face>::canReadType
{
return true;
}
wordHashSet available = readTypes();
available += SiblingType::readTypes();;
return checkSupport(available, ext, verbose, "reading");
else
{
return checkSupport
(
readTypes() | SiblingType::readTypes(),
ext,
verbose,
"reading"
);
}
}
......@@ -139,8 +117,9 @@ void Foam::UnsortedMeshedSurface<Face>::write
{
if (debug)
{
Info<< "UnsortedMeshedSurface::write(const fileName&, const UnsortedMeshedSurface&) : "
"writing UnsortedMeshedSurface to " << fName
Info<< "UnsortedMeshedSurface::write"
"(const fileName&, const UnsortedMeshedSurface&) : "
"writing to " << fName
<< endl;
}
......
......@@ -107,37 +107,37 @@ public:
//- Read from file
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
//- Write MeshedSurface
static void write
(
Ostream&,
const UnsortedMeshedSurface<Face>&
const MeshedSurface<Face>&
);
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
//- Write MeshedSurface
static void write
(
const fileName& fName,
const UnsortedMeshedSurface<Face>& surf
const MeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
}
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
static void write
(
Ostream&,
const MeshedSurface<Face>&
const UnsortedMeshedSurface<Face>&
);
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
static void write
(
const fileName& fName,
const MeshedSurface<Face>& surf
const UnsortedMeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
......
......@@ -56,7 +56,7 @@ addNamedTemplatedToRunTimeSelectionTable
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
AC3DsurfaceFormat,
face,
write,
......@@ -65,7 +65,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
AC3DsurfaceFormat,
triFace,
write,
......@@ -76,7 +76,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
AC3DsurfaceFormat,
face,
write,
......@@ -85,7 +85,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
AC3DsurfaceFormat,
triFace,
write,
......
......@@ -95,37 +95,37 @@ public:
//- Read from file
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
//- Write MeshedSurface
static void write
(
Ostream&,
const UnsortedMeshedSurface<Face>&
const MeshedSurface<Face>&
);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
//- Write MeshedSurface
static void write
(
const fileName& fName,
const UnsortedMeshedSurface<Face>& surf
const MeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
}
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
Ostream&,
const MeshedSurface<Face>&
const UnsortedMeshedSurface<Face>&
);
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
const fileName& fName,
const MeshedSurface<Face>& surf
const UnsortedMeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
......
......@@ -55,7 +55,7 @@ addNamedTemplatedToRunTimeSelectionTable
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
GTSsurfaceFormat,
face,
write,
......@@ -64,7 +64,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
GTSsurfaceFormat,
triFace,
write,
......@@ -72,10 +72,9 @@ addNamedTemplatedToMemberFunctionSelectionTable
gts
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
GTSsurfaceFormat,
face,
write,
......@@ -84,7 +83,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
GTSsurfaceFormat,
triFace,
write,
......
......@@ -109,37 +109,37 @@ public:
//- Read from file
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
//- Write MeshedSurface
static void write
(
Ostream&,
const UnsortedMeshedSurface<Face>&
const MeshedSurface<Face>&
);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
//- Write MeshedSurface
static void write
(
const fileName& fName,
const UnsortedMeshedSurface<Face>& surf
const MeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
}
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
Ostream&,
const MeshedSurface<Face>&
const UnsortedMeshedSurface<Face>&
);
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
const fileName& fName,
const MeshedSurface<Face>& surf
const UnsortedMeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
......
......@@ -56,7 +56,7 @@ addNamedTemplatedToRunTimeSelectionTable
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
OBJsurfaceFormat,
face,
write,
......@@ -65,7 +65,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
OBJsurfaceFormat,
triFace,
write,
......@@ -73,10 +73,9 @@ addNamedTemplatedToMemberFunctionSelectionTable
obj
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
OBJsurfaceFormat,
face,
write,
......@@ -85,7 +84,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
OBJsurfaceFormat,
triFace,
write,
......@@ -93,6 +92,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
obj
);
}
}
......
......@@ -91,37 +91,37 @@ public:
// Member Functions
//- Write UnsortedMeshedSurface
// The output is sorted by region.
//- Write MeshedSurface
static void write
(
Ostream&,
const UnsortedMeshedSurface<Face>&
const MeshedSurface<Face>&
);
//- Write UnsortedMeshedSurface
// The output is sorted by region.
//- Write MeshedSurface
static void write
(
const fileName& fName,
const UnsortedMeshedSurface<Face>& surf
const MeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
}
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is sorted by region.
static void write
(
Ostream&,
const MeshedSurface<Face>&
const UnsortedMeshedSurface<Face>&
);
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is sorted by region.
static void write
(
const fileName& fName,
const MeshedSurface<Face>& surf
const UnsortedMeshedSurface<Face>& surf
)
{
write(OFstream(fName)(), surf);
......
......@@ -38,7 +38,7 @@ namespace fileFormats
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
SMESHsurfaceFormat,
face,
write,
......@@ -47,7 +47,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
SMESHsurfaceFormat,
triFace,
write,
......@@ -55,10 +55,9 @@ addNamedTemplatedToMemberFunctionSelectionTable
smesh
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
SMESHsurfaceFormat,
face,
write,
......@@ -67,7 +66,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
SMESHsurfaceFormat,
triFace,
write,
......
......@@ -119,19 +119,19 @@ public:
//- Read from file
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
//- Write MeshedSurface
static void write
(
const fileName&,
const UnsortedMeshedSurface<Face>&
const MeshedSurface<Face>&
);
//- Write MeshedSurface
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
const fileName&,
const MeshedSurface<Face>&
const UnsortedMeshedSurface<Face>&
);
//- Write to Ostream as one large file - not really useful
......
......@@ -56,7 +56,7 @@ addNamedTemplatedToRunTimeSelectionTable
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
STARCDsurfaceFormat,
face,
write,
......@@ -65,7 +65,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
UnsortedMeshedSurface,
MeshedSurface,
STARCDsurfaceFormat,
triFace,
write,
......@@ -76,7 +76,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
STARCDsurfaceFormat,
face,
write,
......@@ -85,7 +85,7 @@ addNamedTemplatedToMemberFunctionSelectionTable
);
addNamedTemplatedToMemberFunctionSelectionTable
(
MeshedSurface,
UnsortedMeshedSurface,
STARCDsurfaceFormat,
triFace,
write,
......
......@@ -25,6 +25,7 @@ License
\*---------------------------------------------------------------------------*/
#include "STLsurfaceFormat.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -289,35 +290,70 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
// read in the values
STLsurfaceFormatCore reader(fName);
// generate the faces:
List<Face>& faceLst = this->storedFaces();
faceLst.setSize(reader.regions().size());
// transfer
// transfer points
this->storedPoints().transfer(reader.points());
this->storedRegions().transfer(reader.regions());
label ptI = 0;
forAll(faceLst, faceI)
// get the original region information
List<word> names(xferMove(reader.names()));
List<label> unsortedRegions(xferMove(reader.regions()));
// and determine the sorted order:
// avoid SortableList since we discard the main list anyhow
List<label> faceMap;