Skip to content
Snippets Groups Projects
Commit 7922f845 authored by laurence's avatar laurence
Browse files

ENH: sortedEdgeFaces: now picks a direction with the largest angle with the edge

parent 08655f27
No related merge requests found
...@@ -66,15 +66,31 @@ Foam::PatchTools::sortedEdgeFaces ...@@ -66,15 +66,31 @@ Foam::PatchTools::sortedEdgeFaces
vector e2 = e.vec(localPoints); vector e2 = e.vec(localPoints);
e2 /= mag(e2) + VSMALL; e2 /= mag(e2) + VSMALL;
// Get opposite vertex for 0th face // Get the vertex on 0th face that forms a vector with the first
const Face& f = localFaces[faceNbs[0]]; // edge point that has the largest angle with the edge
label fp0 = findIndex(f, e[0]); const Face& f0 = localFaces[faceNbs[0]];
label fp1 = f.fcIndex(fp0);
label vertI = (f[fp1] != e[1] ? f[fp1] : f[f.fcIndex(fp1)]); scalar maxAngle = GREAT;
vector maxAngleEdgeDir(vector::max);
forAll(f0, fpI)
{
if (f0[fpI] != e.start())
{
const vector faceEdgeDir = localPoints[f0[fpI]] - edgePt;
const scalar angle = faceEdgeDir & e2;
if (angle < maxAngle)
{
maxAngle = angle;
maxAngleEdgeDir = faceEdgeDir;
}
}
}
// Get vector normal both to e2 and to edge from opposite vertex // Get vector normal both to e2 and to edge from opposite vertex
// to edge (will be x-axis of our coordinate system) // to edge (will be x-axis of our coordinate system)
vector e0 = e2 ^ (localPoints[vertI] - edgePt); vector e0 = e2 ^ maxAngleEdgeDir;
e0 /= mag(e0) + VSMALL; e0 /= mag(e0) + VSMALL;
// Get y-axis of coordinate system // Get y-axis of coordinate system
...@@ -87,13 +103,29 @@ Foam::PatchTools::sortedEdgeFaces ...@@ -87,13 +103,29 @@ Foam::PatchTools::sortedEdgeFaces
for (label nbI = 1; nbI < faceNbs.size(); nbI++) for (label nbI = 1; nbI < faceNbs.size(); nbI++)
{ {
// Get opposite vertex // Get the vertex on face that forms a vector with the first
// edge point that has the largest angle with the edge
const Face& f = localFaces[faceNbs[nbI]]; const Face& f = localFaces[faceNbs[nbI]];
label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0);
label vertI = (f[fp1] != e[1] ? f[fp1] : f[f.fcIndex(fp1)]);
vector vec = e2 ^ (localPoints[vertI] - edgePt); maxAngle = GREAT;
maxAngleEdgeDir = vector::max;
forAll(f, fpI)
{
if (f[fpI] != e.start())
{
const vector faceEdgeDir = localPoints[f[fpI]] - edgePt;
const scalar angle = faceEdgeDir & e2;
if (angle < maxAngle)
{
maxAngle = angle;
maxAngleEdgeDir = faceEdgeDir;
}
}
}
vector vec = e2 ^ maxAngleEdgeDir;
vec /= mag(vec) + VSMALL; vec /= mag(vec) + VSMALL;
faceAngles[nbI] = pseudoAngle faceAngles[nbI] = pseudoAngle
......
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