surfMesh code cleanup

- added protected storedPoints(), storedFaces() functions for non-const
   access to the data. Mixing protected non-const versions and public const
   versions of the same method does not agree with the compiler
 - better handling of triFace/face distinction
This commit is contained in:
Mark Olesen
2008-11-15 23:29:50 +01:00
parent 59bfd4ecef
commit c651a0ba29
45 changed files with 639 additions and 739 deletions

View File

@ -71,6 +71,7 @@ int main(int argc, char *argv[])
argList::validOptions.insert("scale", "scale");
argList::validOptions.insert("triSurface", "");
argList::validOptions.insert("unsorted", "");
argList::validOptions.insert("triFace", "");
# include "setRootCase.H"
const stringList& params = args.additionalArgs();
@ -125,7 +126,7 @@ int main(int argc, char *argv[])
}
else if (args.options().found("unsorted"))
{
unsortedMeshedSurface surf(importName);
UnsortedMeshedSurface<face> surf(importName);
if (args.options().found("clean"))
{
@ -146,9 +147,33 @@ int main(int argc, char *argv[])
surf.write(exportName);
}
#if 1
else if (args.options().found("triFace"))
{
MeshedSurface<triFace> surf(importName);
if (args.options().found("clean"))
{
surf.cleanup(true);
surf.checkOrientation(true);
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
}
surf.write(exportName);
}
#endif
else
{
meshedSurface surf(importName);
MeshedSurface<face> surf(importName);
if (args.options().found("clean"))
{

View File

@ -44,6 +44,13 @@ 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)
{
@ -165,8 +172,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
ParentType(List<Face>(), pointField()),
patches_(patchLst)
{
points().transfer(pointLst());
faces().transfer(faceLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
}
@ -182,8 +189,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
:
ParentType(List<Face>(), pointField())
{
points().transfer(pointLst());
faces().transfer(faceLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
surfGroupList newPatches(patchSizes.size());
@ -216,8 +223,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
:
ParentType(List<Face>(), pointField())
{
points().transfer(pointLst());
faces().transfer(faceLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
if
(
@ -257,8 +264,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
:
ParentType(List<Face>(), pointField())
{
points().transfer(pointLst());
faces().transfer(faceLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
if (regionIds.size() != nFaces())
{
@ -316,14 +323,14 @@ Foam::MeshedSurface<Face>::MeshedSurface
if (useGlobalPoints)
{
// copy in the global points and the global face addressing
points() = mesh.points();
faces() = allBoundary;
storedPoints() = mesh.points();
storedFaces() = allBoundary;
}
else
{
// copy in the local points and the local face addressing
points() = allBoundary.localPoints();
faces() = allBoundary.localFaces();
storedPoints() = allBoundary.localPoints();
storedFaces() = allBoundary.localFaces();
}
// create patch list
@ -405,7 +412,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
newFaces[faceI] = origFaces[faceMap[faceI]];
}
faces().transfer(newFaces);
storedFaces().transfer(newFaces);
}
@ -595,7 +602,7 @@ void Foam::MeshedSurface<Face>::sortFacesByRegion
}
faceMap.clear();
faces().transfer(newFaces);
storedFaces().transfer(newFaces);
}
}
@ -610,8 +617,8 @@ void Foam::MeshedSurface<Face>::clear()
{
ParentType::clearOut();
points().clear();
faces().clear();
storedPoints().clear();
storedFaces().clear();
patches_.clear();
}
@ -626,7 +633,7 @@ void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints)
ParentType::movePoints(newPoints);
// Copy new points
points() = newPoints;
storedPoints() = newPoints;
}
@ -642,7 +649,7 @@ void Foam::MeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
// Adapt for new point position
ParentType::movePoints(pointField());
points() *= scaleFactor;
storedPoints() *= scaleFactor;
}
}
@ -741,8 +748,8 @@ void Foam::MeshedSurface<Face>::transfer
{
clear();
points().transfer(surf.points());
faces().transfer(surf.faces());
storedPoints().transfer(surf.storedPoints());
storedFaces().transfer(surf.storedFaces());
patches_.transfer(surf.patches_);
surf.clear();
@ -756,7 +763,7 @@ void Foam::MeshedSurface<Face>::transfer
)
{
clear();
points().transfer(surf.points());
storedPoints().transfer(surf.storedPoints());
labelList faceMap;
surfGroupList patchLst = surf.sortedRegions(faceMap);
@ -765,7 +772,7 @@ void Foam::MeshedSurface<Face>::transfer
surf.regions_.clear();
surf.patches_.clear();
List<Face>& oldFaces = surf.faces();
const List<Face>& oldFaces = surf.faces();
List<Face> newFaces(oldFaces.size());
// this is somewhat like ListOps reorder and/or IndirectList
@ -774,7 +781,7 @@ void Foam::MeshedSurface<Face>::transfer
newFaces[faceI] = oldFaces[faceMap[faceI]];
}
faces().transfer(newFaces);
storedFaces().transfer(newFaces);
surf.clear();
}
@ -852,8 +859,8 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
{
clear();
faces() = surf.faces();
points() = surf.points();
storedPoints() = surf.points();
storedFaces() = surf.faces();
patches_ = surf.patches_;
}

View File

@ -87,7 +87,6 @@ class MeshedSurface
private:
//- Private typedefs for convenience
typedef MeshedSurface<Face> ThisType;
typedef PrimitivePatchExtra
<
Face,
@ -117,6 +116,22 @@ 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
@ -124,6 +139,9 @@ public:
// Static
//- Only handles triangulated faces
inline static bool isTri();
//- Can we read this file format?
static bool canRead(const word& ext, const bool verbose=false);
@ -270,7 +288,7 @@ public:
//- Return the number of points
label nPoints() const
{
return points().size();
return ParentType::points().size();
}
//- Return the number of faces
@ -291,30 +309,13 @@ public:
return ParentType::points();
}
//- Return non-const access to global points
pointField& points()
{
return const_cast<pointField&>(ParentType::points());
}
//- Return const access to the faces
const List<Face>& faces() const
{
return static_cast<const List<Face> &>(*this);
}
//- Return non-const access to the faces
List<Face>& faces()
{
return static_cast<List<Face> &>(*this);
}
const surfGroupList& patches() const
{
return patches_;
}
surfGroupList& patches()
const List<surfGroup>& patches() const
{
return patches_;
}
@ -403,6 +404,22 @@ 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()
{
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -48,7 +48,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
const bool verbose
)
{
pointField& pointLst = points();
pointField& pointLst = 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 = faces();
List<Face>& faceLst = storedFaces();
// ensure we have at some patches, and they cover all the faces
checkPatches();
@ -78,7 +78,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
// Reset the point labels to the unique points array
label oldFaceI = 0;
label newFaceI = 0;
forAll (patches_, patchI)
forAll(patches_, patchI)
{
surfGroup& p = patches_[patchI];
@ -89,7 +89,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
for (; oldFaceI < patchEnd; ++oldFaceI)
{
Face& f = faceLst[oldFaceI];
forAll (f, fp)
forAll(f, fp)
{
f[fp] = pointMap[f[fp]];
}
@ -141,14 +141,14 @@ void Foam::MeshedSurface<Face>::checkFaces(const bool verbose)
// Simple check on indices ok.
const label maxPointI = points().size() - 1;
List<Face>& faceLst = faces();
List<Face>& faceLst = storedFaces();
// Phase 0: detect badly labelled faces
forAll (faceLst, faceI)
forAll(faceLst, faceI)
{
const Face& f = faceLst[faceI];
forAll (f, fp)
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] > maxPointI)
{
@ -170,7 +170,7 @@ void Foam::MeshedSurface<Face>::checkFaces(const bool verbose)
label oldFaceI = 0;
label newFaceI = 0;
forAll (patches_, patchI)
forAll(patches_, patchI)
{
surfGroup& p = patches_[patchI];
@ -191,7 +191,7 @@ void Foam::MeshedSurface<Face>::checkFaces(const bool verbose)
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll (neighbours, neighI)
forAll(neighbours, neighI)
{
if (neighbours[neighI] <= oldFaceI)
{
@ -199,7 +199,7 @@ void Foam::MeshedSurface<Face>::checkFaces(const bool verbose)
continue;
}
const face& nei = faceLst[neighbours[neighI]];
const Face& nei = faceLst[neighbours[neighI]];
if (f == nei)
{
@ -271,10 +271,10 @@ template<class Face>
Foam::label Foam::MeshedSurface<Face>::triangulate()
{
label nTri = 0;
List<Face>& faceLst = faces();
List<Face>& faceLst = storedFaces();
// determine how many triangles are needed
forAll (faceLst, faceI)
forAll(faceLst, faceI)
{
nTri += faceLst[faceI].size() - 2;
}
@ -293,7 +293,7 @@ Foam::label Foam::MeshedSurface<Face>::triangulate()
// Reset the point labels to the unique points array
label oldFaceI = 0;
label newFaceI = 0;
forAll (patches_, patchI)
forAll(patches_, patchI)
{
surfGroup& p = patches_[patchI];

View File

@ -61,17 +61,17 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
}
// read points:
is >> points();
is >> storedPoints();
// read faces:
// TODO - specialization to triangulate on-the-fly
if (mustTriangulate)
{
is >> faces();
is >> storedFaces();
}
else
{
is >> faces();
is >> storedFaces();
}
return is.good();

View File

@ -39,6 +39,13 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face>
inline bool Foam::UnsortedMeshedSurface<Face>::isTri()
{
return false;
}
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::canRead
(
@ -205,8 +212,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
regions_(regionIds),
patches_(patchLst)
{
points().transfer(pointLst());
faces().transfer(faceLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
}
@ -222,8 +229,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
ParentType(List<Face>(), pointField()),
regions_(regionIds)
{
faces().transfer(faceLst());
points().transfer(pointLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
if (&regionNames)
{
@ -250,8 +257,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
ParentType(List<Face>(), pointField()),
regions_(regionIds)
{
points().transfer(pointLst());
faces().transfer(faceLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
// set patch names from (name => id) mapping
setPatches(labelToRegion);
@ -269,8 +276,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
regions_(faceLst().size(), 0), // single default patch
patches_()
{
points().transfer(pointLst());
faces().transfer(faceLst());
storedPoints().transfer(pointLst());
storedFaces().transfer(faceLst());
setPatches(0);
}
@ -310,12 +317,12 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
if (useGlobalPoints)
{
// copy in the global points
points() = mesh.points();
storedPoints() = mesh.points();
}
else
{
// copy in the local points
points() = allBoundary.localPoints();
storedPoints() = allBoundary.localPoints();
}
// global or local face addressing
@ -345,7 +352,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
}
}
faces().transfer(newFaces);
storedFaces().transfer(newFaces);
regions_.transfer(newRegions);
patches_.transfer(newPatches);
}
@ -380,7 +387,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
}
}
faces().transfer(newFaces);
storedFaces().transfer(newFaces);
regions_.transfer(newRegions);
patches_.transfer(newPatches);
}
@ -606,8 +613,8 @@ void Foam::UnsortedMeshedSurface<Face>::clear()
{
ParentType::clearOut();
points().clear();
faces().clear();
storedPoints().clear();
storedFaces().clear();
regions_.clear();
patches_.clear();
}
@ -640,7 +647,7 @@ void Foam::UnsortedMeshedSurface<Face>::movePoints(const pointField& newPoints)
ParentType::movePoints(newPoints);
// Copy new points
points() = newPoints;
storedPoints() = newPoints;
}
@ -656,7 +663,7 @@ void Foam::UnsortedMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
// Adapt for new point position
ParentType::movePoints(pointField());
points() *= scaleFactor;
storedPoints() *= scaleFactor;
}
}
@ -722,8 +729,8 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
{
clear();
faces().transfer(surf.faces());
points().transfer(surf.points());
storedPoints().transfer(surf.storedPoints());
storedFaces().transfer(surf.storedFaces());
regions_.transfer(surf.regions_);
patches_.transfer(surf.patches_);
@ -742,8 +749,8 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
clear();
points().transfer(surf.points());
faces().transfer(surf.faces());
storedPoints().transfer(surf.storedPoints());
storedFaces().transfer(surf.storedFaces());
regions_.setSize(size());
patches_.setSize(patchLst.size());
@ -839,8 +846,8 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
)
{
clear();
faces() = surf.faces();
points() = surf.points();
storedPoints() = surf.points();
storedFaces() = surf.faces();
regions_ = surf.regions_;
patches_ = surf.patches_;
}

View File

@ -89,17 +89,9 @@ class UnsortedMeshedSurface
{
friend class MeshedSurface<Face>;
protected:
// Protected Member Data
//- Typedef for type holding the region (patch) informationm
typedef surfPatchIdentifier PatchRegionType;
private:
//- Private typedefs for convenience
typedef UnsortedMeshedSurface<Face> ThisType;
typedef PrimitivePatchExtra
<
Face,
@ -109,6 +101,9 @@ private:
>
ParentType;
//- Typedef for type holding the region (patch) informationm
typedef surfPatchIdentifier PatchRegionType;
// Private Member Data
//- The regions associated with the faces
@ -146,6 +141,25 @@ 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()
{
return regions_;
}
public:
//- Runtime type information
@ -153,6 +167,9 @@ public:
// Static
//- Only handles triangulated faces
inline static bool isTri();
//- Can we read this file format?
static bool canRead(const word& ext, const bool verbose=false);
@ -294,7 +311,7 @@ public:
//- Return the number of points
label nPoints() const
{
return points().size();
return ParentType::points().size();
}
//- Return the number of faces
@ -318,51 +335,27 @@ public:
return ParentType::points();
}
//- Return non-const access to global points
pointField& points()
{
return const_cast<pointField&>(ParentType::points());
}
//- Return const access to the faces
const List<Face>& faces() const
{
return static_cast<const List<Face> &>(*this);
}
//- Return non-const access to the faces
List<Face>& faces()
{
return static_cast<List<Face> &>(*this);
}
//- Return const access to the regions
const List<label>& regions() const
{
return regions_;
}
//- Return non-const access to the region Ids
List<label>& regions()
{
return regions_;
}
//- Return const access to the patches
const surfPatchIdentifierList& patches() const
{
return patches_;
}
//- Return non-const access to the patches
surfPatchIdentifierList& patches()
const List<surfPatchIdentifier>& patches() const
{
return patches_;
}
//- Sort faces according to region.
// Returns patch list and sets faceMap to index within faces()
surfGroupList sortedRegions(labelList& faceMap) const;
List<surfGroup> sortedRegions(labelList& faceMap) const;
// Edit
@ -446,6 +439,22 @@ 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()
{
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -48,7 +48,7 @@ bool Foam::UnsortedMeshedSurface<Face>::stitchFaces
const bool verbose
)
{
pointField& pointLst = points();
pointField& pointLst = storedPoints();
// Merge points
labelList pointMap(pointLst.size());
@ -70,14 +70,14 @@ bool Foam::UnsortedMeshedSurface<Face>::stitchFaces
// Set the coordinates to the merged ones
pointLst.transfer(newPoints);
List<Face>& faceLst = faces();
List<Face>& faceLst = storedFaces();
// Reset the point labels to the unique points array
label newFaceI = 0;
forAll (faceLst, faceI)
forAll(faceLst, faceI)
{
Face& f = faceLst[faceI];
forAll (f, fp)
forAll(f, fp)
{
f[fp] = pointMap[f[fp]];
}
@ -125,14 +125,14 @@ void Foam::UnsortedMeshedSurface<Face>::checkFaces(const bool verbose)
// Simple check on indices ok.
const label maxPointI = points().size() - 1;
List<Face>& faceLst = faces();
List<Face>& faceLst = storedFaces();
// Phase 0: detect badly labelled faces
forAll (faceLst, faceI)
forAll(faceLst, faceI)
{
const Face& f = faceLst[faceI];
forAll (f, fp)
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] > maxPointI)
{
@ -151,7 +151,7 @@ void Foam::UnsortedMeshedSurface<Face>::checkFaces(const bool verbose)
const labelListList& fFaces = ParentType::faceFaces();
label newFaceI = 0;
forAll (faceLst, faceI)
forAll(faceLst, faceI)
{
Face& f = faceLst[faceI];
@ -164,7 +164,7 @@ void Foam::UnsortedMeshedSurface<Face>::checkFaces(const bool verbose)
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll (neighbours, neighI)
forAll(neighbours, neighI)
{
if (neighbours[neighI] <= faceI)
{
@ -172,7 +172,7 @@ void Foam::UnsortedMeshedSurface<Face>::checkFaces(const bool verbose)
continue;
}
const face& nei = faceLst[neighbours[neighI]];
const Face& nei = faceLst[neighbours[neighI]];
if (f == nei)
{
@ -242,10 +242,10 @@ template<class Face>
Foam::label Foam::UnsortedMeshedSurface<Face>::triangulate()
{
label nTri = 0;
List<Face>& faceLst = faces();
List<Face>& faceLst = storedFaces();
// determine how many triangles are needed
forAll (faceLst, faceI)
forAll(faceLst, faceI)
{
nTri += faceLst[faceI].size() - 2;
}
@ -264,7 +264,7 @@ Foam::label Foam::UnsortedMeshedSurface<Face>::triangulate()
// Reset the point labels to the unique points array
label newFaceI = 0;
forAll (faceLst, faceI)
forAll(faceLst, faceI)
{
const Face& f = faceLst[faceI];
triFace fTri;

View File

@ -49,18 +49,18 @@ bool Foam::UnsortedMeshedSurface<Face>::read(Istream& is)
List<surfGroup> patchLst(is);
// read points:
is >> points();
is >> storedPoints();
// read faces:
// TODO - specialization to triangulate on-the-fly
if (mustTriangulate)
{
is >> faces();
is >> storedFaces();
}
else
{
is >> faces();
is >> storedFaces();
}
patches_.setSize(patchLst.size());

View File

@ -38,13 +38,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::AC3DsurfaceFormat<Face>::AC3DsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::AC3DsurfaceFormat<Face>::AC3DsurfaceFormat
(
@ -65,16 +58,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
)
{
ParentType::clear();
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
const bool mustTriangulate = ParentType::isTri();
IFstream is(fName);
if (!is.good())
@ -296,9 +280,9 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
}
// transfer to normal lists
ParentType::points().transfer(pointLst);
ParentType::faces().transfer(faceLst);
ParentType::regions().transfer(regionLst);
ParentType::storedPoints().transfer(pointLst);
ParentType::storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst);
ParentType::setPatches(regionNames);
ParentType::stitchFaces(SMALL);
@ -339,10 +323,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
labelList pMap;
labelList fMap;
ParentType patch = surf.subsetMesh
(
include, pMap, fMap
);
ParentType patch = surf.subsetMesh(include, pMap, fMap);
// Now we have triSurface for this patch alone. Write it.
os << "numvert " << patch.nPoints() << endl;

View File

@ -34,6 +34,8 @@ Note
Since the faces are already organized as patches, the reader could be
optimized for this, but at expense of losing a common reading approach.
The output is always sorted by regions.
SourceFiles
AC3DsurfaceFormat.C
@ -66,7 +68,6 @@ class AC3DsurfaceFormat
public AC3DsurfaceFormatCore
{
//- Private typedefs for convenience
typedef AC3DsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -81,9 +82,6 @@ public:
// Constructors
//- Construct null
AC3DsurfaceFormat();
//- Construct from file name
AC3DsurfaceFormat(const fileName&);
@ -113,6 +111,7 @@ public:
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
static void write
(
Ostream&,
@ -120,6 +119,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
static void write
(
const fileName& fName,

View File

@ -55,44 +55,29 @@ namespace fileFormats
class AC3DsurfaceFormatCore
{
protected:
// Protected Member Functions
// Protected Member Functions
//- Read a type via IStringStream
template<class Type>
static Type parse(const string&);
//- Read a type via IStringStream
template<class Type>
static Type parse(const string&);
//- Read cmd, args from IFstream
static bool readCmd(IFstream&, string& cmd, string& args);
//- Read cmd, args from IFstream
static bool readCmd(IFstream&, string& cmd, string& args);
//- Cue up to cmd, reading args
static bool cueTo(IFstream&, const string& cmd, string& args);
//- Cue up to cmd, reading args
static bool cueTo(IFstream&, const string& cmd, string& args);
//- Cue up to cmd, reading args or exit with a FatalError
// returns the command args
static string cueToOrDie
(
IFstream&,
const string& cmd,
const string& errorMsg=string::null
);
//- Cue up to cmd, reading args or exit with a FatalError
// returns the command args
static string cueToOrDie
(
IFstream&,
const string& cmd,
const string& errorMsg=string::null
);
//- Write header with materials
static void writeHeader(Ostream&, const List<surfGroup>&);
public:
// Constructors
//- Construct null
AC3DsurfaceFormatCore()
{}
// Destructor
~AC3DsurfaceFormatCore()
{}
// Member Functions
//- Write header with materials
static void writeHeader(Ostream&, const List<surfGroup>&);
};

View File

@ -31,12 +31,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat
@ -46,7 +40,7 @@ Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat
:
ParentType()
{
ThisType::read(fName);
read(fName);
}
@ -75,13 +69,13 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
List<point> pointLst(is);
// transfer to normal list
ParentType::points().transfer(pointLst);
ParentType::storedPoints().transfer(pointLst);
// read faces with keys
List<Keyed<triFace> > readFaces(is);
List<Face> faceLst(readFaces.size());
List<label> regionLst(readFaces.size());
List<Face> faceLst(readFaces.size());
List<label> regionLst(readFaces.size());
// disentangle faces/keys - already triangulated
forAll(readFaces, faceI)
@ -91,8 +85,8 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
regionLst[faceI] = readFaces[faceI].key();
}
ParentType::faces().transfer(faceLst);
ParentType::regions().transfer(regionLst);
ParentType::storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst);
Map<word> regionNames;
forAll(readPatches, patchI)

View File

@ -26,7 +26,7 @@ Class
Foam::fileFormats::FTRsurfaceFormat
Description
Reading of Foam Trisurface Format
Reading of the (now deprecated) Foam Trisurface Format.
SourceFiles
FTRsurfaceFormat.C
@ -57,7 +57,6 @@ class FTRsurfaceFormat
public UnsortedMeshedSurface<Face>
{
//- Private typedefs for convenience
typedef FTRsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -69,13 +68,13 @@ class FTRsurfaceFormat
void operator=(const FTRsurfaceFormat<Face>&);
//- read compatibility for ftr format
//- read compatibility for ftr patch definitions
class ftrPatch
{
//- Name of patch
word name_;
//- Type of patch
//- Type of patch (ignored since it is usually "empty")
word type_;
public:
@ -96,9 +95,6 @@ public:
// Constructors
//- Construct null
FTRsurfaceFormat();
//- Construct from file name
FTRsurfaceFormat(const fileName&);

View File

@ -35,13 +35,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::GTSsurfaceFormat<Face>::GTSsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::GTSsurfaceFormat<Face>::GTSsurfaceFormat
(
@ -89,15 +82,14 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
// write directly into the lists:
pointField& pointLst = ParentType::points();
List<Face>& faceLst = ParentType::faces();
List<label>& regionLst = ParentType::regions();
pointField& pointLst = ParentType::storedPoints();
List<Face>& faceLst = ParentType::storedFaces();
List<label>& regionLst = ParentType::storedRegions();
pointLst.setSize(nPoints);
faceLst.setSize(nElems);
regionLst.setSize(nElems);
// Read points
forAll(pointLst, pointI)
{
@ -234,8 +226,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
// check if output triangulation would be required
// It is too annoying to triangulate on-the-fly
// just issue a warning and get out
//
if (faceLst.size() && faceLst[0].max_size() != 3)
if (!surf.isTri())
{
label nNonTris = 0;
forAll(faceLst, faceI)
@ -337,7 +328,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
// It is too annoying to triangulate on-the-fly
// just issue a warning and get out
//
if (faceLst.size() && faceLst[0].max_size() != 3)
if (!surf.isTri())
{
label nNonTris = 0;
forAll(faceLst, faceI)

View File

@ -58,7 +58,6 @@ class GTSsurfaceFormat
public UnsortedMeshedSurface<Face>
{
//- Private typedefs for convenience
typedef GTSsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -73,9 +72,6 @@ public:
// Constructors
//- Construct null
GTSsurfaceFormat();
//- Construct from file name
GTSsurfaceFormat(const fileName&);
@ -103,6 +99,7 @@ public:
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
Ostream&,
@ -110,6 +107,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
const fileName& fName,

View File

@ -35,13 +35,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::NASsurfaceFormat<Face>::NASsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::NASsurfaceFormat<Face>::NASsurfaceFormat
(
@ -50,7 +43,7 @@ Foam::fileFormats::NASsurfaceFormat<Face>::NASsurfaceFormat
:
ParentType()
{
ThisType::read(fName);
read(fName);
}
@ -63,16 +56,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
)
{
ParentType::clear();
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
const bool mustTriangulate = ParentType::isTri();
IFstream is(fName);
if (!is.good())
@ -364,8 +348,8 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
// transfer to normal lists
ParentType::points().transfer(pointLst);
ParentType::regions().transfer(regionLst);
ParentType::storedPoints().transfer(pointLst);
ParentType::storedRegions().transfer(regionLst);
pointId.shrink();
faceLst.shrink();
@ -405,7 +389,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
}
// transfer to normal lists
ParentType::faces().transfer(faceLst);
ParentType::storedFaces().transfer(faceLst);
ParentType::setPatches(regionNames);
return true;

View File

@ -68,7 +68,6 @@ class NASsurfaceFormat
public NASsurfaceFormatCore
{
//- Private typedefs for convenience
typedef NASsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -83,9 +82,6 @@ public:
// Constructors
//- Construct null
NASsurfaceFormat();
//- Construct from file name
NASsurfaceFormat(const fileName&);

View File

@ -53,24 +53,10 @@ namespace fileFormats
class NASsurfaceFormatCore
{
protected:
// Protected Member Functions
//- Do weird things to extract number
static scalar parseNASCoord(const string&);
public:
// Constructors
//- Construct null
NASsurfaceFormatCore()
{}
// Destructor
~NASsurfaceFormatCore()
{}
//- Do weird things to extract number
static scalar parseNASCoord(const string&);
};

View File

@ -25,7 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "OBJsurfaceFormat.H"
#include "clock.H"
#include "IFstream.H"
#include "IStringStream.H"
@ -33,13 +32,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::OBJsurfaceFormat<Face>::OBJsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::OBJsurfaceFormat<Face>::OBJsurfaceFormat
(
@ -48,7 +40,7 @@ Foam::fileFormats::OBJsurfaceFormat<Face>::OBJsurfaceFormat
:
ParentType()
{
ThisType::read(fName);
read(fName);
}
@ -61,16 +53,7 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
)
{
ParentType::clear();
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
const bool mustTriangulate = ParentType::isTri();
IFstream is(fName);
if (!is.good())
@ -215,9 +198,9 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
}
// transfer to normal lists
ParentType::points().transfer(pointLst);
ParentType::faces().transfer(faceLst);
ParentType::regions().transfer(regionLst);
ParentType::storedPoints().transfer(pointLst);
ParentType::storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst);
ParentType::setPatches(groupToPatch);
return true;
@ -250,7 +233,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
{
const Face& f = faceLst[faceMap[faceIndex++]];
os << 'f';
os << 'f';
forAll(f, fp)
{
os << ' ' << f[fp] + 1;
@ -259,7 +242,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
}
}
os << "# </faces>" << endl;
os << "# </faces>" << endl;
}
@ -286,7 +269,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
{
const Face& f = faceLst[faceIndex++];
os << 'f';
os << 'f';
forAll(f, fp)
{
os << ' ' << f[fp] + 1;
@ -294,7 +277,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
os << endl;
}
}
os << "# </faces>" << endl;
os << "# </faces>" << endl;
}
// ************************************************************************* //

View File

@ -62,7 +62,6 @@ class OBJsurfaceFormat
public OBJsurfaceFormatCore
{
//- Private typedefs for convenience
typedef OBJsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -85,9 +84,6 @@ public:
// Constructors
//- Construct null
OBJsurfaceFormat();
//- Construct from file name
OBJsurfaceFormat(const fileName&);
@ -117,6 +113,7 @@ public:
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
Ostream&,
@ -124,6 +121,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
static void write
(
const fileName& fName,

View File

@ -49,37 +49,22 @@ namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class AC3DfileFormat Declaration
Class OBJsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/
class OBJsurfaceFormatCore
{
protected:
// Protected Member Functions
// Protected Member Functions
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&,
const label nFaces,
const List<surfGroup>&
);
public:
// Constructors
//- Construct null
OBJsurfaceFormatCore()
{}
// Destructor
~OBJsurfaceFormatCore()
{}
// Member Functions
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&,
const label nFaces,
const List<surfGroup>&
);
};

View File

@ -25,7 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "OFFsurfaceFormat.H"
#include "clock.H"
#include "IFstream.H"
#include "IStringStream.H"
@ -35,13 +34,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::OFFsurfaceFormat<Face>::OFFsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::OFFsurfaceFormat<Face>::OFFsurfaceFormat
(
@ -50,7 +42,7 @@ Foam::fileFormats::OFFsurfaceFormat<Face>::OFFsurfaceFormat
:
ParentType()
{
ThisType::read(fName);
read(fName);
}
@ -63,16 +55,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
)
{
ParentType::clear();
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
const bool mustTriangulate = ParentType::isTri();
IFstream is(fName);
if (!is.good())
@ -167,12 +150,12 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
}
// transfer to normal lists
ParentType::points().transfer(pointLst);
ParentType::faces().transfer(faceLst);
ParentType::storedPoints().transfer(pointLst);
ParentType::storedFaces().transfer(faceLst);
// no region information
ParentType::regions().setSize(ThisType::size());
ParentType::regions() = 0;
ParentType::storedRegions().setSize(ParentType::size());
ParentType::storedRegions() = 0;
ParentType::setPatches(0);
return true;
@ -202,7 +185,7 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
{
const Face& f = faceLst[faceMap[faceIndex++]];
os << f.size();
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
@ -213,7 +196,7 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
}
os << "# </patch>" << endl;
}
os << "# </faces>" << endl;
os << "# </faces>" << endl;
}
@ -238,7 +221,7 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
{
const Face& f = faceLst[faceIndex++];
os << f.size();
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
@ -249,7 +232,7 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
}
os << "# </patch>" << endl;
}
os << "# </faces>" << endl;
os << "# </faces>" << endl;
}
// ************************************************************************* //

View File

@ -70,7 +70,6 @@ class OFFsurfaceFormat
public OFFsurfaceFormatCore
{
//- Private typedefs for convenience
typedef OFFsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -93,9 +92,6 @@ public:
// Constructors
//- Construct null
OFFsurfaceFormat();
//- Construct from file name
OFFsurfaceFormat(const fileName&);
@ -123,6 +119,7 @@ public:
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// The output is sorted by region.
static void write
(
Ostream&,
@ -130,6 +127,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by region.
static void write
(
const fileName& fName,

View File

@ -55,30 +55,16 @@ namespace fileFormats
class OFFsurfaceFormatCore
{
protected:
// Protected Member Functions
// Protected Member Functions
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&,
const label nFaces,
const List<surfGroup>&
);
public:
// Constructors
//- Construct null
OFFsurfaceFormatCore()
{}
// Destructor
~OFFsurfaceFormatCore()
{}
// Member Functions
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&,
const label nFaces,
const List<surfGroup>&
);
};

View File

@ -25,8 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "SMESHsurfaceFormat.H"
#include "clock.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -63,7 +61,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
{
const Face& f = faceLst[faceMap[faceIndex++]];
os << f.size();
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
@ -95,7 +93,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
{
const Face& f = faceLst[faceIndex++];
os << f.size();
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];

View File

@ -67,7 +67,6 @@ class SMESHsurfaceFormat
public SMESHsurfaceFormatCore
{
//- Private typedefs for convenience
typedef SMESHsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -96,6 +95,7 @@ public:
// Member Functions
//- Write UnsortedMeshedSurface
// The output is sorted by region.
static void write
(
Ostream&,
@ -103,6 +103,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by region.
static void write
(
const fileName& fName,

View File

@ -26,7 +26,6 @@ License
#include "SMESHsurfaceFormatCore.H"
#include "clock.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -36,8 +36,6 @@ SourceFiles
#ifndef SMESHsurfaceFormatCore_H
#define SMESHsurfaceFormatCore_H
#include "IFstream.H"
#include "OFstream.H"
#include "Ostream.H"
#include "MeshedSurface.H"
#include "UnsortedMeshedSurface.H"
@ -58,31 +56,16 @@ class SMESHsurfaceFormatCore
protected:
// Protected Member Functions
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&,
const label nFaces
);
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&,
const label nFaces
);
//- Write tail information
static void writeTail(Ostream&);
public:
// Constructors
//- Construct null
SMESHsurfaceFormatCore()
{}
// Destructor
~SMESHsurfaceFormatCore()
{}
// Member Functions
//- Write tail information
static void writeTail(Ostream&);
};

View File

@ -25,16 +25,13 @@ License
\*---------------------------------------------------------------------------*/
#include "STARCDsurfaceFormat.H"
#include "clock.H"
#include "OSspecific.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Face>
void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
(
Ostream& os,
const Face& f,
@ -69,26 +66,6 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::STARCDsurfaceFormat<Face>::STARCDsurfaceFormat()
:
ParentType()
{}
// .vrt file format:
/*---------------------------------------------------------------------------*\
Line 1:
PROSTAR_VERTEX [newline]
Line 2:
<version> 0 0 0 0 0 0 0 [newline]
Body:
<vertexId> <x> <y> <z> [newline]
\*---------------------------------------------------------------------------*/
template<class Face>
Foam::fileFormats::STARCDsurfaceFormat<Face>::STARCDsurfaceFormat
(
@ -102,7 +79,6 @@ Foam::fileFormats::STARCDsurfaceFormat<Face>::STARCDsurfaceFormat
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Face>
bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
(
@ -110,17 +86,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
)
{
ParentType::clear();
// triangulation required?
bool mustTriangulate = false;
{
Face f;
if (f.max_size() == 3)
{
mustTriangulate = true;
}
}
const bool mustTriangulate = ParentType::isTri();
fileName baseName = fName.lessExt();
autoPtr<IFstream> isPtr;
@ -160,7 +126,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
}
// transfer to normal lists
ParentType::points().transfer(pointLst);
ParentType::storedPoints().transfer(pointLst);
// Build inverse mapping (index to point)
pointId.shrink();
@ -294,8 +260,8 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
}
// transfer to normal lists
ParentType::faces().transfer(faceLst);
ParentType::regions().transfer(regionLst);
ParentType::storedFaces().transfer(faceLst);
ParentType::storedRegions().transfer(regionLst);
ParentType::setPatches(regionNames);
@ -310,22 +276,16 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
const UnsortedMeshedSurface<Face>& surf
)
{
const List<Face>& faceLst = surf.faces();
fileName baseName = fName.lessExt();
autoPtr<OFstream> osPtr;
osPtr.reset(new OFstream(baseName + ".vrt"));
writePoints(osPtr(), surf.points());
writePoints(OFstream(baseName + ".vrt")(), surf.points());
OFstream os(baseName + ".cel");
writeHeader(os, "CELL");
const List<Face>& faceLst = surf.faces();
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
osPtr.reset(new OFstream(baseName + ".cel"));
writeHeader(osPtr(), "CELL");
label faceIndex = 0;
forAll(patchLst, patchI)
{
@ -334,10 +294,18 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
forAll(patch, patchFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
writeShell(osPtr(), f, faceIndex, patchI + 1);
writeShell(os, f, faceIndex, patchI + 1);
}
}
// write simple .inp file
writeCase
(
OFstream(baseName + ".inp")(),
surf.points(),
surf.nFaces(),
patchLst
);
}
@ -348,20 +316,15 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
const MeshedSurface<Face>& surf
)
{
fileName baseName = fName.lessExt();
writePoints(OFstream(baseName + ".vrt")(), surf.points());
OFstream os(baseName + ".cel");
writeHeader(os, "CELL");
const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches();
fileName baseName = fName.lessExt();
autoPtr<OFstream> osPtr;
osPtr.reset(new OFstream(baseName + ".vrt"));
writePoints(osPtr(), surf.points());
osPtr.reset(new OFstream(baseName + ".cel"));
writeHeader(osPtr(), "CELL");
label faceIndex = 0;
forAll(patchLst, patchI)
{
@ -370,9 +333,18 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
forAll(patch, patchFaceI)
{
const Face& f = faceLst[faceIndex++];
writeShell(osPtr(), f, faceIndex, patchI + 1);
writeShell(os, f, faceIndex, patchI + 1);
}
}
// write simple .inp file
writeCase
(
OFstream(baseName + ".inp")(),
surf.points(),
surf.nFaces(),
patchLst
);
}
// ************************************************************************* //

View File

@ -42,7 +42,6 @@ SourceFiles
#ifndef STARCDsurfaceFormat_H
#define STARCDsurfaceFormat_H
#include "IFstream.H"
#include "Ostream.H"
#include "OFstream.H"
#include "MeshedSurface.H"
@ -67,7 +66,6 @@ class STARCDsurfaceFormat
public STARCDsurfaceFormatCore
{
//- Private typedefs for convenience
typedef STARCDsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Data
@ -79,12 +77,6 @@ class STARCDsurfaceFormat
// Private Member Functions
//- Disallow default bitwise copy construct
STARCDsurfaceFormat(const STARCDsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const STARCDsurfaceFormat<Face>&);
static inline void writeShell
(
Ostream&,
@ -93,13 +85,16 @@ class STARCDsurfaceFormat
const label cellTableId
);
//- Disallow default bitwise copy construct
STARCDsurfaceFormat(const STARCDsurfaceFormat<Face>&);
//- Disallow default bitwise assignment
void operator=(const STARCDsurfaceFormat<Face>&);
public:
// Constructors
//- Construct null
STARCDsurfaceFormat();
//- Construct from file name
STARCDsurfaceFormat(const fileName&);
@ -128,10 +123,19 @@ public:
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
// The output is sorted by regions
static void write
(
const fileName&,
const UnsortedMeshedSurface<Face>&
);
//- Write MeshedSurface
static void write(const fileName&, const MeshedSurface<Face>&);
static void write
(
const fileName&,
const MeshedSurface<Face>&
);
//- Write to Ostream as one large file - not really useful
virtual void write(Ostream&) const

View File

@ -26,17 +26,10 @@ License
#include "STARCDsurfaceFormatCore.H"
#include "clock.H"
#include "OSspecific.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
//! @cond localscope
const int starcdShellShape = 3;
const int starcdShellType = 4;
//! @endcond localscope
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::fileFormats::STARCDsurfaceFormatCore::readHeader
@ -121,6 +114,43 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writePoints
os.flush();
}
void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
(
Ostream& os,
const pointField& pointLst,
const label nFaces,
const List<surfGroup>& patchLst
)
{
word caseName = os.name().lessExt().name();
os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
<< "! " << pointLst.size() << " points, " << nFaces << " faces" << nl
<< "! case " << caseName << nl
<< "! ------------------------------" << nl;
forAll(patchLst, patchI)
{
os << "ctable " << patchI + 1 << " shell" << nl
<< "ctname " << patchI + 1 << " " << patchLst[patchI].name() << nl;
}
os << "! ------------------------------" << nl
<< "*set icvo mxv - 1" << nl
<< "vread " << caseName << ".vrt icvo,,,coded" << nl
<< "cread " << caseName << ".cel icvo,,,add,coded" << nl
<< "*set icvo" << nl
<< "! end" << nl;
os.flush();
}
#if 0
#endif
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -38,7 +38,6 @@ SourceFiles
#include "IFstream.H"
#include "Ostream.H"
#include "OFstream.H"
#include "MeshedSurface.H"
#include "UnsortedMeshedSurface.H"
@ -58,25 +57,19 @@ class STARCDsurfaceFormatCore
protected:
// Protected Member Functions
static bool readHeader(IFstream&, const word&);
static bool readHeader(IFstream&, const word&);
static void writeHeader(Ostream&, const char* filetype);
static void writeHeader(Ostream&, const char* filetype);
static void writePoints(Ostream&, const pointField&);
static void writePoints(Ostream&, const pointField&);
public:
// Constructors
//- Construct null
STARCDsurfaceFormatCore()
{}
// Destructor
~STARCDsurfaceFormatCore()
{}
// Member Functions
static void writeCase
(
Ostream&,
const pointField&,
const label nFaces,
const List<surfGroup>&
);
};

View File

@ -59,21 +59,34 @@ public:
// Constructors
//- Construct null
inline STLpoint();
inline STLpoint()
{}
//- Construct from components
inline STLpoint(float x, float y, float z);
inline STLpoint(float x, float y, float z)
:
Vector<float>(x, y, z)
{}
//- Construct from point
inline STLpoint(const point&);
inline STLpoint(const point& pt)
:
Vector<float>(float(pt.x()), float(pt.y()), float(pt.z()))
{}
//- Construct from istream
inline STLpoint(Istream&);
inline STLpoint(Istream& is)
:
Vector<float>(is)
{}
// Member Operators
inline operator point() const;
inline operator point() const
{
return point(x(), y(), z());
}
};
@ -84,10 +97,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "STLpointI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,60 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::STLpoint::STLpoint()
{}
inline Foam::STLpoint::STLpoint(float x, float y, float z)
:
Vector<float>(x, y, z)
{}
inline Foam::STLpoint::STLpoint(const point& pt)
:
Vector<float>(float(pt.x()), float(pt.y()), float(pt.z()))
{}
inline Foam::STLpoint::STLpoint(Istream& is)
:
Vector<float>(is)
{}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline Foam::STLpoint::operator point() const
{
return point(x(), y(), z());
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -50,17 +50,14 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
const point& p2 = pointLst[f[fp2]];
// write STL triangle
os << " facet normal "
os << " facet normal "
<< norm.x() << ' ' << norm.y() << ' ' << norm.z() << nl
<< " outer loop\n"
<< " vertex "
<< p0.x() << ' ' << p0.y() << ' ' << p0.z() << nl
<< " vertex "
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl
<< " vertex "
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << nl
<< " endloop\n"
<< " endfacet" << endl;
<< " outer loop\n"
<< " vertex " << p0.x() << ' ' << p0.y() << ' ' << p0.z() << nl
<< " vertex " << p1.x() << ' ' << p1.y() << ' ' << p1.z() << nl
<< " vertex " << p2.x() << ' ' << p2.y() << ' ' << p2.z() << nl
<< " endloop\n"
<< " endfacet" << endl;
}
}
@ -108,24 +105,37 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
const List<Face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals();
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0;
forAll(patchLst, patchI)
if (surf.patches().size() == 1)
{
// Print all faces belonging to this region
const surfGroup& patch = patchLst[patchI];
os << "solid " << patch.name() << endl;
forAll(patch, patchFaceI)
// a single region - we can skip sorting
os << "solid " << surf.patches()[0].name() << endl;
forAll(faceLst, faceI)
{
const label faceI = faceMap[faceIndex++];
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << patch.name() << endl;
os << "endsolid " << surf.patches()[0].name() << endl;
}
else
{
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0;
forAll(patchLst, patchI)
{
// Print all faces belonging to this region
const surfGroup& patch = patchLst[patchI];
os << "solid " << patch.name() << endl;
forAll(patch, patchFaceI)
{
const label faceI = faceMap[faceIndex++];
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << patch.name() << endl;
}
}
}
@ -143,7 +153,6 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
const List<surfGroup>& patchLst = surf.patches();
const vectorField& normLst = surf.faceNormals();
// force triangulation, but just do the cheapest form possible
label faceIndex = 0;
forAll(patchLst, patchI)
{
@ -151,13 +160,11 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
const surfGroup& patch = patchLst[patchI];
os << "solid " << patch.name() << endl;
forAll(patch, patchFaceI)
{
const label faceI = faceIndex++;
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << patch.name() << endl;
}
}
@ -176,17 +183,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
const List<label>& regionLst = surf.regions();
const vectorField& normLst = surf.faceNormals();
// Write the STL header
STLsurfaceFormatCore::writeHeaderBINARY(os);
// force triangulation, but just do the cheapest form possible
unsigned int nTris = 0;
forAll(faceLst, faceI)
if (surf.isTri())
{
nTris += faceLst[faceI].size() - 2;
nTris = faceLst.size();
}
else
{
// count triangles for on-the-fly triangulation
forAll(faceLst, faceI)
{
nTris += faceLst[faceI].size() - 2;
}
}
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
// Write the STL header
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
// always write unsorted
forAll(faceLst, faceI)
@ -215,17 +227,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
const vectorField& normLst = surf.faceNormals();
const List<surfGroup>& patchLst = surf.patches();
// Write the STL header
STLsurfaceFormatCore::writeHeaderBINARY(os);
// force triangulation, but just do the cheapest form possible
unsigned int nTris = 0;
forAll(faceLst, faceI)
if (surf.isTri())
{
nTris += faceLst[faceI].size() - 2;
nTris = faceLst.size();
}
else
{
// count triangles for on-the-fly triangulation
forAll(faceLst, faceI)
{
nTris += faceLst[faceI].size() - 2;
}
}
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
// Write the STL header
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
label faceIndex = 0;
forAll(patchLst, patchI)
@ -249,13 +266,6 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::STLsurfaceFormat<Face>::STLsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::STLsurfaceFormat<Face>::STLsurfaceFormat
(
@ -264,7 +274,7 @@ Foam::fileFormats::STLsurfaceFormat<Face>::STLsurfaceFormat
:
ParentType()
{
ThisType::read(fName);
read(fName);
}
@ -281,16 +291,13 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
// read in the values
STLsurfaceFormatCore reader(fName);
pointField& pointLst = ParentType::points();
List<Face>& faceLst = ParentType::faces();
List<label>& regionLst = ParentType::regions();
// transfer
pointLst.transfer(reader.points());
regionLst.transfer(reader.regions());
ParentType::storedPoints().transfer(reader.points());
ParentType::storedRegions().transfer(reader.regions());
// assemble the faces:
faceLst.setSize(regionLst.size());
// generate the faces:
List<Face>& faceLst = ParentType::storedFaces();
faceLst.setSize(ParentType::regions().size());
label ptI = 0;
forAll(faceLst, faceI)

View File

@ -58,7 +58,6 @@ class STLsurfaceFormat
public UnsortedMeshedSurface<Face>
{
//- Private typedefs for convenience
typedef STLsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private data
@ -107,9 +106,6 @@ public:
// Constructors
//- Construct null
STLsurfaceFormat();
//- Construct from file name
STLsurfaceFormat(const fileName&);
@ -137,7 +133,7 @@ public:
//- Read from file
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface (as ASCII)
//- Write UnsortedMeshedSurface (as ASCII) sorted by region
static void write
(
Ostream&,
@ -152,7 +148,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The ASCII output is sorted by patch, the binary output is unsorted
// ASCII output is sorted by region; binary output is unsorted
static void write
(
const fileName&,
@ -160,7 +156,6 @@ public:
);
//- Write MeshedSurface
// The ASCII output is sorted by patch, the binary output is unsorted
static void write
(
const fileName&,

View File

@ -149,7 +149,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
// Read an STL triangle
STLtriangle stlTri(is);
// transcript the vertices of the STL triangle -> points
// transcribe the vertices of the STL triangle -> points
points_[ptI++] = stlTri.a();
points_[ptI++] = stlTri.b();
points_[ptI++] = stlTri.c();
@ -173,13 +173,13 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
Info<< "solid region" << prevRegion << nl;
}
Info<< " facet normal " << stlTri.normal() << nl;
Info<< " outer loop" << nl;
Info<< " vertex " << stlTri.a() << nl;
Info<< " vertex " << stlTri.b() << nl;
Info<< " vertex " << stlTri.c() << nl;
Info<< " outer loop" << nl;
Info<< " endfacet" << endl;
Info<< " facet normal " << stlTri.normal() << nl
<< " outer loop" << nl
<< " vertex " << stlTri.a() << nl
<< " vertex " << stlTri.b() << nl
<< " vertex " << stlTri.c() << nl
<< " outer loop" << nl
<< " endfacet" << endl;
#endif
}
@ -222,7 +222,11 @@ Foam::fileFormats::STLsurfaceFormatCore::~STLsurfaceFormatCore()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fileFormats::STLsurfaceFormatCore::writeHeaderBINARY(ostream& os)
void Foam::fileFormats::STLsurfaceFormatCore::writeHeaderBINARY
(
ostream& os,
unsigned int nTris
)
{
// Write the STL header, avoid possible trailing junk
string header("STL binary file", headerSize);
@ -231,6 +235,9 @@ void Foam::fileFormats::STLsurfaceFormatCore::writeHeaderBINARY(ostream& os)
header[i] = 0;
}
os.write(header.c_str(), headerSize);
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
}
// ************************************************************************* //

View File

@ -96,16 +96,13 @@ public:
// Static Member Functions
//- Write "STL binary file" to stream
static void writeHeaderBINARY(ostream&);
//- Write "STL binary file" and number of triangles to stream
static void writeHeaderBINARY(ostream&, unsigned int);
// Constructors
//- Read from file, filling in the information
STLsurfaceFormatCore
(
const fileName&
);
STLsurfaceFormatCore(const fileName&);
// Destructor

View File

@ -25,7 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "TRIsurfaceFormat.H"
#include "clock.H"
#include "IFstream.H"
#include "IOmanip.H"
#include "IStringStream.H"
@ -64,13 +63,6 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::fileFormats::TRIsurfaceFormat<Face>::TRIsurfaceFormat()
:
ParentType()
{}
template<class Face>
Foam::fileFormats::TRIsurfaceFormat<Face>::TRIsurfaceFormat
(
@ -190,11 +182,11 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
}
// transfer to normal list
ParentType::points().transfer(pointLst);
ParentType::regions().transfer(regionLst);
ParentType::storedPoints().transfer(pointLst);
ParentType::storedRegions().transfer(regionLst);
// make our triangles directly
List<Face>& faceLst = ParentType::faces();
List<Face>& faceLst = ParentType::storedFaces();
faceLst.setSize(ParentType::regions().size());
label ptI = 0;
@ -225,16 +217,35 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0;
forAll(patchLst, patchI)
bool doSort = false;
// a single region needs no sorting
if (surf.patches().size() == 1)
{
forAll(patchLst[patchI], patchFaceI)
doSort = false;
}
if (doSort)
{
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0;
forAll(patchLst, patchI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
writeShell(os, pointLst, f, patchI);
forAll(patchLst[patchI], patchFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
writeShell(os, pointLst, f, patchI);
}
}
}
else
{
const List<label>& regionLst = surf.regions();
forAll(faceLst, faceI)
{
writeShell(os, pointLst, faceLst[faceI], regionLst[faceI]);
}
}
}

View File

@ -58,7 +58,6 @@ class TRIsurfaceFormat
public UnsortedMeshedSurface<Face>
{
//- Private typedefs for convenience
typedef TRIsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -81,9 +80,6 @@ public:
// Constructors
//- Construct null
TRIsurfaceFormat();
//- Construct from file name
TRIsurfaceFormat(const fileName&);
@ -111,6 +107,7 @@ public:
virtual bool read(const fileName&);
//- Write UnsortedMeshedSurface
// By default, the output is not sorted by regions
static void write
(
Ostream&,
@ -118,6 +115,7 @@ public:
);
//- Write UnsortedMeshedSurface
// By default, the output is not sorted by regions
static void write
(
const fileName& fName,
@ -145,6 +143,7 @@ public:
}
//- Write object
// By default, the output is not sorted by regions
virtual void write(Ostream& os) const
{
write(os, *this);

View File

@ -25,9 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "VTKsurfaceFormat.H"
#include "clock.H"
#include "IFstream.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -75,27 +72,57 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
writeHeader(os, surf.points());
writeHeaderPolygons(os, faceLst);
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0;
forAll(patchLst, patchI)
bool doSort = false;
// a single region needs no sorting
if (surf.patches().size() == 1)
{
forAll(patchLst[patchI], patchFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
}
os << ' ' << nl;
}
doSort = false;
}
// Print region numbers
writeTail(os, patchLst);
if (doSort)
{
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0;
forAll(patchLst, patchI)
{
forAll(patchLst[patchI], patchFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
}
os << ' ' << nl;
}
}
// Print region numbers
writeTail(os, patchLst);
}
else
{
labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
forAll(faceLst, faceI)
{
const Face& f = faceLst[faceI];
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
}
os << ' ' << nl;
}
// Print region numbers
writeTail(os, surf.regions());
}
}
@ -119,12 +146,12 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
{
const Face& f = faceLst[faceIndex++];
os << f.size();
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
os << ' ' << f[fp];
}
os << ' ' << nl;
os << ' ' << nl;
}
}

View File

@ -60,7 +60,6 @@ class VTKsurfaceFormat
public VTKsurfaceFormatCore
{
//- Private typedefs for convenience
typedef VTKsurfaceFormat<Face> ThisType;
typedef UnsortedMeshedSurface<Face> ParentType;
// Private Member Functions
@ -94,6 +93,7 @@ public:
// Write
//- Write UnsortedMeshedSurface
// By default, the output is not sorted by regions.
static void write
(
Ostream&,
@ -101,6 +101,7 @@ public:
);
//- Write UnsortedMeshedSurface
// By default, the output is not sorted by regions.
static void write
(
const fileName& fName,

View File

@ -26,8 +26,6 @@ License
#include "VTKsurfaceFormatCore.H"
#include "clock.H"
#include "IFstream.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -84,11 +82,11 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
{
if ((patchFaceI % 20) == 0)
{
os << nl;
os << nl;
}
else
{
os << ' ';
os << ' ';
}
}
os << patchI + 1;
@ -98,6 +96,38 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
}
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
(
Ostream& os,
const List<label>& regionLst
)
{
// Print region numbers
os << nl
<< "CELL_DATA " << regionLst.size() << nl
<< "FIELD attributes 1" << nl
<< "region 1 " << regionLst.size() << " float" << nl;
forAll(regionLst, faceI)
{
if (faceI)
{
if ((faceI % 20) == 0)
{
os << nl;
}
else
{
os << ' ';
}
}
os << regionLst[faceI] + 1;
}
os << nl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -57,30 +57,18 @@ class VTKsurfaceFormatCore
protected:
// Protected Member Functions
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&
);
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&
);
//- Write header information with patch informattion
static void writeTail(Ostream&, const List<surfGroup>&);
//- Write trailing information with patch information
static void writeTail(Ostream&, const List<surfGroup>&);
public:
// Constructors
//- Construct null
VTKsurfaceFormatCore()
{}
// Destructor
virtual ~VTKsurfaceFormatCore()
{}
// Member Functions
//- Write trailing information with region information
static void writeTail(Ostream&, const List<label>& regionLst);
};