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

@ -99,7 +99,7 @@ int main(int argc, char *argv[])
Info<< "xB[" << xB->size() << "]\n";
DynamicList<label> dl(10);
for (label i = 0; i < 5; i++)
for (label i = 0; i < 5; ++i)
{
dl.append(i);
}
@ -111,11 +111,23 @@ int main(int argc, char *argv[])
Info<< "f1: " << f1 << endl;
Info<< "f2: " << f2 << endl;
// add some more labels
for (label i = 5; i < 8; ++i)
{
dl.append(i);
}
// note: xfer() method returns a plain labelList
face f3( dl.xfer() );
face f3(dl.xfer());
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
Info<< "f3: " << f3 << endl;
Info<<"\nflip faces:" << endl;
f1.flip();
f3.flip();
Info<< "f1: " << f1 << endl;
Info<< "f3: " << f3 << endl;
return 0;
}

View File

@ -853,7 +853,7 @@ int main(int argc, char *argv[])
{
foamOwner[faceI] = foamNeighbour[faceI];
foamNeighbour[faceI] = own;
foamFaces[faceI] = foamFaces[faceI].reverseFace();
foamFaces[faceI].flip();
}
}

View File

@ -375,7 +375,7 @@ faceList hexBlock::patchFaces(const label direc, const labelList& range) const
// turn all faces inside out
forAll(result, faceI)
{
result[faceI] = result[faceI].reverseFace();
result[faceI].flip();
}
}

View File

@ -867,7 +867,7 @@ int main(int argc, char *argv[])
fm[facei] = true;
if (!cubitFile)
{
faces[facei] = faces[facei].reverseFace();
faces[facei].flip();
}
Swap(owner[facei], neighbour[facei]);
}

View File

@ -226,7 +226,7 @@ int main(int argc, char *argv[])
if (((fc - cc) & fn) < 0)
{
// Boundary face points inwards. Flip.
boundaryFaces[faceI] = boundaryFaces[faceI].reverseFace();
boundaryFaces[faceI].flip();
}
// Done this face so erase from hash

View File

@ -472,7 +472,7 @@ faceList hexBlock::patchFaces(const label direc, const labelList& range) const
// turn all faces inside out
forAll(result, faceI)
{
result[faceI] = result[faceI].reverseFace();
result[faceI].flip();
}
}

View File

@ -1035,7 +1035,7 @@ void starMesh::createCoupleMatches()
# ifdef DEBUG_RIGHT_HAND_WALK
Info<< "Turning edge for right-hand turn rule" << endl;
# endif
startEdge = startEdge.reverseEdge();
startEdge.flip();
}
// prepare the loop for the right-hand walk
@ -1348,7 +1348,7 @@ void starMesh::createCoupleMatches()
) < VSMALL
)
{
intersectedFace = intersectedFace.reverseFace();
intersectedFace.flip();
}
// Add the new face to both master and slave

View File

@ -414,7 +414,7 @@ void Foam::createShellMesh::setRefinement
{
// Swap
Swap(minCellI, maxCellI);
newF = newF.reverseFace();
newF.flip();
}
//Pout<< "for internal edge:" << e

View File

@ -295,7 +295,7 @@ autoPtr<mapPolyMesh> reorderMesh
if (nei < own)
{
newFaces[faceI] = newFaces[faceI].reverseFace();
newFaces[faceI].flip();
Swap(newOwner[faceI], newNeighbour[faceI]);
}
}

View File

@ -403,7 +403,7 @@ void Foam::tecplotWriter::writeConnectivity
edge e = pp.edges()[edgeI];
if (e[0] > e[1])
{
e = e.reverseEdge();
e.flip();
}
FaceNodes[nodeI++] = INTEGER4(e[0]+1);
@ -448,7 +448,7 @@ void Foam::tecplotWriter::writeConnectivity
edge e = pp.edges()[edgeI];
if (e[0] > e[1])
{
e = e.reverseEdge();
e.flip();
}
const face& f0 = pp.localFaces()[eFaces[0]];

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