Commit 448bd7be authored by laurence's avatar laurence
Browse files

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.
parent 15ba9ec7
......@@ -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<Switch>
(
"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
const dictionary& extractFromSurfaceDict =
surfaceDict.subDict("extractFromSurfaceCoeffs");
includedAngle =
readScalar(extractFromSurfaceDict.lookup("includedAngle"));
const Switch geometricTestOnly =
extractFromSurfaceDict.lookupOrDefault<Switch>
(
"geometricTestOnly",
"no"
);
Info<< nl
<< "Constructing feature set from included angle "
<< includedAngle << nl
<< "Selecting edges purely based on geometric tests: "
<< geometricTestOnly.asText() << endl;
set.set
(
surfaceDict.subDict("extractFromSurfaceCoeffs").lookup
new surfaceFeatures
(
"includedAngle"
surf,
includedAngle,
0,
0,
geometricTestOnly
)
);
Info<< nl << "Constructing feature set from included angle "
<< includedAngle << endl;
set.set(new surfaceFeatures(surf, includedAngle));
}
else
{
......
......@@ -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
......
......@@ -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<edgeStatus>& 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<edgeStatus> 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<edgeStatus> edgeStat(surf_.nEdges(), NONE);
classifyFeatureAngles(surf_.edgeFaces(), edgeStat, minCos);
classifyFeatureAngles
(
surf_.edgeFaces(),
edgeStat,
minCos,
geometricTestOnly
);
setFromStatus(edgeStat);
}
......
......@@ -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<edgeStatus>& 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.
......
Supports Markdown
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