mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: When writing a triSurface to ascii stl or obj, exclude empty patches
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -52,8 +52,12 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
|
|||||||
// Print patch names as comment
|
// Print patch names as comment
|
||||||
forAll(myPatches, patchI)
|
forAll(myPatches, patchI)
|
||||||
{
|
{
|
||||||
os << "# " << patchI << " "
|
const surfacePatch& patch = myPatches[patchI];
|
||||||
<< myPatches[patchI].name() << nl;
|
|
||||||
|
if (patch.size() > 0)
|
||||||
|
{
|
||||||
|
os << "# " << patchI << " " << patch.name() << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
os << "#" << nl;
|
os << "#" << nl;
|
||||||
|
|
||||||
@ -77,25 +81,29 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
|
|||||||
|
|
||||||
forAll(myPatches, patchI)
|
forAll(myPatches, patchI)
|
||||||
{
|
{
|
||||||
|
const surfacePatch& patch = myPatches[patchI];
|
||||||
|
|
||||||
// Print all faces belonging to this patch
|
// Print all faces belonging to this patch
|
||||||
|
if (patch.size() > 0)
|
||||||
os << "g " << myPatches[patchI].name() << nl;
|
|
||||||
|
|
||||||
for
|
|
||||||
(
|
|
||||||
label patchFaceI = 0;
|
|
||||||
patchFaceI < myPatches[patchI].size();
|
|
||||||
patchFaceI++
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const label faceI = faceMap[faceIndex++];
|
os << "g " << patch.name() << nl;
|
||||||
|
|
||||||
os << "f "
|
for
|
||||||
<< operator[](faceI)[0] + 1 << ' '
|
(
|
||||||
<< operator[](faceI)[1] + 1 << ' '
|
label patchFaceI = 0;
|
||||||
<< operator[](faceI)[2] + 1
|
patchFaceI < patch.size();
|
||||||
//<< " # " << operator[](faceI).region()
|
patchFaceI++
|
||||||
<< nl;
|
)
|
||||||
|
{
|
||||||
|
const label faceI = faceMap[faceIndex++];
|
||||||
|
|
||||||
|
os << "f "
|
||||||
|
<< operator[](faceI)[0] + 1 << ' '
|
||||||
|
<< operator[](faceI)[1] + 1 << ' '
|
||||||
|
<< operator[](faceI)[2] + 1
|
||||||
|
//<< " # " << operator[](faceI).region()
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -43,39 +43,42 @@ void Foam::triSurface::writeSTLASCII(Ostream& os) const
|
|||||||
// Print all faces belonging to this region
|
// Print all faces belonging to this region
|
||||||
const surfacePatch& patch = myPatches[patchI];
|
const surfacePatch& patch = myPatches[patchI];
|
||||||
|
|
||||||
os << "solid " << patch.name() << endl;
|
if (patch.size() > 0)
|
||||||
|
|
||||||
for
|
|
||||||
(
|
|
||||||
label patchFaceI = 0;
|
|
||||||
patchFaceI < patch.size();
|
|
||||||
patchFaceI++
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const label faceI = faceMap[faceIndex++];
|
os << "solid " << patch.name() << endl;
|
||||||
|
|
||||||
const vector& n = faceNormals()[faceI];
|
for
|
||||||
|
(
|
||||||
|
label patchFaceI = 0;
|
||||||
|
patchFaceI < patch.size();
|
||||||
|
patchFaceI++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const label faceI = faceMap[faceIndex++];
|
||||||
|
|
||||||
os << " facet normal "
|
const vector& n = faceNormals()[faceI];
|
||||||
<< n.x() << ' ' << n.y() << ' ' << n.z() << nl
|
|
||||||
<< " outer loop" << endl;
|
|
||||||
|
|
||||||
const labelledTri& f = (*this)[faceI];
|
os << " facet normal "
|
||||||
const point& pa = points()[f[0]];
|
<< n.x() << ' ' << n.y() << ' ' << n.z() << nl
|
||||||
const point& pb = points()[f[1]];
|
<< " outer loop" << endl;
|
||||||
const point& pc = points()[f[2]];
|
|
||||||
|
|
||||||
os << " vertex "
|
const labelledTri& f = (*this)[faceI];
|
||||||
<< pa.x() << ' ' << pa.y() << ' ' << pa.z() << nl
|
const point& pa = points()[f[0]];
|
||||||
<< " vertex "
|
const point& pb = points()[f[1]];
|
||||||
<< pb.x() << ' ' << pb.y() << ' ' << pb.z() << nl
|
const point& pc = points()[f[2]];
|
||||||
<< " vertex "
|
|
||||||
<< pc.x() << ' ' << pc.y() << ' ' << pc.z() << nl
|
os << " vertex "
|
||||||
<< " endloop" << nl
|
<< pa.x() << ' ' << pa.y() << ' ' << pa.z() << nl
|
||||||
<< " endfacet" << endl;
|
<< " vertex "
|
||||||
|
<< pb.x() << ' ' << pb.y() << ' ' << pb.z() << nl
|
||||||
|
<< " vertex "
|
||||||
|
<< pc.x() << ' ' << pc.y() << ' ' << pc.z() << nl
|
||||||
|
<< " endloop" << nl
|
||||||
|
<< " endfacet" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "endsolid " << patch.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "endsolid " << patch.name() << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user