1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0024422: Wrong result done by FaceClassifier algorithm

Control of out of boundaries by finding circle-point extrema.
This commit is contained in:
nbv
2013-12-04 15:07:25 +04:00
committed by abv
parent 6bf1bdbd22
commit 73cd8a8afd
5 changed files with 690 additions and 646 deletions

View File

@@ -34,19 +34,19 @@ Extrema_ExtPElC2d::Extrema_ExtPElC2d () { myDone = Standard_False; }
Extrema_ExtPElC2d::Extrema_ExtPElC2d
(const gp_Pnt2d& P,
const gp_Lin2d& L,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Lin2d& L,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
Perform(P, L, Tol, Uinf, Usup);
}
void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
const gp_Lin2d& L,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Lin2d& L,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
myDone = Standard_True;
gp_Pnt2d OR, MyP;
@@ -57,13 +57,13 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
gp_Vec2d V(OR, P);
Standard_Real Mydist = V1.Dot(V);
if ((Mydist >= Uinf -Tol) &&
(Mydist <= Usup+ Tol)){
myNbExt = 1;
MyP = OR.Translated(Mydist*V1);
Extrema_POnCurv2d MyPOnCurve(Mydist, MyP);
mySqDist[0] = P.SquareDistance(MyP);
myPoint[0] = MyPOnCurve;
myIsMin[0] = Standard_True;
(Mydist <= Usup+ Tol)){
myNbExt = 1;
MyP = OR.Translated(Mydist*V1);
Extrema_POnCurv2d MyPOnCurve(Mydist, MyP);
mySqDist[0] = P.SquareDistance(MyP);
myPoint[0] = MyPOnCurve;
myIsMin[0] = Standard_True;
}
}
@@ -71,30 +71,32 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
Extrema_ExtPElC2d::Extrema_ExtPElC2d
(const gp_Pnt2d& P,
const gp_Circ2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Circ2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
Perform(P, C, Tol, Uinf, Usup);
}
void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
const gp_Circ2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Circ2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
Standard_Real radius, U1, U2;
// gp_Pnt2d OC, P1, P2, OL;
gp_Pnt2d OC, P1, P2;
OC = C.Location();
// gp_Pnt2d OC, P1, P2, OL;
gp_Pnt2d OC(C.Location());
myNbExt = 0;
if (OC.IsEqual(P, Precision::Confusion())) {
myDone = Standard_False;
}
else {
else
{
Standard_Real radius, U1, U2;
gp_Pnt2d P1, P2;
myDone = Standard_True;
gp_Dir2d V(gp_Vec2d(P, OC));
radius = C.Radius();
@@ -105,18 +107,29 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
Standard_Real myuinf = Uinf;
ElCLib::AdjustPeriodic(Uinf, Uinf+2*M_PI, Precision::PConfusion(), myuinf, U1);
ElCLib::AdjustPeriodic(Uinf, Uinf+2*M_PI, Precision::PConfusion(), myuinf, U2);
if (((U1-2*M_PI-Uinf) < Tol) && ((U1-2*M_PI-Uinf) > -Tol)) U1 = Uinf;
if (((U2-2*M_PI-Uinf) < Tol) && ((U2-2*M_PI-Uinf) > -Tol)) U2 = Uinf;
if (((U1-2*M_PI-Uinf) < Tol) && ((U1-2*M_PI-Uinf) > -Tol))
{
U1 = Uinf;
P1 = OC.XY() + radius * (cos(U1) * C.XAxis().Direction().XY() + sin(U1) * C.YAxis().Direction().XY());
}
if (((Uinf-U1) < Tol) && ((U1-Usup) < Tol)) {
if (((U2-2*M_PI-Uinf) < Tol) && ((U2-2*M_PI-Uinf) > -Tol))
{
U2 = Uinf;
P2 = OC.XY() + radius * (cos(U2) * C.XAxis().Direction().XY() + sin(U2) * C.YAxis().Direction().XY());
}
if (((Uinf-U1) < Tol) && ((U1-Usup) < Tol))
{
Extrema_POnCurv2d MyPOnCurve(U1, P1);
mySqDist[0] = P.SquareDistance(P1);
myPoint[0] = MyPOnCurve;
myIsMin[0] = Standard_True;
myNbExt++;
}
if (((Uinf-U2) < Tol) && ((U2-Usup) < Tol)) {
if (((Uinf-U2) < Tol) && ((U2-Usup) < Tol))
{
Extrema_POnCurv2d MyPOnCurve(U2, P2);
mySqDist[myNbExt] = P.SquareDistance(P2);
myPoint[myNbExt] = MyPOnCurve;
@@ -130,10 +143,10 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
Extrema_ExtPElC2d::Extrema_ExtPElC2d (const gp_Pnt2d& P,
const gp_Elips2d& E,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Elips2d& E,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
Perform(P, E, Tol, Uinf, Usup);
}
@@ -141,23 +154,23 @@ Extrema_ExtPElC2d::Extrema_ExtPElC2d (const gp_Pnt2d& P,
void Extrema_ExtPElC2d::Perform (const gp_Pnt2d& P,
const gp_Elips2d& E,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Elips2d& E,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
// gp_Pnt2d OR, P1, P2;
// gp_Pnt2d OR, P1, P2;
gp_Pnt2d OR;
OR = E.Location();
Standard_Integer NoSol, NbSol;
Standard_Real A = E.MajorRadius();
Standard_Real B = E.MinorRadius();
gp_Vec2d V(OR,P);
if (OR.IsEqual(P, Precision::Confusion()) &&
(Abs(A-B) <= Tol)) {
myDone = Standard_False;
(Abs(A-B) <= Tol)) {
myDone = Standard_False;
}
else {
Standard_Real X = V.Dot(gp_Vec2d(E.XAxis().Direction()));
@@ -184,20 +197,20 @@ void Extrema_ExtPElC2d::Perform (const gp_Pnt2d& P,
//=============================================================================
Extrema_ExtPElC2d::Extrema_ExtPElC2d (const gp_Pnt2d& P,
const gp_Hypr2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Hypr2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
Perform(P, C, Tol, Uinf, Usup);
}
void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
const gp_Hypr2d& H,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Hypr2d& H,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
gp_Pnt2d O = H.Location();
myDone = Standard_False;
@@ -223,21 +236,21 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
if (Vs > 0.) {
Us = Log(Vs);
if ((Us >= Uinf) && (Us <= Usup)) {
Cu = ElCLib::Value(Us,H);
DejaEnr = Standard_False;
for (NoExt = 0; NoExt < myNbExt; NoExt++) {
if (TbExt[NoExt].SquareDistance(Cu) < Tol2) {
DejaEnr = Standard_True;
break;
}
}
if (!DejaEnr) {
TbExt[myNbExt] = Cu;
mySqDist[myNbExt] = Cu.SquareDistance(P);
myIsMin[myNbExt] = (NoSol == 0);
myPoint[myNbExt] = Extrema_POnCurv2d(Us,Cu);
myNbExt++;
}
Cu = ElCLib::Value(Us,H);
DejaEnr = Standard_False;
for (NoExt = 0; NoExt < myNbExt; NoExt++) {
if (TbExt[NoExt].SquareDistance(Cu) < Tol2) {
DejaEnr = Standard_True;
break;
}
}
if (!DejaEnr) {
TbExt[myNbExt] = Cu;
mySqDist[myNbExt] = Cu.SquareDistance(P);
myIsMin[myNbExt] = (NoSol == 0);
myPoint[myNbExt] = Extrema_POnCurv2d(Us,Cu);
myNbExt++;
}
} // if ((Us >= Uinf) && (Us <= Usup))
} // if (Vs > 0.)
} // for (Standard_Integer NoSol = 1; ...
@@ -247,20 +260,20 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
//=============================================================================
Extrema_ExtPElC2d::Extrema_ExtPElC2d (const gp_Pnt2d& P,
const gp_Parab2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Parab2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
Perform(P, C, Tol, Uinf, Usup);
}
void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
const gp_Parab2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
const gp_Parab2d& C,
const Standard_Real Tol,
const Standard_Real Uinf,
const Standard_Real Usup)
{
myDone = Standard_False;
myNbExt = 0;
@@ -286,17 +299,17 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
Cu = ElCLib::Value(Us,C);
DejaEnr = Standard_False;
for (NoExt = 0; NoExt < myNbExt; NoExt++) {
if (TbExt[NoExt].SquareDistance(Cu) < Tol2) {
DejaEnr = Standard_True;
break;
}
if (TbExt[NoExt].SquareDistance(Cu) < Tol2) {
DejaEnr = Standard_True;
break;
}
}
if (!DejaEnr) {
TbExt[myNbExt] = Cu;
mySqDist[myNbExt] = Cu.SquareDistance(P);
myIsMin[myNbExt] = (NoSol == 0);
myPoint[myNbExt] = Extrema_POnCurv2d(Us,Cu);
myNbExt++;
TbExt[myNbExt] = Cu;
mySqDist[myNbExt] = Cu.SquareDistance(P);
myIsMin[myNbExt] = (NoSol == 0);
myPoint[myNbExt] = Extrema_POnCurv2d(Us,Cu);
myNbExt++;
}
} // if ((Us >= Uinf) && (Us <= Usup))
} // for (Standard_Integer NoSol = 1; ...