surfaceFeatureExtract: Refactoring surface closeness functions

This commit is contained in:
Henry Weller
2018-04-12 07:42:25 +01:00
parent 4e2074419b
commit ed5f44e7e8
5 changed files with 460 additions and 485 deletions

View File

@ -27,45 +27,205 @@ License
#include "Time.H" #include "Time.H"
#include "triSurfaceMesh.H" #include "triSurfaceMesh.H"
#include "vtkSurfaceWriter.H" #include "vtkSurfaceWriter.H"
#include "meshTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::extractCloseness const Foam::scalar Foam::internalAngleTolerance(80);
const Foam::scalar Foam::internalToleranceCosAngle
( (
const fileName &sFeatFileName, cos(degToRad(180 - internalAngleTolerance))
const Time& runTime, );
const triSurface &surf,
const bool writeVTK const Foam::scalar Foam::externalAngleTolerance(10);
const Foam::scalar Foam::externalToleranceCosAngle
(
cos(degToRad(180 - externalAngleTolerance))
);
void Foam::drawHitProblem
(
const label fi,
const triSurface& surf,
const point& start,
const point& p,
const point& end,
const pointIndexHitList& hitInfo
) )
{ {
// Searchable triSurface Info<< nl << "# findLineAll did not hit its own face."
const triSurfaceMesh searchSurf << nl << "# fi " << fi
( << nl << "# start " << start
IOobject << nl << "# point " << p
( << nl << "# end " << end
sFeatFileName + ".closeness", << nl << "# hitInfo " << hitInfo
runTime.constant(), << endl;
"triSurface",
runTime
),
surf
);
meshTools::writeOBJ(Info, start);
meshTools::writeOBJ(Info, p);
meshTools::writeOBJ(Info, end);
Info<< "l 1 2 3" << endl;
meshTools::writeOBJ(Info, surf.points()[surf[fi][0]]);
meshTools::writeOBJ(Info, surf.points()[surf[fi][1]]);
meshTools::writeOBJ(Info, surf.points()[surf[fi][2]]);
Info<< "f 4 5 6" << endl;
forAll(hitInfo, hi)
{
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
<< endl;
}
}
void Foam::processHit
(
scalar& internalCloseness,
scalar& externalCloseness,
const label fi,
const triSurface& surf,
const point& start,
const point& p,
const point& end,
const vector& normal,
const vectorField& normals,
const pointIndexHitList& hitInfo
)
{
if (hitInfo.size() < 1)
{
drawHitProblem(fi, surf, start, p, end, hitInfo);
}
else if (hitInfo.size() == 1)
{
if (!hitInfo[0].hit())
{
}
else if (hitInfo[0].index() != fi)
{
drawHitProblem(fi, surf, start, p, end, hitInfo);
}
}
else
{
label ownHiti = -1;
forAll(hitInfo, hI)
{
// Find the hit on the triangle that launched the ray
if (hitInfo[hI].index() == fi)
{
ownHiti = hI;
break;
}
}
if (ownHiti < 0)
{
drawHitProblem(fi, surf, start, p, end, hitInfo);
}
else if (ownHiti == 0)
{
// There are no internal hits, the first hit is the
// closest external hit
if
(
(normal & normals[hitInfo[ownHiti + 1].index()])
< externalToleranceCosAngle
)
{
externalCloseness = min
(
externalCloseness,
mag(p - hitInfo[ownHiti + 1].hitPoint())
);
}
}
else if (ownHiti == hitInfo.size() - 1)
{
// There are no external hits, the last but one hit is
// the closest internal hit
if
(
(normal & normals[hitInfo[ownHiti - 1].index()])
< internalToleranceCosAngle
)
{
internalCloseness = min
(
internalCloseness,
mag(p - hitInfo[ownHiti - 1].hitPoint())
);
}
}
else
{
if
(
(normal & normals[hitInfo[ownHiti + 1].index()])
< externalToleranceCosAngle
)
{
externalCloseness = min
(
externalCloseness,
mag(p - hitInfo[ownHiti + 1].hitPoint())
);
}
if
(
(normal & normals[hitInfo[ownHiti - 1].index()])
< internalToleranceCosAngle
)
{
internalCloseness = min
(
internalCloseness,
mag(p - hitInfo[ownHiti - 1].hitPoint())
);
}
}
}
}
Foam::Pair<Foam::tmp<Foam::triSurfaceScalarField>> Foam::extractCloseness
(
const triSurfaceMesh& surf
)
{
const Time& runTime = surf.objectRegistry::time();
// Prepare start and end points for intersection tests // Prepare start and end points for intersection tests
const vectorField& normals = searchSurf.faceNormals(); const vectorField& normals = surf.faceNormals();
const scalar span = searchSurf.bounds().mag(); const scalar span = surf.bounds().mag();
const pointField start(searchSurf.faceCentres() - span*normals); const pointField start(surf.faceCentres() - span*normals);
const pointField end(searchSurf.faceCentres() + span*normals); const pointField end(surf.faceCentres() + span*normals);
const pointField& faceCentres = searchSurf.faceCentres(); const pointField& faceCentres = surf.faceCentres();
List<List<pointIndexHit>> allHitinfo; List<List<pointIndexHit>> allHitinfo;
// Find all intersections (in order) // Find all intersections (in order)
searchSurf.findLineAll(start, end, allHitinfo); surf.findLineAll(start, end, allHitinfo);
scalarField internalCloseness(start.size(), great); scalarField internalCloseness(start.size(), great);
scalarField externalCloseness(start.size(), great); scalarField externalCloseness(start.size(), great);
@ -89,66 +249,42 @@ void Foam::extractCloseness
); );
} }
triSurfaceScalarField internalClosenessField return Pair<tmp<triSurfaceScalarField>>
( (
IOobject tmp<triSurfaceScalarField>
( (
sFeatFileName + ".internalCloseness", new triSurfaceScalarField
runTime.constant(), (
"triSurface", IOobject
runTime (
surf.objectRegistry::name() + ".internalCloseness",
runTime.constant(),
"triSurface",
runTime
),
surf,
dimLength,
internalCloseness
)
), ),
surf,
dimLength, tmp<triSurfaceScalarField>
internalCloseness (
new triSurfaceScalarField
(
IOobject
(
surf.objectRegistry::name() + ".externalCloseness",
runTime.constant(),
"triSurface",
runTime
),
surf,
dimLength,
externalCloseness
)
)
); );
internalClosenessField.write();
triSurfaceScalarField externalClosenessField
(
IOobject
(
sFeatFileName + ".externalCloseness",
runTime.constant(),
"triSurface",
runTime
),
surf,
dimLength,
externalCloseness
);
externalClosenessField.write();
if (writeVTK)
{
const faceList faces(surf.faces());
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
"internalCloseness", // fieldName
internalCloseness,
false, // isNodeValues
true // verbose
);
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
"externalCloseness", // fieldName
externalCloseness,
false, // isNodeValues
true // verbose
);
}
} }

View File

@ -25,157 +25,27 @@ License
#include "surfaceFeatureExtract.H" #include "surfaceFeatureExtract.H"
#include "Time.H" #include "Time.H"
#include "triSurfaceMesh.H"
#include "vtkSurfaceWriter.H" #include "vtkSurfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::processHit Foam::Pair<Foam::tmp<Foam::triSurfacePointScalarField>>
Foam::extractPointCloseness
( (
scalar& internalCloseness, const triSurfaceMesh& surf
scalar& externalCloseness,
const label fi,
const triSurface& surf,
const point& start,
const point& p,
const point& end,
const vector& normal,
const vectorField& normals,
const List<pointIndexHit>& hitInfo
) )
{ {
if (hitInfo.size() < 1) const Time& runTime = surf.objectRegistry::time();
{
drawHitProblem(fi, surf, start, p, end, hitInfo);
}
else if (hitInfo.size() == 1)
{
if (!hitInfo[0].hit())
{
}
else if (hitInfo[0].index() != fi)
{
drawHitProblem(fi, surf, start, p, end, hitInfo);
}
}
else
{
label ownHiti = -1;
forAll(hitInfo, hI)
{
// Find the hit on the triangle that launched the ray
if (hitInfo[hI].index() == fi)
{
ownHiti = hI;
break;
}
}
if (ownHiti < 0)
{
drawHitProblem(fi, surf, start, p, end, hitInfo);
}
else if (ownHiti == 0)
{
// There are no internal hits, the first hit is the
// closest external hit
if
(
(normal & normals[hitInfo[ownHiti + 1].index()])
< externalToleranceCosAngle
)
{
externalCloseness = min
(
externalCloseness,
mag(p - hitInfo[ownHiti + 1].hitPoint())
);
}
}
else if (ownHiti == hitInfo.size() - 1)
{
// There are no external hits, the last but one hit is
// the closest internal hit
if
(
(normal & normals[hitInfo[ownHiti - 1].index()])
< internalToleranceCosAngle
)
{
internalCloseness = min
(
internalCloseness,
mag(p - hitInfo[ownHiti - 1].hitPoint())
);
}
}
else
{
if
(
(normal & normals[hitInfo[ownHiti + 1].index()])
< externalToleranceCosAngle
)
{
externalCloseness = min
(
externalCloseness,
mag(p - hitInfo[ownHiti + 1].hitPoint())
);
}
if
(
(normal & normals[hitInfo[ownHiti - 1].index()])
< internalToleranceCosAngle
)
{
internalCloseness = min
(
internalCloseness,
mag(p - hitInfo[ownHiti - 1].hitPoint())
);
}
}
}
}
void Foam::extractPointCloseness
(
const fileName &sFeatFileName,
const Time& runTime,
const triSurface &surf,
const bool writeVTK
)
{
// Searchable triSurface
const triSurfaceMesh searchSurf
(
IOobject
(
sFeatFileName + ".closeness",
runTime.constant(),
"triSurface",
runTime
),
surf
);
// Prepare start and end points for intersection tests // Prepare start and end points for intersection tests
const pointField& points = searchSurf.points(); const pointField& points = surf.points();
const labelList& meshPoints = searchSurf.meshPoints(); const labelList& meshPoints = surf.meshPoints();
const pointField& faceCentres = searchSurf.faceCentres(); const pointField& faceCentres = surf.faceCentres();
const vectorField& normals = searchSurf.faceNormals(); const vectorField& normals = surf.faceNormals();
const labelListList& pointFaces = searchSurf.pointFaces(); const labelListList& pointFaces = surf.pointFaces();
const scalar span = searchSurf.bounds().mag(); const scalar span = surf.bounds().mag();
label nPointFaces = 0; label nPointFaces = 0;
forAll(pointFaces, pfi) forAll(pointFaces, pfi)
@ -204,10 +74,10 @@ void Foam::extractPointCloseness
} }
} }
List<List<pointIndexHit>> allHitinfo; List<pointIndexHitList> allHitinfo;
// Find all intersections (in order) // Find all intersections (in order)
searchSurf.findLineAll(start, end, allHitinfo); surf.findLineAll(start, end, allHitinfo);
scalarField internalCloseness(points.size(), great); scalarField internalCloseness(points.size(), great);
scalarField externalCloseness(points.size(), great); scalarField externalCloseness(points.size(), great);
@ -218,7 +88,7 @@ void Foam::extractPointCloseness
forAll(pointFaces[pi], pfi) forAll(pointFaces[pi], pfi)
{ {
const label fi = pointFaces[pi][pfi]; const label fi = pointFaces[pi][pfi];
const List<pointIndexHit>& hitInfo = allHitinfo[i]; const pointIndexHitList& hitInfo = allHitinfo[i];
processHit processHit
( (
@ -238,76 +108,42 @@ void Foam::extractPointCloseness
} }
} }
triSurfacePointScalarField internalClosenessPointField return Pair<tmp<triSurfacePointScalarField>>
( (
IOobject tmp<triSurfacePointScalarField>
( (
sFeatFileName + ".internalPointCloseness", new triSurfacePointScalarField
runTime.constant(), (
"triSurface", IOobject
runTime (
surf.objectRegistry::name() + ".internalPointCloseness",
runTime.constant(),
"triSurface",
runTime
),
surf,
dimLength,
internalCloseness
)
), ),
surf,
dimLength, tmp<triSurfacePointScalarField>
internalCloseness (
new triSurfacePointScalarField
(
IOobject
(
surf.objectRegistry::name() + ".externalPointCloseness",
runTime.constant(),
"triSurface",
runTime
),
surf,
dimLength,
externalCloseness
)
)
); );
internalClosenessPointField.write();
triSurfacePointScalarField externalClosenessPointField
(
IOobject
(
sFeatFileName + ".externalPointCloseness",
runTime.constant(),
"triSurface",
runTime
),
surf,
dimLength,
externalCloseness
);
externalClosenessPointField.write();
if (writeVTK)
{
const faceList faces(surf.faces());
const Map<label>& meshPointMap = surf.meshPointMap();
forAll(meshPointMap, pi)
{
internalCloseness[pi] =
internalClosenessPointField[meshPointMap[pi]];
externalCloseness[pi] =
externalClosenessPointField[meshPointMap[pi]];
}
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
"internalPointCloseness", // fieldName
internalCloseness,
true, // isNodeValues
true // verbose
);
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
"externalPointCloseness", // fieldName
externalCloseness,
true, // isNodeValues
true // verbose
);
}
} }

View File

@ -26,6 +26,7 @@ License
#include "surfaceFeatureExtract.H" #include "surfaceFeatureExtract.H"
#include "argList.H" #include "argList.H"
#include "Time.H" #include "Time.H"
#include "triSurfaceMesh.H"
#include "featureEdgeMesh.H" #include "featureEdgeMesh.H"
#include "vtkSurfaceWriter.H" #include "vtkSurfaceWriter.H"
#include "IOdictionary.H" #include "IOdictionary.H"
@ -255,26 +256,7 @@ int main(int argc, char *argv[])
<< " (edges with > 2 connected faces) unless they" << " (edges with > 2 connected faces) unless they"
<< " cross multiple regions" << endl; << " cross multiple regions" << endl;
forAll(edgeStat, edgeI) deleteNonManifoldEdges(surf, 1e-5, includedAngle, edgeStat);
{
const labelList& eFaces = surf.edgeFaces()[edgeI];
if
(
eFaces.size() > 2
&& edgeStat[edgeI] == surfaceFeatures::REGION
&& (eFaces.size() % 2) == 0
)
{
edgeStat[edgeI] = checkFlatRegionEdge
(
surf,
1e-5, //tol,
includedAngle,
edgeI
);
}
}
} }
const Switch openEdges = const Switch openEdges =
@ -285,11 +267,11 @@ int main(int argc, char *argv[])
Info<< "Removing all open edges" Info<< "Removing all open edges"
<< " (edges with 1 connected face)" << endl; << " (edges with 1 connected face)" << endl;
forAll(edgeStat, edgeI) forAll(edgeStat, edgei)
{ {
if (surf.edgeFaces()[edgeI].size() == 1) if (surf.edgeFaces()[edgei].size() == 1)
{ {
edgeStat[edgeI] = surfaceFeatures::NONE; edgeStat[edgei] = surfaceFeatures::NONE;
} }
} }
} }
@ -422,8 +404,115 @@ int main(int argc, char *argv[])
<< "internalToleranceCosAngle: " << internalToleranceCosAngle << "internalToleranceCosAngle: " << internalToleranceCosAngle
<< endl; << endl;
extractCloseness(sFeatFileName, runTime, surf, writeVTK); // Searchable triSurface
extractPointCloseness(sFeatFileName, runTime, surf, writeVTK); const triSurfaceMesh searchSurf
(
IOobject
(
sFeatFileName + ".closeness",
runTime.constant(),
"triSurface",
runTime
),
surf
);
{
Pair<tmp<triSurfaceScalarField>> closenessFields
(
extractCloseness(searchSurf)
);
closenessFields.first()->write();
closenessFields.second()->write();
if (writeVTK)
{
const faceList faces(searchSurf.faces());
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName
searchSurf.points(),
faces,
"internalCloseness", // fieldName
closenessFields.first(),
false, // isNodeValues
true // verbose
);
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName
searchSurf.points(),
faces,
"externalCloseness", // fieldName
closenessFields.second(),
false, // isNodeValues
true // verbose
);
}
}
{
Pair<tmp<triSurfacePointScalarField >> closenessFields
(
extractPointCloseness(searchSurf)
);
closenessFields.first()->write();
closenessFields.second()->write();
if (writeVTK)
{
const faceList faces(searchSurf.faces());
const Map<label>& meshPointMap = searchSurf.meshPointMap();
const triSurfacePointScalarField&
internalClosenessPointField = closenessFields.first();
const triSurfacePointScalarField&
externalClosenessPointField = closenessFields.second();
scalarField internalCloseness(searchSurf.nPoints(), great);
scalarField externalCloseness(searchSurf.nPoints(), great);
forAll(meshPointMap, pi)
{
internalCloseness[pi] =
internalClosenessPointField[meshPointMap[pi]];
externalCloseness[pi] =
externalClosenessPointField[meshPointMap[pi]];
}
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName
searchSurf.points(),
faces,
"internalPointCloseness", // fieldName
internalCloseness,
true, // isNodeValues
true // verbose
);
vtkSurfaceWriter().write
(
runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName
searchSurf.points(),
faces,
"externalPointCloseness", // fieldName
externalCloseness,
true, // isNodeValues
true // verbose
);
}
}
} }

View File

@ -31,6 +31,7 @@ Description
#include "surfaceFeatures.H" #include "surfaceFeatures.H"
#include "extendedFeatureEdgeMesh.H" #include "extendedFeatureEdgeMesh.H"
#include "triSurfaceMesh.H"
#include "triSurfaceFields.H" #include "triSurfaceFields.H"
#include "pointIndexHitList.H" #include "pointIndexHitList.H"
#include "plane.H" #include "plane.H"
@ -61,6 +62,39 @@ namespace Foam
List<surfaceFeatures::edgeStatus>& edgeStat List<surfaceFeatures::edgeStatus>& edgeStat
); );
//- Divide into multiple normal bins
// - return REGION if != 2 normals
// - return REGION if 2 normals that make feature angle
// - otherwise return NONE and set normals,bins
surfaceFeatures::edgeStatus checkNonManifoldEdge
(
const triSurface& surf,
const scalar tol,
const scalar includedAngle,
const label edgei
);
void deleteNonManifoldEdges
(
const triSurface& surf,
const scalar tol,
const scalar includedAngle,
List<surfaceFeatures::edgeStatus>& edgeStat
);
void writeStats(const extendedFeatureEdgeMesh& fem, Ostream& os);
void drawHitProblem
(
const label fi,
const triSurface& surf,
const point& start,
const point& p,
const point& end,
const pointIndexHitList& hitInfo
);
void processHit void processHit
( (
scalar& internalCloseness, scalar& internalCloseness,
@ -75,53 +109,15 @@ namespace Foam
const pointIndexHitList& hitInfo const pointIndexHitList& hitInfo
); );
void drawHitProblem Pair<tmp<triSurfaceScalarField>> extractCloseness
( (
const label fi, const triSurfaceMesh& surf
const triSurface& surf,
const point& start,
const point& p,
const point& end,
const pointIndexHitList& hitInfo
); );
//- Unmark non-manifold edges if individual triangles are not features Pair<tmp<triSurfacePointScalarField>> extractPointCloseness
void unmarkBaffles
( (
const triSurface& surf, const triSurfaceMesh& surf
const scalar includedAngle,
List<surfaceFeatures::edgeStatus>& edgeStat
); );
//- Divide into multiple normal bins
// - return REGION if != 2 normals
// - return REGION if 2 normals that make feature angle
// - otherwise return NONE and set normals,bins
surfaceFeatures::edgeStatus checkFlatRegionEdge
(
const triSurface& surf,
const scalar tol,
const scalar includedAngle,
const label edgeI
);
void extractCloseness
(
const fileName &sFeatFileName,
const Time& runTime,
const triSurface &surf,
const bool writeVTK
);
void extractPointCloseness
(
const fileName &sFeatFileName,
const Time& runTime,
const triSurface &surf,
const bool writeVTK
);
void writeStats(const extendedFeatureEdgeMesh& fem, Ostream& os);
} }

View File

@ -32,25 +32,11 @@ Description
#include "surfaceFeatureExtract.H" #include "surfaceFeatureExtract.H"
#include "Time.H" #include "Time.H"
#include "meshTools.H"
#include "tensor2D.H" #include "tensor2D.H"
#include "symmTensor2D.H" #include "symmTensor2D.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const Foam::scalar Foam::internalAngleTolerance(80);
const Foam::scalar Foam::internalToleranceCosAngle
(
cos(degToRad(180 - internalAngleTolerance))
);
const Foam::scalar Foam::externalAngleTolerance(10);
const Foam::scalar Foam::externalToleranceCosAngle
(
cos(degToRad(180 - externalAngleTolerance))
);
void Foam::deleteBox void Foam::deleteBox
( (
const triSurface& surf, const triSurface& surf,
@ -59,13 +45,13 @@ void Foam::deleteBox
List<surfaceFeatures::edgeStatus>& edgeStat List<surfaceFeatures::edgeStatus>& edgeStat
) )
{ {
forAll(edgeStat, edgeI) forAll(edgeStat, edgei)
{ {
const point eMid = surf.edges()[edgeI].centre(surf.localPoints()); const point eMid = surf.edges()[edgei].centre(surf.localPoints());
if (removeInside ? bb.contains(eMid) : !bb.contains(eMid)) if (removeInside ? bb.contains(eMid) : !bb.contains(eMid))
{ {
edgeStat[edgeI] = surfaceFeatures::NONE; edgeStat[edgei] = surfaceFeatures::NONE;
} }
} }
} }
@ -81,9 +67,9 @@ void Foam::deleteEdges
const pointField& points = surf.points(); const pointField& points = surf.points();
const labelList& meshPoints = surf.meshPoints(); const labelList& meshPoints = surf.meshPoints();
forAll(edgeStat, edgeI) forAll(edgeStat, edgei)
{ {
const edge& e = surf.edges()[edgeI]; const edge& e = surf.edges()[edgei];
const point& p0 = points[meshPoints[e.start()]]; const point& p0 = points[meshPoints[e.start()]];
const point& p1 = points[meshPoints[e.end()]]; const point& p1 = points[meshPoints[e.end()]];
const linePointRef line(p0, p1); const linePointRef line(p0, p1);
@ -95,117 +81,22 @@ void Foam::deleteEdges
if (!line.insideBoundBox(featPoint)) if (!line.insideBoundBox(featPoint))
{ {
edgeStat[edgeI] = surfaceFeatures::NONE; edgeStat[edgei] = surfaceFeatures::NONE;
} }
} }
} }
void Foam::drawHitProblem Foam::surfaceFeatures::edgeStatus Foam::checkNonManifoldEdge
(
const label fi,
const triSurface& surf,
const point& start,
const point& p,
const point& end,
const pointIndexHitList& hitInfo
)
{
Info<< nl << "# findLineAll did not hit its own face."
<< nl << "# fi " << fi
<< nl << "# start " << start
<< nl << "# point " << p
<< nl << "# end " << end
<< nl << "# hitInfo " << hitInfo
<< endl;
meshTools::writeOBJ(Info, start);
meshTools::writeOBJ(Info, p);
meshTools::writeOBJ(Info, end);
Info<< "l 1 2 3" << endl;
meshTools::writeOBJ(Info, surf.points()[surf[fi][0]]);
meshTools::writeOBJ(Info, surf.points()[surf[fi][1]]);
meshTools::writeOBJ(Info, surf.points()[surf[fi][2]]);
Info<< "f 4 5 6" << endl;
forAll(hitInfo, hi)
{
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
<< endl;
}
}
void Foam::unmarkBaffles
(
const triSurface& surf,
const scalar includedAngle,
List<surfaceFeatures::edgeStatus>& edgeStat
)
{
scalar minCos = Foam::cos(degToRad(180.0 - includedAngle));
const labelListList& edgeFaces = surf.edgeFaces();
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() > 2)
{
label i0 = eFaces[0];
//const labelledTri& f0 = surf[i0];
const Foam::vector& n0 = surf.faceNormals()[i0];
//Pout<< "edge:" << edgeI << " n0:" << n0 << endl;
bool same = true;
for (label i = 1; i < eFaces.size(); i++)
{
//const labelledTri& f = surf[i];
const Foam::vector& n = surf.faceNormals()[eFaces[i]];
//Pout<< " mag(n&n0): " << mag(n&n0) << endl;
if (mag(n&n0) < minCos)
{
same = false;
break;
}
}
if (same)
{
edgeStat[edgeI] = surfaceFeatures::NONE;
}
}
}
}
Foam::surfaceFeatures::edgeStatus Foam::checkFlatRegionEdge
( (
const triSurface& surf, const triSurface& surf,
const scalar tol, const scalar tol,
const scalar includedAngle, const scalar includedAngle,
const label edgeI const label edgei
) )
{ {
const edge& e = surf.edges()[edgeI]; const edge& e = surf.edges()[edgei];
const labelList& eFaces = surf.edgeFaces()[edgeI]; const labelList& eFaces = surf.edgeFaces()[edgei];
// Bin according to normal // Bin according to normal
@ -353,15 +244,42 @@ Foam::surfaceFeatures::edgeStatus Foam::checkFlatRegionEdge
} }
} }
// Passed all checks, two normal bins with the same contents.
//Pout<< "regionAndNormal:" << regionAndNormal << endl;
//Pout<< "myRegionAndNormal:" << regionAndNormal1 << endl;
return surfaceFeatures::NONE; return surfaceFeatures::NONE;
} }
} }
void Foam::deleteNonManifoldEdges
(
const triSurface& surf,
const scalar tol,
const scalar includedAngle,
List<surfaceFeatures::edgeStatus>& edgeStat
)
{
forAll(edgeStat, edgei)
{
const labelList& eFaces = surf.edgeFaces()[edgei];
if
(
eFaces.size() > 2
&& edgeStat[edgei] == surfaceFeatures::REGION
&& (eFaces.size() % 2) == 0
)
{
edgeStat[edgei] = checkNonManifoldEdge
(
surf,
tol,
includedAngle,
edgei
);
}
}
}
void Foam::writeStats(const extendedFeatureEdgeMesh& fem, Ostream& os) void Foam::writeStats(const extendedFeatureEdgeMesh& fem, Ostream& os)
{ {
os << " points : " << fem.points().size() << nl os << " points : " << fem.points().size() << nl
@ -369,23 +287,23 @@ void Foam::writeStats(const extendedFeatureEdgeMesh& fem, Ostream& os)
<< " convex : " << " convex : "
<< fem.concaveStart() << nl << fem.concaveStart() << nl
<< " concave : " << " concave : "
<< (fem.mixedStart()-fem.concaveStart()) << nl << (fem.mixedStart() - fem.concaveStart()) << nl
<< " mixed : " << " mixed : "
<< (fem.nonFeatureStart()-fem.mixedStart()) << nl << (fem.nonFeatureStart() - fem.mixedStart()) << nl
<< " non-feature : " << " non-feature : "
<< (fem.points().size()-fem.nonFeatureStart()) << nl << (fem.points().size() - fem.nonFeatureStart()) << nl
<< " edges : " << fem.edges().size() << nl << " edges : " << fem.edges().size() << nl
<< " of which" << nl << " of which" << nl
<< " external edges : " << " external edges : "
<< fem.internalStart() << nl << fem.internalStart() << nl
<< " internal edges : " << " internal edges : "
<< (fem.flatStart()- fem.internalStart()) << nl << (fem.flatStart() - fem.internalStart()) << nl
<< " flat edges : " << " flat edges : "
<< (fem.openStart()- fem.flatStart()) << nl << (fem.openStart() - fem.flatStart()) << nl
<< " open edges : " << " open edges : "
<< (fem.multipleStart()- fem.openStart()) << nl << (fem.multipleStart() - fem.openStart()) << nl
<< " multiply connected : " << " multiply connected : "
<< (fem.edges().size()- fem.multipleStart()) << endl; << (fem.edges().size() - fem.multipleStart()) << endl;
} }