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"
//