/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Application surfaceFeatureExtract Group grpSurfaceUtilities 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 "argList.H" #include "Time.H" #include "triSurface.H" #include "surfaceFeatures.H" #include "featureEdgeMesh.H" #include "extendedFeatureEdgeMesh.H" #include "treeBoundBox.H" #include "meshTools.H" #include "OFstream.H" #include "triSurfaceMesh.H" #include "vtkSurfaceWriter.H" #include "triSurfaceFields.H" #include "indexedOctree.H" #include "treeDataEdge.H" #include "unitConversion.H" #include "plane.H" #include "tensor2D.H" #include "symmTensor2D.H" #include "point.H" #include "triadField.H" #include "transform.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // scalar calcVertexNormalWeight ( const triFace& f, const label pI, const vector& fN, const pointField& points ) { label index = findIndex(f, pI); if (index == -1) { FatalErrorInFunction << "Point not in face" << abort(FatalError); } const vector e1 = points[f[index]] - points[f[f.fcIndex(index)]]; const vector e2 = points[f[index]] - points[f[f.rcIndex(index)]]; return mag(fN)/(magSqr(e1)*magSqr(e2) + VSMALL); } point 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 ); } } triadField calcVertexCoordSys ( const triSurface& surf, const vectorField& pointNormals ) { const pointField& points = surf.points(); const Map