From 6c319ce47beeda74ca24d4f8849371acc73acada Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 11 Jul 2013 17:12:49 +0100 Subject: [PATCH] ENH: surfaceSubset: add select-by-plane --- .../surface/surfaceSubset/surfaceSubset.C | 26 +++++++++++++++++++ .../surface/surfaceSubset/surfaceSubsetDict | 21 +++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubset.C b/applications/utilities/surface/surfaceSubset/surfaceSubset.C index 1958355238..c0ae6bd241 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubset.C +++ b/applications/utilities/surface/surfaceSubset/surfaceSubset.C @@ -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" // diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubsetDict b/applications/utilities/surface/surfaceSubset/surfaceSubsetDict index dec91897ba..9fe665f187 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubsetDict +++ b/applications/utilities/surface/surfaceSubset/surfaceSubsetDict @@ -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;