ENH: surfaceSubset: add select-by-plane

This commit is contained in:
mattijs
2013-07-11 17:12:49 +01:00
parent 7c081ac3e7
commit 6c319ce47b
2 changed files with 47 additions and 0 deletions

View File

@ -42,6 +42,7 @@ Description
#include "treeDataTriSurface.H"
#include "Random.H"
#include "volumeType.H"
#include "plane.H"
using namespace Foam;
@ -277,6 +278,31 @@ int main(int argc, char *argv[])
}
if (meshSubsetDict.found("plane"))
{
const dictionary& planeDict = meshSubsetDict.subDict("plane");
const plane pl(planeDict);
const scalar distance(readScalar(planeDict.lookup("distance")));
const scalar cosAngle(readScalar(planeDict.lookup("cosAngle")));
// Select all triangles that are close to the plane and
// whose normal aligns with the plane as well.
forAll(surf1.faceCentres(), faceI)
{
const point& fc = surf1.faceCentres()[faceI];
const point& nf = surf1.faceNormals()[faceI];
if (pl.distance(fc) < distance && mag(pl.normal() & nf) > cosAngle)
{
facesToSubset[faceI] = true;
}
}
}
//
// pick up specified "faces"
//

View File

@ -38,6 +38,27 @@ surface
outside yes;
}
// Select triangles on plane
plane
{
planeType embeddedPoints;
embeddedPointsDict
{
//point1 (-937.259845440205 160.865349115986 240.738791238078);
//point2 (-934.767379895778 9.63875523747379 14.412359671298);
//point3 (44.4744688899417 121.852927962709 182.352485273106);
point1 (-957.895294591874 242.865936478961 162.286611511875);
point2 (-961.43140327772 4.53895551562943 3.04159982093444);
point3 (91.2414146173805 72.1504381996692 48.2181961945329);
}
// Distance from plane
distance 0.1;
// Normal difference to plane
cosAngle 0.99;
}
// Extend selection with edge neighbours
addFaceNeighbours no;