From 21d5267b6fb67d4fdcb4461a0c3998ce3cf5dec6 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 6 Apr 2018 20:15:28 +0100 Subject: [PATCH] surfaceFeatureExtract: Refactor core functionality into core classes and libraries --- .../surfaceFeatureExtract.C | 30 +- .../surfaceFeatureExtract.H | 17 - .../surfaceFeatureExtractUtilities.C | 335 ---------- .../meshes/primitiveShapes/plane/plane.C | 67 ++ .../meshes/primitiveShapes/plane/plane.H | 5 +- .../meshes/treeBoundBox/treeBoundBox.C | 26 + .../meshes/treeBoundBox/treeBoundBox.H | 6 + src/triSurface/triSurface/triSurface.C | 590 ++++++++++++------ src/triSurface/triSurface/triSurface.H | 33 +- 9 files changed, 533 insertions(+), 576 deletions(-) diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 60f682529..fdb3c9ec3 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -231,18 +231,18 @@ int main(int argc, char *argv[]) { treeBoundBox bb(subsetDict.lookup("insideBox")()); - Info<< "Removing all edges outside bb " << bb << endl; - dumpBox(bb, "subsetBox.obj"); - + Info<< "Removing all edges outside bb " << bb + << " see subsetBox.obj" << endl; + bb.writeOBJ("subsetBox.obj"); deleteBox(surf, bb, false, edgeStat); } else if (subsetDict.found("outsideBox")) { treeBoundBox bb(subsetDict.lookup("outsideBox")()); - Info<< "Removing all edges inside bb " << bb << endl; - dumpBox(bb, "deleteBox.obj"); - + Info<< "Removing all edges inside bb " << bb + << " see deleteBox.obj" << endl; + bb.writeOBJ("deleteBox.obj"); deleteBox(surf, bb, true, edgeStat); } @@ -432,16 +432,18 @@ int main(int argc, char *argv[]) Info<< nl << "Extracting curvature of surface at the points." << endl; - const vectorField pointNormals(surf.pointNormals2()); - triadField pointCoordSys = calcVertexCoordSys(surf, pointNormals); - - triSurfacePointScalarField k = calcCurvature + triSurfacePointScalarField k ( - sFeatFileName, - runTime, + IOobject + ( + sFeatFileName + ".curvature", + runTime.constant(), + "triSurface", + runTime + ), surf, - pointNormals, - pointCoordSys + dimLength, + surf.curvature() ); k.write(); diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H index 40333d3c1..7c326975e 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H @@ -45,21 +45,6 @@ namespace Foam point randomPointInPlane(const plane& p); - triadField calcVertexCoordSys - ( - const triSurface& surf, - const vectorField& pointNormals - ); - - triSurfacePointScalarField calcCurvature - ( - const word& name, - const Time& runTime, - const triSurface& surf, - const vectorField& pointNormals, - const triadField& pointCoordSys - ); - bool edgesConnected(const edge& e1, const edge& e2); scalar calcProximityOfFeaturePoints @@ -75,8 +60,6 @@ namespace Foam const scalar defaultCellSize ); - void dumpBox(const treeBoundBox& bb, const fileName& fName); - //- Deletes all edges inside/outside bounding box from set. void deleteBox ( diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C index 2321fb8b6..42a5e083c 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C @@ -28,11 +28,6 @@ Description Extracts and writes surface features to file. All but the basic feature extraction is WIP. - Curvature calculation is an implementation of the algorithm from: - - "Estimating Curvatures and their Derivatives on Triangle Meshes" - by S. Rusinkiewicz - \*---------------------------------------------------------------------------*/ #include "surfaceFeatureExtract.H" @@ -56,294 +51,6 @@ const Foam::scalar Foam::externalToleranceCosAngle ); -Foam::point Foam::randomPointInPlane(const plane& p) -{ - // Perturb base point - const point& refPt = p.refPoint(); - - // ax + by + cz + d = 0 - const FixedList& planeCoeffs = p.planeCoeffs(); - - const scalar perturbX = refPt.x() + 1e-3; - const scalar perturbY = refPt.y() + 1e-3; - const scalar perturbZ = refPt.z() + 1e-3; - - if (mag(planeCoeffs[2]) < small) - { - if (mag(planeCoeffs[1]) < small) - { - const scalar x = - -1.0 - *( - planeCoeffs[3] - + planeCoeffs[1]*perturbY - + planeCoeffs[2]*perturbZ - )/planeCoeffs[0]; - - return point - ( - x, - perturbY, - perturbZ - ); - } - - const scalar y = - -1.0 - *( - planeCoeffs[3] - + planeCoeffs[0]*perturbX - + planeCoeffs[2]*perturbZ - )/planeCoeffs[1]; - - return point - ( - perturbX, - y, - perturbZ - ); - } - else - { - const scalar z = - -1.0 - *( - planeCoeffs[3] - + planeCoeffs[0]*perturbX - + planeCoeffs[1]*perturbY - )/planeCoeffs[2]; - - return point - ( - perturbX, - perturbY, - z - ); - } -} - - -Foam::triadField Foam::calcVertexCoordSys -( - const triSurface& surf, - const vectorField& pointNormals -) -{ - const pointField& points = surf.points(); - const Map