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