1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0030203: ProjLib_ComputeApproxOnPolarSurface::BuildInitialCurve2d array out of bound

Bug fixing: avoiding calculation if tPp == NbOfPnts
This commit is contained in:
ifv 2018-10-16 17:10:44 +03:00 committed by apn
parent d8406b2f3a
commit e5826d916c
2 changed files with 32 additions and 20 deletions

View File

@ -1180,32 +1180,30 @@ Handle(Adaptor2d_HCurve2d)
} }
} }
if( tPp != 0 ) { if (tPp != 0 && tPp != NbOfPnts) {
gp_Pnt2d aPp = gp_Pnt2d(u,v); gp_Pnt2d aPp = gp_Pnt2d(u,v);
gp_Pnt2d aPn; gp_Pnt2d aPn;
j = 1;
Standard_Boolean isFound = Standard_False; Standard_Boolean isFound = Standard_False;
while( !isFound ) { for (j = tPp + 1; j <= NbOfPnts; ++j)
Curve->D0( Param.Value(tPp+j), pntproj ); {
Curve->D0( Param.Value(j), pntproj );
Extrema_ExtPS aTPS( pntproj, Surf->Surface(), TolU, TolV ); Extrema_ExtPS aTPS( pntproj, Surf->Surface(), TolU, TolV );
Dist2Min = 1.e+200; Dist2Min = RealLast();
Standard_Integer indExt = 0;
if( aTPS.IsDone() && aTPS.NbExt() >= 1 ) { if( aTPS.IsDone() && aTPS.NbExt() >= 1 ) {
Standard_Integer indExt = 0;
for (i = 1; i <= aTPS.NbExt(); i++) { for (i = 1; i <= aTPS.NbExt(); i++) {
if (aTPS.SquareDistance(i) < DistTol3d2 && aTPS.SquareDistance(i) < Dist2Min) { if (aTPS.SquareDistance(i) < DistTol3d2 && aTPS.SquareDistance(i) < Dist2Min) {
Dist2Min = aTPS.SquareDistance(i); Dist2Min = aTPS.SquareDistance(i);
indExt = i; indExt = i;
isFound = Standard_True;
} }
} }
} if (indExt > 0) {
if( isFound ) {
aTPS.Point(indExt).Parameter(u,v); aTPS.Point(indExt).Parameter(u,v);
aPn = gp_Pnt2d(u,v); aPn = gp_Pnt2d(u,v);
isFound = Standard_True;
break; break;
} }
j++; }
if( (tPp+j) > NbOfPnts ) break;
} }
if( isFound ) { if( isFound ) {

View File

@ -0,0 +1,14 @@
puts "========"
puts "0030203: ProjLib_ComputeApproxOnPolarSurface::BuildInitialCurve2d array out of bound"
puts "========"
puts ""
restore [locate_data_file bug30203_curv.draw] c
restore [locate_data_file bug30203_surf.draw] s
catch {project cc c s}
if { [isdraw cc]} {
checklength cc -l 1.
} else {
puts "Error: projection fails"
}