diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index fdb3c9ec3..e27b7cd12 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -475,9 +475,9 @@ int main(int argc, char *argv[]) scalarField featureProximity(surf.size(), searchDistance); - forAll(surf, fI) + forAll(surf, fi) { - const triPointRef& tri = surf[fI].tri(surf.points()); + const triPointRef& tri = surf[fi].tri(surf.points()); const point& triCentre = tri.circumCentre(); const scalar radiusSqr = min @@ -486,26 +486,21 @@ int main(int argc, char *argv[]) sqr(searchDistance) ); - List hitList; + pointIndexHitList hitList; feMesh.allNearestFeatureEdges(triCentre, radiusSqr, hitList); - - featureProximity[fI] = - calcProximityOfFeatureEdges - ( - feMesh, - hitList, - featureProximity[fI] - ); + featureProximity[fi] = min + ( + feMesh.minDisconnectedDist(hitList), + featureProximity[fi] + ); feMesh.allNearestFeaturePoints(triCentre, radiusSqr, hitList); - - featureProximity[fI] = - calcProximityOfFeaturePoints - ( - hitList, - featureProximity[fI] - ); + featureProximity[fi] = min + ( + minDist(hitList), + featureProximity[fi] + ); } triSurfaceScalarField featureProximityField diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H index 85a9726ee..2cbaeafc6 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.H @@ -32,6 +32,7 @@ Description #include "surfaceFeatures.H" #include "extendedFeatureEdgeMesh.H" #include "triSurfaceFields.H" +#include "pointIndexHitList.H" #include "plane.H" #include "triadField.H" @@ -43,19 +44,6 @@ namespace Foam extern const scalar externalAngleTolerance; extern const scalar externalToleranceCosAngle; - scalar calcProximityOfFeaturePoints - ( - const List& hitList, - const scalar defaultCellSize - ); - - scalar calcProximityOfFeatureEdges - ( - const extendedFeatureEdgeMesh& efem, - const List& hitList, - const scalar defaultCellSize - ); - //- Deletes all edges inside/outside bounding box from set. void deleteBox ( @@ -84,7 +72,7 @@ namespace Foam const point& end, const vector& normal, const vectorField& normals, - const List& hitInfo + const pointIndexHitList& hitInfo ); void drawHitProblem @@ -94,7 +82,7 @@ namespace Foam const point& start, const point& p, const point& end, - const List& hitInfo + const pointIndexHitList& hitInfo ); //- Unmark non-manifold edges if individual triangles are not features diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C index ad37d5908..5b14c81e8 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractUtilities.C @@ -51,100 +51,6 @@ const Foam::scalar Foam::externalToleranceCosAngle ); -Foam::scalar Foam::calcProximityOfFeaturePoints -( - const List& hitList, - const scalar defaultCellSize -) -{ - scalar minDist = defaultCellSize; - - for - ( - label hI1 = 0; - hI1 < hitList.size() - 1; - ++hI1 - ) - { - const pointIndexHit& pHit1 = hitList[hI1]; - - if (pHit1.hit()) - { - for - ( - label hI2 = hI1 + 1; - hI2 < hitList.size(); - ++hI2 - ) - { - const pointIndexHit& pHit2 = hitList[hI2]; - - if (pHit2.hit()) - { - scalar curDist = mag(pHit1.hitPoint() - pHit2.hitPoint()); - - minDist = min(curDist, minDist); - } - } - } - } - - return minDist; -} - - -Foam::scalar Foam::calcProximityOfFeatureEdges -( - const extendedFeatureEdgeMesh& efem, - const List& hitList, - const scalar defaultCellSize -) -{ - scalar minDist = defaultCellSize; - - for - ( - label hI1 = 0; - hI1 < hitList.size() - 1; - ++hI1 - ) - { - const pointIndexHit& pHit1 = hitList[hI1]; - - if (pHit1.hit()) - { - const edge& e1 = efem.edges()[pHit1.index()]; - - for - ( - label hI2 = hI1 + 1; - hI2 < hitList.size(); - ++hI2 - ) - { - const pointIndexHit& pHit2 = hitList[hI2]; - - if (pHit2.hit()) - { - const edge& e2 = efem.edges()[pHit2.index()]; - - // Don't refine if the edges are connected to each other - if (!e1.connected(e2)) - { - scalar curDist = - mag(pHit1.hitPoint() - pHit2.hitPoint()); - - minDist = min(curDist, minDist); - } - } - } - } - } - - return minDist; -} - - void Foam::deleteBox ( const triSurface& surf, @@ -202,7 +108,7 @@ void Foam::drawHitProblem const point& start, const point& p, const point& end, - const List& hitInfo + const pointIndexHitList& hitInfo ) { Info<< nl << "# findLineAll did not hit its own face." @@ -225,18 +131,18 @@ void Foam::drawHitProblem Info<< "f 4 5 6" << endl; - forAll(hitInfo, hI) + forAll(hitInfo, hi) { - label hFI = hitInfo[hI].index(); + label hFI = hitInfo[hi].index(); meshTools::writeOBJ(Info, surf.points()[surf[hFI][0]]); meshTools::writeOBJ(Info, surf.points()[surf[hFI][1]]); meshTools::writeOBJ(Info, surf.points()[surf[hFI][2]]); Info<< "f " - << 3*hI + 7 << " " - << 3*hI + 8 << " " - << 3*hI + 9 + << 3*hi + 7 << " " + << 3*hi + 8 << " " + << 3*hi + 9 << endl; } } diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index a3b1f2640..d73a5734a 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -406,6 +406,7 @@ primitiveShapes = meshes/primitiveShapes $(primitiveShapes)/line/line.C $(primitiveShapes)/plane/plane.C $(primitiveShapes)/triangle/intersection.C +$(primitiveShapes)/objectHit/pointIndexHitList.C $(primitiveShapes)/objectHit/pointIndexHitIOList.C meshShapes = meshes/meshShapes diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHitList.C b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHitList.C new file mode 100644 index 000000000..f57cb820a --- /dev/null +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHitList.C @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 . + +\*---------------------------------------------------------------------------*/ + +#include "pointIndexHitList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::scalar Foam::minDist(const List& hitList) +{ + scalar minDist = GREAT; + + for (label hi1=0; hi1. + +Typedef + Foam::pointIndexHitList + +Description + List of pointIndexHits and associated functions + +\*---------------------------------------------------------------------------*/ + +#ifndef pointIndexHitList_H +#define pointIndexHitList_H + +#include "pointIndexHit.H" +#include "List.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef List pointIndexHitList; + + scalar minDist + ( + const List& hitList + ); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/edgeMesh/Make/files b/src/meshTools/edgeMesh/Make/files deleted file mode 100644 index 648ffed01..000000000 --- a/src/meshTools/edgeMesh/Make/files +++ /dev/null @@ -1,47 +0,0 @@ -em = . - -$(em)/edgeMesh.C -$(em)/edgeMeshIO.C -$(em)/edgeMeshNew.C - - -edgeMeshFormats = $(em)/edgeMeshFormats -$(edgeMeshFormats)/edgeMeshFormatsCore.C - -$(edgeMeshFormats)/edgeMesh/edgeMeshFormat.C -$(edgeMeshFormats)/edgeMesh/edgeMeshFormatRunTime.C - -$(edgeMeshFormats)/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshFormat.C -$(edgeMeshFormats)/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshFormatRunTime.C - - -$(edgeMeshFormats)/nas/NASedgeFormat.C -$(edgeMeshFormats)/nas/NASedgeFormatRunTime.C - -$(edgeMeshFormats)/obj/OBJedgeFormat.C -$(edgeMeshFormats)/obj/OBJedgeFormatRunTime.C - -$(edgeMeshFormats)/starcd/STARCDedgeFormat.C -$(edgeMeshFormats)/starcd/STARCDedgeFormatRunTime.C - -$(edgeMeshFormats)/vtk/VTKedgeFormat.C -$(edgeMeshFormats)/vtk/VTKedgeFormatRunTime.C - - -$(em)/featureEdgeMesh/featureEdgeMesh.C - -eem = $(em)/extendedEdgeMesh - -$(eem)/extendedEdgeMesh.C -$(eem)/extendedEdgeMeshNew.C - -$(eem)/extendedEdgeMeshFormats/extendedEdgeMeshFormat/extendedEdgeMeshFormat.C -$(eem)/extendedEdgeMeshFormats/extendedEdgeMeshFormat/extendedEdgeMeshFormatRunTime.C - -efm = $(eem)/extendedFeatureEdgeMesh - -$(efm)/extendedFeatureEdgeMesh.C - -searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C - -LIB = $(FOAM_LIBBIN)/libedgeMesh diff --git a/src/meshTools/edgeMesh/Make/options b/src/meshTools/edgeMesh/Make/options deleted file mode 100644 index 61439e40e..000000000 --- a/src/meshTools/edgeMesh/Make/options +++ /dev/null @@ -1,11 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/fileFormats/lnInclude \ - -I$(LIB_SRC)/surfMesh/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -LIB_LIBS = \ - -ltriSurface \ - -lmeshTools \ - -lfileFormats \ - -lsurfMesh diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C index 201c40d3e..0fab36c7b 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C @@ -631,7 +631,7 @@ void Foam::extendedEdgeMesh::nearestFeatureEdge ( const pointField& samples, const scalarField& searchDistSqr, - List& info + pointIndexHitList& info ) const { info.setSize(samples.size()); @@ -652,7 +652,7 @@ void Foam::extendedEdgeMesh::nearestFeatureEdgeByType ( const point& sample, const scalarField& searchDistSqr, - List& info + pointIndexHitList& info ) const { const PtrList>& edgeTrees = edgeTreesByType(); @@ -688,7 +688,7 @@ void Foam::extendedEdgeMesh::allNearestFeaturePoints ( const point& sample, scalar searchRadiusSqr, - List& info + pointIndexHitList& info ) const { // Pick up all the feature points that intersect the search sphere @@ -719,7 +719,7 @@ void Foam::extendedEdgeMesh::allNearestFeatureEdges ( const point& sample, const scalar searchRadiusSqr, - List& info + pointIndexHitList& info ) const { const PtrList>& edgeTrees = edgeTreesByType(); @@ -771,6 +771,56 @@ void Foam::extendedEdgeMesh::allNearestFeatureEdges } +Foam::scalar Foam::extendedEdgeMesh::minDisconnectedDist +( + const pointIndexHitList& hitList +) const +{ + scalar minDist = GREAT; + + for + ( + label hi1 = 0; + hi1 < hitList.size() - 1; + ++hi1 + ) + { + const pointIndexHit& pHit1 = hitList[hi1]; + + if (pHit1.hit()) + { + const edge& e1 = edges()[pHit1.index()]; + + for + ( + label hi2 = hi1 + 1; + hi2 < hitList.size(); + ++hi2 + ) + { + const pointIndexHit& pHit2 = hitList[hi2]; + + if (pHit2.hit()) + { + const edge& e2 = edges()[pHit2.index()]; + + // Don't refine if the edges are connected to each other + if (!e1.connected(e2)) + { + scalar curDist = + mag(pHit1.hitPoint() - pHit2.hitPoint()); + + minDist = min(curDist, minDist); + } + } + } + } + } + + return minDist; +} + + const Foam::indexedOctree& Foam::extendedEdgeMesh::pointTree() const { diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H index f5bc7c219..c73d3c26b 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -61,6 +61,7 @@ SourceFiles #include "treeDataEdge.H" #include "treeDataPoint.H" #include "PrimitivePatch.H" +#include "pointIndexHitList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -362,7 +363,7 @@ public: ( const pointField& samples, const scalarField& searchDistSqr, - List& info + pointIndexHitList& info ) const; //- Find the nearest point on each type of feature edge @@ -370,7 +371,7 @@ public: ( const point& sample, const scalarField& searchDistSqr, - List& info + pointIndexHitList& info ) const; //- Find all the feature points within searchDistSqr of sample @@ -378,7 +379,7 @@ public: ( const point& sample, scalar searchRadiusSqr, - List& info + pointIndexHitList& info ) const; //- Find all the feature edges within searchDistSqr of sample @@ -386,9 +387,12 @@ public: ( const point& sample, const scalar searchRadiusSqr, - List& info + pointIndexHitList& info ) const; + //- Return the minimum distance between disconnected edges + scalar minDisconnectedDist(const pointIndexHitList& hitList) const; + // Access