mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
use triFace when triangulating surfaces
This commit is contained in:
@ -25,10 +25,12 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "AC3DfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
#include "tensor.H"
|
||||
#include "triFace.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
@ -231,9 +233,9 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
|
||||
// Start of vertices for object/patch
|
||||
label patchVertOffset = 0;
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<FaceType> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
|
||||
// patchId => patchName
|
||||
Map<word> regionNames;
|
||||
@ -349,7 +351,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
|
||||
|
||||
if (triangulate && verts.size() > 3)
|
||||
{
|
||||
face fTri(3);
|
||||
triFace fTri;
|
||||
|
||||
// simple face triangulation about f[0].
|
||||
// cannot use face::triangulation
|
||||
@ -535,7 +537,7 @@ void Foam::fileFormats::AC3DfileFormat::write
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHeader(os, patchLst);
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GTSfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
@ -115,7 +116,7 @@ Foam::fileFormats::GTSfileFormat::GTSfileFormat
|
||||
|
||||
// write directly into the lists:
|
||||
pointField& pointLst = points();
|
||||
List<face>& faceLst = faces();
|
||||
List<FaceType>& faceLst = faces();
|
||||
List<label>& regionLst = regions();
|
||||
|
||||
pointLst.setSize(nPoints);
|
||||
@ -239,13 +240,7 @@ Foam::fileFormats::GTSfileFormat::GTSfileFormat
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
|
||||
fTri[0] = e0Far;
|
||||
fTri[1] = common01;
|
||||
fTri[2] = e1Far;
|
||||
|
||||
faceLst[faceI] = triFace(e0Far, common01, e1Far);
|
||||
regionLst[faceI] = regionI;
|
||||
}
|
||||
|
||||
@ -263,7 +258,7 @@ void Foam::fileFormats::GTSfileFormat::write
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
// just issue a warning and get out
|
||||
@ -356,7 +351,7 @@ void Foam::fileFormats::GTSfileFormat::write
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "NASfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
@ -128,12 +129,12 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<point> pointLst;
|
||||
// Nastran index of points
|
||||
DynamicList<label> pointId;
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
DynamicList<label> pointId;
|
||||
DynamicList<FaceType> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
|
||||
// From face groupId to patchId
|
||||
Map<label> groupIdToPatchId;
|
||||
@ -265,7 +266,7 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
|
||||
if (cmd == "CTRIA3")
|
||||
{
|
||||
face fTri(3);
|
||||
triFace fTri;
|
||||
|
||||
label groupId = readLabel(IStringStream(line.substr(16,8))());
|
||||
fTri[0] = readLabel(IStringStream(line.substr(24,8))());
|
||||
@ -317,7 +318,7 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
|
||||
|
||||
if (triangulate)
|
||||
{
|
||||
face fTri(3);
|
||||
triFace fTri;
|
||||
|
||||
// simple face triangulation about f[0].
|
||||
// cannot use face::triangulation since points are incomplete
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OBJfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
@ -72,7 +73,7 @@ void Foam::fileFormats::OBJfileFormat::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst,
|
||||
const List<FaceType>& faceLst,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
@ -136,10 +137,10 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<face> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
DynamicList<point> pointLst;
|
||||
DynamicList<FaceType> faceLst;
|
||||
DynamicList<label> regionLst;
|
||||
HashTable<label> groupToPatch;
|
||||
|
||||
// leave faces that didn't have a group in 0
|
||||
label groupID = 0;
|
||||
@ -193,7 +194,7 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
}
|
||||
else if (cmd == "f")
|
||||
{
|
||||
DynamicList<label> verts;
|
||||
DynamicList<label> dynVertices;
|
||||
|
||||
// Assume 'f' is followed by space.
|
||||
string::size_type endNum = 1;
|
||||
@ -235,23 +236,25 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
|
||||
intStream >> vertI;
|
||||
}
|
||||
verts.append(vertI - 1);
|
||||
dynVertices.append(vertI - 1);
|
||||
}
|
||||
verts.shrink();
|
||||
dynVertices.shrink();
|
||||
|
||||
if (triangulate && verts.size() > 3)
|
||||
FaceType f(SubList<label>(dynVertices, dynVertices.size()));
|
||||
|
||||
if (triangulate && f.size() > 3)
|
||||
{
|
||||
face fTri(3);
|
||||
triFace fTri;
|
||||
|
||||
// simple face triangulation about f[0].
|
||||
// Cannot use face::triangulation since points are incomplete
|
||||
fTri[0] = verts[0];
|
||||
for (label fp1 = 1; fp1 < verts.size() - 1; fp1++)
|
||||
fTri[0] = f[0];
|
||||
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
|
||||
{
|
||||
label fp2 = (fp1 + 1) % verts.size();
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
fTri[1] = verts[fp1];
|
||||
fTri[2] = verts[fp2];
|
||||
fTri[1] = f[fp1];
|
||||
fTri[2] = f[fp2];
|
||||
|
||||
faceLst.append(fTri);
|
||||
regionLst.append(groupID);
|
||||
@ -259,7 +262,7 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
|
||||
}
|
||||
else
|
||||
{
|
||||
faceLst.append(face(verts));
|
||||
faceLst.append(f);
|
||||
regionLst.append(groupID);
|
||||
}
|
||||
}
|
||||
@ -282,7 +285,7 @@ void Foam::fileFormats::OBJfileFormat::write
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -320,7 +323,7 @@ void Foam::fileFormats::OBJfileFormat::write
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
|
||||
@ -69,9 +69,9 @@ class OBJfileFormat
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<face>&,
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<FaceType>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OFFfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IStringStream.H"
|
||||
@ -72,7 +73,7 @@ void Foam::fileFormats::OFFfileFormat::writeHead
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const List<face>& faceLst,
|
||||
const List<FaceType>& faceLst,
|
||||
const List<surfGroup>& patchLst
|
||||
)
|
||||
{
|
||||
@ -178,7 +179,7 @@ Foam::fileFormats::OFFfileFormat::OFFfileFormat
|
||||
|
||||
// Read faces - ignore optional region information
|
||||
// use a DynamicList for possible on-the-fly triangulation
|
||||
DynamicList<face> faceLst(nElems);
|
||||
DynamicList<FaceType> faceLst(nElems);
|
||||
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
@ -198,7 +199,7 @@ Foam::fileFormats::OFFfileFormat::OFFfileFormat
|
||||
|
||||
if (triangulate && f.size() > 3)
|
||||
{
|
||||
face fTri(3);
|
||||
triFace fTri;
|
||||
|
||||
// simple face triangulation about f[0].
|
||||
// cannot use face::triangulation since points are incomplete
|
||||
@ -241,7 +242,7 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
const keyedSurface& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
@ -278,7 +279,7 @@ void Foam::fileFormats::OFFfileFormat::write
|
||||
const meshedSurface& surf
|
||||
)
|
||||
{
|
||||
const List<face>& faceLst = surf.faces();
|
||||
const List<FaceType>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
|
||||
writeHead(os, surf.points(), faceLst, patchLst);
|
||||
|
||||
@ -78,7 +78,7 @@ class OFFfileFormat
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<face>&,
|
||||
const List<FaceType>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "STLfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "OSspecific.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
@ -216,9 +217,7 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
|
||||
label pointI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
|
||||
triFace fTri;
|
||||
|
||||
// Read an STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
@ -235,14 +234,16 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
|
||||
pointLst[pointI] = stlTri.c();
|
||||
fTri[2] = pointI++;
|
||||
|
||||
faceLst[faceI] = fTri;
|
||||
|
||||
// interprete colour as a region
|
||||
regionLst[faceI] = stlTri.region();
|
||||
|
||||
if (maxRegionId < stlTri.region())
|
||||
{
|
||||
maxRegionId = stlTri.region();
|
||||
}
|
||||
|
||||
// interprete colour as a region
|
||||
regionLst[faceI] = stlTri.region();
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
if
|
||||
(
|
||||
|
||||
@ -33,6 +33,7 @@ License
|
||||
\* ------------------------------------------------------------------------ */
|
||||
|
||||
#include "STLfileFormat.H"
|
||||
#include "triFace.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -395,18 +396,19 @@ Foam::fileFormats::STLfileFormat::readASCII
|
||||
regions().transfer(lexer.facets());
|
||||
|
||||
// make our triangles directly
|
||||
List<face>& faceLst = faces();
|
||||
List<FaceType>& faceLst = faces();
|
||||
faceLst.setSize(regions().size());
|
||||
|
||||
label ptI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
triFace fTri;
|
||||
|
||||
fTri[0] = ptI++;
|
||||
fTri[1] = ptI++;
|
||||
fTri[2] = ptI++;
|
||||
|
||||
faceLst[faceI] = fTri;
|
||||
}
|
||||
|
||||
setPatches(lexer.groupToPatch());
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "TRIfileFormat.H"
|
||||
#include "triFace.H"
|
||||
#include "clock.H"
|
||||
#include "IFstream.H"
|
||||
#include "IOmanip.H"
|
||||
@ -214,18 +215,19 @@ Foam::fileFormats::TRIfileFormat::TRIfileFormat
|
||||
regions().transfer(regionLst);
|
||||
|
||||
// make our triangles directly
|
||||
List<face>& faceLst = faces();
|
||||
List<FaceType>& faceLst = faces();
|
||||
faceLst.setSize(regions().size());
|
||||
|
||||
label ptI = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
face& fTri = faceLst[faceI];
|
||||
fTri.setSize(3);
|
||||
triFace fTri;
|
||||
|
||||
fTri[0] = ptI++;
|
||||
fTri[1] = ptI++;
|
||||
fTri[2] = ptI++;
|
||||
|
||||
faceLst[faceI] = fTri;
|
||||
}
|
||||
|
||||
setPatches(groupToPatch);
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "keyedSurface.H"
|
||||
#include "mergePoints.H"
|
||||
#include "triFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -259,8 +260,7 @@ Foam::label Foam::keyedSurface::triangulate()
|
||||
forAll (faceLst, faceI)
|
||||
{
|
||||
const FaceType& f = faceLst[faceI];
|
||||
|
||||
FaceType fTri(3);
|
||||
triFace fTri;
|
||||
|
||||
// Do simple face triangulation around f[0].
|
||||
// we could also use face::triangulation
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "meshedSurface.H"
|
||||
#include "mergePoints.H"
|
||||
#include "triFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -296,7 +297,7 @@ Foam::label Foam::meshedSurface::triangulate()
|
||||
for (; oldFaceI < patchEnd; ++oldFaceI)
|
||||
{
|
||||
const FaceType& f = faceLst[oldFaceI];
|
||||
FaceType fTri(3);
|
||||
triFace fTri;
|
||||
|
||||
// Do simple face triangulation around f[0].
|
||||
// we could also use face::triangulation
|
||||
|
||||
@ -88,7 +88,7 @@ Foam::surfGroup::surfGroup
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(const Foam::surfGroup& p)
|
||||
Foam::surfGroup::surfGroup(const surfGroup& p)
|
||||
:
|
||||
surfPatchIdentifier(p, p.index()),
|
||||
size_(p.size()),
|
||||
@ -96,7 +96,7 @@ Foam::surfGroup::surfGroup(const Foam::surfGroup& p)
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(const Foam::surfGroup& p, const label index)
|
||||
Foam::surfGroup::surfGroup(const surfGroup& p, const label index)
|
||||
:
|
||||
surfPatchIdentifier(p, index),
|
||||
size_(p.size()),
|
||||
|
||||
@ -107,11 +107,7 @@ public:
|
||||
surfGroup(const surfGroup&);
|
||||
|
||||
//- Construct from another patch, resetting the index
|
||||
surfGroup
|
||||
(
|
||||
const surfGroup&,
|
||||
const label index
|
||||
);
|
||||
surfGroup(const surfGroup&, const label index);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<surfGroup> clone() const
|
||||
|
||||
Reference in New Issue
Block a user