surfaceFeatureExtract: Refactored pointIndexHitList functionality into corresponding core classes

This commit is contained in:
Henry Weller
2018-04-10 23:08:56 +01:00
parent 388b3107c8
commit 3e1ab675f6
10 changed files with 197 additions and 200 deletions

View File

@ -475,9 +475,9 @@ int main(int argc, char *argv[])
scalarField featureProximity(surf.size(), searchDistance); 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 point& triCentre = tri.circumCentre();
const scalar radiusSqr = min const scalar radiusSqr = min
@ -486,26 +486,21 @@ int main(int argc, char *argv[])
sqr(searchDistance) sqr(searchDistance)
); );
List<pointIndexHit> hitList; pointIndexHitList hitList;
feMesh.allNearestFeatureEdges(triCentre, radiusSqr, hitList); feMesh.allNearestFeatureEdges(triCentre, radiusSqr, hitList);
featureProximity[fi] = min
featureProximity[fI] = (
calcProximityOfFeatureEdges feMesh.minDisconnectedDist(hitList),
( featureProximity[fi]
feMesh, );
hitList,
featureProximity[fI]
);
feMesh.allNearestFeaturePoints(triCentre, radiusSqr, hitList); feMesh.allNearestFeaturePoints(triCentre, radiusSqr, hitList);
featureProximity[fi] = min
featureProximity[fI] = (
calcProximityOfFeaturePoints minDist(hitList),
( featureProximity[fi]
hitList, );
featureProximity[fI]
);
} }
triSurfaceScalarField featureProximityField triSurfaceScalarField featureProximityField

View File

@ -32,6 +32,7 @@ Description
#include "surfaceFeatures.H" #include "surfaceFeatures.H"
#include "extendedFeatureEdgeMesh.H" #include "extendedFeatureEdgeMesh.H"
#include "triSurfaceFields.H" #include "triSurfaceFields.H"
#include "pointIndexHitList.H"
#include "plane.H" #include "plane.H"
#include "triadField.H" #include "triadField.H"
@ -43,19 +44,6 @@ namespace Foam
extern const scalar externalAngleTolerance; extern const scalar externalAngleTolerance;
extern const scalar externalToleranceCosAngle; extern const scalar externalToleranceCosAngle;
scalar calcProximityOfFeaturePoints
(
const List<pointIndexHit>& hitList,
const scalar defaultCellSize
);
scalar calcProximityOfFeatureEdges
(
const extendedFeatureEdgeMesh& efem,
const List<pointIndexHit>& hitList,
const scalar defaultCellSize
);
//- Deletes all edges inside/outside bounding box from set. //- Deletes all edges inside/outside bounding box from set.
void deleteBox void deleteBox
( (
@ -84,7 +72,7 @@ namespace Foam
const point& end, const point& end,
const vector& normal, const vector& normal,
const vectorField& normals, const vectorField& normals,
const List<pointIndexHit>& hitInfo const pointIndexHitList& hitInfo
); );
void drawHitProblem void drawHitProblem
@ -94,7 +82,7 @@ namespace Foam
const point& start, const point& start,
const point& p, const point& p,
const point& end, const point& end,
const List<pointIndexHit>& hitInfo const pointIndexHitList& hitInfo
); );
//- Unmark non-manifold edges if individual triangles are not features //- Unmark non-manifold edges if individual triangles are not features

View File

@ -51,100 +51,6 @@ const Foam::scalar Foam::externalToleranceCosAngle
); );
Foam::scalar Foam::calcProximityOfFeaturePoints
(
const List<pointIndexHit>& 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<pointIndexHit>& 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 void Foam::deleteBox
( (
const triSurface& surf, const triSurface& surf,
@ -202,7 +108,7 @@ void Foam::drawHitProblem
const point& start, const point& start,
const point& p, const point& p,
const point& end, const point& end,
const List<pointIndexHit>& hitInfo const pointIndexHitList& hitInfo
) )
{ {
Info<< nl << "# findLineAll did not hit its own face." Info<< nl << "# findLineAll did not hit its own face."
@ -225,18 +131,18 @@ void Foam::drawHitProblem
Info<< "f 4 5 6" << endl; 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][0]]);
meshTools::writeOBJ(Info, surf.points()[surf[hFI][1]]); meshTools::writeOBJ(Info, surf.points()[surf[hFI][1]]);
meshTools::writeOBJ(Info, surf.points()[surf[hFI][2]]); meshTools::writeOBJ(Info, surf.points()[surf[hFI][2]]);
Info<< "f " Info<< "f "
<< 3*hI + 7 << " " << 3*hi + 7 << " "
<< 3*hI + 8 << " " << 3*hi + 8 << " "
<< 3*hI + 9 << 3*hi + 9
<< endl; << endl;
} }
} }

View File

@ -406,6 +406,7 @@ primitiveShapes = meshes/primitiveShapes
$(primitiveShapes)/line/line.C $(primitiveShapes)/line/line.C
$(primitiveShapes)/plane/plane.C $(primitiveShapes)/plane/plane.C
$(primitiveShapes)/triangle/intersection.C $(primitiveShapes)/triangle/intersection.C
$(primitiveShapes)/objectHit/pointIndexHitList.C
$(primitiveShapes)/objectHit/pointIndexHitIOList.C $(primitiveShapes)/objectHit/pointIndexHitIOList.C
meshShapes = meshes/meshShapes meshShapes = meshes/meshShapes

View File

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pointIndexHitList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::scalar Foam::minDist(const List<pointIndexHit>& hitList)
{
scalar minDist = GREAT;
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())
{
minDist =
min(mag(pHit1.hitPoint() - pHit2.hitPoint()), minDist);
}
}
}
}
return minDist;
}
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
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<pointIndexHit> pointIndexHitList;
scalar minDist
(
const List<pointIndexHit>& hitList
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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

View File

@ -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

View File

@ -631,7 +631,7 @@ void Foam::extendedEdgeMesh::nearestFeatureEdge
( (
const pointField& samples, const pointField& samples,
const scalarField& searchDistSqr, const scalarField& searchDistSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const ) const
{ {
info.setSize(samples.size()); info.setSize(samples.size());
@ -652,7 +652,7 @@ void Foam::extendedEdgeMesh::nearestFeatureEdgeByType
( (
const point& sample, const point& sample,
const scalarField& searchDistSqr, const scalarField& searchDistSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const ) const
{ {
const PtrList<indexedOctree<treeDataEdge>>& edgeTrees = edgeTreesByType(); const PtrList<indexedOctree<treeDataEdge>>& edgeTrees = edgeTreesByType();
@ -688,7 +688,7 @@ void Foam::extendedEdgeMesh::allNearestFeaturePoints
( (
const point& sample, const point& sample,
scalar searchRadiusSqr, scalar searchRadiusSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const ) const
{ {
// Pick up all the feature points that intersect the search sphere // Pick up all the feature points that intersect the search sphere
@ -719,7 +719,7 @@ void Foam::extendedEdgeMesh::allNearestFeatureEdges
( (
const point& sample, const point& sample,
const scalar searchRadiusSqr, const scalar searchRadiusSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const ) const
{ {
const PtrList<indexedOctree<treeDataEdge>>& edgeTrees = edgeTreesByType(); const PtrList<indexedOctree<treeDataEdge>>& 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::treeDataPoint>& const Foam::indexedOctree<Foam::treeDataPoint>&
Foam::extendedEdgeMesh::pointTree() const Foam::extendedEdgeMesh::pointTree() const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -61,6 +61,7 @@ SourceFiles
#include "treeDataEdge.H" #include "treeDataEdge.H"
#include "treeDataPoint.H" #include "treeDataPoint.H"
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "pointIndexHitList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -362,7 +363,7 @@ public:
( (
const pointField& samples, const pointField& samples,
const scalarField& searchDistSqr, const scalarField& searchDistSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const; ) const;
//- Find the nearest point on each type of feature edge //- Find the nearest point on each type of feature edge
@ -370,7 +371,7 @@ public:
( (
const point& sample, const point& sample,
const scalarField& searchDistSqr, const scalarField& searchDistSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const; ) const;
//- Find all the feature points within searchDistSqr of sample //- Find all the feature points within searchDistSqr of sample
@ -378,7 +379,7 @@ public:
( (
const point& sample, const point& sample,
scalar searchRadiusSqr, scalar searchRadiusSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const; ) const;
//- Find all the feature edges within searchDistSqr of sample //- Find all the feature edges within searchDistSqr of sample
@ -386,9 +387,12 @@ public:
( (
const point& sample, const point& sample,
const scalar searchRadiusSqr, const scalar searchRadiusSqr,
List<pointIndexHit>& info pointIndexHitList& info
) const; ) const;
//- Return the minimum distance between disconnected edges
scalar minDisconnectedDist(const pointIndexHitList& hitList) const;
// Access // Access