From 448bd7be3e64ecbb825c0bde0c10fcad8825e6b6 Mon Sep 17 00:00:00 2001 From: laurence Date: Wed, 27 Feb 2013 12:34:44 +0000 Subject: [PATCH] ENH: surfaceFeatures: Add an option to only extract features geometrically If geometricTestOnly is set to true then edges will not be marked as region edges, only as internal or external edges. If there are any edges still marked as regions then this is because they are non-manifold. --- .../surfaceFeatureExtract.C | 63 +++++++++++++++---- .../surfaceFeatureExtractDict | 7 ++- .../surfaceFeatures/surfaceFeatures.C | 41 +++++++++--- .../surfaceFeatures/surfaceFeatures.H | 21 +++++-- 4 files changed, 102 insertions(+), 30 deletions(-) diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 88c7f67a41..f18bdda053 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -767,10 +767,17 @@ int main(int argc, char *argv[]) if (extractionMethod == "extractFromFile") { + const dictionary& extractFromFileDict = + surfaceDict.subDict("extractFromFileCoeffs"); + const fileName featureEdgeFile = - surfaceDict.subDict("extractFromFileCoeffs").lookup + extractFromFileDict.lookup("featureEdgeFile"); + + const Switch geometricTestOnly = + extractFromFileDict.lookupOrDefault ( - "featureEdgeFile" + "geometricTestOnly", + "no" ); edgeMesh eMesh(featureEdgeFile); @@ -779,24 +786,54 @@ int main(int argc, char *argv[]) eMesh.mergeEdges(); Info<< nl << "Reading existing feature edges from file " - << featureEdgeFile << endl; + << featureEdgeFile << nl + << "Selecting edges purely based on geometric tests: " + << geometricTestOnly.asText() << endl; - set.set(new surfaceFeatures(surf, eMesh.points(), eMesh.edges())); + set.set + ( + new surfaceFeatures + ( + surf, + eMesh.points(), + eMesh.edges(), + 1e-6, + geometricTestOnly + ) + ); } else if (extractionMethod == "extractFromSurface") { - includedAngle = readScalar - ( - surfaceDict.subDict("extractFromSurfaceCoeffs").lookup + const dictionary& extractFromSurfaceDict = + surfaceDict.subDict("extractFromSurfaceCoeffs"); + + includedAngle = + readScalar(extractFromSurfaceDict.lookup("includedAngle")); + + const Switch geometricTestOnly = + extractFromSurfaceDict.lookupOrDefault ( - "includedAngle" + "geometricTestOnly", + "no" + ); + + Info<< nl + << "Constructing feature set from included angle " + << includedAngle << nl + << "Selecting edges purely based on geometric tests: " + << geometricTestOnly.asText() << endl; + + set.set + ( + new surfaceFeatures + ( + surf, + includedAngle, + 0, + 0, + geometricTestOnly ) ); - - Info<< nl << "Constructing feature set from included angle " - << includedAngle << endl; - - set.set(new surfaceFeatures(surf, includedAngle)); } else { diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict index 0137468804..4928b881a0 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict @@ -26,6 +26,9 @@ surface1.stl // - 0 : selects no edges // - 180: selects all edges includedAngle 120; + + // Do not mark region edges + geometricTestOnly yes; } // Write options @@ -71,10 +74,10 @@ surface2.nas // Keep nonManifold edges (edges with >2 connected faces where // the faces form more than two different normal planes) - nonManifoldEdges yes; + nonManifoldEdges yes; // Keep open edges (edges with 1 connected face) - openEdges yes; + openEdges yes; } addFeatures diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index 514099c8df..800d3cf39e 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -213,7 +213,8 @@ void Foam::surfaceFeatures::classifyFeatureAngles ( const labelListList& edgeFaces, List& edgeStat, - const scalar minCos + const scalar minCos, + const bool geometricTestOnly ) const { const vectorField& faceNormals = surf_.faceNormals(); @@ -236,7 +237,11 @@ void Foam::surfaceFeatures::classifyFeatureAngles label face0 = eFaces[0]; label face1 = eFaces[1]; - if (surf_[face0].region() != surf_[face1].region()) + if + ( + !geometricTestOnly + && surf_[face0].region() != surf_[face1].region() + ) { edgeStat[edgeI] = REGION; } @@ -445,7 +450,8 @@ Foam::surfaceFeatures::surfaceFeatures const triSurface& surf, const scalar includedAngle, const scalar minLen, - const label minElems + const label minElems, + const bool geometricTestOnly ) : surf_(surf), @@ -454,7 +460,7 @@ Foam::surfaceFeatures::surfaceFeatures externalStart_(0), internalStart_(0) { - findFeatures(includedAngle); + findFeatures(includedAngle, geometricTestOnly); if (minLen > 0 || minElems > 0) { @@ -507,7 +513,8 @@ Foam::surfaceFeatures::surfaceFeatures const triSurface& surf, const pointField& points, const edgeList& edges, - const scalar mergeTol + const scalar mergeTol, + const bool geometricTestOnly ) : surf_(surf), @@ -553,7 +560,13 @@ Foam::surfaceFeatures::surfaceFeatures // Find whether an edge is external or internal List edgeStat(dynFeatEdges.size(), NONE); - classifyFeatureAngles(dynFeatureEdgeFaces, edgeStat, GREAT); + classifyFeatureAngles + ( + dynFeatureEdgeFaces, + edgeStat, + GREAT, + geometricTestOnly + ); // Transfer the edge status to a list encompassing all edges in the surface // so that calcFeatPoints can be used. @@ -632,14 +645,24 @@ Foam::labelList Foam::surfaceFeatures::selectFeatureEdges } -void Foam::surfaceFeatures::findFeatures(const scalar includedAngle) +void Foam::surfaceFeatures::findFeatures +( + const scalar includedAngle, + const bool geometricTestOnly +) { scalar minCos = Foam::cos(degToRad(180.0 - includedAngle)); // Per edge whether is feature edge. List edgeStat(surf_.nEdges(), NONE); - classifyFeatureAngles(surf_.edgeFaces(), edgeStat, minCos); + classifyFeatureAngles + ( + surf_.edgeFaces(), + edgeStat, + minCos, + geometricTestOnly + ); setFromStatus(edgeStat); } diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.H b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.H index 0fca9798a2..1eb76850f3 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.H +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -140,7 +140,8 @@ private: ( const labelListList& edgeFaces, List& edgeStat, - const scalar minCos + const scalar minCos, + const bool geometricTestOnly ) const; //- Choose next unset feature edge. @@ -184,13 +185,16 @@ public: ); //- Construct from surface, angle and min cumulative length and/or - // number of elements + // number of elements. If geometric test only is true, then region + // information is ignored and features are only assigned based on the + // geometric criteria surfaceFeatures ( const triSurface&, const scalar includedAngle, const scalar minLen = 0, - const label minElems = 0 + const label minElems = 0, + const bool geometricTestOnly = false ); //- Construct from dictionary @@ -205,7 +209,8 @@ public: const triSurface&, const pointField& points, const edgeList& edges, - const scalar mergeTol = 1e-6 + const scalar mergeTol = 1e-6, + const bool geometricTestOnly = false ); //- Construct as copy @@ -275,7 +280,11 @@ public: // Edit //- Find feature edges using provided included angle - void findFeatures(const scalar includedAngle); + void findFeatures + ( + const scalar includedAngle, + const bool geometricTestOnly + ); //- Delete small sets of edges. Edges are stringed up and any // string of length < minLen (or nElems < minElems) is deleted.