From a8ef9e9742ba0ba4edeb925ec1e3c403aca73c77 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 14 Sep 2018 09:34:14 +0200 Subject: [PATCH] ENH: make cuttingPlane cell walker an algorithm - takes two general actions: 1. orient edge in canonical direction (positive gradient) and detect any edge intersection. 2. edge intersection alpha (0-1) - refactor into a cuttingSurfaceBase intermediate class with the actions as templated parameters rather than function pointers. This allows the use of lambda functions with captures from the caller. --- src/sampling/Make/files | 2 +- src/sampling/surface/cutting/cuttingPlane.C | 87 ++++---- src/sampling/surface/cutting/cuttingPlane.H | 82 +------- .../surface/cutting/cuttingSurfaceBase.C | 109 ++++++++++ .../surface/cutting/cuttingSurfaceBase.H | 187 ++++++++++++++++++ ...neWalk.C => cuttingSurfaceBaseTemplates.C} | 43 +--- 6 files changed, 348 insertions(+), 162 deletions(-) create mode 100644 src/sampling/surface/cutting/cuttingSurfaceBase.C create mode 100644 src/sampling/surface/cutting/cuttingSurfaceBase.H rename src/sampling/surface/cutting/{cuttingPlaneWalk.C => cuttingSurfaceBaseTemplates.C} (91%) diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 7d3665f9a4..5e6a2e2ac6 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -21,7 +21,7 @@ sampledSet/shortestPath/shortestPathSet.C surface/cutting/cuttingPlane.C surface/cutting/cuttingPlaneCuts.C -surface/cutting/cuttingPlaneWalk.C +surface/cutting/cuttingSurfaceBase.C surface/distanceSurface/distanceSurface.C surface/isoSurface/isoSurface.C surface/isoSurface/isoSurfaceCell.C diff --git a/src/sampling/surface/cutting/cuttingPlane.C b/src/sampling/surface/cutting/cuttingPlane.C index 46f41212d9..30d6e29fe7 100644 --- a/src/sampling/surface/cutting/cuttingPlane.C +++ b/src/sampling/surface/cutting/cuttingPlane.C @@ -25,11 +25,6 @@ License #include "cuttingPlane.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -int Foam::cuttingPlane::debug(Foam::debug::debugSwitch("cuttingPlane", 0)); - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cuttingPlane::cuttingPlane(const plane& pln) @@ -89,6 +84,9 @@ void Foam::cuttingPlane::performCut bitSet&& cellIdLabels ) { + const plane& pln = *this; + const pointField& pts = mesh.points(); + MeshStorage::clear(); meshCells_.clear(); @@ -107,57 +105,40 @@ void Foam::cuttingPlane::performCut // - some ambiguity when plane is exactly between cells const label nFaceCuts = calcCellCuts(mesh, sides, cellCuts); - // Find closed loop from cell cuts - walkCellCuts(mesh, cellCuts, sides, triangulate, nFaceCuts); -} + // Walk cell cuts to create faces -void Foam::cuttingPlane::performCut -( - const primitiveMesh& mesh, - const bool triangulate, - const bitSet& cellIdLabels -) -{ - bitSet subsetCells(cellIdLabels); - - performCut(mesh, triangulate, std::move(subsetCells)); -} - - -void Foam::cuttingPlane::performCut -( - const primitiveMesh& mesh, - const bool triangulate, - const labelUList& cellIdLabels -) -{ - bitSet subsetCells; - - if (notNull(cellIdLabels)) - { - // Pre-populate with restriction - subsetCells.resize(mesh.nCells()); - subsetCells.set(cellIdLabels); - } - - performCut(mesh, triangulate, std::move(subsetCells)); -} - - -void Foam::cuttingPlane::remapFaces(const labelUList& faceMap) -{ - if (notNull(faceMap) && !faceMap.empty()) - { - MeshStorage::remapFaces(faceMap); - - List