ENH: add 'flip()' in-place method to edge, face, triFace

This commit is contained in:
Mark Olesen
2010-12-07 08:58:31 +01:00
parent e72d32028c
commit f367ee2ece
23 changed files with 74 additions and 22 deletions

View File

@ -103,6 +103,9 @@ public:
//- Return common vertex
inline label commonVertex(const edge& a) const;
//- Flip the edge in-place.
inline void flip();
//- Return reverse edge
inline edge reverseEdge() const;

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "Swap.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -135,6 +136,12 @@ inline Foam::label Foam::edge::commonVertex(const edge& a) const
}
inline void Foam::edge::flip()
{
Swap(operator[](0), operator[](1));
}
inline Foam::edge Foam::edge::reverseEdge() const
{
return edge(end(), start());

View File

@ -27,11 +27,13 @@ License
#include "triFace.H"
#include "triPointRef.H"
#include "mathematicalConstants.H"
#include "Swap.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* const Foam::face::typeName = "face";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::vectorField>
@ -475,6 +477,20 @@ Foam::label Foam::face::collapse()
}
void Foam::face::flip()
{
const label n = size();
if (n > 2)
{
for (label i=1; i < (n+1)/2; ++i)
{
Swap(operator[](i), operator[](n-i));
}
}
}
Foam::point Foam::face::centre(const pointField& meshPoints) const
{
// Calculate the centre by breaking the face into triangles and

View File

@ -173,6 +173,10 @@ public:
// return the collapsed size
label collapse();
//- Flip the face in-place.
// The starting points of the original and flipped face are identical.
void flip();
//- Return the points corresponding to this face
inline pointField points(const pointField& meshPoints) const;

View File

@ -98,6 +98,10 @@ public:
// return the collapsed size, set collapsed point labels to -1
inline label collapse();
//- Flip the face in-place.
// The starting points of the original and flipped face are identical.
inline void flip();
//- Return the points corresponding to this face
inline pointField points(const pointField& meshPoints) const;

View File

@ -26,6 +26,7 @@ License
#include "IOstreams.H"
#include "face.H"
#include "triPointRef.H"
#include "Swap.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -118,6 +119,12 @@ inline Foam::label Foam::triFace::collapse()
}
inline void Foam::triFace::flip()
{
Swap(operator[](1), operator[](2));
}
inline Foam::pointField Foam::triFace::points(const pointField& points) const
{
pointField p(3);

View File

@ -360,7 +360,7 @@ void Foam::layerAdditionRemoval::removeCellLayer
if (flipFace)
{
newFace = newFace.reverseFace();
newFace.flip();
zoneFlip = !zoneFlip;
}

View File

@ -105,7 +105,7 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const
// Flip face based on flip index to recover original orientation
if (mfFlip[faceI])
{
curLocalFace = curLocalFace.reverseFace();
curLocalFace.flip();
}
// Get the opposing face from the master cell

View File

@ -1125,7 +1125,7 @@ Foam::label Foam::hexRef8::storeMidPointInfo
{
own = anchorCell1;
nei = anchorCell0;
newFace = newFace.reverseFace();
newFace.flip();
ownPt = mesh_.points()[anchors.otherVertex(anchorPointI)];
neiPt = mesh_.points()[anchorPointI];

View File

@ -1078,7 +1078,7 @@ void Foam::polyTopoChange::compact
&& faceNeighbour_[faceI] < faceOwner_[faceI]
)
{
faces_[faceI] = faces_[faceI].reverseFace();
faces_[faceI].flip();
Swap(faceOwner_[faceI], faceNeighbour_[faceI]);
flipFaceFlux_[faceI] =
(

View File

@ -89,7 +89,7 @@ void Foam::slidingInterface::decoupleInterface
if (masterPatchFlip[faceI])
{
newFace = newFace.reverseFace();
newFace.flip();
}
ref.setAction
@ -141,7 +141,7 @@ void Foam::slidingInterface::decoupleInterface
if (slavePatchFlip[faceI])
{
newFace = newFace.reverseFace();
newFace.flip();
}
// Recover retired points on the slave side

View File

@ -519,8 +519,7 @@ void Foam::enrichedPatch::calcCutFaces() const
// Reverse the face such that it
// points out of the master patch
cf[cf.size() - 1] =
cf[cf.size() - 1].reverseFace();
cf[cf.size() - 1].flip();
if (debug)
{

View File

@ -315,7 +315,7 @@ void Foam::cuttingPlane::walkCellCuts
// Orient face to point in the same direction as the plane normal
if ((f.normal(cutPoints) & normal()) < 0)
{
f = f.reverseFace();
f.flip();
}
// the cut faces are usually quite ugly, so optionally triangulate