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
(
!meshedSurface::canRead(importName.ext(), true)
|| !meshedSurface::canWrite(exportName.ext(), true)
!meshedSurface::canRead(importName, true)
|| !meshedSurface::canWriteType(exportName.ext(), true)
)
{
return 1;

View File

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

View File

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

View File

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

View File

@ -37,16 +37,6 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
{
clear();
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
List<surfGroup> patchLst(is);
// copy and set the indices
@ -61,17 +51,45 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
}
// read points:
is >> storedPoints();
is >> this->storedPoints();
// read faces:
// TODO - specialization to triangulate on-the-fly
if (mustTriangulate)
#if 1
// must triangulate?
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
#endif
{
is >> storedFaces();
// read faces:
is >> this->storedFaces();
}
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
IOobject::writeBanner(os);
os << "// OpenFOAM Surface format" << nl
os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
@ -97,10 +115,10 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
IOobject::writeDivider(os);
// Note: Write with global point numbering
os << "\n// points:" << nl << points() << nl;
os << "\n// points:" << nl << this->points() << nl;
IOobject::writeDivider(os);
os << "\n// faces:" << nl << faces() << nl;
os << "\n// faces:" << nl << this->faces() << nl;
IOobject::writeDivider(os);

View File

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

View File

@ -33,17 +33,14 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define makeMeshedSurface(faceType) \
defineNamedTemplateTypeNameAndDebug \
(MeshedSurface<faceType>, 0); \
defineTemplatedRunTimeSelectionTable \
(MeshedSurface, fileExtension,faceType); \
defineTemplatedMemberFunctionSelectionTable \
(MeshedSurface, write,fileExtension,faceType);
#define makeSurface(surfType, faceType) \
defineNamedTemplateTypeNameAndDebug(surfType<faceType>, 0); \
defineTemplatedRunTimeSelectionTable(surfType,fileExtension,faceType); \
defineTemplatedMemberFunctionSelectionTable(surfType,write,fileExtension,faceType);
makeMeshedSurface(face)
makeMeshedSurface(triFace)
makeSurface(MeshedSurface, face)
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 * * * * * * * * * * * * //
template<class Face>
inline bool Foam::UnsortedMeshedSurface<Face>::isTri()
{
return false;
}
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::canRead
bool Foam::UnsortedMeshedSurface<Face>::canReadType
(
const word& ext,
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
if (isNative(fExt))
if (isNative(ext))
{
return true;
}
typename fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(fExt);
fileExtensionConstructorTablePtr_->find(ext);
// would be nice to have information about which format this actually is
if (cstrIter == fileExtensionConstructorTablePtr_->end())
@ -81,7 +65,7 @@ bool Foam::UnsortedMeshedSurface<Face>::canRead
fileExtensionConstructorTablePtr_->toc()
);
Info<<"Unknown file extension for reading: " << fExt << nl;
Info<<"Unknown file extension for reading: " << ext << nl;
// compact output:
Info<<"Valid types: ( " << nativeExt;
forAll(known, i)
@ -98,29 +82,20 @@ bool Foam::UnsortedMeshedSurface<Face>::canRead
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::canWrite
bool Foam::UnsortedMeshedSurface<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
if (isNative(fExt))
if (isNative(ext))
{
return true;
}
typename writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(fExt);
writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{
@ -131,7 +106,7 @@ bool Foam::UnsortedMeshedSurface<Face>::canWrite
writefileExtensionMemberFunctionTablePtr_->toc()
);
Info<<"Unknown file extension for writing: " << fExt << nl;
Info<<"Unknown file extension for writing: " << ext << nl;
// compact output:
Info<<"Valid types: ( " << nativeExt;
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>
void Foam::UnsortedMeshedSurface<Face>::write
(
@ -194,8 +185,6 @@ void Foam::UnsortedMeshedSurface<Face>::write
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface()
:
ParentType(List<Face>(), pointField())
{}
@ -208,13 +197,10 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const xfer<surfPatchIdentifierList>& patchLst
)
:
ParentType(List<Face>(), pointField()),
ParentType(pointLst, faceLst),
regions_(regionIds),
patches_(patchLst)
{
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
}
{}
template<class Face>
@ -226,12 +212,9 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const Map<word>& regionNames
)
:
ParentType(List<Face>(), pointField()),
ParentType(pointLst, faceLst),
regions_(regionIds)
{
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
if (&regionNames)
{
// set patch names from (id => name) mapping
@ -254,12 +237,9 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const HashTable<label>& labelToRegion
)
:
ParentType(List<Face>(), pointField()),
ParentType(pointLst, faceLst),
regions_(regionIds)
{
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
// set patch names from (name => id) mapping
setPatches(labelToRegion);
}
@ -272,126 +252,50 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const xfer<List<Face> >& faceLst
)
:
ParentType(List<Face>(), pointField()),
regions_(faceLst().size(), 0), // single default patch
patches_()
ParentType(pointLst, faceLst)
{
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
setPatches(0);
onePatch();
}
#if 0
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const polyBoundaryMesh& bMesh,
const bool useGlobalPoints
)
:
ParentType(List<Face>(), pointField())
{
const polyMesh& mesh = bMesh.mesh();
const polyPatchList& bPatches = bMesh;
const label nIntFaces = mesh.nInternalFaces();
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();
// creating via MeshedSurface is the easiest
MeshedSurface<Face> surf(bMesh, useGlobalPoints);
transfer(surf);
}
// 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>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
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();
List<Face> newFaces(origFaces.size());
List<label> newRegions(origFaces.size());
List<PatchRegionType> newPatches(patchLst.size());
regions_.setSize(size());
patches_.setSize(patchLst.size());
label faceIndex = 0;
label faceI = 0;
forAll(patchLst, patchI)
{
newPatches[patchI] = patchLst[patchI];
patches_[patchI] = patchLst[patchI];
forAll(patchLst[patchI], patchFaceI)
{
newFaces[faceIndex] = origFaces[faceIndex];
newRegions[faceIndex] = patchI;
faceIndex++;
regions_[faceI++] = patchI;
}
}
}
storedFaces().transfer(newFaces);
regions_.transfer(newRegions);
patches_.transfer(newPatches);
}
#endif
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
@ -399,32 +303,20 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const fileName& fName,
const word& ext
)
:
ParentType(List<Face>(), pointField())
{
read(fName, ext);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const fileName& fName
)
:
ParentType(List<Face>(), pointField())
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const fileName& fName)
{
read(fName, fName.ext());
read(fName);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
Istream& is
)
:
ParentType(List<Face>(), pointField())
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(Istream& is)
{
read(is);
}
@ -432,8 +324,6 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const Time& d)
:
ParentType(List<Face>(), pointField())
{
read(IFstream(findMeshName(d))());
}
@ -445,7 +335,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const UnsortedMeshedSurface<Face>& surf
)
:
ParentType(surf.faces(), surf.points()),
ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
regions_(surf.regions_),
patches_(surf.patches_)
{}
@ -456,28 +346,19 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const xfer<UnsortedMeshedSurface<Face> >& surf
)
:
ParentType(List<Face>(), pointField()),
regions_(),
patches_()
{
transfer(surf());
}
#if 0
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const xfer<MeshedSurface<Face> >& surf
)
:
ParentType(List<Face>(), pointField()),
regions_(),
patches_()
{
transfer(surf());
}
#endif
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -489,6 +370,18 @@ Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
// * * * * * * * * * * * * 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>
void Foam::UnsortedMeshedSurface<Face>::setPatches(const label maxPatch)
{
@ -604,17 +497,15 @@ template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
{
ParentType::setSize(s);
regions_.setSize(s);
// if regions extend: set with last patchId
regions_.setSize(s, patches_.size() - 1);
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::clear()
{
ParentType::clearOut();
storedPoints().clear();
storedFaces().clear();
ParentType::clear();
regions_.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>
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
(
@ -676,11 +536,11 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
labelList& faceMap
) const
{
const pointField& locPoints = ParentType::localPoints();
const List<Face>& locFaces = ParentType::localFaces();
const pointField& locPoints = this->localPoints();
const List<Face>& locFaces = this->localFaces();
// Fill pointMap, faceMap
ParentType::subsetMap(include, pointMap, faceMap);
this->subsetMap(include, pointMap, faceMap);
// Create compact coordinate list and forward mapping array
pointField newPoints(pointMap.size());
@ -693,11 +553,12 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
// Renumber face node labels and compact
List<Face> newFaces(faceMap.size());
List<label> newRegions(faceMap.size());
forAll(faceMap, faceI)
{
// Get old vertex labels
const Face& oldFace = locFaces[faceMap[faceI]];
const label origFaceI = faceMap[faceI];
const Face& oldFace = locFaces[origFaceI];
newFaces[faceI] = Face(oldFace);
@ -707,17 +568,47 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
{
f[fp] = oldToNew[oldFace[fp]];
}
newRegions[faceI] = regions_[origFaceI];
}
oldToNew.clear();
// construct a sub-surface
UnsortedMeshedSurface<Face> subSurf;
return UnsortedMeshedSurface
(
xferMove(newPoints),
xferMove(newFaces),
xferMove(newRegions),
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
)
{
clear();
storedPoints().transfer(surf.storedPoints());
storedFaces().transfer(surf.storedFaces());
regions_.transfer(surf.regions_);
reset
(
xferMove(surf.storedPoints()),
xferMove(surf.storedFaces()),
xferMove(surf.regions_)
);
patches_.transfer(surf.patches_);
surf.clear();
}
#if 0
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::transfer
(
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());
patches_.setSize(patchLst.size());
@ -769,29 +658,21 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
patchLst.clear();
surf.clear();
}
#endif
// Read from file in given format
// Read from file, determine format from extension
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::read
(
const fileName& fName
)
bool Foam::UnsortedMeshedSurface<Face>::read(const fileName& fName)
{
clear();
const word ext = fName.ext();
// handle 'native' format directly
if (isNative(ext))
word ext = fName.ext();
if (ext == "gz")
{
return read(IFstream(fName)());
fileName unzipName = fName.lessExt();
return read(unzipName, unzipName.ext());
}
else
{
// use selector mechanism
transfer(New(fName, ext)());
return true;
return read(fName, ext);
}
}
@ -804,8 +685,6 @@ bool Foam::UnsortedMeshedSurface<Face>::read
const word& ext
)
{
clear();
// handle 'native' format directly
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 * * * * * * * * * * * * * //
template<class Face>
@ -846,8 +715,9 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
)
{
clear();
storedPoints() = surf.points();
storedFaces() = surf.faces();
this->storedPoints() = surf.points();
this->storedFaces() = surf.faces();
regions_ = surf.regions_;
patches_ = surf.patches_;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,8 +43,6 @@ Foam::fileFormats::AC3DsurfaceFormat<Face>::AC3DsurfaceFormat
(
const fileName& fName
)
:
ParentType()
{
read(fName);
}
@ -57,8 +55,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
const fileName& fName
)
{
ParentType::clear();
const bool mustTriangulate = ParentType::isTri();
const bool mustTriangulate = this->isTri();
this->clear();
IFstream is(fName);
if (!is.good())
@ -280,12 +278,12 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
}
// transfer to normal lists
ParentType::storedPoints().transfer(pointLst);
ParentType::storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst);
this->storedPoints().transfer(pointLst);
this->storedFaces().transfer(faceLst);
this->storedRegions().transfer(regionLst);
ParentType::setPatches(regionNames);
ParentType::stitchFaces(SMALL);
this->setPatches(regionNames);
this->stitchFaces(SMALL);
return true;
}
@ -316,30 +314,26 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
forAll(p, patchFaceI)
{
const label faceI = faceMap[faceIndex++];
include[faceI] = true;
}
labelList pMap;
labelList fMap;
UnsortedMeshedSurface<Face> subm = surf.subsetMesh(include);
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.
os << "numvert " << patch.nPoints() << endl;
forAll(patch.localPoints(), ptI)
forAll(subm.localPoints(), ptI)
{
const point& pt = patch.localPoints()[ptI];
const point& pt = subm.localPoints()[ptI];
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
<< "mat " << patchI << nl

View File

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

View File

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

View File

@ -56,17 +56,7 @@ class FTRsurfaceFormat
:
public UnsortedMeshedSurface<Face>
{
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
//- Disallow default bitwise copy construct
FTRsurfaceFormat(const FTRsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const FTRsurfaceFormat<Face>&);
// Private classes
//- read compatibility for ftr patch definitions
class ftrPatch
@ -91,6 +81,14 @@ class FTRsurfaceFormat
}
};
// Private Member Functions
//- Disallow default bitwise copy construct
FTRsurfaceFormat(const FTRsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const FTRsurfaceFormat<Face>&);
public:
// Constructors

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -65,9 +65,6 @@ class STARCDsurfaceFormat
public UnsortedMeshedSurface<Face>,
public STARCDsurfaceFormatCore
{
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Data
//- STAR-CD identifier for shell shapes (2d elements)
static const int starcdShellShape_ = 3;

View File

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

View File

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

View File

@ -57,19 +57,8 @@ class STLsurfaceFormat
:
public UnsortedMeshedSurface<Face>
{
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ParentType;
// Private data
// 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
static inline void writeShell
(
@ -102,6 +91,12 @@ class STLsurfaceFormat
//- Write MeshedSurface
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:
// Constructors

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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