mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
reworked keyedSurface to store region information indirectly
- improves efficiency throughout
This commit is contained in:
@ -40,6 +40,9 @@ Usage
|
||||
@param -triSurface \n
|
||||
Use triSurface library for input/output
|
||||
|
||||
@param -keyed \n
|
||||
Use keyedSurface for input/output
|
||||
|
||||
Note
|
||||
The filename extensions are used to determine the file format type.
|
||||
|
||||
@ -49,6 +52,7 @@ Note
|
||||
#include "timeSelector.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "keyedSurface.H"
|
||||
#include "meshedSurface.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
@ -65,6 +69,7 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("clean", "");
|
||||
argList::validOptions.insert("scale", "scale");
|
||||
argList::validOptions.insert("triSurface", "");
|
||||
argList::validOptions.insert("keyed", "");
|
||||
# include "setRootCase.H"
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
@ -113,6 +118,31 @@ int main(int argc, char *argv[])
|
||||
Info<< " with scaling " << scaleFactor << endl;
|
||||
surf.scalePoints(scaleFactor);
|
||||
}
|
||||
|
||||
// write sorted by region
|
||||
surf.write(exportName, true);
|
||||
}
|
||||
else if (args.options().found("keyed"))
|
||||
{
|
||||
keyedSurface 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);
|
||||
}
|
||||
else
|
||||
|
||||
@ -232,7 +232,8 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
|
||||
label patchVertOffset = 0;
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<keyedFace> faceLst;
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
|
||||
// patchId => patchName
|
||||
Map<word> regionNames;
|
||||
@ -339,7 +340,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
|
||||
|
||||
label nVert = parse<int>(args);
|
||||
|
||||
List<label> verts(nVert);
|
||||
face verts(nVert);
|
||||
forAll(verts, vertI)
|
||||
{
|
||||
is.getLine(line);
|
||||
@ -361,12 +362,14 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
|
||||
fTri[1] = verts[fp1];
|
||||
fTri[2] = verts[fp2];
|
||||
|
||||
faceLst.append(keyedFace(fTri, patchI));
|
||||
faceLst.append(fTri);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(keyedFace(face(verts), patchI));
|
||||
faceLst.append(verts);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,13 +405,13 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
regions().transfer(regionLst);
|
||||
|
||||
setPatches(regionNames);
|
||||
stitchFaces(SMALL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::AC3DfileFormat::writeHeader
|
||||
@ -508,7 +511,7 @@ void Foam::fileFormats::AC3DfileFormat::write
|
||||
|
||||
forAll(patch.localFaces(), faceI)
|
||||
{
|
||||
const keyedFace& f = patch.localFaces()[faceI];
|
||||
const face& f = patch.localFaces()[faceI];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << patchI << nl
|
||||
@ -569,7 +572,7 @@ void Foam::fileFormats::AC3DfileFormat::write
|
||||
|
||||
forAll(patch.localFaces(), faceI)
|
||||
{
|
||||
const keyedFace& f = patch.localFaces()[faceI];
|
||||
const face& f = patch.localFaces()[faceI];
|
||||
|
||||
os << "SURF 0x20" << nl // polygon
|
||||
<< "mat " << patchI << nl
|
||||
|
||||
@ -70,6 +70,7 @@ addNamedToMemberFunctionSelectionTable
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::GTSfileFormat::GTSfileFormat()
|
||||
@ -111,7 +112,16 @@ Foam::fileFormats::GTSfileFormat::GTSfileFormat
|
||||
>> nElems;
|
||||
}
|
||||
|
||||
pointField pointLst(nPoints);
|
||||
|
||||
// write directly into the lists:
|
||||
pointField& pointLst = points();
|
||||
List<face>& faceLst = faces();
|
||||
List<label>& regionLst = regions();
|
||||
|
||||
pointLst.setSize(nPoints);
|
||||
faceLst.setSize(nElems);
|
||||
regionLst.setSize(nElems);
|
||||
|
||||
|
||||
// Read points
|
||||
forAll(pointLst, pointI)
|
||||
@ -143,14 +153,11 @@ Foam::fileFormats::GTSfileFormat::GTSfileFormat
|
||||
|
||||
|
||||
// Read triangles. Convert references to edges into pointlabels
|
||||
List<keyedFace> faceLst(nElems);
|
||||
|
||||
label maxPatch = 0;
|
||||
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
label e0Label, e1Label, e2Label;
|
||||
label region = 0;
|
||||
label regionI = 0;
|
||||
|
||||
line = getLineNoComment(is);
|
||||
{
|
||||
@ -165,10 +172,10 @@ Foam::fileFormats::GTSfileFormat::GTSfileFormat
|
||||
lineStream >> num;
|
||||
if (!lineStream.bad())
|
||||
{
|
||||
region = num;
|
||||
if (maxPatch < region)
|
||||
regionI = num;
|
||||
if (maxPatch < regionI)
|
||||
{
|
||||
maxPatch = region;
|
||||
maxPatch = regionI;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -232,25 +239,21 @@ Foam::fileFormats::GTSfileFormat::GTSfileFormat
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
keyedFace lface(face(3), region);
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
|
||||
lface[0] = e0Far;
|
||||
lface[1] = common01;
|
||||
lface[2] = e1Far;
|
||||
fTri[0] = e0Far;
|
||||
fTri[1] = common01;
|
||||
fTri[2] = e1Far;
|
||||
|
||||
faceLst[faceI] = lface;
|
||||
regionLst[faceI] = regionI;
|
||||
}
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
setPatches(maxPatch);
|
||||
// stitchFaces(SMALL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::GTSfileFormat::write
|
||||
@ -260,7 +263,7 @@ void Foam::fileFormats::GTSfileFormat::write
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
// just issue a warning and get out
|
||||
@ -353,8 +356,8 @@ void Foam::fileFormats::GTSfileFormat::write
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<surfacePatch>& patchLst = surf.patches();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<surfacePatch>& patchLst = surf.patches();
|
||||
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
// just issue a warning and get out
|
||||
@ -416,7 +419,6 @@ void Foam::fileFormats::GTSfileFormat::write
|
||||
<< meshPts[es[edgei].end()] + 1 << endl;
|
||||
}
|
||||
|
||||
|
||||
// Write faces in terms of edges.
|
||||
const labelListList& faceEs = surf.faceEdges();
|
||||
|
||||
|
||||
@ -128,7 +128,8 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
DynamicList<point> pointLst;
|
||||
// Nastran index of points
|
||||
DynamicList<label> pointId;
|
||||
DynamicList<keyedFace> faceLst;
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
|
||||
// From face groupId to patchId
|
||||
@ -283,7 +284,8 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
patchI = iter();
|
||||
}
|
||||
|
||||
faceLst.append(keyedFace(fTri, patchI));
|
||||
faceLst.append(fTri);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
else if (cmd == "CQUAD4")
|
||||
{
|
||||
@ -324,12 +326,14 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
fTri[1] = fQuad[fp1];
|
||||
fTri[2] = fQuad[fp2];
|
||||
|
||||
faceLst.append(keyedFace(fTri, patchI));
|
||||
faceLst.append(fTri);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(keyedFace(fQuad, patchI));
|
||||
faceLst.append(fQuad);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
else if (cmd == "PSHELL")
|
||||
@ -401,6 +405,7 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
regions().transfer(regionLst);
|
||||
|
||||
pointId.shrink();
|
||||
faceLst.shrink();
|
||||
@ -418,7 +423,7 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
// Relabel faces
|
||||
forAll(faceLst, i)
|
||||
{
|
||||
keyedFace& f = faceLst[i];
|
||||
face& f = faceLst[i];
|
||||
forAll(f, fp)
|
||||
{
|
||||
f[fp] = nasToFoamPoint[f[fp]];
|
||||
@ -441,21 +446,10 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
|
||||
// transfer to normal lists
|
||||
faces().transfer(faceLst);
|
||||
|
||||
setPatches(regionNames);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -68,6 +68,46 @@ addNamedToMemberFunctionSelectionTable
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::OBJfileFormat::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst,
|
||||
const List<surfacePatch>& patchLst
|
||||
)
|
||||
{
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << "v " << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::OBJfileFormat::OBJfileFormat()
|
||||
@ -94,7 +134,8 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
}
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<keyedFace> faceLst;
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
|
||||
// leave faces that didn't have a group in 0
|
||||
@ -156,7 +197,8 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
|
||||
while (true)
|
||||
{
|
||||
string::size_type startNum = line.find_first_not_of(' ', endNum);
|
||||
string::size_type startNum =
|
||||
line.find_first_not_of(' ', endNum);
|
||||
|
||||
if (startNum == string::size_type(string::npos))
|
||||
{
|
||||
@ -208,19 +250,14 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
fTri[1] = verts[fp1];
|
||||
fTri[2] = verts[fp2];
|
||||
|
||||
faceLst.append(keyedFace(fTri, groupID));
|
||||
faceLst.append(fTri);
|
||||
regionLst.append(groupID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append
|
||||
(
|
||||
keyedFace
|
||||
(
|
||||
face( xferMoveTo<labelList>(verts) ),
|
||||
groupID
|
||||
)
|
||||
);
|
||||
faceLst.append(face(verts));
|
||||
regionLst.append(groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,12 +265,12 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
regions().transfer(regionLst);
|
||||
|
||||
setPatches(groupToPatch);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::OBJfileFormat::write
|
||||
@ -242,40 +279,12 @@ void Foam::fileFormats::OBJfileFormat::write
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << "v " << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -308,38 +317,10 @@ void Foam::fileFormats::OBJfileFormat::write
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<surfacePatch>& patchLst = surf.patches();
|
||||
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << "v " << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -363,9 +344,4 @@ void Foam::fileFormats::OBJfileFormat::write
|
||||
os << "# </faces>" << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -67,6 +67,14 @@ class OBJfileFormat
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const OBJfileFormat&);
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<face>&,
|
||||
const List<surfacePatch>&
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -68,6 +68,51 @@ addNamedToMemberFunctionSelectionTable
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::OFFfileFormat::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst,
|
||||
const List<surfacePatch>& patchLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
os << "OFF" << endl
|
||||
<< "# Geomview OFF file written " << clock::dateTime().c_str() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# nPoints nFaces nEdges" << nl
|
||||
<< pointLst.size() << ' ' << faceLst.size() << ' ' << 0 << nl;
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << pointLst[ptI].x() << ' '
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << " #" << ptI << endl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::OFFfileFormat::OFFfileFormat()
|
||||
@ -128,7 +173,7 @@ Foam::fileFormats::OFFfileFormat::OFFfileFormat
|
||||
|
||||
// Read faces - ignore optional region information
|
||||
// use a DynamicList for possible on-the-fly triangulation
|
||||
DynamicList<keyedFace> faceLst(nElems);
|
||||
DynamicList<face> faceLst(nElems);
|
||||
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
@ -160,24 +205,28 @@ Foam::fileFormats::OFFfileFormat::OFFfileFormat
|
||||
fTri[1] = f[fp1];
|
||||
fTri[2] = f[fp2];
|
||||
|
||||
faceLst.append(keyedFace(fTri, 0));
|
||||
faceLst.append(fTri);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(keyedFace(f, 0));
|
||||
faceLst.append(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no region information
|
||||
// transfer to normal lists
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
|
||||
// no region information
|
||||
regions().setSize(nFaces());
|
||||
regions() = 0;
|
||||
|
||||
setPatches(0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -187,45 +236,12 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
// Write header
|
||||
os << "OFF" << endl
|
||||
<< "# Geomview OFF file written " << clock::dateTime().c_str() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# nPoints nFaces nEdges" << nl
|
||||
<< pointLst.size() << ' ' << faceLst.size() << ' ' << 0 << nl;
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << pointLst[ptI].x() << ' '
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << " #" << ptI << endl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -257,43 +273,10 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<surfacePatch>& patchLst = surf.patches();
|
||||
|
||||
// Write header
|
||||
os << "OFF" << endl
|
||||
<< "# Geomview OFF file written " << clock::dateTime().c_str() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "# nPoints nFaces nEdges" << nl
|
||||
<< pointLst.size() << ' ' << faceLst.size() << ' ' << 0 << nl;
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << pointLst[ptI].x() << ' '
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << " #" << ptI << endl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -318,9 +301,4 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
os << "# </faces>" << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -74,6 +74,14 @@ class OFFfileFormat
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const OFFfileFormat&);
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<face>&,
|
||||
const List<surfacePatch>&
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -60,29 +60,14 @@ addNamedToMemberFunctionSelectionTable
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
Foam::fileFormats::SMESHfileFormat::SMESHfileFormat()
|
||||
:
|
||||
keyedSurface()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::fileFormats::SMESHfileFormat::write
|
||||
void Foam::fileFormats::SMESHfileFormat::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst
|
||||
)
|
||||
{
|
||||
const pointField& pointLst= surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
// Write header
|
||||
os << "# tetgen .smesh file written " << clock::dateTime().c_str() << nl;
|
||||
os << "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
os << pointLst.size() << " 3" << nl; // 3: dimensions
|
||||
@ -100,6 +85,41 @@ Foam::fileFormats::SMESHfileFormat::write
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
|
||||
os << faceLst.size() << " 1" << endl; // one attribute: region number
|
||||
}
|
||||
|
||||
|
||||
void Foam::fileFormats::SMESHfileFormat::writeTail(Ostream& os)
|
||||
{
|
||||
os << "# </faces>" << nl
|
||||
<< nl
|
||||
<< "# no holes or regions:" << nl
|
||||
<< '0' << nl // holes
|
||||
<< '0' << endl; // regions
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileFormats::SMESHfileFormat::SMESHfileFormat()
|
||||
:
|
||||
keyedSurface()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::fileFormats::SMESHfileFormat::write
|
||||
(
|
||||
Ostream& os,
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
|
||||
labelList faceMap;
|
||||
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -117,11 +137,7 @@ Foam::fileFormats::SMESHfileFormat::write
|
||||
}
|
||||
}
|
||||
|
||||
os << "# </faces>" << nl
|
||||
<< nl
|
||||
<< "# no holes or regions:" << nl
|
||||
<< '0' << nl // holes
|
||||
<< '0' << endl; // regions
|
||||
writeTail(os);
|
||||
}
|
||||
|
||||
|
||||
@ -132,27 +148,10 @@ Foam::fileFormats::SMESHfileFormat::write
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst= surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<surfacePatch>& patchLst = surf.patches();
|
||||
|
||||
os << "# tetgen .smesh file written " << clock::dateTime().c_str() << nl;
|
||||
os << "# <points count=\"" << pointLst.size() << "\">" << endl;
|
||||
os << pointLst.size() << " 3" << nl; // 3: dimensions
|
||||
|
||||
// Write vertex coords
|
||||
forAll(pointLst, ptI)
|
||||
{
|
||||
os << ptI
|
||||
<< ' ' << pointLst[ptI].x()
|
||||
<< ' ' << pointLst[ptI].y()
|
||||
<< ' ' << pointLst[ptI].z() << nl;
|
||||
}
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faceLst.size() << "\">" << endl;
|
||||
|
||||
os << faceLst.size() << " 1" << endl; // one attribute: region number
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -170,16 +169,8 @@ Foam::fileFormats::SMESHfileFormat::write
|
||||
}
|
||||
}
|
||||
|
||||
os << "# </faces>" << nl
|
||||
<< nl
|
||||
<< "# no holes or regions:" << nl
|
||||
<< '0' << nl // holes
|
||||
<< '0' << endl; // regions
|
||||
writeTail(os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -73,6 +73,9 @@ class SMESHfileFormat
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const SMESHfileFormat&);
|
||||
|
||||
static void writeHead(Ostream&, const pointField&, const List<face>&);
|
||||
static void writeTail(Ostream&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -66,10 +66,10 @@ addNamedToMemberFunctionSelectionTable
|
||||
}
|
||||
}
|
||||
|
||||
//! @cond localScope
|
||||
//! @cond localscope
|
||||
const int starcdShellShape = 3;
|
||||
const int starcdShellType = 4;
|
||||
//! @endcond localScope
|
||||
//! @endcond localscope
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -226,7 +226,7 @@ Foam::fileFormats::STARCDfileFormat::STARCDfileFormat
|
||||
|
||||
//
|
||||
// read .vrt file
|
||||
//
|
||||
// ~~~~~~~~~~~~~~
|
||||
isPtr.reset(new IFstream(baseName + ".vrt"));
|
||||
|
||||
if (!isPtr().good())
|
||||
@ -266,7 +266,8 @@ Foam::fileFormats::STARCDfileFormat::STARCDfileFormat
|
||||
pointId.clear();
|
||||
|
||||
|
||||
DynamicList<keyedFace> faceLst;
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
|
||||
// From face cellTableId to patchId
|
||||
Map<label> cellTableToPatchId;
|
||||
@ -275,7 +276,7 @@ Foam::fileFormats::STARCDfileFormat::STARCDfileFormat
|
||||
|
||||
//
|
||||
// read .cel file
|
||||
//
|
||||
// ~~~~~~~~~~~~~~
|
||||
isPtr.reset(new IFstream(baseName + ".cel"));
|
||||
|
||||
if (!isPtr().good())
|
||||
@ -351,26 +352,17 @@ Foam::fileFormats::STARCDfileFormat::STARCDfileFormat
|
||||
|
||||
forAll(triFaces, faceI)
|
||||
{
|
||||
faceLst.append
|
||||
(
|
||||
keyedFace
|
||||
(
|
||||
triFaces[faceI],
|
||||
patchI
|
||||
)
|
||||
);
|
||||
faceLst.append(triFaces[faceI]);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append
|
||||
(
|
||||
keyedFace
|
||||
(
|
||||
face(SubList<label>(starLabels, nLabels)),
|
||||
patchI
|
||||
)
|
||||
face(SubList<label>(starLabels, nLabels))
|
||||
);
|
||||
regionLst.append(patchI);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -390,22 +382,20 @@ Foam::fileFormats::STARCDfileFormat::STARCDfileFormat
|
||||
|
||||
// transfer to normal lists
|
||||
faces().transfer(faceLst);
|
||||
regions().transfer(regionLst);
|
||||
|
||||
setPatches(regionNames);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDfileFormat::write
|
||||
(
|
||||
const fileName& fName,
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
|
||||
fileName baseName = fName.lessExt();
|
||||
autoPtr<OFstream> osPtr;
|
||||
@ -436,7 +426,6 @@ void Foam::fileFormats::STARCDfileFormat::write
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::fileFormats::STARCDfileFormat::write
|
||||
(
|
||||
const fileName& fName,
|
||||
@ -470,9 +459,4 @@ void Foam::fileFormats::STARCDfileFormat::write
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -93,7 +93,6 @@ addNamedToMemberFunctionSelectionTable
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// check binary by getting the header and number of facets
|
||||
// this seems to work better than the old token-based method
|
||||
// - some programs (eg, pro-STAR) have 'solid' as the first word in
|
||||
@ -197,29 +196,38 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
|
||||
#endif
|
||||
|
||||
|
||||
pointField pointLst(3*nTris);
|
||||
List<keyedFace> faceLst(nTris);
|
||||
// write directly into the lists:
|
||||
pointField& pointLst = points();
|
||||
List<face>& faceLst = faces();
|
||||
List<label>& regionLst = regions();
|
||||
|
||||
pointLst.setSize(3*nTris);
|
||||
faceLst.setSize(nTris);
|
||||
regionLst.setSize(nTris);
|
||||
|
||||
label maxRegionId = 0;
|
||||
|
||||
label pointI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
|
||||
|
||||
// Read an STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
|
||||
// Set the rawPoints to the vertices of the STL triangle
|
||||
// and set the point labels of the face
|
||||
face f(3);
|
||||
|
||||
pointLst[pointI] = stlTri.a();
|
||||
f[0] = pointI++;
|
||||
fTri[0] = pointI++;
|
||||
|
||||
pointLst[pointI] = stlTri.b();
|
||||
f[1] = pointI++;
|
||||
fTri[1] = pointI++;
|
||||
|
||||
pointLst[pointI] = stlTri.c();
|
||||
f[2] = pointI++;
|
||||
fTri[2] = pointI++;
|
||||
|
||||
if (maxRegionId < stlTri.region())
|
||||
{
|
||||
@ -227,7 +235,7 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
|
||||
}
|
||||
|
||||
// interprete colour as a region
|
||||
faceLst[faceI] = keyedFace(f, stlTri.region());
|
||||
regionLst[faceI] = stlTri.region();
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
if
|
||||
@ -257,8 +265,6 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
|
||||
Info<< "endsolid region" << prevRegion << nl;
|
||||
#endif
|
||||
|
||||
points().transfer(pointLst);
|
||||
faces().transfer(faceLst);
|
||||
setPatches(maxRegionId);
|
||||
stitchFaces(SMALL);
|
||||
|
||||
@ -340,7 +346,7 @@ void Foam::fileFormats::STLfileFormat::writeASCII
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
labelList faceMap;
|
||||
@ -406,7 +412,8 @@ void Foam::fileFormats::STLfileFormat::writeBINARY
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
// Write the STL header
|
||||
@ -428,6 +435,7 @@ void Foam::fileFormats::STLfileFormat::writeBINARY
|
||||
|
||||
os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int));
|
||||
|
||||
// always write unsorted
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
writeShell
|
||||
@ -436,7 +444,7 @@ void Foam::fileFormats::STLfileFormat::writeBINARY
|
||||
pointLst,
|
||||
faceLst[faceI],
|
||||
normLst[faceI],
|
||||
faceLst[faceI].key()
|
||||
regionLst[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -450,8 +458,8 @@ void Foam::fileFormats::STLfileFormat::writeBINARY
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const surfacePatchList& patchLst = surf.patches();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
const surfacePatchList& patchLst = surf.patches();
|
||||
|
||||
// Write the STL header
|
||||
string header("STL binary file", headerSize);
|
||||
@ -517,8 +525,6 @@ Foam::fileFormats::STLfileFormat::STLfileFormat
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -583,8 +589,4 @@ void Foam::fileFormats::STLfileFormat::write
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -390,30 +390,25 @@ Foam::fileFormats::STLfileFormat::readASCII
|
||||
STLASCIILexer lexer(&ifs.stdStream(), fileSize/400);
|
||||
while (lexer.lex() != 0) {}
|
||||
|
||||
DynamicList<point>& pointLst = lexer.points();
|
||||
DynamicList<label>& facetsLst = lexer.facets();
|
||||
// transfer to normal lists
|
||||
points().transfer(lexer.points());
|
||||
regions().transfer(lexer.facets());
|
||||
|
||||
// transfer to normal list
|
||||
points().transfer(pointLst);
|
||||
// make our triangles directly
|
||||
List<face>& faceLst = faces();
|
||||
faceLst.setSize(regions().size());
|
||||
|
||||
// make our triangles
|
||||
facetsLst.shrink();
|
||||
List<keyedFace> faceLst(facetsLst.size());
|
||||
|
||||
face fTri(3);
|
||||
label ptI = 0;
|
||||
forAll(facetsLst, faceI)
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
|
||||
fTri[0] = ptI++;
|
||||
fTri[1] = ptI++;
|
||||
fTri[2] = ptI++;
|
||||
|
||||
faceLst[faceI] = keyedFace(fTri, facetsLst[faceI]);
|
||||
}
|
||||
facetsLst.clearStorage();
|
||||
|
||||
// transfer to normal list
|
||||
faces().transfer(faceLst);
|
||||
setPatches(lexer.groupToPatch());
|
||||
stitchFaces(SMALL);
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ Foam::fileFormats::TRIfileFormat::TRIfileFormat
|
||||
|
||||
// uses similar structure as STL, just some points
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<label> facetsLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
|
||||
// leave faces that didn't have a group in 0
|
||||
@ -193,46 +193,43 @@ Foam::fileFormats::TRIfileFormat::TRIfileFormat
|
||||
else
|
||||
{
|
||||
// special treatment if any initial faces were not in a group
|
||||
if (maxGroupID == -1 && facetsLst.size())
|
||||
if (maxGroupID == -1 && regionLst.size())
|
||||
{
|
||||
groupToPatch.insert("patch0", 0);
|
||||
nUngrouped = facetsLst.size();
|
||||
nUngrouped = regionLst.size();
|
||||
maxGroupID = 0;
|
||||
}
|
||||
groupID = ++maxGroupID;
|
||||
groupToPatch.insert(groupName, groupID);
|
||||
}
|
||||
|
||||
facetsLst.append(groupID);
|
||||
regionLst.append(groupID);
|
||||
}
|
||||
|
||||
// transfer to normal list
|
||||
points().transfer(pointLst);
|
||||
regions().transfer(regionLst);
|
||||
|
||||
// make our triangles
|
||||
facetsLst.shrink();
|
||||
List<keyedFace> faceLst(facetsLst.size());
|
||||
// make our triangles directly
|
||||
List<face>& faceLst = faces();
|
||||
faceLst.setSize(regions().size());
|
||||
|
||||
face fTri(3);
|
||||
label ptI = 0;
|
||||
forAll(facetsLst, faceI)
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
|
||||
fTri[0] = ptI++;
|
||||
fTri[1] = ptI++;
|
||||
fTri[2] = ptI++;
|
||||
|
||||
faceLst[faceI] = keyedFace(fTri, facetsLst[faceI]);
|
||||
}
|
||||
facetsLst.clearStorage();
|
||||
|
||||
faces().transfer(faceLst);
|
||||
setPatches(groupToPatch);
|
||||
stitchFaces(SMALL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::TRIfileFormat::write
|
||||
@ -242,7 +239,7 @@ void Foam::fileFormats::TRIfileFormat::write
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -280,8 +277,4 @@ void Foam::fileFormats::TRIfileFormat::write
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -64,7 +64,8 @@ addNamedToMemberFunctionSelectionTable
|
||||
void Foam::fileFormats::VTKfileFormat::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
@ -82,6 +83,16 @@ void Foam::fileFormats::VTKfileFormat::writeHead
|
||||
<< pointLst[ptI].y() << ' '
|
||||
<< pointLst[ptI].z() << nl;
|
||||
}
|
||||
|
||||
label nNodes = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nNodes += faceLst[faceI].size();
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "POLYGONS " << faceLst.size() << ' '
|
||||
<< faceLst.size() + nNodes << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -134,8 +145,6 @@ Foam::fileFormats::VTKfileFormat::VTKfileFormat()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileFormats::VTKfileFormat::write
|
||||
@ -144,24 +153,13 @@ void Foam::fileFormats::VTKfileFormat::write
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<keyedFace>& faceLst = surf.faces();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
|
||||
labelList faceMap;
|
||||
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
writeHead(os, pointLst);
|
||||
|
||||
label nNodes = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nNodes += faceLst[faceI].size();
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "POLYGONS " << faceLst.size() << ' '
|
||||
<< faceLst.size() + nNodes << nl;
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
@ -189,21 +187,10 @@ void Foam::fileFormats::VTKfileFormat::write
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<surfacePatch>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, pointLst);
|
||||
|
||||
label nNodes = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
nNodes += faceLst[faceI].size();
|
||||
}
|
||||
|
||||
os << nl
|
||||
<< "POLYGONS " << faceLst.size() << ' '
|
||||
<< faceLst.size() + nNodes << nl;
|
||||
writeHead(os, surf.points(), faceLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
@ -225,9 +212,4 @@ void Foam::fileFormats::VTKfileFormat::write
|
||||
writeTail(os, patchLst);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -65,7 +65,7 @@ class VTKfileFormat
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const VTKfileFormat&);
|
||||
|
||||
static void writeHead(Ostream&, const pointField&);
|
||||
static void writeHead(Ostream&, const pointField&, const List<face>&);
|
||||
static void writeTail(Ostream&, const List<surfacePatch>&);
|
||||
|
||||
public:
|
||||
|
||||
@ -199,12 +199,11 @@ void Foam::keyedSurface::setPatches(const label maxPatch)
|
||||
void Foam::keyedSurface::setPatches()
|
||||
{
|
||||
label maxPatch = 0;
|
||||
const List<keyedFace>& faceLst = faces();
|
||||
|
||||
// find the max region that occurs
|
||||
forAll(faceLst, faceI)
|
||||
forAll(regions_, faceI)
|
||||
{
|
||||
const label regId = faceLst[faceI].key();
|
||||
const label regId = regions_[faceI];
|
||||
|
||||
if (maxPatch < regId)
|
||||
{
|
||||
@ -288,13 +287,16 @@ void Foam::keyedSurface::setPatches
|
||||
setPatches(regionNames, maxPatch);
|
||||
}
|
||||
|
||||
|
||||
// Read triangles, points from Istream
|
||||
//
|
||||
// FIXME: needs to handle labelledTri etc.
|
||||
bool Foam::keyedSurface::read(Istream& is)
|
||||
{
|
||||
is >> geoPatches_ >> points() >> faces();
|
||||
notImplemented("Foam::keyedSurface::read(Istream&)");
|
||||
return false;
|
||||
|
||||
return true;
|
||||
//// is >> geoPatches_ >> points() >> faces();
|
||||
//// return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -311,91 +313,6 @@ bool Foam::keyedSurface::read(const fileName& name, const word& ext)
|
||||
#endif
|
||||
|
||||
|
||||
// Returns patch info.
|
||||
// Sets faceMap to the indexing according to patch numbers.
|
||||
// Patch numbers start at 0.
|
||||
Foam::surfacePatchList
|
||||
Foam::keyedSurface::sortedRegions
|
||||
(
|
||||
const List<keyedFace>& faceLst,
|
||||
const Map<word>& patchNames,
|
||||
labelList& faceMap
|
||||
)
|
||||
{
|
||||
// determine sort order according to region numbers
|
||||
|
||||
// std::sort() really seems to mix up the order.
|
||||
// Assuming that we have relatively fewer regions compared to the
|
||||
// number of items, just do it ourselves
|
||||
|
||||
// step 1: get region sizes and store (regionId => patchI)
|
||||
Map<label> regionLookup;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
const label regId = faceLst[faceI].key();
|
||||
|
||||
Map<label>::iterator iter = regionLookup.find(regId);
|
||||
if (iter == regionLookup.end())
|
||||
{
|
||||
regionLookup.insert(regId, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter()++;
|
||||
}
|
||||
}
|
||||
|
||||
// step 2: assign start/size (and name) to the newPatches
|
||||
// re-use the lookup to map (regionId => patchI)
|
||||
surfacePatchList surfPatches(regionLookup.size());
|
||||
label patchStart = 0;
|
||||
label patchI = 0;
|
||||
forAllIter(Map<label>, regionLookup, iter)
|
||||
{
|
||||
label regId = iter.key();
|
||||
|
||||
word patchName;
|
||||
Map<word>::const_iterator iter2 = patchNames.find(regId);
|
||||
if (iter2 == patchNames.end())
|
||||
{
|
||||
patchName = word("patch") + ::Foam::name(patchI);
|
||||
}
|
||||
else
|
||||
{
|
||||
patchName = iter2();
|
||||
}
|
||||
|
||||
surfPatches[patchI] = surfacePatch
|
||||
(
|
||||
defaultGeometricType,
|
||||
patchName,
|
||||
0, // initialize with zero size
|
||||
patchStart,
|
||||
patchI
|
||||
);
|
||||
|
||||
// increment the start for the next patch
|
||||
// and save the (regionId => patchI) mapping
|
||||
patchStart += iter();
|
||||
iter() = patchI++;
|
||||
}
|
||||
|
||||
// step 3: build the re-ordering
|
||||
faceMap.setSize(faceLst.size());
|
||||
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
label patchI = regionLookup[faceLst[faceI].key()];
|
||||
|
||||
faceMap[faceI] =
|
||||
surfPatches[patchI].start() + surfPatches[patchI].size()++;
|
||||
}
|
||||
|
||||
// with reordered faces
|
||||
return surfPatches;
|
||||
}
|
||||
|
||||
|
||||
// Returns patch info.
|
||||
// Sets faceMap to the indexing according to patch numbers.
|
||||
// Patch numbers start at 0.
|
||||
@ -493,7 +410,7 @@ Foam::surfacePatchList Foam::keyedSurface::sortedRegions
|
||||
patchNames.insert(patchI, geoPatches_[patchI].name());
|
||||
}
|
||||
|
||||
return sortedRegions(faces(), patchNames, faceMap);
|
||||
return sortedRegions(regions_, patchNames, faceMap);
|
||||
}
|
||||
|
||||
|
||||
@ -501,48 +418,37 @@ Foam::surfacePatchList Foam::keyedSurface::sortedRegions
|
||||
|
||||
Foam::keyedSurface::keyedSurface()
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
(
|
||||
const pointField& pointLst,
|
||||
const List<keyedFace>& faceLst,
|
||||
const geometricSurfacePatchList& patchLst
|
||||
)
|
||||
:
|
||||
MeshStorage(faceLst, pointLst),
|
||||
geoPatches_(patchLst)
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<keyedFace> >& faceLst,
|
||||
const xfer<List<face> >& faceLst,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const xfer<geometricSurfacePatchList>& patchLst
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
regions_(regionIds),
|
||||
geoPatches_(patchLst)
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
geoPatches_.transfer(patchLst());
|
||||
}
|
||||
|
||||
|
||||
Foam::keyedSurface::keyedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<keyedFace> >& faceLst,
|
||||
const xfer<List<face> >& faceLst,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const Map<word>& regionNames
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
regions_(regionIds)
|
||||
{
|
||||
faces().transfer(faceLst());
|
||||
points().transfer(pointLst());
|
||||
@ -563,12 +469,13 @@ Foam::keyedSurface::keyedSurface
|
||||
Foam::keyedSurface::keyedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<keyedFace> >& faceLst,
|
||||
const xfer<List<face> >& faceLst,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const HashTable<label>& labelToRegion
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
regions_(regionIds)
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
@ -581,15 +488,16 @@ Foam::keyedSurface::keyedSurface
|
||||
Foam::keyedSurface::keyedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const List<face>& faceLst
|
||||
const xfer<List<face> >& faceLst
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
regions_(faceLst().size(), 0), // single default patch
|
||||
geoPatches_()
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces() = keyedFace::createList(faceLst, 0);
|
||||
// single default patch
|
||||
faces().transfer(faceLst());
|
||||
|
||||
setPatches(0);
|
||||
}
|
||||
|
||||
@ -601,8 +509,7 @@ Foam::keyedSurface::keyedSurface
|
||||
const bool useGlobalPoints
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
const polyMesh& mesh = bMesh.mesh();
|
||||
const polyPatchList& bPatches = bMesh;
|
||||
@ -622,7 +529,8 @@ Foam::keyedSurface::keyedSurface
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
List<keyedFace> newFaces(allBoundary.size());
|
||||
List<FaceType> newFaces(allBoundary.size());
|
||||
List<label> newRegions(allBoundary.size());
|
||||
|
||||
if (useGlobalPoints)
|
||||
{
|
||||
@ -657,16 +565,14 @@ Foam::keyedSurface::keyedSurface
|
||||
|
||||
forAll(p, patchFaceI)
|
||||
{
|
||||
newFaces[faceIndex] = keyedFace
|
||||
(
|
||||
bfaces[faceIndex],
|
||||
patchI
|
||||
);
|
||||
newFaces[faceIndex] = bfaces[faceIndex];
|
||||
newRegions[faceIndex] = patchI;
|
||||
faceIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
faces().transfer(newFaces);
|
||||
regions_.transfer(newRegions);
|
||||
geoPatches_.transfer(newPatches);
|
||||
}
|
||||
|
||||
@ -676,13 +582,13 @@ Foam::keyedSurface::keyedSurface
|
||||
const meshedSurface& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(List<keyedFace>(), surf.points()),
|
||||
geoPatches_()
|
||||
MeshStorage(List<FaceType>(), surf.points())
|
||||
{
|
||||
const List<face>& origFaces = surf.faces();
|
||||
const surfacePatchList& patchLst = surf.patches();
|
||||
|
||||
List<keyedFace> newFaces(origFaces.size());
|
||||
List<FaceType> newFaces(origFaces.size());
|
||||
List<label> newRegions(origFaces.size());
|
||||
geometricSurfacePatchList newPatches(patchLst.size());
|
||||
|
||||
label faceIndex = 0;
|
||||
@ -691,12 +597,14 @@ Foam::keyedSurface::keyedSurface
|
||||
newPatches[patchI] = patchLst[patchI];
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
newFaces[faceIndex] = keyedFace(origFaces[faceIndex], patchI);
|
||||
newFaces[faceIndex] = origFaces[faceIndex];
|
||||
newRegions[faceIndex] = patchI;
|
||||
faceIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
faces().transfer(newFaces);
|
||||
regions_.transfer(newRegions);
|
||||
geoPatches_.transfer(newPatches);
|
||||
}
|
||||
|
||||
@ -708,8 +616,7 @@ Foam::keyedSurface::keyedSurface
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
// use selector mechanism
|
||||
autoPtr<keyedSurface> surfPtr = New(fName, ext, triangulate);
|
||||
@ -723,8 +630,7 @@ Foam::keyedSurface::keyedSurface
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
// use selector mechanism
|
||||
autoPtr<keyedSurface> surfPtr = New(fName, triangulate);
|
||||
@ -734,8 +640,7 @@ Foam::keyedSurface::keyedSurface
|
||||
|
||||
Foam::keyedSurface::keyedSurface(Istream& is)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
read(is);
|
||||
setPatches();
|
||||
@ -744,8 +649,7 @@ Foam::keyedSurface::keyedSurface(Istream& is)
|
||||
|
||||
Foam::keyedSurface::keyedSurface(const Time& d)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
geoPatches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
read(IFstream(triSurfName(d))());
|
||||
setPatches();
|
||||
@ -755,6 +659,7 @@ Foam::keyedSurface::keyedSurface(const Time& d)
|
||||
Foam::keyedSurface::keyedSurface(const keyedSurface& surf)
|
||||
:
|
||||
MeshStorage(surf.faces(), surf.points()),
|
||||
regions_(surf.regions_),
|
||||
geoPatches_(surf.geoPatches_)
|
||||
{}
|
||||
|
||||
@ -762,6 +667,7 @@ Foam::keyedSurface::keyedSurface(const keyedSurface& surf)
|
||||
Foam::keyedSurface::keyedSurface(const xfer<keyedSurface>& surf)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
regions_(),
|
||||
geoPatches_()
|
||||
{
|
||||
transfer(surf());
|
||||
@ -771,6 +677,7 @@ Foam::keyedSurface::keyedSurface(const xfer<keyedSurface>& surf)
|
||||
Foam::keyedSurface::keyedSurface(const xfer<meshedSurface>& surf)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
regions_(),
|
||||
geoPatches_()
|
||||
{
|
||||
transfer(surf());
|
||||
@ -878,6 +785,7 @@ void Foam::keyedSurface::transfer(keyedSurface& surf)
|
||||
clearOut();
|
||||
faces().transfer(surf.faces());
|
||||
points().transfer(surf.points());
|
||||
regions_.transfer(surf.regions_);
|
||||
geoPatches_.transfer(surf.geoPatches_);
|
||||
surf.clearOut();
|
||||
}
|
||||
@ -887,28 +795,24 @@ void Foam::keyedSurface::transfer(meshedSurface& surf)
|
||||
{
|
||||
clearOut();
|
||||
points().transfer(surf.points());
|
||||
faces().transfer(surf.faces());
|
||||
regions_.setSize(nFaces());
|
||||
|
||||
const List<face>& origFaces = surf.faces();
|
||||
List<keyedFace> newFaces(origFaces.size());
|
||||
|
||||
const surfacePatchList& patchLst = surf.patches();
|
||||
geometricSurfacePatchList newPatches(patchLst.size());
|
||||
surfacePatchList& patchLst = surf.patches();
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
{
|
||||
newPatches[patchI] = patchLst[patchI];
|
||||
// copy info
|
||||
geoPatches_[patchI] = patchLst[patchI];
|
||||
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
{
|
||||
newFaces[faceIndex] = keyedFace(origFaces[faceIndex], patchI);
|
||||
faceIndex++;
|
||||
regions_[faceIndex++] = patchI;
|
||||
}
|
||||
}
|
||||
|
||||
faces().transfer(newFaces);
|
||||
geoPatches_.transfer(newPatches);
|
||||
surf.faces().clear();
|
||||
patchLst.clear();
|
||||
surf.clearOut();
|
||||
}
|
||||
|
||||
@ -1060,10 +964,16 @@ void Foam::keyedSurface::write
|
||||
|
||||
void Foam::keyedSurface::write(Ostream& os) const
|
||||
{
|
||||
os << geoPatches_ << endl;
|
||||
os << "\n// geometric regions:\n"
|
||||
<< geoPatches_ << endl;
|
||||
|
||||
// Note: Write with global point numbering
|
||||
os << points() << nl << faces() << endl;
|
||||
os << "\n// points:"
|
||||
<< points() << nl
|
||||
<< "\n// faces:"
|
||||
<< faces() << nl
|
||||
<< "\n// regions:"
|
||||
<< regions() << endl;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("keyedSurface::write(Ostream&)");
|
||||
|
||||
@ -27,7 +27,7 @@ Class
|
||||
|
||||
Description
|
||||
A surface geometry mesh, in which the patch information is conveyed by
|
||||
the 'key' attached to each face.
|
||||
the 'region' associated with each face.
|
||||
|
||||
This form of surface description is particularly useful for reading in
|
||||
surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
|
||||
@ -74,7 +74,7 @@ class polyBoundaryMesh;
|
||||
|
||||
class keyedSurface
|
||||
:
|
||||
public PrimitivePatchExtra<Keyed<face>, ::Foam::List, pointField, point>
|
||||
public PrimitivePatchExtra<face, ::Foam::List, pointField, point>
|
||||
{
|
||||
friend class meshedSurface;
|
||||
|
||||
@ -86,12 +86,10 @@ protected:
|
||||
typedef Keyed<face> keyedFace;
|
||||
|
||||
//- Typedef for similar code in keyedSurface and meshedSurface
|
||||
typedef keyedFace FaceType;
|
||||
typedef face FaceType;
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Data
|
||||
|
||||
// Private typedefs
|
||||
|
||||
typedef PrimitivePatchExtra
|
||||
@ -103,7 +101,10 @@ private:
|
||||
>
|
||||
MeshStorage;
|
||||
|
||||
// Private data
|
||||
// Private Member Data
|
||||
|
||||
//- The regions associated with the faces
|
||||
labelList regions_;
|
||||
|
||||
//- Patch information (face ordering nFaces/startFace only used
|
||||
// during reading and writing)
|
||||
@ -159,6 +160,12 @@ protected:
|
||||
return static_cast<List<FaceType> &>(*this);
|
||||
}
|
||||
|
||||
//- Return non-const access to the region Ids
|
||||
List<label>& regions()
|
||||
{
|
||||
return regions_;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -181,47 +188,42 @@ public:
|
||||
//- Construct null
|
||||
keyedSurface();
|
||||
|
||||
//- Construct from components (points, labelled faces, patches).
|
||||
keyedSurface
|
||||
(
|
||||
const pointField&,
|
||||
const List<keyedFace>&,
|
||||
const geometricSurfacePatchList&
|
||||
);
|
||||
|
||||
//- Construct by transferring components
|
||||
// (points, labelled faces, patches.
|
||||
// (points, faces, region ids, patches).
|
||||
keyedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<keyedFace> >&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const xfer<geometricSurfacePatchList>&
|
||||
);
|
||||
|
||||
//- Construct by transferring points and labelled faces
|
||||
// With region names per map or set to default.
|
||||
//- Construct by transferring points, faces and regionIds
|
||||
// with region names per map or set to default.
|
||||
keyedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<keyedFace> >&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const Map<word>& regionNames = Map<word>::null()
|
||||
);
|
||||
|
||||
//- Construct by transferring points and labelled faces
|
||||
//- Construct by transferring points, faces and regionIds
|
||||
// with patch-names from hash
|
||||
keyedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<keyedFace> >&,
|
||||
const xfer<List<face> >&,
|
||||
const xfer<List<label> >& regionIds,
|
||||
const HashTable<label>& labelToRegion
|
||||
);
|
||||
|
||||
//- Construct by transferring points, copying unlabelled faces.
|
||||
//- Construct by transferring points, faces.
|
||||
// Set single default patch.
|
||||
keyedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const List<face>&
|
||||
const xfer<List<face> >&
|
||||
);
|
||||
|
||||
//- Construct from a boundary mesh with local points/faces
|
||||
@ -360,6 +362,12 @@ public:
|
||||
return static_cast<const List<FaceType> &>(*this);
|
||||
}
|
||||
|
||||
//- Return const access to the regions
|
||||
const List<label>& regions() const
|
||||
{
|
||||
return regions_;
|
||||
}
|
||||
|
||||
const geometricSurfacePatchList& geoPatches() const
|
||||
{
|
||||
return geoPatches_;
|
||||
@ -370,15 +378,6 @@ public:
|
||||
return geoPatches_;
|
||||
}
|
||||
|
||||
//- Determine the sort order from the face regions.
|
||||
// Returns patch list and sets faceMap to index within faceLst
|
||||
static surfacePatchList sortedRegions
|
||||
(
|
||||
const List<keyedFace>& faceLst,
|
||||
const Map<word>& patchNames,
|
||||
labelList& faceMap
|
||||
);
|
||||
|
||||
//- Determine the sort order from the region list.
|
||||
// Returns patch list and sets faceMap to indices within faceLst
|
||||
static surfacePatchList sortedRegions
|
||||
|
||||
@ -27,8 +27,6 @@ License
|
||||
#include "keyedSurface.H"
|
||||
#include "mergePoints.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Remove badly degenerate faces, double faces.
|
||||
@ -83,6 +81,7 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
if (newFaceI != faceI)
|
||||
{
|
||||
faceLst[newFaceI] = f;
|
||||
regions_[newFaceI] = regions_[faceI];
|
||||
}
|
||||
newFaceI++;
|
||||
}
|
||||
@ -103,6 +102,7 @@ bool Foam::keyedSurface::stitchFaces(const scalar tol, const bool verbose)
|
||||
<< " faces" << endl;
|
||||
}
|
||||
faceLst.setSize(newFaceI);
|
||||
regions_.setSize(newFaceI);
|
||||
}
|
||||
|
||||
// Merging points might have changed geometric factors
|
||||
@ -138,9 +138,8 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
}
|
||||
}
|
||||
|
||||
// Two phase process
|
||||
// 1. mark invalid faces
|
||||
// 2. pack
|
||||
// Phase 1: mark invalid faces
|
||||
// Phase 1: pack
|
||||
// Done to keep numbering constant in phase 1
|
||||
const labelListList& fFaces = faceFaces();
|
||||
label newFaceI = 0;
|
||||
@ -197,6 +196,7 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
if (newFaceI != faceI)
|
||||
{
|
||||
faceLst[newFaceI] = f;
|
||||
regions_[newFaceI] = regions_[faceI];
|
||||
}
|
||||
newFaceI++;
|
||||
}
|
||||
@ -223,13 +223,11 @@ void Foam::keyedSurface::checkFaces(const bool verbose)
|
||||
<< " illegal faces." << endl;
|
||||
}
|
||||
faceLst.setSize(newFaceI);
|
||||
regions_.setSize(newFaceI);
|
||||
|
||||
// Topology can change because of renumbering
|
||||
clearOut();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -240,12 +240,50 @@ void Foam::meshedSurface::checkPatches()
|
||||
}
|
||||
|
||||
|
||||
// Read triangles, points from Istream
|
||||
void Foam::meshedSurface::sortFacesByRegion
|
||||
(
|
||||
const List<label>& regionIds,
|
||||
const Map<word>& regionNames
|
||||
)
|
||||
{
|
||||
const List<FaceType>& unsortedFaces = faces();
|
||||
|
||||
if (!®ionNames || !®ionIds || regionIds.size() == 0)
|
||||
{
|
||||
onePatch();
|
||||
}
|
||||
else if (regionIds.size() == unsortedFaces.size())
|
||||
{
|
||||
labelList faceMap;
|
||||
surfacePatchList newPatches = keyedSurface::sortedRegions
|
||||
(
|
||||
regionIds,
|
||||
regionNames,
|
||||
faceMap
|
||||
);
|
||||
patches_.transfer(newPatches);
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
List<FaceType> newFaces(unsortedFaces.size());
|
||||
forAll(newFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = unsortedFaces[faceMap[faceI]];
|
||||
}
|
||||
faceMap.clear();
|
||||
|
||||
faces().transfer(newFaces);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read points, faces, from Istream
|
||||
bool Foam::meshedSurface::read(Istream& is)
|
||||
{
|
||||
is >> patches_ >> points() >> faces();
|
||||
notImplemented("Foam::meshedSurface::read(Istream&)");
|
||||
return false;
|
||||
|
||||
return true;
|
||||
//// is >> patches_ >> points() >> faces();
|
||||
//// return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -266,20 +304,7 @@ bool Foam::meshedSurface::read(const fileName& name, const word& ext)
|
||||
|
||||
Foam::meshedSurface::meshedSurface()
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
(
|
||||
const pointField& pointLst,
|
||||
const List<FaceType>& faceLst,
|
||||
const surfacePatchList& patchLst
|
||||
)
|
||||
:
|
||||
MeshStorage(faceLst, pointLst),
|
||||
patches_(patchLst)
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{}
|
||||
|
||||
|
||||
@ -293,8 +318,8 @@ Foam::meshedSurface::meshedSurface
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_(patchLst)
|
||||
{
|
||||
faces().transfer(faceLst());
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
}
|
||||
|
||||
|
||||
@ -307,8 +332,7 @@ Foam::meshedSurface::meshedSurface
|
||||
const List<word>& patchTypes
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
@ -338,57 +362,38 @@ Foam::meshedSurface::meshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<FaceType> >& faceLst,
|
||||
const List<label>& regionLst,
|
||||
const List<label>& regionIds,
|
||||
const Map<word>& regionNames
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
|
||||
const List<FaceType>& unsortedFaces = faces();
|
||||
|
||||
if (regionLst.size() == 0)
|
||||
{
|
||||
onePatch();
|
||||
}
|
||||
else if (regionLst.size() != unsortedFaces.size())
|
||||
if
|
||||
(
|
||||
®ionIds
|
||||
&& regionIds.size() != 0
|
||||
&& regionIds.size() != nFaces()
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshedSurface::meshedSurface(\n"
|
||||
"(\n"
|
||||
" const pointField&,\n"
|
||||
" const List<FaceType>&,\n"
|
||||
" const List<label>& regionLst,\n"
|
||||
" const xfer<pointField>&,\n"
|
||||
" const xfer<List<FaceType> >&,\n"
|
||||
" const List<label>& regionIds,\n"
|
||||
" const Map<word>& regionNames\n"
|
||||
" )\n"
|
||||
)
|
||||
<< "size mismatch : regionLst.size() != faceLst.size()"
|
||||
<< "size mismatch : regionIds.size() != nFaces()"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
labelList faceMap;
|
||||
surfacePatchList newPatches = keyedSurface::sortedRegions
|
||||
(
|
||||
regionLst,
|
||||
regionNames,
|
||||
faceMap
|
||||
);
|
||||
patches_.transfer(newPatches);
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
List<FaceType> newFaces(unsortedFaces.size());
|
||||
forAll(newFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = unsortedFaces[faceMap[faceI]];
|
||||
}
|
||||
faceMap.clear();
|
||||
|
||||
faces().transfer(newFaces);
|
||||
sortFacesByRegion(regionIds, regionNames);
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,88 +401,41 @@ Foam::meshedSurface::meshedSurface
|
||||
Foam::meshedSurface::meshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const xfer<List<FaceType> >& faceLst
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
{
|
||||
faces().transfer(faceLst());
|
||||
points().transfer(pointLst());
|
||||
|
||||
onePatch();
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const List<keyedFace>& faceLst,
|
||||
const Map<word>& regionNames
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
|
||||
labelList faceMap;
|
||||
surfacePatchList newPatches = keyedSurface::sortedRegions
|
||||
(
|
||||
faceLst,
|
||||
regionNames,
|
||||
faceMap
|
||||
);
|
||||
patches_.transfer(newPatches);
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
List<FaceType> newFaces(faceLst.size());
|
||||
forAll(newFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = faceLst[faceMap[faceI]];
|
||||
}
|
||||
|
||||
faces().transfer(newFaces);
|
||||
}
|
||||
|
||||
|
||||
Foam::meshedSurface::meshedSurface
|
||||
(
|
||||
const xfer<pointField>& pointLst,
|
||||
const List<keyedFace>& faceLst,
|
||||
const xfer<List<FaceType> >& faceLst,
|
||||
const List<label>& regionIds,
|
||||
const HashTable<label>& nameToRegionMapping
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
points().transfer(pointLst());
|
||||
faces().transfer(faceLst());
|
||||
|
||||
if (regionIds.size() != nFaces())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshedSurface::meshedSurface(\n"
|
||||
"(\n"
|
||||
" const xfer<pointField>&,\n"
|
||||
" const xfer<List<FaceType> >&,\n"
|
||||
" const List<label>& regionIds,\n"
|
||||
" const HashTable<label>& nameToRegionMapping\n"
|
||||
" )\n"
|
||||
)
|
||||
<< "size mismatch : regionIds.size() != nFaces()"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<word> regionNames;
|
||||
forAllConstIter(HashTable<label>, nameToRegionMapping, iter)
|
||||
{
|
||||
regionNames.insert(iter(), iter.key());
|
||||
}
|
||||
|
||||
|
||||
labelList faceMap;
|
||||
surfacePatchList newPatches = keyedSurface::sortedRegions
|
||||
(
|
||||
faceLst,
|
||||
regionNames,
|
||||
faceMap
|
||||
);
|
||||
patches_.transfer(newPatches);
|
||||
|
||||
List<FaceType> newFaces(faceLst.size());
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
forAll(newFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = faceLst[faceMap[faceI]];
|
||||
sortFacesByRegion(regionIds, regionNames);
|
||||
}
|
||||
|
||||
faces().transfer(newFaces);
|
||||
}
|
||||
|
||||
|
||||
@ -487,8 +445,7 @@ Foam::meshedSurface::meshedSurface
|
||||
const bool useGlobalPoints
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
const polyMesh& mesh = bMesh.mesh();
|
||||
const polyPatchList& bPatches = bMesh;
|
||||
@ -550,8 +507,7 @@ Foam::meshedSurface::meshedSurface
|
||||
const surfMesh& sMesh
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(sMesh.faces()), sMesh.points()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(sMesh.faces()), sMesh.points())
|
||||
{
|
||||
const surfPatchList& sPatches = sMesh.boundaryMesh();
|
||||
|
||||
@ -585,14 +541,13 @@ Foam::meshedSurface::meshedSurface
|
||||
const keyedSurface& surf
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), surf.points()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), surf.points())
|
||||
{
|
||||
labelList faceMap;
|
||||
surfacePatchList newPatches = surf.sortedRegions(faceMap);
|
||||
patches_.transfer(newPatches);
|
||||
surfacePatchList patchLst = surf.sortedRegions(faceMap);
|
||||
patches_.transfer(patchLst);
|
||||
|
||||
const List<keyedFace>& origFaces = surf.faces();
|
||||
const List<FaceType>& origFaces = surf.faces();
|
||||
List<FaceType> newFaces(origFaces.size());
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
@ -612,8 +567,7 @@ Foam::meshedSurface::meshedSurface
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
// use selector mechanism
|
||||
autoPtr<meshedSurface> surfPtr = New(fName, ext, triangulate);
|
||||
@ -626,8 +580,7 @@ Foam::meshedSurface::meshedSurface
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
// use selector mechanism
|
||||
autoPtr<meshedSurface> surfPtr = New(fName, triangulate);
|
||||
@ -637,8 +590,7 @@ Foam::meshedSurface::meshedSurface
|
||||
|
||||
Foam::meshedSurface::meshedSurface(Istream& is)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
read(is);
|
||||
// setDefaultPatches();
|
||||
@ -647,8 +599,7 @@ Foam::meshedSurface::meshedSurface(Istream& is)
|
||||
|
||||
Foam::meshedSurface::meshedSurface(const Time& d)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
read(IFstream(triSurfName(d))());
|
||||
// setDefaultPatches();
|
||||
@ -664,8 +615,7 @@ Foam::meshedSurface::meshedSurface(const meshedSurface& surf)
|
||||
|
||||
Foam::meshedSurface::meshedSurface(const xfer<keyedSurface>& surf)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
transfer(surf());
|
||||
}
|
||||
@ -673,8 +623,7 @@ Foam::meshedSurface::meshedSurface(const xfer<keyedSurface>& surf)
|
||||
|
||||
Foam::meshedSurface::meshedSurface(const xfer<meshedSurface>& surf)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
patches_()
|
||||
MeshStorage(List<FaceType>(), pointField())
|
||||
{
|
||||
transfer(surf());
|
||||
}
|
||||
@ -703,6 +652,7 @@ void Foam::meshedSurface::movePoints(const pointField& newPoints)
|
||||
points() = newPoints;
|
||||
}
|
||||
|
||||
|
||||
//- scale points
|
||||
void Foam::meshedSurface::scalePoints(const scalar& scaleFactor)
|
||||
{
|
||||
@ -720,7 +670,6 @@ void Foam::meshedSurface::scalePoints(const scalar& scaleFactor)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
||||
(
|
||||
const boolList& include,
|
||||
@ -806,8 +755,8 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
|
||||
void Foam::meshedSurface::transfer(meshedSurface& surf)
|
||||
{
|
||||
clearOut();
|
||||
faces().transfer(surf.faces());
|
||||
points().transfer(surf.points());
|
||||
faces().transfer(surf.faces());
|
||||
patches_.transfer(surf.patches_);
|
||||
surf.clearOut();
|
||||
}
|
||||
@ -817,18 +766,21 @@ void Foam::meshedSurface::transfer(keyedSurface& surf)
|
||||
{
|
||||
clearOut();
|
||||
points().transfer(surf.points());
|
||||
faces().clear();
|
||||
|
||||
labelList faceMap;
|
||||
surfacePatchList newPatches = surf.sortedRegions(faceMap);
|
||||
patches_.transfer(newPatches);
|
||||
surfacePatchList patchLst = surf.sortedRegions(faceMap);
|
||||
patches_.transfer(patchLst);
|
||||
surf.regions().clear();
|
||||
surf.geoPatches_.clear();
|
||||
|
||||
const List<keyedFace>& origFaces = surf.faces();
|
||||
List<FaceType> newFaces(origFaces.size());
|
||||
List<FaceType>& oldFaces = surf.faces();
|
||||
List<FaceType> newFaces(oldFaces.size());
|
||||
|
||||
// this is somewhat like ListOps reorder and/or IndirectList
|
||||
forAll(newFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = origFaces[faceMap[faceI]];
|
||||
newFaces[faceI] = oldFaces[faceMap[faceI]];
|
||||
}
|
||||
|
||||
faces().transfer(newFaces);
|
||||
@ -932,15 +884,19 @@ void Foam::meshedSurface::write
|
||||
void Foam::meshedSurface::write(Ostream& os) const
|
||||
{
|
||||
// quick-hack
|
||||
os << patches_.size() << nl << token::BEGIN_LIST;
|
||||
os << "\n// regions:\n"
|
||||
<< patches_.size() << nl << token::BEGIN_LIST;
|
||||
forAll(patches_, patchI)
|
||||
{
|
||||
patches_[patchI].writeDict(os);
|
||||
}
|
||||
os << token::END_LIST;
|
||||
os << token::END_LIST << endl;
|
||||
|
||||
// Note: Write with global point numbering
|
||||
os << points() << nl << faces() << endl;
|
||||
os << "\n// points:"
|
||||
<< points() << nl
|
||||
<< "\n// faces:"
|
||||
<< faces() << endl;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("meshedSurface::write(Ostream&)");
|
||||
|
||||
@ -108,6 +108,9 @@ private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Sort faces by regionIds and set patches
|
||||
void sortFacesByRegion(const List<label>&, const Map<word>&);
|
||||
|
||||
//- set a single patch
|
||||
void onePatch();
|
||||
|
||||
@ -162,16 +165,8 @@ public:
|
||||
//- Construct null
|
||||
meshedSurface();
|
||||
|
||||
//- Construct from components (points, faces and patches).
|
||||
meshedSurface
|
||||
(
|
||||
const pointField&,
|
||||
const List<face>&,
|
||||
const surfacePatchList&
|
||||
);
|
||||
|
||||
//- Construct by transferring components
|
||||
//- (points, faces and patches).
|
||||
// (points, faces and patches).
|
||||
meshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
@ -189,39 +184,24 @@ public:
|
||||
const List<word>& patchTypes
|
||||
);
|
||||
|
||||
//- Construct from points, faces, a list of (unsorted) region Ids
|
||||
// and with the names of the regions.
|
||||
//- Construct by transferring points, faces.
|
||||
// Sort faces according to regionIds with the names of the regions,
|
||||
// or jsut set a single default patch.
|
||||
meshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const List<label>& regionIds = List<label>::null(),
|
||||
const Map<word>& regionNames = Map<word>::null()
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces.
|
||||
// Sort faces according to regionIds with patch-names from hash
|
||||
meshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&,
|
||||
const List<label>& regionIds,
|
||||
const Map<word>& regionNames
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces
|
||||
// with a single default patch
|
||||
meshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const xfer<List<face> >&
|
||||
);
|
||||
|
||||
//- Construct by transferring points and copying labelled faces
|
||||
// With region names per map or set to default.
|
||||
meshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const List<keyedFace>&,
|
||||
const Map<word>& regionNames
|
||||
);
|
||||
|
||||
//- Construct by transferring points and labelled faces
|
||||
//- with patch-names from hash
|
||||
meshedSurface
|
||||
(
|
||||
const xfer<pointField>&,
|
||||
const List<keyedFace>&,
|
||||
const HashTable<label>& nameToRegionMapping
|
||||
);
|
||||
|
||||
|
||||
@ -27,8 +27,6 @@ License
|
||||
#include "meshedSurface.H"
|
||||
#include "mergePoints.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Remove badly degenerate faces, double faces.
|
||||
@ -324,7 +322,4 @@ Foam::label Foam::meshedSurface::triangulate()
|
||||
return nTri;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user