mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0025894: BRepOffsetAPI_NormalProjection fails to projection an edge on a face
Test cases have been added Fix for trimmed parameters case.
This commit is contained in:
parent
aa9d6bec4e
commit
d1db9125d0
@ -583,10 +583,13 @@ void ProjLib_CompProjectedCurve::Init()
|
|||||||
}
|
}
|
||||||
// end of new part
|
// end of new part
|
||||||
|
|
||||||
Standard_Real FirstU, LastU, Step, DecStep, SearchStep, WalkStep, t;
|
Standard_Real FirstU, LastU, Step, SearchStep, WalkStep, t;
|
||||||
|
|
||||||
FirstU = myCurve->FirstParameter();
|
FirstU = myCurve->FirstParameter();
|
||||||
LastU = myCurve->LastParameter();
|
LastU = myCurve->LastParameter();
|
||||||
|
const Standard_Real GlobalMinStep = 1.e-4;
|
||||||
|
//<GlobalMinStep> is sufficiently small to provide solving from initial point
|
||||||
|
//and, on the other hand, it is sufficiently large to avoid too close solutions.
|
||||||
const Standard_Real MinStep = 0.01*(LastU - FirstU),
|
const Standard_Real MinStep = 0.01*(LastU - FirstU),
|
||||||
MaxStep = 0.1*(LastU - FirstU);
|
MaxStep = 0.1*(LastU - FirstU);
|
||||||
SearchStep = 10*MinStep;
|
SearchStep = 10*MinStep;
|
||||||
@ -669,11 +672,16 @@ void ProjLib_CompProjectedCurve::Init()
|
|||||||
// as initial point for aPrjPS, so we switch them
|
// as initial point for aPrjPS, so we switch them
|
||||||
gp_Vec2d D;
|
gp_Vec2d D;
|
||||||
|
|
||||||
|
if ((mySurface->IsUPeriodic() &&
|
||||||
|
Abs(Usup - Uinf - mySurface->UPeriod()) < Precision::Confusion()) ||
|
||||||
|
(mySurface->IsVPeriodic() &&
|
||||||
|
Abs(Vsup - Vinf - mySurface->VPeriod()) < Precision::Confusion()))
|
||||||
|
{
|
||||||
if((Abs(U - Uinf) < mySurface->UResolution(Precision::PConfusion())) &&
|
if((Abs(U - Uinf) < mySurface->UResolution(Precision::PConfusion())) &&
|
||||||
mySurface->IsUPeriodic())
|
mySurface->IsUPeriodic())
|
||||||
{
|
{
|
||||||
d1(t, U, V, D, myCurve, mySurface);
|
d1(t, U, V, D, myCurve, mySurface);
|
||||||
if (D.X() < 0) U = Usup;
|
if (D.X() < 0 ) U = Usup;
|
||||||
}
|
}
|
||||||
else if((Abs(U - Usup) < mySurface->UResolution(Precision::PConfusion())) &&
|
else if((Abs(U - Usup) < mySurface->UResolution(Precision::PConfusion())) &&
|
||||||
mySurface->IsUPeriodic())
|
mySurface->IsUPeriodic())
|
||||||
@ -694,6 +702,7 @@ void ProjLib_CompProjectedCurve::Init()
|
|||||||
d1(t, U, V, D, myCurve, mySurface);
|
d1(t, U, V, D, myCurve, mySurface);
|
||||||
if (D.Y() > 0) V = Vinf;
|
if (D.Y() > 0) V = Vinf;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (myMaxDist > 0)
|
if (myMaxDist > 0)
|
||||||
@ -765,7 +774,6 @@ void ProjLib_CompProjectedCurve::Init()
|
|||||||
else WalkStep = Min(MaxStep, Max(MinStep, 0.1*MagnD1/MagnD2));
|
else WalkStep = Min(MaxStep, Max(MinStep, 0.1*MagnD1/MagnD2));
|
||||||
|
|
||||||
Step = WalkStep;
|
Step = WalkStep;
|
||||||
DecStep = Step;;
|
|
||||||
|
|
||||||
t = Triple.X() + Step;
|
t = Triple.X() + Step;
|
||||||
if (t > LastU) t = LastU;
|
if (t > LastU) t = LastU;
|
||||||
@ -790,8 +798,7 @@ void ProjLib_CompProjectedCurve::Init()
|
|||||||
aLowBorder, aUppBorder, FuncTol, Standard_True);
|
aLowBorder, aUppBorder, FuncTol, Standard_True);
|
||||||
if(!aPrjPS.IsDone())
|
if(!aPrjPS.IsDone())
|
||||||
{
|
{
|
||||||
|
if (Step <= GlobalMinStep)
|
||||||
if (DecStep <= MinStep)
|
|
||||||
{
|
{
|
||||||
//Search for exact boundary point
|
//Search for exact boundary point
|
||||||
Tol = Min(myTolU, myTolV);
|
Tol = Min(myTolU, myTolV);
|
||||||
@ -820,18 +827,19 @@ void ProjLib_CompProjectedCurve::Init()
|
|||||||
Step =Step+LastU-t;
|
Step =Step+LastU-t;
|
||||||
t = LastU;
|
t = LastU;
|
||||||
}
|
}
|
||||||
DecStep=Step;
|
|
||||||
new_part = Standard_False;
|
new_part = Standard_False;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// decrease step
|
// decrease step
|
||||||
DecStep=DecStep / 2.;
|
Standard_Real SaveStep = Step;
|
||||||
Step = Max (MinStep , DecStep);
|
Step /= 2.;
|
||||||
t = Triple .X() + Step;
|
t = Triple .X() + Step;
|
||||||
if (t > (LastU-MinStep/4) )
|
if (t > (LastU-MinStep/4) )
|
||||||
{
|
{
|
||||||
Step =Step+LastU-t;
|
Step =Step+LastU-t;
|
||||||
|
if (Abs(Step - SaveStep) <= Precision::PConfusion())
|
||||||
|
Step = GlobalMinStep; //to avoid looping
|
||||||
t = LastU;
|
t = LastU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -878,7 +886,6 @@ void ProjLib_CompProjectedCurve::Init()
|
|||||||
Step =Step+LastU-t;
|
Step =Step+LastU-t;
|
||||||
t = LastU;
|
t = LastU;
|
||||||
}
|
}
|
||||||
DecStep=Step;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1220,8 +1227,28 @@ void ProjLib_CompProjectedCurve::D0(const Standard_Real U,gp_Pnt2d& P) const
|
|||||||
aPrjPS.Perform(U, U0, V0, gp_Pnt2d(myTolU, myTolV),
|
aPrjPS.Perform(U, U0, V0, gp_Pnt2d(myTolU, myTolV),
|
||||||
gp_Pnt2d(mySurface->FirstUParameter(), mySurface->FirstVParameter()),
|
gp_Pnt2d(mySurface->FirstUParameter(), mySurface->FirstVParameter()),
|
||||||
gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()));
|
gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()));
|
||||||
|
if (aPrjPS.IsDone())
|
||||||
P = aPrjPS.Solution();
|
P = aPrjPS.Solution();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gp_Pnt thePoint = myCurve->Value(U);
|
||||||
|
Extrema_ExtPS aExtPS(thePoint, mySurface->Surface(), myTolU, myTolV);
|
||||||
|
if (aExtPS.IsDone() && aExtPS.NbExt())
|
||||||
|
{
|
||||||
|
Standard_Integer i, Nend, imin = 1;
|
||||||
|
// Search for the nearest solution which is also a normal projection
|
||||||
|
Nend = aExtPS.NbExt();
|
||||||
|
for(i = 2; i <= Nend; i++)
|
||||||
|
if (aExtPS.SquareDistance(i) < aExtPS.SquareDistance(imin))
|
||||||
|
imin = i;
|
||||||
|
const Extrema_POnSurf& POnS = aExtPS.Point(imin);
|
||||||
|
Standard_Real ParU,ParV;
|
||||||
|
POnS.Parameter(ParU, ParV);
|
||||||
|
P.SetCoord(ParU, ParV);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
P.SetCoord(U0,V0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : D1
|
//function : D1
|
||||||
|
21
tests/bugs/moddata_3/bug25894_1
Normal file
21
tests/bugs/moddata_3/bug25894_1
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "CR25894"
|
||||||
|
puts "==========="
|
||||||
|
puts ""
|
||||||
|
###############################################################################
|
||||||
|
# BRepOffsetAPI_NormalProjection fails to projection an edge on a face
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
restore [locate_data_file bug25894_ProjectionFailed.brep] p
|
||||||
|
|
||||||
|
explode p
|
||||||
|
|
||||||
|
nproject r p_1 p_2
|
||||||
|
whatis r
|
||||||
|
set explode_log [explode r]
|
||||||
|
|
||||||
|
if { [regexp "r_1" ${explode_log}] != 1 } {
|
||||||
|
puts "Error : projection an edge on a face works wrongly"
|
||||||
|
} else {
|
||||||
|
puts "OK: projection an edge on a face works good"
|
||||||
|
}
|
21
tests/bugs/moddata_3/bug25894_2
Normal file
21
tests/bugs/moddata_3/bug25894_2
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "CR25894"
|
||||||
|
puts "==========="
|
||||||
|
puts ""
|
||||||
|
###############################################################################
|
||||||
|
# BRepOffsetAPI_NormalProjection fails to projection an edge on a face
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
restore [locate_data_file bug25894_ProjectionNotFailed.brep] p
|
||||||
|
|
||||||
|
explode p
|
||||||
|
|
||||||
|
nproject r p_2 p_1
|
||||||
|
whatis r
|
||||||
|
set explode_log [explode r]
|
||||||
|
|
||||||
|
if { [regexp "r_1" ${explode_log}] != 1 } {
|
||||||
|
puts "Error : projection an edge on a face works wrongly"
|
||||||
|
} else {
|
||||||
|
puts "OK: projection an edge on a face works good"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user