surfMesh gets PrimitiveMeshedSurface as common basis

This commit is contained in:
Mark Olesen
2008-11-17 01:41:07 +01:00
parent d56220c34a
commit d01c115f02
40 changed files with 845 additions and 935 deletions

View File

@ -93,8 +93,8 @@ int main(int argc, char *argv[])
if if
( (
!meshedSurface::canRead(importName.ext(), true) !meshedSurface::canRead(importName, true)
|| !meshedSurface::canWrite(exportName.ext(), true) || !meshedSurface::canWriteType(exportName.ext(), true)
) )
{ {
return 1; return 1;

View File

@ -26,11 +26,9 @@ License
#include "MeshedSurface.H" #include "MeshedSurface.H"
#include "UnsortedMeshedSurface.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 "SortableList.H" #include "SortableList.H"
#include "ListOps.H" #include "ListOps.H"
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
@ -45,14 +43,11 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face> template<class Face>
inline bool Foam::MeshedSurface<Face>::isTri() bool Foam::MeshedSurface<Face>::canReadType
{ (
return false; const word& ext,
} const bool verbose
)
template<class Face>
bool Foam::MeshedSurface<Face>::canRead(const word& ext, const bool verbose)
{ {
// handle 'native' format directly // handle 'native' format directly
if (isNative(ext)) if (isNative(ext))
@ -65,25 +60,20 @@ bool Foam::MeshedSurface<Face>::canRead(const word& ext, const bool verbose)
template<class Face> template<class Face>
bool Foam::MeshedSurface<Face>::canWrite(const word& ext, const bool verbose) bool Foam::MeshedSurface<Face>::canWriteType
(
const word& ext,
const bool verbose
)
{ {
// perhaps sent an entire name
word fExt(ext);
string::size_type dot = ext.find_last_of(".");
if (dot != string::npos)
{
fExt = ext.substr(dot+1);
}
// handle 'native' format directly // handle 'native' format directly
if (isNative(fExt)) if (isNative(ext))
{ {
return true; return true;
} }
typename writefileExtensionMemberFunctionTable::iterator mfIter = typename writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(fExt); writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end()) if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{ {
@ -94,7 +84,7 @@ bool Foam::MeshedSurface<Face>::canWrite(const word& ext, const bool verbose)
writefileExtensionMemberFunctionTablePtr_->toc() writefileExtensionMemberFunctionTablePtr_->toc()
); );
Info<<"Unknown file extension for writing: " << fExt << nl; Info<<"Unknown file extension for writing: " << ext << nl;
// compact output: // compact output:
Info<<"Valid types: ( " << nativeExt; Info<<"Valid types: ( " << nativeExt;
forAll(known, i) forAll(known, i)
@ -111,6 +101,22 @@ bool Foam::MeshedSurface<Face>::canWrite(const word& ext, const bool verbose)
} }
template<class Face>
bool Foam::MeshedSurface<Face>::canRead
(
const fileName& fName,
const bool verbose
)
{
word ext = fName.ext();
if (ext == "gz")
{
ext = fName.lessExt().ext();
}
return canReadType(ext, verbose);
}
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::write void Foam::MeshedSurface<Face>::write
( (
@ -125,7 +131,7 @@ void Foam::MeshedSurface<Face>::write
<< endl; << endl;
} }
const word ext = fName.ext(); word ext = fName.ext();
// handle 'native' format directly // handle 'native' format directly
if (isNative(ext)) if (isNative(ext))
@ -156,8 +162,6 @@ void Foam::MeshedSurface<Face>::write
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface() Foam::MeshedSurface<Face>::MeshedSurface()
:
ParentType(List<Face>(), pointField())
{} {}
@ -169,12 +173,9 @@ Foam::MeshedSurface<Face>::MeshedSurface
const xfer<surfGroupList>& patchLst const xfer<surfGroupList>& patchLst
) )
: :
ParentType(List<Face>(), pointField()), ParentType(pointLst, faceLst),
patches_(patchLst) patches_(patchLst)
{ {}
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
}
template<class Face> template<class Face>
@ -187,11 +188,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
const UList<word>& patchTypes const UList<word>& patchTypes
) )
: :
ParentType(List<Face>(), pointField()) ParentType(pointLst, faceLst)
{ {
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
surfGroupList newPatches(patchSizes.size()); surfGroupList newPatches(patchSizes.size());
label start = 0; label start = 0;
@ -221,17 +219,9 @@ Foam::MeshedSurface<Face>::MeshedSurface
const Map<word>& regionNames const Map<word>& regionNames
) )
: :
ParentType(List<Face>(), pointField()) ParentType(pointLst, faceLst)
{ {
storedPoints().transfer(pointLst()); if (&regionIds && regionIds.size() && regionIds.size() != size())
storedFaces().transfer(faceLst());
if
(
&regionIds
&& regionIds.size() != 0
&& regionIds.size() != nFaces()
)
{ {
FatalErrorIn FatalErrorIn
( (
@ -243,7 +233,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
" const Map<word>& regionNames\n" " const Map<word>& regionNames\n"
" )\n" " )\n"
) )
<< "size mismatch : regionIds.size() != nFaces()" << "size mismatch : region and face sizes"
<< exit(FatalError); << exit(FatalError);
} }
else else
@ -262,12 +252,9 @@ Foam::MeshedSurface<Face>::MeshedSurface
const HashTable<label>& nameToRegionMapping const HashTable<label>& nameToRegionMapping
) )
: :
ParentType(List<Face>(), pointField()) ParentType(pointLst, faceLst)
{ {
storedPoints().transfer(pointLst()); if (&regionIds && regionIds.size() && regionIds.size() != size())
storedFaces().transfer(faceLst());
if (regionIds.size() != nFaces())
{ {
FatalErrorIn FatalErrorIn
( (
@ -279,7 +266,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
" const HashTable<label>& nameToRegionMapping\n" " const HashTable<label>& nameToRegionMapping\n"
" )\n" " )\n"
) )
<< "size mismatch : regionIds.size() != nFaces()" << "size mismatch : region and face sizes"
<< exit(FatalError); << exit(FatalError);
} }
else else
@ -301,37 +288,34 @@ Foam::MeshedSurface<Face>::MeshedSurface
const polyBoundaryMesh& bMesh, const polyBoundaryMesh& bMesh,
const bool useGlobalPoints const bool useGlobalPoints
) )
:
ParentType(List<Face>(), pointField())
{ {
const polyMesh& mesh = bMesh.mesh(); const polyMesh& mesh = bMesh.mesh();
const polyPatchList& bPatches = bMesh; const polyPatchList& bPatches = bMesh;
const label nIntFaces = mesh.nInternalFaces();
// Get patch for all of outside // Get a single patch for all boundaries
primitivePatch allBoundary primitivePatch allBoundary
( (
SubList<Face> SubList<face>
( (
mesh.faces(), mesh.faces(),
mesh.nFaces() - nIntFaces, mesh.nFaces() - mesh.nInternalFaces(),
nIntFaces mesh.nInternalFaces()
), ),
mesh.points() mesh.points()
); );
if (useGlobalPoints) // use global/local points
{ const pointField& bPoints =
// copy in the global points and the global face addressing (
storedPoints() = mesh.points(); useGlobalPoints ? mesh.points() : allBoundary.localPoints()
storedFaces() = allBoundary; );
}
else // global or local face addressing
{ const List<Face>& bFaces =
// copy in the local points and the local face addressing (
storedPoints() = allBoundary.localPoints(); useGlobalPoints ? allBoundary : allBoundary.localFaces()
storedFaces() = allBoundary.localFaces(); );
}
// create patch list // create patch list
surfGroupList newPatches(bPatches.size()); surfGroupList newPatches(bPatches.size());
@ -352,7 +336,40 @@ Foam::MeshedSurface<Face>::MeshedSurface
startFaceI += p.size(); startFaceI += p.size();
} }
patches_.transfer(newPatches); // must create with the same face type as the polyBoundaryMesh
MeshedSurface<face> surf
(
xferCopy(bPoints),
xferCopy(bFaces),
xferMove(newPatches)
);
// must triangulate?
if (this->isTri())
{
surf.triangulate();
this->storedPoints().transfer(surf.storedPoints());
// transcribe from face -> triFace
List<face>& origFaces = surf.storedFaces();
List<triFace> newFaces(origFaces.size());
forAll(origFaces, faceI)
{
newFaces[faceI] = Face
(
static_cast<const UList<label>&>(origFaces[faceI])
);
}
origFaces.clear();
this->storedFaces().transfer(newFaces);
patches_.transfer(surf.patches_);
}
else
{
this->transfer(surf);
}
} }
@ -363,7 +380,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
const surfMesh& sMesh const surfMesh& sMesh
) )
: :
ParentType(List<Face>(sMesh.faces()), sMesh.points()) ParentType(xferCopy(sMesh.points()), xferCopy(sMesh.faces()))
{ {
const surfPatchList& sPatches = sMesh.boundaryMesh(); const surfPatchList& sPatches = sMesh.boundaryMesh();
@ -396,8 +413,6 @@ Foam::MeshedSurface<Face>::MeshedSurface
( (
const UnsortedMeshedSurface<Face>& surf const UnsortedMeshedSurface<Face>& surf
) )
:
ParentType(List<Face>(), surf.points())
{ {
labelList faceMap; labelList faceMap;
surfGroupList patchLst = surf.sortedRegions(faceMap); surfGroupList patchLst = surf.sortedRegions(faceMap);
@ -412,7 +427,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
newFaces[faceI] = origFaces[faceMap[faceI]]; newFaces[faceI] = origFaces[faceMap[faceI]];
} }
storedFaces().transfer(newFaces); reset(xferCopy(surf.points()), xferMove(newFaces));
} }
@ -422,29 +437,20 @@ Foam::MeshedSurface<Face>::MeshedSurface
const fileName& fName, const fileName& fName,
const word& ext const word& ext
) )
:
ParentType(List<Face>(), pointField())
{ {
read(fName, ext); read(fName, ext);
} }
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface Foam::MeshedSurface<Face>::MeshedSurface(const fileName& fName)
(
const fileName& fName
)
:
ParentType(List<Face>(), pointField())
{ {
read(fName, fName.ext()); read(fName);
} }
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface(Istream& is) Foam::MeshedSurface<Face>::MeshedSurface(Istream& is)
:
ParentType(List<Face>(), pointField())
{ {
read(is); read(is);
} }
@ -452,8 +458,6 @@ Foam::MeshedSurface<Face>::MeshedSurface(Istream& is)
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface(const Time& d) Foam::MeshedSurface<Face>::MeshedSurface(const Time& d)
:
ParentType(List<Face>(), pointField())
{ {
read(IFstream(findMeshName(d))()); read(IFstream(findMeshName(d))());
// setDefaultPatches(); // setDefaultPatches();
@ -463,7 +467,7 @@ Foam::MeshedSurface<Face>::MeshedSurface(const Time& d)
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf) Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
: :
ParentType(surf.faces(), surf.points()), ParentType(surf),
patches_(surf.patches_) patches_(surf.patches_)
{} {}
@ -473,8 +477,6 @@ Foam::MeshedSurface<Face>::MeshedSurface
( (
const xfer<UnsortedMeshedSurface<Face> >& surf const xfer<UnsortedMeshedSurface<Face> >& surf
) )
:
ParentType(List<Face>(), pointField())
{ {
transfer(surf()); transfer(surf());
} }
@ -482,8 +484,6 @@ Foam::MeshedSurface<Face>::MeshedSurface
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface(const xfer<MeshedSurface>& surf) Foam::MeshedSurface<Face>::MeshedSurface(const xfer<MeshedSurface>& surf)
:
ParentType(List<Face>(), pointField())
{ {
transfer(surf()); transfer(surf());
} }
@ -556,8 +556,8 @@ void Foam::MeshedSurface<Face>::checkPatches()
else if (patches_.size() == 1) else if (patches_.size() == 1)
{ {
// like onePatch, but preserve the name // like onePatch, but preserve the name
patches_[0].start() = 0;
patches_[0].size() = size(); patches_[0].size() = size();
patches_[0].start() = 0;
if (!patches_[0].name().size()) if (!patches_[0].name().size())
{ {
patches_[0].name() = "patch0"; patches_[0].name() = "patch0";
@ -577,7 +577,7 @@ void Foam::MeshedSurface<Face>::sortFacesByRegion
const Map<word>& regionNames const Map<word>& regionNames
) )
{ {
const List<Face>& unsortedFaces = faces(); const List<Face>& unsortedFaces = this->faces();
if (!&regionNames || !&regionIds || regionIds.size() == 0) if (!&regionNames || !&regionIds || regionIds.size() == 0)
{ {
@ -602,7 +602,7 @@ void Foam::MeshedSurface<Face>::sortFacesByRegion
} }
faceMap.clear(); faceMap.clear();
storedFaces().transfer(newFaces); this->storedFaces().transfer(newFaces);
} }
} }
@ -615,45 +615,11 @@ void Foam::MeshedSurface<Face>::sortFacesByRegion
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::clear() void Foam::MeshedSurface<Face>::clear()
{ {
ParentType::clearOut(); ParentType::clear();
storedPoints().clear();
storedFaces().clear();
patches_.clear(); patches_.clear();
} }
template<class Face>
void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(newPoints);
// Copy new points
storedPoints() = newPoints;
}
template<class Face>
void Foam::MeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
{
// avoid bad scaling
if (scaleFactor > 0 && scaleFactor != 1.0)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(pointField());
storedPoints() *= scaleFactor;
}
}
template<class Face> template<class Face>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
( (
@ -662,11 +628,11 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
labelList& faceMap labelList& faceMap
) const ) const
{ {
const pointField& locPoints = ParentType::localPoints(); const pointField& locPoints = this->localPoints();
const List<Face>& locFaces = ParentType::localFaces(); const List<Face>& locFaces = this->localFaces();
// Fill pointMap, faceMap // Fill pointMap, faceMap
ParentType::subsetMap(include, pointMap, faceMap); this->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());
@ -675,10 +641,9 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
{ {
newPoints[pointI] = locPoints[pointMap[pointI]]; newPoints[pointI] = locPoints[pointMap[pointI]];
oldToNew[pointMap[pointI]] = pointI; oldToNew[pointMap[pointI]] = pointI;
} }
// create a new patch list // create/copy a new patch list, each patch with zero size
surfGroupList newPatches(patches_); surfGroupList newPatches(patches_);
forAll(newPatches, patchI) forAll(newPatches, patchI)
{ {
@ -690,8 +655,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
forAll(faceMap, faceI) forAll(faceMap, faceI)
{ {
// Get old vertex labels const label origFaceI = faceMap[faceI];
label origFaceI = faceMap[faceI];
const Face& oldFace = locFaces[origFaceI]; const Face& oldFace = locFaces[origFaceI];
newFaces[faceI] = Face(oldFace); newFaces[faceI] = Face(oldFace);
@ -704,7 +668,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
} }
// adjust patch sizes // adjust patch sizes
forAllReverse (newPatches, patchI) forAllReverse(newPatches, patchI)
{ {
if if
( (
@ -717,7 +681,6 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
} }
} }
} }
oldToNew.clear(); oldToNew.clear();
// adjust patch start // adjust patch start
@ -729,14 +692,33 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
} }
// construct a sub-surface // construct a sub-surface
MeshedSurface subSurf return MeshedSurface
( (
xferMove(newPoints), xferMove(newPoints),
xferMove(newFaces), xferMove(newFaces),
xferMove(newPatches) xferMove(newPatches)
); );
}
return subSurf;
template<class Face>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
(
const UList<bool>& include
) const
{
labelList pointMap, faceMap;
return subsetMesh(include, pointMap, faceMap);
}
template<class Face>
void Foam::MeshedSurface<Face>::addPatches
(
const UList<surfGroup>& patchLst
)
{
patches_ = patchLst;
} }
@ -746,10 +728,7 @@ void Foam::MeshedSurface<Face>::transfer
MeshedSurface<Face>& surf MeshedSurface<Face>& surf
) )
{ {
clear(); reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
storedPoints().transfer(surf.storedPoints());
storedFaces().transfer(surf.storedFaces());
patches_.transfer(surf.patches_); patches_.transfer(surf.patches_);
surf.clear(); surf.clear();
@ -763,14 +742,9 @@ void Foam::MeshedSurface<Face>::transfer
) )
{ {
clear(); clear();
storedPoints().transfer(surf.storedPoints());
labelList faceMap; labelList faceMap;
surfGroupList patchLst = surf.sortedRegions(faceMap); surfGroupList patchLst = surf.sortedRegions(faceMap);
patches_.transfer(patchLst);
surf.regions_.clear();
surf.patches_.clear();
const List<Face>& oldFaces = surf.faces(); const List<Face>& oldFaces = surf.faces();
List<Face> newFaces(oldFaces.size()); List<Face> newFaces(oldFaces.size());
@ -780,33 +754,30 @@ void Foam::MeshedSurface<Face>::transfer
{ {
newFaces[faceI] = oldFaces[faceMap[faceI]]; newFaces[faceI] = oldFaces[faceMap[faceI]];
} }
faceMap.clear();
storedFaces().transfer(newFaces); reset(xferMove(surf.storedPoints()), xferMove(newFaces));
patches_.transfer(patchLst);
surf.regions_.clear();
surf.patches_.clear();
surf.clear(); surf.clear();
} }
// Read from file in given format // Read from file, determine format from extension
template<class Face> template<class Face>
bool Foam::MeshedSurface<Face>::read bool Foam::MeshedSurface<Face>::read(const fileName& fName)
(
const fileName& fName
)
{ {
clear(); word ext = fName.ext();
const word ext = fName.ext(); if (ext == "gz")
// handle 'native' format directly
if (isNative(ext))
{ {
return read(IFstream(fName)()); fileName unzipName = fName.lessExt();
return read(unzipName, unzipName.ext());
} }
else else
{ {
// use selector mechanism return read(fName, ext);
transfer(New(fName, ext)());
return true;
} }
} }
@ -819,8 +790,6 @@ bool Foam::MeshedSurface<Face>::read
const word& ext const word& ext
) )
{ {
clear();
// handle 'native' format directly // handle 'native' format directly
if (isNative(ext)) if (isNative(ext))
{ {
@ -841,17 +810,6 @@ void Foam::MeshedSurface<Face>::write(const Time& d) const
write(OFstream(findMeshName(d))()); write(OFstream(findMeshName(d))());
} }
template<class Face>
void Foam::MeshedSurface<Face>::writeStats(Ostream& os) const
{
// os << "Faces : " << size() << endl
// << "Edges : " << nEdges() << endl
// << "Vertices : " << nPoints() << endl
// << "Bounding Box : " << boundBox(localPoints(), false) << endl;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Face> template<class Face>
@ -859,8 +817,8 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
{ {
clear(); clear();
storedPoints() = surf.points(); this->storedPoints() = surf.points();
storedFaces() = surf.faces(); this->storedFaces() = surf.faces();
patches_ = surf.patches_; patches_ = surf.patches_;
} }

View File

@ -44,14 +44,9 @@ SourceFiles
#ifndef MeshedSurface_H #ifndef MeshedSurface_H
#define MeshedSurface_H #define MeshedSurface_H
#include "pointField.H" #include "PrimitiveMeshedSurface.H"
#include "PrimitivePatchExtra.H"
#include "boolList.H"
#include "surfGroupList.H" #include "surfGroupList.H"
#include "surfaceFormatsCore.H" #include "surfaceFormatsCore.H"
#include "xfer.H"
#include "face.H"
#include "triFace.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H" #include "memberFunctionSelectionTables.H"
@ -79,7 +74,7 @@ template<class Face>
template<class Face> template<class Face>
class MeshedSurface class MeshedSurface
: :
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point>, public PrimitiveMeshedSurface<Face>,
public fileFormats::surfaceFormatsCore public fileFormats::surfaceFormatsCore
{ {
friend class UnsortedMeshedSurface<Face>; friend class UnsortedMeshedSurface<Face>;
@ -87,14 +82,7 @@ class MeshedSurface
private: private:
//- Private typedefs for convenience //- Private typedefs for convenience
typedef PrimitivePatchExtra typedef PrimitiveMeshedSurface<Face> ParentType;
<
Face,
::Foam::List,
pointField,
point
>
ParentType;
// Private Member Data // Private Member Data
@ -116,22 +104,6 @@ private:
//- Read OpenFOAM Surface format //- Read OpenFOAM Surface format
bool read(Istream&); bool read(Istream&);
protected:
// Protected member functions
//- Return non-const access to global points
pointField& storedPoints()
{
return const_cast<pointField&>(ParentType::points());
}
//- Return non-const access to the faces
List<Face>& storedFaces()
{
return static_cast<List<Face> &>(*this);
}
public: public:
//- Runtime type information //- Runtime type information
@ -139,14 +111,14 @@ public:
// Static // Static
//- Only handles triangulated faces //- Can we read this file format?
inline static bool isTri(); static bool canRead(const fileName&, const bool verbose=false);
//- Can we read this file format? //- Can we read this file format?
static bool canRead(const word& ext, const bool verbose=false); static bool canReadType(const word& ext, const bool verbose=false);
//- Can we write this file format? //- Can we write this file format?
static bool canWrite(const word& ext, const bool verbose=false); static bool canWriteType(const word& ext, const bool verbose=false);
// Constructors // Constructors
@ -243,12 +215,6 @@ public:
// Selectors // Selectors
//- Select constructed from filename (implicit extension)
static autoPtr<MeshedSurface> New
(
const fileName&
);
//- Select constructed from filename (explicit extension) //- Select constructed from filename (explicit extension)
static autoPtr<MeshedSurface> New static autoPtr<MeshedSurface> New
( (
@ -256,6 +222,8 @@ public:
const word& ext const word& ext
); );
//- Select constructed from filename (implicit extension)
static autoPtr<MeshedSurface> New(const fileName&);
// Destructor // Destructor
@ -285,68 +253,41 @@ public:
// Access // Access
//- Return the number of points
label nPoints() const
{
return ParentType::points().size();
}
//- Return the number of faces
label nFaces() const
{
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 ParentType::size(); return ParentType::size();
} }
//- Return const access to global points
const pointField& points() const
{
return ParentType::points();
}
//- Return const access to the faces
const List<Face>& faces() const
{
return static_cast<const List<Face> &>(*this);
}
const List<surfGroup>& patches() const const List<surfGroup>& patches() const
{ {
return patches_; return patches_;
} }
void addPatches(const UList<surfGroup>&);
// Edit // Edit
//- Clear all storage //- Clear all storage
virtual void clear(); virtual void clear();
//- Move points //- Remove invalid faces
virtual void movePoints(const pointField&); void cleanup(const bool verbose);
//- Scale points. A non-positive factor is ignored //- Check/fix duplicate/degenerate faces
virtual void scalePoints(const scalar&); void checkFaces(const bool verbose);
//- Triangulate the surface, return the number of added faces.
// The patch list will be adjusted accordingly.
label triangulate();
//- Join the faces by removing duplicate points. //- Join the faces by removing duplicate points.
// Returns true if any points merged // Returns true if any points merged
bool stitchFaces(const scalar tol=SMALL, const bool verbose=false); bool stitchFaces(const scalar tol=SMALL, const bool verbose=false);
//- Check/fix duplicate/degenerate faces //- Triangulate the surface, return the number of added faces.
void checkFaces(const bool verbose); // The patch list will be adjusted accordingly.
virtual label triangulate();
//- Remove invalid faces
void cleanup(const bool verbose);
//- Return new surface. //- Return new surface.
// Returns pointMap, faceMap from subsetMeshMap // Returns return pointMap, faceMap from subsetMeshMap
MeshedSurface subsetMesh MeshedSurface subsetMesh
( (
const UList<bool>& include, const UList<bool>& include,
@ -354,6 +295,12 @@ public:
labelList& faceMap labelList& faceMap
) const; ) const;
//- Return new surface.
MeshedSurface subsetMesh
(
const UList<bool>& include
) const;
//- Transfer the contents of the argument and annull the argument //- Transfer the contents of the argument and annull the argument
void transfer(MeshedSurface<Face>&); void transfer(MeshedSurface<Face>&);
@ -366,7 +313,6 @@ public:
//- Read from file. Chooses reader based on explicit extension //- Read from file. Chooses reader based on explicit extension
bool read(const fileName&, const word& ext); bool read(const fileName&, const word& ext);
//- Read from file. Chooses reader based on detected extension //- Read from file. Chooses reader based on detected extension
virtual bool read(const fileName&); virtual bool read(const fileName&);
@ -385,9 +331,6 @@ public:
//- Write to database //- Write to database
void write(const Time&) const; void write(const Time&) const;
//- Write some statistics
void writeStats(Ostream&) const;
// Member operators // Member operators
@ -406,13 +349,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Specialization for holding triangulated information
template<>
inline bool MeshedSurface<triFace>::isTri()
{
return true;
}
//- Specialization for holding triangulated information //- Specialization for holding triangulated information
template<> template<>
inline label MeshedSurface<triFace>::triangulate() inline label MeshedSurface<triFace>::triangulate()

View File

@ -48,7 +48,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
const bool verbose const bool verbose
) )
{ {
pointField& pointLst = storedPoints(); pointField& pointLst = this->storedPoints();
// Merge points // Merge points
labelList pointMap(pointLst.size()); labelList pointMap(pointLst.size());
@ -70,7 +70,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
// Set the coordinates to the merged ones // Set the coordinates to the merged ones
pointLst.transfer(newPoints); pointLst.transfer(newPoints);
List<Face>& faceLst = storedFaces(); List<Face>& faceLst = this->storedFaces();
// 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();
@ -111,7 +111,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
} }
// adjust patch size // adjust patch size
p.size() = newFaceI - p.size(); p.size() = newFaceI - p.start();
} }
if (newFaceI != faceLst.size()) if (newFaceI != faceLst.size())
@ -139,9 +139,9 @@ template<class Face>
void Foam::MeshedSurface<Face>::checkFaces(const bool verbose) 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 = this->points().size() - 1;
List<Face>& faceLst = storedFaces(); List<Face>& faceLst = this->storedFaces();
// Phase 0: detect badly labelled faces // Phase 0: detect badly labelled faces
forAll(faceLst, faceI) forAll(faceLst, faceI)
@ -166,7 +166,7 @@ void Foam::MeshedSurface<Face>::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 = ParentType::faceFaces(); const labelListList& fFaces = this->faceFaces();
label oldFaceI = 0; label oldFaceI = 0;
label newFaceI = 0; label newFaceI = 0;
@ -271,7 +271,7 @@ template<class Face>
Foam::label Foam::MeshedSurface<Face>::triangulate() Foam::label Foam::MeshedSurface<Face>::triangulate()
{ {
label nTri = 0; label nTri = 0;
List<Face>& faceLst = storedFaces(); List<Face>& faceLst = this->storedFaces();
// determine how many triangles are needed // determine how many triangles are needed
forAll(faceLst, faceI) forAll(faceLst, faceI)

View File

@ -37,16 +37,6 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
{ {
clear(); clear();
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
List<surfGroup> patchLst(is); List<surfGroup> patchLst(is);
// copy and set the indices // copy and set the indices
@ -61,17 +51,45 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
} }
// read points: // read points:
is >> storedPoints(); is >> this->storedPoints();
// read faces: #if 1
// TODO - specialization to triangulate on-the-fly // must triangulate?
if (mustTriangulate) if (this->isTri())
{ {
is >> storedFaces(); List<face> faceLst(is);
MeshedSurface<face> surf;
surf.reset
(
xfer<pointField>::null(),
xferMove(faceLst)
);
surf.addPatches(patches_);
// this will break if the triangulation uses points
surf.triangulate();
patches_ = surf.patches();
// transcribe from face -> triFace (Face)
const List<face>& origFaces = surf.faces();
List<Face> newFaces(origFaces.size());
forAll(origFaces, faceI)
{
newFaces[faceI] = Face
(
static_cast<const UList<label>&>(origFaces[faceI])
);
}
surf.clear();
this->storedFaces().transfer(newFaces);
} }
else else
#endif
{ {
is >> storedFaces(); // read faces:
is >> this->storedFaces();
} }
return is.good(); return is.good();
@ -83,7 +101,7 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
{ {
// just emit some information until we get a nice IOobject // just emit some information until we get a nice IOobject
IOobject::writeBanner(os); IOobject::writeBanner(os);
os << "// OpenFOAM Surface format" << nl os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl << "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl << "// regions:" << nl
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl; << patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
@ -97,10 +115,10 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
IOobject::writeDivider(os); IOobject::writeDivider(os);
// Note: Write with global point numbering // Note: Write with global point numbering
os << "\n// points:" << nl << points() << nl; os << "\n// points:" << nl << this->points() << nl;
IOobject::writeDivider(os); IOobject::writeDivider(os);
os << "\n// faces:" << nl << faces() << nl; os << "\n// faces:" << nl << this->faces() << nl;
IOobject::writeDivider(os); IOobject::writeDivider(os);

View File

@ -52,6 +52,7 @@ Foam::MeshedSurface<Face>::New
return surf; return surf;
} }
template<class Face> template<class Face>
Foam::autoPtr<Foam::MeshedSurface<Face> > Foam::autoPtr<Foam::MeshedSurface<Face> >
Foam::MeshedSurface<Face>::New Foam::MeshedSurface<Face>::New
@ -59,14 +60,12 @@ Foam::MeshedSurface<Face>::New
const fileName& fName const fileName& fName
) )
{ {
if (debug) word ext = fName.ext();
if (ext == "gz")
{ {
Info<< "MeshedSurface::New(const fileName&) : " ext = fName.lessExt().ext();
"constructing MeshedSurface"
<< endl;
} }
return New(fName, ext);
return New(fName, fName.ext());
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -33,17 +33,14 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define makeMeshedSurface(faceType) \ #define makeSurface(surfType, faceType) \
defineNamedTemplateTypeNameAndDebug \ defineNamedTemplateTypeNameAndDebug(surfType<faceType>, 0); \
(MeshedSurface<faceType>, 0); \ defineTemplatedRunTimeSelectionTable(surfType,fileExtension,faceType); \
defineTemplatedRunTimeSelectionTable \ defineTemplatedMemberFunctionSelectionTable(surfType,write,fileExtension,faceType);
(MeshedSurface, fileExtension,faceType); \
defineTemplatedMemberFunctionSelectionTable \
(MeshedSurface, write,fileExtension,faceType);
makeMeshedSurface(face) makeSurface(MeshedSurface, face)
makeMeshedSurface(triFace) makeSurface(MeshedSurface, triFace)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "PrimitiveMeshedSurface.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face>
inline bool Foam::PrimitiveMeshedSurface<Face>::isTri()
{
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::PrimitiveMeshedSurface<Face>::PrimitiveMeshedSurface()
:
ParentType(List<Face>(), pointField())
{}
template<class Face>
Foam::PrimitiveMeshedSurface<Face>::PrimitiveMeshedSurface
(
const xfer<pointField>& pointLst,
const xfer<List<Face> >& faceLst
)
:
ParentType(List<Face>(), pointField())
{
reset(pointLst, faceLst);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Face>
Foam::PrimitiveMeshedSurface<Face>::~PrimitiveMeshedSurface()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Face>
void Foam::PrimitiveMeshedSurface<Face>::clear()
{
ParentType::clearOut();
storedPoints().clear();
storedFaces().clear();
}
template<class Face>
void Foam::PrimitiveMeshedSurface<Face>::movePoints(const pointField& newPoints)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(newPoints);
// Copy new points
storedPoints() = newPoints;
}
template<class Face>
void Foam::PrimitiveMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
{
// avoid bad scaling
if (scaleFactor > 0 && scaleFactor != 1.0)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(pointField());
storedPoints() *= scaleFactor;
}
}
template<class Face>
void Foam::PrimitiveMeshedSurface<Face>::reset
(
const xfer<pointField>& pointLst,
const xfer<List<Face> >& faceLst
)
{
ParentType::clearOut();
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (&pointLst)
{
storedPoints().transfer(pointLst());
}
if (&faceLst)
{
storedFaces().transfer(faceLst());
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,164 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::PrimitiveMeshedSurface
Description
Holds surfaces without any patch information
SourceFiles
PrimitiveMeshedSurface.C
\*---------------------------------------------------------------------------*/
#ifndef PrimitiveMeshedSurface_H
#define PrimitiveMeshedSurface_H
#include "PrimitivePatchExtra.H"
#include "pointField.H"
#include "xfer.H"
#include "face.H"
#include "triFace.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
/*---------------------------------------------------------------------------*\
Class PrimitiveMeshedSurface Declaration
\*---------------------------------------------------------------------------*/
template<class Face>
class PrimitiveMeshedSurface
:
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point>
{
//- Typedefs for convenience
typedef PrimitivePatchExtra
<
Face,
::Foam::List,
pointField,
point
>
ParentType;
protected:
// Protected Member Functions
//- Non-const access to global points
pointField& storedPoints()
{
return const_cast<pointField&>(ParentType::points());
}
//- Non-const access to the faces
List<Face>& storedFaces()
{
return static_cast<List<Face> &>(*this);
}
public:
// Static
//- Face storage only handles triangulated faces
inline static bool isTri();
// Constructors
//- Construct null
PrimitiveMeshedSurface();
//- Construct by transferring components (points, faces).
PrimitiveMeshedSurface
(
const xfer<pointField>&,
const xfer<List<Face> >&
);
// Destructor
virtual ~PrimitiveMeshedSurface();
// Member Functions
// Access
//- Return const access to the faces
inline const List<Face>& faces() const
{
return static_cast<const List<Face> &>(*this);
}
// Edit
//- Clear all storage
virtual void clear();
//- Move points
virtual void movePoints(const pointField&);
//- Scale points. A non-positive factor is ignored
virtual void scalePoints(const scalar&);
//- Transfer components (points, faces).
virtual void reset
(
const xfer<pointField>&,
const xfer<List<Face> >&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Specialization for holding triangulated information
template<>
inline bool PrimitiveMeshedSurface<triFace>::isTri()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PrimitiveMeshedSurface.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -40,36 +40,20 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face> template<class Face>
inline bool Foam::UnsortedMeshedSurface<Face>::isTri() bool Foam::UnsortedMeshedSurface<Face>::canReadType
{
return false;
}
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::canRead
( (
const word& ext, const word& ext,
const bool verbose const bool verbose
) )
{ {
// perhaps sent an entire name
word fExt(ext);
string::size_type dot = fExt.find_last_of(".");
if (dot != string::npos)
{
fExt = fExt.substr(dot+1);
}
// handle 'native' format directly // handle 'native' format directly
if (isNative(fExt)) if (isNative(ext))
{ {
return true; return true;
} }
typename fileExtensionConstructorTable::iterator cstrIter = typename fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(fExt); fileExtensionConstructorTablePtr_->find(ext);
// would be nice to have information about which format this actually is // would be nice to have information about which format this actually is
if (cstrIter == fileExtensionConstructorTablePtr_->end()) if (cstrIter == fileExtensionConstructorTablePtr_->end())
@ -81,7 +65,7 @@ bool Foam::UnsortedMeshedSurface<Face>::canRead
fileExtensionConstructorTablePtr_->toc() fileExtensionConstructorTablePtr_->toc()
); );
Info<<"Unknown file extension for reading: " << fExt << nl; Info<<"Unknown file extension for reading: " << ext << nl;
// compact output: // compact output:
Info<<"Valid types: ( " << nativeExt; Info<<"Valid types: ( " << nativeExt;
forAll(known, i) forAll(known, i)
@ -98,29 +82,20 @@ bool Foam::UnsortedMeshedSurface<Face>::canRead
template<class Face> template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::canWrite bool Foam::UnsortedMeshedSurface<Face>::canWriteType
( (
const word& ext, const word& ext,
const bool verbose const bool verbose
) )
{ {
// perhaps sent an entire name
word fExt(ext);
string::size_type dot = ext.find_last_of(".");
if (dot != string::npos)
{
fExt = ext.substr(dot+1);
}
// handle 'native' format directly // handle 'native' format directly
if (isNative(fExt)) if (isNative(ext))
{ {
return true; return true;
} }
typename writefileExtensionMemberFunctionTable::iterator mfIter = typename writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(fExt); writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end()) if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{ {
@ -131,7 +106,7 @@ bool Foam::UnsortedMeshedSurface<Face>::canWrite
writefileExtensionMemberFunctionTablePtr_->toc() writefileExtensionMemberFunctionTablePtr_->toc()
); );
Info<<"Unknown file extension for writing: " << fExt << nl; Info<<"Unknown file extension for writing: " << ext << nl;
// compact output: // compact output:
Info<<"Valid types: ( " << nativeExt; Info<<"Valid types: ( " << nativeExt;
forAll(known, i) forAll(known, i)
@ -148,6 +123,22 @@ bool Foam::UnsortedMeshedSurface<Face>::canWrite
} }
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::canRead
(
const fileName& fName,
const bool verbose
)
{
word ext = fName.ext();
if (ext == "gz")
{
ext = fName.lessExt().ext();
}
return canReadType(ext, verbose);
}
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::write void Foam::UnsortedMeshedSurface<Face>::write
( (
@ -194,8 +185,6 @@ void Foam::UnsortedMeshedSurface<Face>::write
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface() Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface()
:
ParentType(List<Face>(), pointField())
{} {}
@ -208,13 +197,10 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const xfer<surfPatchIdentifierList>& patchLst const xfer<surfPatchIdentifierList>& patchLst
) )
: :
ParentType(List<Face>(), pointField()), ParentType(pointLst, faceLst),
regions_(regionIds), regions_(regionIds),
patches_(patchLst) patches_(patchLst)
{ {}
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
}
template<class Face> template<class Face>
@ -226,12 +212,9 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const Map<word>& regionNames const Map<word>& regionNames
) )
: :
ParentType(List<Face>(), pointField()), ParentType(pointLst, faceLst),
regions_(regionIds) regions_(regionIds)
{ {
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
if (&regionNames) if (&regionNames)
{ {
// set patch names from (id => name) mapping // set patch names from (id => name) mapping
@ -254,12 +237,9 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const HashTable<label>& labelToRegion const HashTable<label>& labelToRegion
) )
: :
ParentType(List<Face>(), pointField()), ParentType(pointLst, faceLst),
regions_(regionIds) regions_(regionIds)
{ {
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
// set patch names from (name => id) mapping // set patch names from (name => id) mapping
setPatches(labelToRegion); setPatches(labelToRegion);
} }
@ -272,126 +252,50 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const xfer<List<Face> >& faceLst const xfer<List<Face> >& faceLst
) )
: :
ParentType(List<Face>(), pointField()), ParentType(pointLst, faceLst)
regions_(faceLst().size(), 0), // single default patch
patches_()
{ {
storedPoints().transfer(pointLst()); onePatch();
storedFaces().transfer(faceLst());
setPatches(0);
} }
#if 0
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
( (
const polyBoundaryMesh& bMesh, const polyBoundaryMesh& bMesh,
const bool useGlobalPoints const bool useGlobalPoints
) )
:
ParentType(List<Face>(), pointField())
{ {
const polyMesh& mesh = bMesh.mesh(); // creating via MeshedSurface is the easiest
const polyPatchList& bPatches = bMesh; MeshedSurface<Face> surf(bMesh, useGlobalPoints);
const label nIntFaces = mesh.nInternalFaces(); transfer(surf);
List<PatchRegionType> newPatches(bPatches.size());
// Get patch for all of outside
primitivePatch allBoundary
(
SubList<Face>
(
mesh.faces(),
mesh.nFaces() - nIntFaces,
nIntFaces
),
mesh.points()
);
List<Face> newFaces(allBoundary.size());
List<label> newRegions(allBoundary.size());
if (useGlobalPoints)
{
// copy in the global points
storedPoints() = mesh.points();
}
else
{
// copy in the local points
storedPoints() = allBoundary.localPoints();
}
// global or local face addressing
const List<Face>& bfaces =
(
useGlobalPoints
? allBoundary
: allBoundary.localFaces()
);
label faceIndex = 0;
forAll(bPatches, patchI)
{
const polyPatch& p = bPatches[patchI];
newPatches[patchI] = PatchRegionType
(
bPatches[patchI].name(),
patchI
);
forAll(p, patchFaceI)
{
newFaces[faceIndex] = bfaces[faceIndex];
newRegions[faceIndex] = patchI;
faceIndex++;
}
}
storedFaces().transfer(newFaces);
regions_.transfer(newRegions);
patches_.transfer(newPatches);
} }
#endif
#if 0
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
( (
const MeshedSurface<Face>& surf const MeshedSurface<Face>& surf
) )
: :
ParentType(List<Face>(), surf.points()) ParentType(xferCopy(surf.points()), xferCopy(surf.faces()))
{ {
const List<Face>& origFaces = surf.faces();
const surfGroupList& patchLst = surf.patches(); const surfGroupList& patchLst = surf.patches();
List<Face> newFaces(origFaces.size()); regions_.setSize(size());
List<label> newRegions(origFaces.size()); patches_.setSize(patchLst.size());
List<PatchRegionType> newPatches(patchLst.size());
label faceIndex = 0; label faceI = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
newPatches[patchI] = patchLst[patchI]; patches_[patchI] = patchLst[patchI];
forAll(patchLst[patchI], patchFaceI) forAll(patchLst[patchI], patchFaceI)
{ {
newFaces[faceIndex] = origFaces[faceIndex]; regions_[faceI++] = patchI;
newRegions[faceIndex] = patchI;
faceIndex++;
} }
} }
storedFaces().transfer(newFaces);
regions_.transfer(newRegions);
patches_.transfer(newPatches);
} }
#endif
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
@ -399,32 +303,20 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const fileName& fName, const fileName& fName,
const word& ext const word& ext
) )
:
ParentType(List<Face>(), pointField())
{ {
read(fName, ext); read(fName, ext);
} }
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const fileName& fName)
(
const fileName& fName
)
:
ParentType(List<Face>(), pointField())
{ {
read(fName, fName.ext()); read(fName);
} }
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(Istream& is)
(
Istream& is
)
:
ParentType(List<Face>(), pointField())
{ {
read(is); read(is);
} }
@ -432,8 +324,6 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const Time& d) Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const Time& d)
:
ParentType(List<Face>(), pointField())
{ {
read(IFstream(findMeshName(d))()); read(IFstream(findMeshName(d))());
} }
@ -445,7 +335,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const UnsortedMeshedSurface<Face>& surf const UnsortedMeshedSurface<Face>& surf
) )
: :
ParentType(surf.faces(), surf.points()), ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
regions_(surf.regions_), regions_(surf.regions_),
patches_(surf.patches_) patches_(surf.patches_)
{} {}
@ -456,28 +346,19 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
( (
const xfer<UnsortedMeshedSurface<Face> >& surf const xfer<UnsortedMeshedSurface<Face> >& surf
) )
:
ParentType(List<Face>(), pointField()),
regions_(),
patches_()
{ {
transfer(surf()); transfer(surf());
} }
#if 0
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
( (
const xfer<MeshedSurface<Face> >& surf const xfer<MeshedSurface<Face> >& surf
) )
:
ParentType(List<Face>(), pointField()),
regions_(),
patches_()
{ {
transfer(surf()); transfer(surf());
} }
#endif
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -489,6 +370,18 @@ Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::onePatch()
{
regions_.setSize(size());
regions_ = 0;
// set single default patch
patches_.setSize(1);
patches_[0] = PatchRegionType("patch0", 0);
}
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setPatches(const label maxPatch) void Foam::UnsortedMeshedSurface<Face>::setPatches(const label maxPatch)
{ {
@ -604,17 +497,15 @@ template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s) void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
{ {
ParentType::setSize(s); ParentType::setSize(s);
regions_.setSize(s); // if regions extend: set with last patchId
regions_.setSize(s, patches_.size() - 1);
} }
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::clear() void Foam::UnsortedMeshedSurface<Face>::clear()
{ {
ParentType::clearOut(); ParentType::clear();
storedPoints().clear();
storedFaces().clear();
regions_.clear(); regions_.clear();
patches_.clear(); patches_.clear();
} }
@ -637,37 +528,6 @@ Foam::surfGroupList Foam::UnsortedMeshedSurface<Face>::sortedRegions
} }
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::movePoints(const pointField& newPoints)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(newPoints);
// Copy new points
storedPoints() = newPoints;
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
{
// avoid bad scaling
if (scaleFactor > 0 && scaleFactor != 1.0)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(pointField());
storedPoints() *= scaleFactor;
}
}
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
( (
@ -676,15 +536,15 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
labelList& faceMap labelList& faceMap
) const ) const
{ {
const pointField& locPoints = ParentType::localPoints(); const pointField& locPoints = this->localPoints();
const List<Face>& locFaces = ParentType::localFaces(); const List<Face>& locFaces = this->localFaces();
// Fill pointMap, faceMap // Fill pointMap, faceMap
ParentType::subsetMap(include, pointMap, faceMap); this->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());
labelList oldToNew(locPoints.size()); labelList oldToNew(locPoints.size());
forAll(pointMap, pointI) forAll(pointMap, pointI)
{ {
newPoints[pointI] = locPoints[pointMap[pointI]]; newPoints[pointI] = locPoints[pointMap[pointI]];
@ -692,12 +552,13 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
} }
// Renumber face node labels and compact // Renumber face node labels and compact
List<Face> newFaces(faceMap.size()); List<Face> newFaces(faceMap.size());
List<label> newRegions(faceMap.size());
forAll(faceMap, faceI) forAll(faceMap, faceI)
{ {
// Get old vertex labels const label origFaceI = faceMap[faceI];
const Face& oldFace = locFaces[faceMap[faceI]]; const Face& oldFace = locFaces[origFaceI];
newFaces[faceI] = Face(oldFace); newFaces[faceI] = Face(oldFace);
@ -707,17 +568,47 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
{ {
f[fp] = oldToNew[oldFace[fp]]; f[fp] = oldToNew[oldFace[fp]];
} }
newRegions[faceI] = regions_[origFaceI];
} }
oldToNew.clear();
// construct a sub-surface // construct a sub-surface
UnsortedMeshedSurface<Face> subSurf; return UnsortedMeshedSurface
( (
xferMove(newPoints), xferMove(newPoints),
xferMove(newFaces), xferMove(newFaces),
xferMove(newRegions),
xferCopy(patches_) xferCopy(patches_)
); );
}
return subSurf;
template<class Face>
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
(
const UList<bool>& include
) const
{
labelList pointMap, faceMap;
return subsetMesh(include, pointMap, faceMap);
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::reset
(
const xfer<pointField>& pointLst,
const xfer<List<Face> >& faceLst,
const xfer<List<label> >& regionIds
)
{
ParentType::reset(pointLst, faceLst);
if (&regionIds)
{
regions_.transfer(regionIds());
}
} }
@ -727,30 +618,28 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
UnsortedMeshedSurface<Face>& surf UnsortedMeshedSurface<Face>& surf
) )
{ {
clear(); reset
(
storedPoints().transfer(surf.storedPoints()); xferMove(surf.storedPoints()),
storedFaces().transfer(surf.storedFaces()); xferMove(surf.storedFaces()),
regions_.transfer(surf.regions_); xferMove(surf.regions_)
);
patches_.transfer(surf.patches_); patches_.transfer(surf.patches_);
surf.clear(); surf.clear();
} }
#if 0
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::transfer void Foam::UnsortedMeshedSurface<Face>::transfer
( (
MeshedSurface<Face>& surf MeshedSurface<Face>& surf
) )
{ {
surfGroupList& patchLst = surf.patches(); surfGroupList& patchLst = surf.patches_;
clear(); reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
storedPoints().transfer(surf.storedPoints());
storedFaces().transfer(surf.storedFaces());
regions_.setSize(size()); regions_.setSize(size());
patches_.setSize(patchLst.size()); patches_.setSize(patchLst.size());
@ -769,29 +658,21 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
patchLst.clear(); patchLst.clear();
surf.clear(); surf.clear();
} }
#endif
// Read from file in given format // Read from file, determine format from extension
template<class Face> template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::read bool Foam::UnsortedMeshedSurface<Face>::read(const fileName& fName)
(
const fileName& fName
)
{ {
clear(); word ext = fName.ext();
const word ext = fName.ext(); if (ext == "gz")
// handle 'native' format directly
if (isNative(ext))
{ {
return read(IFstream(fName)()); fileName unzipName = fName.lessExt();
return read(unzipName, unzipName.ext());
} }
else else
{ {
// use selector mechanism return read(fName, ext);
transfer(New(fName, ext)());
return true;
} }
} }
@ -804,8 +685,6 @@ bool Foam::UnsortedMeshedSurface<Face>::read
const word& ext const word& ext
) )
{ {
clear();
// handle 'native' format directly // handle 'native' format directly
if (isNative(ext)) if (isNative(ext))
{ {
@ -827,16 +706,6 @@ void Foam::UnsortedMeshedSurface<Face>::write(const Time& d) const
} }
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::writeStats(Ostream& os) const
{
// os << "Faces : " << size() << endl
// << "Edges : " << nEdges() << endl
// << "Vertices : " << nPoints() << endl
// << "Bounding Box : " << boundBox(localPoints(), false) << endl;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Face> template<class Face>
@ -846,8 +715,9 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
) )
{ {
clear(); clear();
storedPoints() = surf.points();
storedFaces() = surf.faces(); this->storedPoints() = surf.points();
this->storedFaces() = surf.faces();
regions_ = surf.regions_; regions_ = surf.regions_;
patches_ = surf.patches_; patches_ = surf.patches_;
} }

View File

@ -47,15 +47,10 @@ SourceFiles
#ifndef UnsortedMeshedSurface_H #ifndef UnsortedMeshedSurface_H
#define UnsortedMeshedSurface_H #define UnsortedMeshedSurface_H
#include "pointField.H" #include "PrimitiveMeshedSurface.H"
#include "PrimitivePatchExtra.H"
#include "boolList.H"
#include "surfPatchIdentifierList.H" #include "surfPatchIdentifierList.H"
#include "surfGroupList.H" #include "surfGroupList.H"
#include "surfaceFormatsCore.H" #include "surfaceFormatsCore.H"
#include "xfer.H"
#include "face.H"
#include "triFace.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H" #include "memberFunctionSelectionTables.H"
@ -84,22 +79,15 @@ template<class Face>
template<class Face> template<class Face>
class UnsortedMeshedSurface class UnsortedMeshedSurface
: :
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point>, public PrimitiveMeshedSurface<Face>,
public fileFormats::surfaceFormatsCore public fileFormats::surfaceFormatsCore
{ {
friend class MeshedSurface<Face>; friend class MeshedSurface<Face>;
private: private:
//- Private typedefs for convenience //- Typedefs for convenience
typedef PrimitivePatchExtra typedef PrimitiveMeshedSurface<Face> ParentType;
<
Face,
::Foam::List,
pointField,
point
>
ParentType;
//- Typedef for type holding the region (patch) informationm //- Typedef for type holding the region (patch) informationm
typedef surfPatchIdentifier PatchRegionType; typedef surfPatchIdentifier PatchRegionType;
@ -125,6 +113,9 @@ protected:
// Protected Member functions // Protected Member functions
//- Set a single patch
void onePatch();
//- Sets default patch names based on the maximum patch number //- Sets default patch names based on the maximum patch number
void setPatches(const label maxPatch); void setPatches(const label maxPatch);
@ -141,19 +132,6 @@ protected:
//- Sets patch names from hashed values (name -> id) //- Sets patch names from hashed values (name -> id)
void setPatches(const HashTable<label>& groupToPatch); void setPatches(const HashTable<label>& groupToPatch);
//- Return non-const access to global points
pointField& storedPoints()
{
return const_cast<pointField&>(ParentType::points());
}
//- Return non-const access to the faces
List<Face>& storedFaces()
{
return static_cast<List<Face> &>(*this);
}
//- Return non-const access to the faces //- Return non-const access to the faces
List<label>& storedRegions() List<label>& storedRegions()
{ {
@ -167,14 +145,14 @@ public:
// Static // Static
//- Only handles triangulated faces //- Can we read this file format?
inline static bool isTri(); static bool canReadType(const word& ext, const bool verbose=false);
//- Can we read this file format? //- Can we read this file format?
static bool canRead(const word& ext, const bool verbose=false); static bool canRead(const fileName&, const bool verbose=false);
//- Can we write this file format? //- Can we write this file format?
static bool canWrite(const word& ext, const bool verbose=false); static bool canWriteType(const word& ext, const bool verbose=false);
// Constructors // Constructors
@ -219,14 +197,12 @@ public:
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
UnsortedMeshedSurface UnsortedMeshedSurface
( (
const polyBoundaryMesh&, const polyBoundaryMesh&,
const bool globalPoints=false const bool globalPoints=false
); );
#endif
//- Construct from a meshedSurface //- Construct from a meshedSurface
UnsortedMeshedSurface(const MeshedSurface<Face>&); UnsortedMeshedSurface(const MeshedSurface<Face>&);
@ -267,12 +243,6 @@ public:
// Selectors // Selectors
//- Select constructed from filename (implicit extension)
static autoPtr<UnsortedMeshedSurface> New
(
const fileName&
);
//- Select constructed from filename (explicit extension) //- Select constructed from filename (explicit extension)
static autoPtr<UnsortedMeshedSurface> New static autoPtr<UnsortedMeshedSurface> New
( (
@ -280,6 +250,9 @@ public:
const word& ext const word& ext
); );
//- Select constructed from filename (implicit extension)
static autoPtr<UnsortedMeshedSurface> New(const fileName&);
// Destructor // Destructor
virtual ~UnsortedMeshedSurface(); virtual ~UnsortedMeshedSurface();
@ -308,18 +281,6 @@ public:
// Access // Access
//- Return the number of points
label nPoints() const
{
return ParentType::points().size();
}
//- Return the number of faces
label nFaces() const
{
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
{ {
@ -329,18 +290,6 @@ public:
//- Reset size of face and region list //- Reset size of face and region list
void setSize(const label); void setSize(const label);
//- Return const access to global points
const pointField& points() const
{
return ParentType::points();
}
//- Return const access to the faces
const List<Face>& faces() const
{
return static_cast<const List<Face> &>(*this);
}
//- Return const access to the regions //- Return const access to the regions
const List<label>& regions() const const List<label>& regions() const
{ {
@ -357,17 +306,12 @@ public:
// Returns patch list and sets faceMap to index within faces() // Returns patch list and sets faceMap to index within faces()
List<surfGroup> sortedRegions(labelList& faceMap) const; List<surfGroup> sortedRegions(labelList& faceMap) const;
// Edit // Edit
//- Clear all storage //- Clear all storage
virtual void clear(); virtual void clear();
//- Move points
virtual void movePoints(const pointField&);
//- Scale points. A non-positive factor is ignored
virtual void scalePoints(const scalar&);
//- Remove invalid faces //- Remove invalid faces
void cleanup(const bool verbose); void cleanup(const bool verbose);
@ -379,10 +323,10 @@ public:
bool stitchFaces(const scalar tol=SMALL, const bool verbose=false); bool stitchFaces(const scalar tol=SMALL, const bool verbose=false);
//- Triangulate the surface, return the number of added faces. //- Triangulate the surface, return the number of added faces.
label triangulate(); virtual label triangulate();
//- Return new surface. Returns pointMap, faceMap from //- Return new surface.
// subsetMeshMap // Returns return pointMap, faceMap from subsetMeshMap
UnsortedMeshedSurface subsetMesh UnsortedMeshedSurface subsetMesh
( (
const UList<bool>& include, const UList<bool>& include,
@ -390,12 +334,27 @@ public:
labelList& faceMap labelList& faceMap
) const; ) const;
//- Return new surface.
UnsortedMeshedSurface subsetMesh
(
const UList<bool>& include
) const;
//- Transfer components (points, faces, region ids).
virtual void reset
(
const xfer<pointField>&,
const xfer<List<Face> >&,
const xfer<List<label> >& regionIds = xfer<List<label> >::null()
);
//- Transfer the contents of the argument and annull the argument //- Transfer the contents of the argument and annull the argument
void transfer(UnsortedMeshedSurface<Face>&); 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<Face>&); void transfer(MeshedSurface<Face>&);
// Read // Read
//- Read from file. Chooses reader based on explicit extension //- Read from file. Chooses reader based on explicit extension
@ -404,6 +363,7 @@ public:
//- Read from file. Chooses reader based on detected extension //- Read from file. Chooses reader based on detected extension
virtual bool read(const fileName&); virtual bool read(const fileName&);
// Write // Write
//- Write to Ostream in simple FOAM format //- Write to Ostream in simple FOAM format
@ -418,9 +378,6 @@ public:
//- Write to database //- Write to database
void write(const Time&) const; void write(const Time&) const;
//- Write some statistics
void writeStats(Ostream&) const;
// Member operators // Member operators
@ -441,13 +398,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Specialization for holding triangulated information
template<>
inline bool UnsortedMeshedSurface<triFace>::isTri()
{
return true;
}
//- Specialization for holding triangulated information //- Specialization for holding triangulated information
template<> template<>
inline label UnsortedMeshedSurface<triFace>::triangulate() inline label UnsortedMeshedSurface<triFace>::triangulate()

View File

@ -48,7 +48,7 @@ bool Foam::UnsortedMeshedSurface<Face>::stitchFaces
const bool verbose const bool verbose
) )
{ {
pointField& pointLst = storedPoints(); pointField& pointLst = this->storedPoints();
// Merge points // Merge points
labelList pointMap(pointLst.size()); labelList pointMap(pointLst.size());
@ -70,7 +70,7 @@ bool Foam::UnsortedMeshedSurface<Face>::stitchFaces
// Set the coordinates to the merged ones // Set the coordinates to the merged ones
pointLst.transfer(newPoints); pointLst.transfer(newPoints);
List<Face>& faceLst = storedFaces(); List<Face>& faceLst = this->storedFaces();
// Reset the point labels to the unique points array // Reset the point labels to the unique points array
label newFaceI = 0; label newFaceI = 0;
@ -123,9 +123,9 @@ template<class Face>
void Foam::UnsortedMeshedSurface<Face>::checkFaces(const bool verbose) 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 = this->points().size() - 1;
List<Face>& faceLst = storedFaces(); List<Face>& faceLst = this->storedFaces();
// Phase 0: detect badly labelled faces // Phase 0: detect badly labelled faces
forAll(faceLst, faceI) forAll(faceLst, faceI)
@ -242,7 +242,7 @@ template<class Face>
Foam::label Foam::UnsortedMeshedSurface<Face>::triangulate() Foam::label Foam::UnsortedMeshedSurface<Face>::triangulate()
{ {
label nTri = 0; label nTri = 0;
List<Face>& faceLst = storedFaces(); List<Face>& faceLst = this->storedFaces();
// determine how many triangles are needed // determine how many triangles are needed
forAll(faceLst, faceI) forAll(faceLst, faceI)

View File

@ -35,53 +35,9 @@ License
template<class Face> template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::read(Istream& is) bool Foam::UnsortedMeshedSurface<Face>::read(Istream& is)
{ {
clear(); MeshedSurface<Face> surf(is);
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
List<surfGroup> patchLst(is);
// read points:
is >> storedPoints();
// read faces:
// TODO - specialization to triangulate on-the-fly
if (mustTriangulate)
{
is >> storedFaces();
}
else
{
is >> storedFaces();
}
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;
}
}
transfer(surf);
return is.good(); return is.good();
} }
@ -90,13 +46,14 @@ bool Foam::UnsortedMeshedSurface<Face>::read(Istream& is)
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
{ {
const List<Face>& faceLst = faces(); const List<Face>& faceLst = this->faces();
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = sortedRegions(faceMap); List<surfGroup> patchLst = sortedRegions(faceMap);
// just emit some information until we get a nice IOobject // just emit some information until we get a nice IOobject
IOobject::writeBanner(os); IOobject::writeBanner(os);
os << "// OpenFOAM Surface format" << nl os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl << "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl << "// regions:" << nl
<< patchLst.size() << nl << token::BEGIN_LIST << incrIndent << nl; << patchLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
@ -110,13 +67,13 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
IOobject::writeDivider(os); IOobject::writeDivider(os);
// Note: Write with global point numbering // Note: Write with global point numbering
os << "\n// points:" << nl << points() << nl; os << "\n// points:" << nl << this->points() << nl;
IOobject::writeDivider(os); IOobject::writeDivider(os);
os << "\n// faces:" << nl; os << "\n// faces:" << nl;
os << faceLst.size() << nl << token::BEGIN_LIST << nl; os << faceLst.size() << nl << token::BEGIN_LIST << nl;
label faceIndex = 0; label faceI = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
@ -124,9 +81,7 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
forAll(patch, patchFaceI) forAll(patch, patchFaceI)
{ {
const face& f = faceLst[faceMap[faceIndex++]]; os << faceLst[faceMap[faceI++]] << nl;
os << f << nl;
} }
} }
os << token::END_LIST << nl; os << token::END_LIST << nl;
@ -134,7 +89,7 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
IOobject::writeDivider(os); IOobject::writeDivider(os);
// Check state of Ostream // Check state of Ostream
os.check("meshedSurface::write(Ostream&)"); os.check("UnsortedMeshedSurface::write(Ostream&)");
} }
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //

View File

@ -75,24 +75,12 @@ Foam::UnsortedMeshedSurface<Face>::New
const fileName& fName const fileName& fName
) )
{ {
const word ext = fName.ext(); word ext = fName.ext();
if (ext == "gz")
if (debug)
{ {
Info<< "UnsortedMeshedSurface<Face>::New" ext = fName.lessExt().ext();
"(const fileName&) : "
"constructing UnsortedMeshedSurface"
<< endl;
} }
// TODO:
// if (ext == "gz")
// {
// fileName unzipName = fName.lessExt();
//
// return New(unzipName, unzipName.ext(), ext);
// }
return New(fName, ext); return New(fName, ext);
} }

View File

@ -33,17 +33,14 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define makeUnsortedMeshedSurface(faceType) \ #define makeSurface(surfType, faceType) \
defineNamedTemplateTypeNameAndDebug \ defineNamedTemplateTypeNameAndDebug(surfType<faceType>, 0); \
(UnsortedMeshedSurface<faceType>, 0); \ defineTemplatedRunTimeSelectionTable(surfType,fileExtension,faceType); \
defineTemplatedRunTimeSelectionTable \ defineTemplatedMemberFunctionSelectionTable(surfType,write,fileExtension,faceType);
(UnsortedMeshedSurface, fileExtension,faceType); \
defineTemplatedMemberFunctionSelectionTable \
(UnsortedMeshedSurface, write,fileExtension,faceType);
makeUnsortedMeshedSurface(face) makeSurface(UnsortedMeshedSurface, face)
makeUnsortedMeshedSurface(triFace) makeSurface(UnsortedMeshedSurface, triFace)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -43,8 +43,6 @@ Foam::fileFormats::AC3DsurfaceFormat<Face>::AC3DsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -57,8 +55,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); const bool mustTriangulate = this->isTri();
const bool mustTriangulate = ParentType::isTri(); this->clear();
IFstream is(fName); IFstream is(fName);
if (!is.good()) if (!is.good())
@ -280,12 +278,12 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
} }
// transfer to normal lists // transfer to normal lists
ParentType::storedPoints().transfer(pointLst); this->storedPoints().transfer(pointLst);
ParentType::storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst); this->storedRegions().transfer(regionLst);
ParentType::setPatches(regionNames); this->setPatches(regionNames);
ParentType::stitchFaces(SMALL); this->stitchFaces(SMALL);
return true; return true;
} }
@ -316,30 +314,26 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
forAll(p, patchFaceI) forAll(p, patchFaceI)
{ {
const label faceI = faceMap[faceIndex++]; const label faceI = faceMap[faceIndex++];
include[faceI] = true; include[faceI] = true;
} }
labelList pMap; UnsortedMeshedSurface<Face> subm = surf.subsetMesh(include);
labelList fMap;
ParentType patch = surf.subsetMesh(include, pMap, fMap); // Now we have isolated surface for this patch alone. Write it.
os << "numvert " << subm.nPoints() << endl;
// Now we have triSurface for this patch alone. Write it. forAll(subm.localPoints(), ptI)
os << "numvert " << patch.nPoints() << endl;
forAll(patch.localPoints(), ptI)
{ {
const point& pt = patch.localPoints()[ptI]; const point& pt = subm.localPoints()[ptI];
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
} }
os << "numsurf " << patch.localFaces().size() << endl; os << "numsurf " << subm.localFaces().size() << endl;
forAll(patch.localFaces(), faceI) forAll(subm.localFaces(), faceI)
{ {
const Face& f = patch.localFaces()[faceI]; const Face& f = subm.localFaces()[faceI];
os << "SURF 0x20" << nl // polygon os << "SURF 0x20" << nl // polygon
<< "mat " << patchI << nl << "mat " << patchI << nl

View File

@ -67,9 +67,6 @@ class AC3DsurfaceFormat
public UnsortedMeshedSurface<Face>, public UnsortedMeshedSurface<Face>,
public AC3DsurfaceFormatCore public AC3DsurfaceFormatCore
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View File

@ -37,8 +37,6 @@ Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -52,7 +50,7 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); this->clear();
IFstream is(fName); IFstream is(fName);
if (!is.good()) if (!is.good())
@ -66,10 +64,9 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
} }
List<ftrPatch> readPatches(is); List<ftrPatch> readPatches(is);
List<point> pointLst(is);
// transfer to normal list // read points directly
ParentType::storedPoints().transfer(pointLst); is >> this->storedPoints();
// read faces with keys // read faces with keys
List<Keyed<triFace> > readFaces(is); List<Keyed<triFace> > readFaces(is);
@ -85,8 +82,8 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
regionLst[faceI] = readFaces[faceI].key(); regionLst[faceI] = readFaces[faceI].key();
} }
ParentType::storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst); this->storedRegions().transfer(regionLst);
Map<word> regionNames; Map<word> regionNames;
forAll(readPatches, patchI) forAll(readPatches, patchI)
@ -94,7 +91,7 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
regionNames.insert(patchI, readPatches[patchI].name()); regionNames.insert(patchI, readPatches[patchI].name());
} }
ParentType::setPatches(regionNames, readPatches.size() - 1); this->setPatches(regionNames, readPatches.size() - 1);
return true; return true;
} }

View File

@ -56,8 +56,30 @@ class FTRsurfaceFormat
: :
public UnsortedMeshedSurface<Face> public UnsortedMeshedSurface<Face>
{ {
//- Private typedefs for convenience // Private classes
typedef UnsortedMeshedSurface<Face> ParentType;
//- read compatibility for ftr patch definitions
class ftrPatch
{
//- Name of patch
word name_;
//- Type of patch (ignored since it is usually "empty")
word type_;
public:
const word& name() const
{
return name_;
}
friend Istream& operator>>(Istream& is, ftrPatch& p)
{
is >> p.name_ >> p.type_;
return is;
}
};
// Private Member Functions // Private Member Functions
@ -67,30 +89,6 @@ class FTRsurfaceFormat
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const FTRsurfaceFormat<Face>&); void operator=(const FTRsurfaceFormat<Face>&);
//- read compatibility for ftr patch definitions
class ftrPatch
{
//- Name of patch
word name_;
//- Type of patch (ignored since it is usually "empty")
word type_;
public:
const word& name() const
{
return name_;
}
friend Istream& operator>>(Istream& is, ftrPatch& p)
{
is >> p.name_ >> p.type_;
return is;
}
};
public: public:
// Constructors // Constructors

View File

@ -40,8 +40,6 @@ Foam::fileFormats::GTSsurfaceFormat<Face>::GTSsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -55,7 +53,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); this->clear();
IFstream is(fName); IFstream is(fName);
if (!is.good()) if (!is.good())
@ -69,7 +67,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
} }
// Read header // Read header
string line = ParentType::getLineNoComment(is); string line = this->getLineNoComment(is);
label nPoints, nEdges, nElems; label nPoints, nEdges, nElems;
{ {
@ -82,9 +80,9 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
// write directly into the lists: // write directly into the lists:
pointField& pointLst = ParentType::storedPoints(); pointField& pointLst = this->storedPoints();
List<Face>& faceLst = ParentType::storedFaces(); List<Face>& faceLst = this->storedFaces();
List<label>& regionLst = ParentType::storedRegions(); List<label>& regionLst = this->storedRegions();
pointLst.setSize(nPoints); pointLst.setSize(nPoints);
faceLst.setSize(nElems); faceLst.setSize(nElems);
@ -94,7 +92,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
forAll(pointLst, pointI) forAll(pointLst, pointI)
{ {
scalar x, y, z; scalar x, y, z;
line = ParentType::getLineNoComment(is); line = this->getLineNoComment(is);
{ {
IStringStream lineStream(line); IStringStream lineStream(line);
lineStream lineStream
@ -109,7 +107,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
forAll(edges, edgei) forAll(edges, edgei)
{ {
label beg, end; label beg, end;
line = ParentType::getLineNoComment(is); line = this->getLineNoComment(is);
{ {
IStringStream lineStream(line); IStringStream lineStream(line);
lineStream lineStream
@ -126,7 +124,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
label e0Label, e1Label, e2Label; label e0Label, e1Label, e2Label;
label regionI = 0; label regionI = 0;
line = ParentType::getLineNoComment(is); line = this->getLineNoComment(is);
{ {
IStringStream lineStream(line); IStringStream lineStream(line);
lineStream lineStream
@ -207,8 +205,8 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
regionLst[faceI] = regionI; regionLst[faceI] = regionI;
} }
ParentType::setPatches(maxPatch); this->setPatches(maxPatch);
// ParentType::stitchFaces(SMALL); // this->stitchFaces(SMALL);
return true; return true;
} }

View File

@ -57,9 +57,6 @@ class GTSsurfaceFormat
: :
public UnsortedMeshedSurface<Face> public UnsortedMeshedSurface<Face>
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View File

@ -40,8 +40,6 @@ Foam::fileFormats::NASsurfaceFormat<Face>::NASsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -55,8 +53,8 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); const bool mustTriangulate = this->isTri();
const bool mustTriangulate = ParentType::isTri(); this->clear();
IFstream is(fName); IFstream is(fName);
if (!is.good()) if (!is.good())
@ -348,8 +346,8 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
// transfer to normal lists // transfer to normal lists
ParentType::storedPoints().transfer(pointLst); this->storedPoints().transfer(pointLst);
ParentType::storedRegions().transfer(regionLst); this->storedRegions().transfer(regionLst);
pointId.shrink(); pointId.shrink();
faceLst.shrink(); faceLst.shrink();
@ -389,9 +387,9 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
} }
// transfer to normal lists // transfer to normal lists
ParentType::storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
ParentType::setPatches(regionNames); this->setPatches(regionNames);
return true; return true;
} }

View File

@ -67,9 +67,6 @@ class NASsurfaceFormat
public UnsortedMeshedSurface<Face>, public UnsortedMeshedSurface<Face>,
public NASsurfaceFormatCore public NASsurfaceFormatCore
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View File

@ -37,8 +37,6 @@ Foam::fileFormats::OBJsurfaceFormat<Face>::OBJsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -52,8 +50,8 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); const bool mustTriangulate = this->isTri();
const bool mustTriangulate = ParentType::isTri(); this->clear();
IFstream is(fName); IFstream is(fName);
if (!is.good()) if (!is.good())
@ -77,13 +75,13 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
while (is.good()) while (is.good())
{ {
string line = ParentType::getLineNoComment(is); string line = this->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 += ParentType::getLineNoComment(is); line += this->getLineNoComment(is);
} }
// Read first word // Read first word
@ -198,11 +196,11 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
} }
// transfer to normal lists // transfer to normal lists
ParentType::storedPoints().transfer(pointLst); this->storedPoints().transfer(pointLst);
ParentType::storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst); this->storedRegions().transfer(regionLst);
ParentType::setPatches(groupToPatch); this->setPatches(groupToPatch);
return true; return true;
} }

View File

@ -61,17 +61,8 @@ class OBJsurfaceFormat
public UnsortedMeshedSurface<Face>, public UnsortedMeshedSurface<Face>,
public OBJsurfaceFormatCore public OBJsurfaceFormatCore
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const OBJsurfaceFormat<Face>&);
static void writeHead static void writeHead
( (
Ostream&, Ostream&,
@ -80,6 +71,12 @@ class OBJsurfaceFormat
const List<surfGroup>& const List<surfGroup>&
); );
//- Disallow default bitwise copy construct
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const OBJsurfaceFormat<Face>&);
public: public:
// Constructors // Constructors

View File

@ -39,8 +39,6 @@ Foam::fileFormats::OFFsurfaceFormat<Face>::OFFsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -54,8 +52,8 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); const bool mustTriangulate = this->isTri();
const bool mustTriangulate = ParentType::isTri(); this->clear();
IFstream is(fName); IFstream is(fName);
if (!is.good()) if (!is.good())
@ -69,7 +67,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
} }
// Read header // Read header
string hdr = ParentType::getLineNoComment(is); string hdr = this->getLineNoComment(is);
if (hdr != "OFF") if (hdr != "OFF")
{ {
FatalErrorIn FatalErrorIn
@ -84,7 +82,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
// get dimensions // get dimensions
label nPoints, nEdges, nElems; label nPoints, nEdges, nElems;
string line = ParentType::getLineNoComment(is); string line = this->getLineNoComment(is);
{ {
IStringStream lineStream(line); IStringStream lineStream(line);
lineStream >> nPoints >> nElems >> nEdges; lineStream >> nPoints >> nElems >> nEdges;
@ -95,7 +93,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
forAll(pointLst, pointI) forAll(pointLst, pointI)
{ {
scalar x, y, z; scalar x, y, z;
line = ParentType::getLineNoComment(is); line = this->getLineNoComment(is);
{ {
IStringStream lineStream(line); IStringStream lineStream(line);
lineStream >> x >> y >> z; lineStream >> x >> y >> z;
@ -109,7 +107,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
forAll(faceLst, faceI) forAll(faceLst, faceI)
{ {
line = ParentType::getLineNoComment(is); line = this->getLineNoComment(is);
{ {
IStringStream lineStream(line); IStringStream lineStream(line);
@ -150,14 +148,14 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
} }
// transfer to normal lists // transfer to normal lists
ParentType::storedPoints().transfer(pointLst); reset
ParentType::storedFaces().transfer(faceLst); (
xferMove(pointLst),
xferMoveTo<List<Face> >(faceLst)
);
// no region information // no region information
ParentType::storedRegions().setSize(ParentType::size()); this->onePatch();
ParentType::storedRegions() = 0;
ParentType::setPatches(0);
return true; return true;
} }

View File

@ -69,17 +69,8 @@ class OFFsurfaceFormat
public UnsortedMeshedSurface<Face>, public UnsortedMeshedSurface<Face>,
public OFFsurfaceFormatCore public OFFsurfaceFormatCore
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct
OFFsurfaceFormat(const OFFsurfaceFormat&);
//- Disallow default bitwise assignment
void operator=(const OFFsurfaceFormat&);
static void writeHead static void writeHead
( (
Ostream&, Ostream&,
@ -88,6 +79,12 @@ class OFFsurfaceFormat
const List<surfGroup>& const List<surfGroup>&
); );
//- Disallow default bitwise copy construct
OFFsurfaceFormat(const OFFsurfaceFormat&);
//- Disallow default bitwise assignment
void operator=(const OFFsurfaceFormat&);
public: public:
// Constructors // Constructors

View File

@ -34,8 +34,6 @@ License
template<class Face> template<class Face>
Foam::fileFormats::SMESHsurfaceFormat<Face>::SMESHsurfaceFormat() Foam::fileFormats::SMESHsurfaceFormat<Face>::SMESHsurfaceFormat()
:
ParentType()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -66,9 +66,6 @@ class SMESHsurfaceFormat
public UnsortedMeshedSurface<Face>, public UnsortedMeshedSurface<Face>,
public SMESHsurfaceFormatCore public SMESHsurfaceFormatCore
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View File

@ -71,8 +71,6 @@ Foam::fileFormats::STARCDsurfaceFormat<Face>::STARCDsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -85,8 +83,8 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); const bool mustTriangulate = this->isTri();
const bool mustTriangulate = ParentType::isTri(); this->clear();
fileName baseName = fName.lessExt(); fileName baseName = fName.lessExt();
autoPtr<IFstream> isPtr; autoPtr<IFstream> isPtr;
@ -126,7 +124,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
} }
// transfer to normal lists // transfer to normal lists
ParentType::storedPoints().transfer(pointLst); this->storedPoints().transfer(pointLst);
// Build inverse mapping (index to point) // Build inverse mapping (index to point)
pointId.shrink(); pointId.shrink();
@ -218,9 +216,9 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
SubList<label>(starLabels, nLabels) SubList<label>(starLabels, nLabels)
); );
faceList triFaces(f.nTriangles(ParentType::points())); faceList triFaces(f.nTriangles(this->points()));
label nTri = 0; label nTri = 0;
f.triangles(ParentType::points(), nTri, triFaces); f.triangles(this->points(), nTri, triFaces);
forAll(triFaces, faceI) forAll(triFaces, faceI)
{ {
@ -260,10 +258,10 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
} }
// transfer to normal lists // transfer to normal lists
ParentType::storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst); this->storedRegions().transfer(regionLst);
ParentType::setPatches(regionNames); this->setPatches(regionNames);
return true; return true;
} }
@ -303,7 +301,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
( (
OFstream(baseName + ".inp")(), OFstream(baseName + ".inp")(),
surf.points(), surf.points(),
surf.nFaces(), surf.size(),
patchLst patchLst
); );
} }
@ -342,7 +340,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
( (
OFstream(baseName + ".inp")(), OFstream(baseName + ".inp")(),
surf.points(), surf.points(),
surf.nFaces(), surf.size(),
patchLst patchLst
); );
} }

View File

@ -65,15 +65,12 @@ class STARCDsurfaceFormat
public UnsortedMeshedSurface<Face>, public UnsortedMeshedSurface<Face>,
public STARCDsurfaceFormatCore public STARCDsurfaceFormatCore
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Data // Private Data
//- STAR-CD identifier for shell shapes (2d elements) //- STAR-CD identifier for shell shapes (2d elements)
static const int starcdShellShape_ = 3; static const int starcdShellShape_ = 3;
//- STAR-CD identifier for shell type (shells vs. baffles) //- STAR-CD identifier for shell type (shells vs. baffles)
static const int starcdShellType_ = 4; static const int starcdShellType_ = 4;
// Private Member Functions // Private Member Functions

View File

@ -83,6 +83,7 @@ public:
// Member Operators // Member Operators
//- Return point
inline operator point() const inline operator point() const
{ {
return point(x(), y(), z()); return point(x(), y(), z());

View File

@ -271,8 +271,6 @@ Foam::fileFormats::STLsurfaceFormat<Face>::STLsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -286,18 +284,18 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); this->clear();
// read in the values // read in the values
STLsurfaceFormatCore reader(fName); STLsurfaceFormatCore reader(fName);
// transfer
ParentType::storedPoints().transfer(reader.points());
ParentType::storedRegions().transfer(reader.regions());
// generate the faces: // generate the faces:
List<Face>& faceLst = ParentType::storedFaces(); List<Face>& faceLst = this->storedFaces();
faceLst.setSize(ParentType::regions().size()); faceLst.setSize(reader.regions().size());
// transfer
this->storedPoints().transfer(reader.points());
this->storedRegions().transfer(reader.regions());
label ptI = 0; label ptI = 0;
forAll(faceLst, faceI) forAll(faceLst, faceI)
@ -313,14 +311,14 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
if (reader.binary()) if (reader.binary())
{ {
ParentType::setPatches(reader.maxRegionId()); this->setPatches(reader.maxRegionId());
} }
else else
{ {
ParentType::setPatches(reader.groupToPatch()); this->setPatches(reader.groupToPatch());
} }
ParentType::stitchFaces(SMALL); this->stitchFaces(SMALL);
return true; return true;
} }
@ -354,7 +352,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
const UnsortedMeshedSurface<Face>& surf const UnsortedMeshedSurface<Face>& surf
) )
{ {
const word ext = fName.ext(); word ext = fName.ext();
// handle 'stlb' as binary directly // handle 'stlb' as binary directly
if (ext == "stlb") if (ext == "stlb")

View File

@ -57,19 +57,8 @@ class STLsurfaceFormat
: :
public UnsortedMeshedSurface<Face> public UnsortedMeshedSurface<Face>
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private data
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct
STLsurfaceFormat(const STLsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const STLsurfaceFormat<Face>&);
//- Write Face in ASCII //- Write Face in ASCII
static inline void writeShell static inline void writeShell
( (
@ -102,6 +91,12 @@ class STLsurfaceFormat
//- Write MeshedSurface //- Write MeshedSurface
static void writeBINARY(ostream&, const MeshedSurface<Face>&); static void writeBINARY(ostream&, const MeshedSurface<Face>&);
//- Disallow default bitwise copy construct
STLsurfaceFormat(const STLsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const STLsurfaceFormat<Face>&);
public: public:
// Constructors // Constructors

View File

@ -39,6 +39,7 @@ SourceFiles
#include "STLtriangle.H" #include "STLtriangle.H"
#include "triFace.H" #include "triFace.H"
#include "gzstream.h"
#include "IFstream.H" #include "IFstream.H"
#include "Ostream.H" #include "Ostream.H"
#include "OFstream.H" #include "OFstream.H"

View File

@ -242,7 +242,6 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
forAll(regionLst, faceI) forAll(regionLst, faceI)
{ {
label patchI = regionLookup[regionLst[faceI]]; label patchI = regionLookup[regionLst[faceI]];
faceMap[faceI] = patchLst[patchI].start() + patchLst[patchI].size()++; faceMap[faceI] = patchLst[patchI].start() + patchLst[patchI].size()++;
} }

View File

@ -68,8 +68,6 @@ Foam::fileFormats::TRIsurfaceFormat<Face>::TRIsurfaceFormat
( (
const fileName& fName const fileName& fName
) )
:
ParentType()
{ {
read(fName); read(fName);
} }
@ -83,7 +81,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
const fileName& fName const fileName& fName
) )
{ {
ParentType::clear(); this->clear();
IFstream is(fName); IFstream is(fName);
if (!is.good()) if (!is.good())
@ -108,13 +106,13 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
while (is.good()) while (is.good())
{ {
string line = ParentType::getLineNoComment(is); string line = this->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 += ParentType::getLineNoComment(is); // line += this->getLineNoComment(is);
// } // }
IStringStream lineStream(line); IStringStream lineStream(line);
@ -181,13 +179,13 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
regionLst.append(groupID); regionLst.append(groupID);
} }
// transfer to normal list
ParentType::storedPoints().transfer(pointLst);
ParentType::storedRegions().transfer(regionLst);
// make our triangles directly // make our triangles directly
List<Face>& faceLst = ParentType::storedFaces(); List<Face>& faceLst = this->storedFaces();
faceLst.setSize(ParentType::regions().size()); faceLst.setSize(regionLst.size());
// transfer to normal list
this->storedPoints().transfer(pointLst);
this->storedRegions().transfer(regionLst);
label ptI = 0; label ptI = 0;
forAll(faceLst, faceI) forAll(faceLst, faceI)
@ -201,8 +199,8 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
faceLst[faceI] = fTri; faceLst[faceI] = fTri;
} }
ParentType::setPatches(groupToPatch); this->setPatches(groupToPatch);
ParentType::stitchFaces(SMALL); this->stitchFaces(SMALL);
return true; return true;
} }

View File

@ -57,17 +57,8 @@ class TRIsurfaceFormat
: :
public UnsortedMeshedSurface<Face> public UnsortedMeshedSurface<Face>
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct
TRIsurfaceFormat(const TRIsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const TRIsurfaceFormat<Face>&);
static inline void writeShell static inline void writeShell
( (
Ostream&, Ostream&,
@ -76,6 +67,12 @@ class TRIsurfaceFormat
const label patchI const label patchI
); );
//- Disallow default bitwise copy construct
TRIsurfaceFormat(const TRIsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const TRIsurfaceFormat<Face>&);
public: public:
// Constructors // Constructors

View File

@ -53,8 +53,6 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHeaderPolygons
template<class Face> template<class Face>
Foam::fileFormats::VTKsurfaceFormat<Face>::VTKsurfaceFormat() Foam::fileFormats::VTKsurfaceFormat<Face>::VTKsurfaceFormat()
:
ParentType()
{} {}

View File

@ -59,15 +59,11 @@ class VTKsurfaceFormat
public UnsortedMeshedSurface<Face>, public UnsortedMeshedSurface<Face>,
public VTKsurfaceFormatCore public VTKsurfaceFormatCore
{ {
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions // Private Member Functions
//- Write header information about number of polygon points //- Write header information about number of polygon points
static void writeHeaderPolygons(Ostream&, const List<Face>&); static void writeHeaderPolygons(Ostream&, const List<Face>&);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
VTKsurfaceFormat(const VTKsurfaceFormat<Face>&); VTKsurfaceFormat(const VTKsurfaceFormat<Face>&);