mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
surfaceFeatureExtract: Refactored core line and edge functions corresponding classes
This commit is contained in:
@ -43,10 +43,6 @@ namespace Foam
|
|||||||
extern const scalar externalAngleTolerance;
|
extern const scalar externalAngleTolerance;
|
||||||
extern const scalar externalToleranceCosAngle;
|
extern const scalar externalToleranceCosAngle;
|
||||||
|
|
||||||
point randomPointInPlane(const plane& p);
|
|
||||||
|
|
||||||
bool edgesConnected(const edge& e1, const edge& e2);
|
|
||||||
|
|
||||||
scalar calcProximityOfFeaturePoints
|
scalar calcProximityOfFeaturePoints
|
||||||
(
|
(
|
||||||
const List<pointIndexHit>& hitList,
|
const List<pointIndexHit>& hitList,
|
||||||
@ -64,13 +60,11 @@ namespace Foam
|
|||||||
void deleteBox
|
void deleteBox
|
||||||
(
|
(
|
||||||
const triSurface& surf,
|
const triSurface& surf,
|
||||||
const treeBoundBox& bb,
|
const boundBox& bb,
|
||||||
const bool removeInside,
|
const bool removeInside,
|
||||||
List<surfaceFeatures::edgeStatus>& edgeStat
|
List<surfaceFeatures::edgeStatus>& edgeStat
|
||||||
);
|
);
|
||||||
|
|
||||||
bool onLine(const point& p, const linePointRef& line);
|
|
||||||
|
|
||||||
//- Deletes all edges inside/outside bounding box from set.
|
//- Deletes all edges inside/outside bounding box from set.
|
||||||
void deleteEdges
|
void deleteEdges
|
||||||
(
|
(
|
||||||
|
|||||||
@ -51,23 +51,6 @@ const Foam::scalar Foam::externalToleranceCosAngle
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
bool Foam::edgesConnected(const edge& e1, const edge& e2)
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
e1.start() == e2.start()
|
|
||||||
|| e1.start() == e2.end()
|
|
||||||
|| e1.end() == e2.start()
|
|
||||||
|| e1.end() == e2.end()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::calcProximityOfFeaturePoints
|
Foam::scalar Foam::calcProximityOfFeaturePoints
|
||||||
(
|
(
|
||||||
const List<pointIndexHit>& hitList,
|
const List<pointIndexHit>& hitList,
|
||||||
@ -146,7 +129,7 @@ Foam::scalar Foam::calcProximityOfFeatureEdges
|
|||||||
const edge& e2 = efem.edges()[pHit2.index()];
|
const edge& e2 = efem.edges()[pHit2.index()];
|
||||||
|
|
||||||
// Don't refine if the edges are connected to each other
|
// Don't refine if the edges are connected to each other
|
||||||
if (!edgesConnected(e1, e2))
|
if (!e1.connected(e2))
|
||||||
{
|
{
|
||||||
scalar curDist =
|
scalar curDist =
|
||||||
mag(pHit1.hitPoint() - pHit2.hitPoint());
|
mag(pHit1.hitPoint() - pHit2.hitPoint());
|
||||||
@ -165,7 +148,7 @@ Foam::scalar Foam::calcProximityOfFeatureEdges
|
|||||||
void Foam::deleteBox
|
void Foam::deleteBox
|
||||||
(
|
(
|
||||||
const triSurface& surf,
|
const triSurface& surf,
|
||||||
const treeBoundBox& bb,
|
const boundBox& bb,
|
||||||
const bool removeInside,
|
const bool removeInside,
|
||||||
List<surfaceFeatures::edgeStatus>& edgeStat
|
List<surfaceFeatures::edgeStatus>& edgeStat
|
||||||
)
|
)
|
||||||
@ -182,25 +165,6 @@ void Foam::deleteBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::onLine(const point& p, const linePointRef& line)
|
|
||||||
{
|
|
||||||
const point& a = line.start();
|
|
||||||
const point& b = line.end();
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
( p.x() < min(a.x(), b.x()) || p.x() > max(a.x(), b.x()) )
|
|
||||||
|| ( p.y() < min(a.y(), b.y()) || p.y() > max(a.y(), b.y()) )
|
|
||||||
|| ( p.z() < min(a.z(), b.z()) || p.z() > max(a.z(), b.z()) )
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::deleteEdges
|
void Foam::deleteEdges
|
||||||
(
|
(
|
||||||
const triSurface& surf,
|
const triSurface& surf,
|
||||||
@ -223,7 +187,7 @@ void Foam::deleteEdges
|
|||||||
|
|
||||||
point featPoint = intersect * (p1 - p0) + p0;
|
point featPoint = intersect * (p1 - p0) + p0;
|
||||||
|
|
||||||
if (!onLine(featPoint, line))
|
if (!line.insideBoundBox(featPoint))
|
||||||
{
|
{
|
||||||
edgeStat[edgeI] = surfaceFeatures::NONE;
|
edgeStat[edgeI] = surfaceFeatures::NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -97,12 +97,15 @@ public:
|
|||||||
//- Return end vertex label
|
//- Return end vertex label
|
||||||
inline label& end();
|
inline label& end();
|
||||||
|
|
||||||
//- Given one vertex, return the other
|
//- Return true if connected to given edge
|
||||||
inline label otherVertex(const label a) const;
|
inline bool connected(const edge& a) const;
|
||||||
|
|
||||||
//- Return common vertex
|
//- Return common vertex
|
||||||
inline label commonVertex(const edge& a) const;
|
inline label commonVertex(const edge& a) const;
|
||||||
|
|
||||||
|
//- Given one vertex, return the other
|
||||||
|
inline label otherVertex(const label a) const;
|
||||||
|
|
||||||
//- Flip the edge in-place.
|
//- Flip the edge in-place.
|
||||||
inline void flip();
|
inline void flip();
|
||||||
|
|
||||||
|
|||||||
@ -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 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -100,20 +100,21 @@ inline Foam::label& Foam::edge::end()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::label Foam::edge::otherVertex(const label a) const
|
inline bool Foam::edge::connected(const edge& a) const
|
||||||
{
|
{
|
||||||
if (a == start())
|
if
|
||||||
|
(
|
||||||
|
start() == a.start()
|
||||||
|
|| start() == a.end()
|
||||||
|
|| end() == a.start()
|
||||||
|
|| end() == a.end()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return end();
|
return true;
|
||||||
}
|
|
||||||
else if (a == end())
|
|
||||||
{
|
|
||||||
return start();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The given vertex is not on the edge in the first place.
|
return false;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +137,23 @@ inline Foam::label Foam::edge::commonVertex(const edge& a) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::edge::otherVertex(const label a) const
|
||||||
|
{
|
||||||
|
if (a == start())
|
||||||
|
{
|
||||||
|
return end();
|
||||||
|
}
|
||||||
|
else if (a == end())
|
||||||
|
{
|
||||||
|
return start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The given vertex is not on the edge in the first place.
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline void Foam::edge::flip()
|
inline void Foam::edge::flip()
|
||||||
{
|
{
|
||||||
Swap(operator[](0), operator[](1));
|
Swap(operator[](0), operator[](1));
|
||||||
|
|||||||
@ -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 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -130,6 +130,8 @@ public:
|
|||||||
Point& edgePoint
|
Point& edgePoint
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
bool insideBoundBox(const Point&) const;
|
||||||
|
|
||||||
|
|
||||||
// Ostream operator
|
// Ostream operator
|
||||||
|
|
||||||
|
|||||||
@ -257,6 +257,23 @@ Foam::scalar Foam::line<Point, PointRef>::nearestDist
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Point, class PointRef>
|
||||||
|
bool Foam::line<Point, PointRef>::insideBoundBox(const Point& p) const
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
( p.x() < min(a_.x(), b_.x()) || p.x() > max(a_.x(), b_.x()) )
|
||||||
|
|| ( p.y() < min(a_.y(), b_.y()) || p.y() > max(a_.y(), b_.y()) )
|
||||||
|
|| ( p.z() < min(a_.z(), b_.z()) || p.z() > max(a_.z(), b_.z()) )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Point, class PointRef>
|
template<class Point, class PointRef>
|
||||||
|
|||||||
Reference in New Issue
Block a user