Commit a1d7080d authored by Mark Olesen's avatar Mark Olesen
Browse files

face class - triangulation

- plain nTriangles() inline method for face class
  - triFace gets the same for symmetry
  - face::triangles(), face::trianglesQuads() return the number of faces generated
  - face::triangles() can append to a DynamicList
parent 129e16f9
......@@ -119,7 +119,7 @@ Foam::label Foam::face::mostConcaveAngle
}
void Foam::face::split
Foam::label Foam::face::split
(
const face::splitMode mode,
const pointField& points,
......@@ -129,6 +129,8 @@ void Foam::face::split
faceList& quadFaces
) const
{
label oldIndices = (triI + quadI);
if (size() <= 2)
{
FatalErrorIn
......@@ -143,7 +145,7 @@ void Foam::face::split
if (size() == 3)
{
// Triangle. Just copy.
if ((mode == COUNTQUAD) || (mode == COUNTTRIANGLE))
if (mode == COUNTTRIANGLE || mode == COUNTQUAD)
{
triI++;
}
......@@ -250,7 +252,7 @@ void Foam::face::split
}
else
{
// folded round
// folded around
diff = minIndex + size() - startIndex;
}
......@@ -281,6 +283,8 @@ void Foam::face::split
face1.split(mode, points, triI, quadI, triFaces, quadFaces);
face2.split(mode, points, triI, quadI, triFaces, quadFaces);
}
return (triI + quadI - oldIndices);
}
......@@ -749,30 +753,27 @@ int Foam::face::edgeDirection(const edge& e) const
// Number of triangles directly known from number of vertices
Foam::label Foam::face::nTriangles
(
const pointField&
) const
Foam::label Foam::face::nTriangles(const pointField&) const
{
return size() - 2;
return nTriangles();
}
void Foam::face::triangles
Foam::label Foam::face::triangles
(
const pointField& points,
label& triI,
faceList& triFaces
) const
{
faceList quadFaces;
label quadI = 0;
faceList quadFaces;
split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces);
return split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces);
}
void Foam::face::nTrianglesQuads
Foam::label Foam::face::nTrianglesQuads
(
const pointField& points,
label& triI,
......@@ -782,11 +783,11 @@ void Foam::face::nTrianglesQuads
faceList triFaces;
faceList quadFaces;
split(COUNTQUAD, points, triI, quadI, triFaces, quadFaces);
return split(COUNTQUAD, points, triI, quadI, triFaces, quadFaces);
}
void Foam::face::trianglesQuads
Foam::label Foam::face::trianglesQuads
(
const pointField& points,
label& triI,
......@@ -795,7 +796,7 @@ void Foam::face::trianglesQuads
faceList& quadFaces
) const
{
split(SPLITQUAD, points, triI, quadI, triFaces, quadFaces);
return split(SPLITQUAD, points, triI, quadI, triFaces, quadFaces);
}
......
......@@ -57,11 +57,14 @@ namespace Foam
class face;
class triFace;
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
class DynamicList;
inline bool operator==(const face& a, const face& b);
inline bool operator!=(const face& a, const face& b);
inline Istream& operator>>(Istream&, face&);
/*---------------------------------------------------------------------------*\
Class face Declaration
\*---------------------------------------------------------------------------*/
......@@ -108,9 +111,10 @@ class face
SPLITQUAD // split into triangles&quads
};
//- Split face into triangles or triangles&quads. Stores results
// quadFaces[quadI], triFaces[triI]
void split
//- Split face into triangles or triangles&quads.
// Stores results quadFaces[quadI], triFaces[triI]
// Returns number of new faces created
label split
(
const splitMode mode,
const pointField& points,
......@@ -270,30 +274,47 @@ public:
// Face splitting utilities
//- Number of triangles after splitting
inline label nTriangles() const;
//- Number of triangles after splitting
label nTriangles(const pointField& points) const;
//- Split into triangles using existing points. Result in
// triFaces[triI..triI+nTri]. Splits intelligently to maximize
// triangle quality.
void triangles
//- Split into triangles using existing points.
// Result in triFaces[triI..triI+nTri].
// Splits intelligently to maximize triangle quality.
// Returns number of faces created.
label triangles
(
const pointField& points,
label& triI,
faceList& triFaces
) const;
//- Split into triangles using existing points.
// Append to DynamicList.
// Returns number of faces created.
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
label triangles
(
const pointField& points,
DynamicList<face, SizeInc,SizeMult, SizeDiv>& triFaces
) const;
//- Number of triangles and quads after splitting
void nTrianglesQuads
// Returns the sum of both
label nTrianglesQuads
(
const pointField& points,
label& nTris,
label& nQuads
) const;
//- Split into triangles and quads. Result in triFaces (starting at
// triI and quadFaces (starting at quadI)
void trianglesQuads
//- Split into triangles and quads.
// Results in triFaces (starting at triI) and quadFaces
// (starting at quadI).
// Returns number of new faces created.
label trianglesQuads
(
const pointField& points,
label& triI,
......
......@@ -127,6 +127,11 @@ inline Foam::label Foam::face::prevLabel(const label i) const
return operator[](rcIndex(i));
}
// Number of triangles directly known from number of vertices
inline Foam::label Foam::face::nTriangles() const
{
return size() - 2;
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
......
......@@ -25,9 +25,28 @@ License
\*---------------------------------------------------------------------------*/
#include "face.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
Foam::label Foam::face::triangles
(
const pointField& points,
DynamicList<face, SizeInc, SizeMult, SizeDiv>& triFaces
) const
{
label triI = triFaces.size();
label quadI = 0;
faceList quadFaces;
// adjusts the addressable size (and allocate space if needed)
triFaces(triI + nTriangles());
return split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces);
}
template<class Type>
Type Foam::face::average
(
......
......@@ -124,6 +124,9 @@ public:
//- Return vector normal
inline vector normal(const pointField&) const;
//- Number of triangles after splitting
inline label nTriangles() const;
//- Return face with reverse direction
inline triFace reverseFace() const;
......
......@@ -224,6 +224,12 @@ inline Foam::vector Foam::triFace::normal(const pointField& points) const
}
inline Foam::label Foam::triFace::nTriangles() const
{
return 1;
}
inline Foam::triFace Foam::triFace::reverseFace() const
{
// The starting points of the original and reverse face are identical.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment