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

0024886: BRepOffsetAPI_NormalProjection failure

Test case for issue CR24886
This commit is contained in:
ifv 2014-09-11 12:33:38 +04:00 committed by bugmaster
parent 1e2fb24474
commit 6e0fd076ae
3 changed files with 617 additions and 593 deletions

View File

@ -93,7 +93,7 @@ static void d1(const Standard_Real t,
//purpose : computes second derivative of the projected curve //purpose : computes second derivative of the projected curve
//======================================================================= //=======================================================================
static void d2(const Standard_Real t, static void d2(const Standard_Real t,
const Standard_Real u, const Standard_Real u,
const Standard_Real v, const Standard_Real v,
gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V1, gp_Vec2d& V2,
@ -206,7 +206,7 @@ static void d1CurvOnSurf(const Standard_Real t,
//purpose : computes second derivative of the 3D projected curve //purpose : computes second derivative of the 3D projected curve
//======================================================================= //=======================================================================
static void d2CurvOnSurf(const Standard_Real t, static void d2CurvOnSurf(const Standard_Real t,
const Standard_Real u, const Standard_Real u,
const Standard_Real v, const Standard_Real v,
gp_Vec& V1 , gp_Vec& V2 , gp_Vec& V1 , gp_Vec& V2 ,
@ -495,7 +495,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
//purpose : //purpose :
//======================================================================= //=======================================================================
ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve() ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve()
{ {
} }
@ -504,7 +504,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
//purpose : //purpose :
//======================================================================= //=======================================================================
ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve( ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve(
const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor3d_HSurface)& S,
const Handle(Adaptor3d_HCurve)& C, const Handle(Adaptor3d_HCurve)& C,
const Standard_Real TolU, const Standard_Real TolU,
@ -521,7 +521,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
//purpose : //purpose :
//======================================================================= //=======================================================================
ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve( ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve(
const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor3d_HSurface)& S,
const Handle(Adaptor3d_HCurve)& C, const Handle(Adaptor3d_HCurve)& C,
const Standard_Real TolU, const Standard_Real TolU,
@ -539,7 +539,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::Init() void ProjLib_CompProjectedCurve::Init()
{ {
myTabInt.Nullify(); myTabInt.Nullify();
@ -847,11 +847,11 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
// Sequence postproceeding // Sequence postproceeding
Standard_Integer j; Standard_Integer j;
// 1. Removing poor parts // 1. Removing poor parts
Standard_Integer NbPart=myNbCurves; Standard_Integer NbPart=myNbCurves;
Standard_Integer ipart=1; Standard_Integer ipart=1;
for(i = 1; i <= NbPart; i++) { for(i = 1; i <= NbPart; i++) {
// Standard_Integer NbPoints = mySequence->Value(i)->Length(); // Standard_Integer NbPoints = mySequence->Value(i)->Length();
if(mySequence->Value(ipart)->Length() < 2) { if(mySequence->Value(ipart)->Length() < 2) {
mySequence->Remove(ipart); mySequence->Remove(ipart);
myNbCurves--; myNbCurves--;
@ -861,7 +861,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
if(myNbCurves == 0) return; if(myNbCurves == 0) return;
// 2. Removing common parts of bounds // 2. Removing common parts of bounds
for(i = 1; i < myNbCurves; i++) for(i = 1; i < myNbCurves; i++)
{ {
if(mySequence->Value(i)->Value(mySequence->Value(i)->Length()).X() >= if(mySequence->Value(i)->Value(mySequence->Value(i)->Length()).X() >=
@ -869,7 +869,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
mySequence->ChangeValue(i+1)->ChangeValue(1).SetX(mySequence->Value(i)->Value(mySequence->Value(i)->Length()).X() + 1.e-12); mySequence->ChangeValue(i+1)->ChangeValue(1).SetX(mySequence->Value(i)->Value(mySequence->Value(i)->Length()).X() + 1.e-12);
} }
// 3. Computation of the maximum distance from each part of curve to surface // 3. Computation of the maximum distance from each part of curve to surface
myMaxDistance = new TColStd_HArray1OfReal(1, myNbCurves); myMaxDistance = new TColStd_HArray1OfReal(1, myNbCurves);
myMaxDistance->Init(0); myMaxDistance->Init(0);
@ -887,7 +887,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
} }
// 4. Check the projection to be a single point // 4. Check the projection to be a single point
gp_Pnt2d Pmoy, Pcurr, P; gp_Pnt2d Pmoy, Pcurr, P;
Standard_Real AveU, AveV; Standard_Real AveU, AveV;
@ -919,7 +919,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
} }
} }
// 5. Check the projection to be an isoparametric curve of the surface // 5. Check the projection to be an isoparametric curve of the surface
myUIso = new TColStd_HArray1OfBoolean(1, myNbCurves); myUIso = new TColStd_HArray1OfBoolean(1, myNbCurves);
for(i = 1; i <= myNbCurves; i++) myUIso->SetValue(i, Standard_True); for(i = 1; i <= myNbCurves; i++) myUIso->SetValue(i, Standard_True);
@ -934,7 +934,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
continue; continue;
} }
// new test for isoparametrics // new test for isoparametrics
if ( mySequence->Value(i)->Length() > 2) { if ( mySequence->Value(i)->Length() > 2) {
//compute an average U and V //compute an average U and V
@ -965,7 +965,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
break; break;
} }
} }
// //
} }
} }
} }
@ -994,7 +994,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
const Handle(Adaptor3d_HSurface)& ProjLib_CompProjectedCurve::GetSurface() const const Handle(Adaptor3d_HSurface)& ProjLib_CompProjectedCurve::GetSurface() const
{ {
return mySurface; return mySurface;
} }
@ -1005,7 +1005,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
const Handle(Adaptor3d_HCurve)& ProjLib_CompProjectedCurve::GetCurve() const const Handle(Adaptor3d_HCurve)& ProjLib_CompProjectedCurve::GetCurve() const
{ {
return myCurve; return myCurve;
} }
@ -1015,7 +1015,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::GetTolerance(Standard_Real& TolU, void ProjLib_CompProjectedCurve::GetTolerance(Standard_Real& TolU,
Standard_Real& TolV) const Standard_Real& TolV) const
{ {
TolU = myTolU; TolU = myTolU;
@ -1027,7 +1027,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer ProjLib_CompProjectedCurve::NbCurves() const Standard_Integer ProjLib_CompProjectedCurve::NbCurves() const
{ {
return myNbCurves; return myNbCurves;
} }
@ -1036,7 +1036,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::Bounds(const Standard_Integer Index, void ProjLib_CompProjectedCurve::Bounds(const Standard_Integer Index,
Standard_Real& Udeb, Standard_Real& Udeb,
Standard_Real& Ufin) const Standard_Real& Ufin) const
{ {
@ -1049,7 +1049,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean ProjLib_CompProjectedCurve::IsSinglePnt(const Standard_Integer Index, gp_Pnt2d& P) const Standard_Boolean ProjLib_CompProjectedCurve::IsSinglePnt(const Standard_Integer Index, gp_Pnt2d& P) const
{ {
if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise();
P = gp_Pnt2d(mySequence->Value(Index)->Value(1).Y(), mySequence->Value(Index)->Value(1).Z()); P = gp_Pnt2d(mySequence->Value(Index)->Value(1).Y(), mySequence->Value(Index)->Value(1).Z());
@ -1061,7 +1061,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean ProjLib_CompProjectedCurve::IsUIso(const Standard_Integer Index, Standard_Real& U) const Standard_Boolean ProjLib_CompProjectedCurve::IsUIso(const Standard_Integer Index, Standard_Real& U) const
{ {
if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise();
U = mySequence->Value(Index)->Value(1).Y(); U = mySequence->Value(Index)->Value(1).Y();
@ -1072,7 +1072,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean ProjLib_CompProjectedCurve::IsVIso(const Standard_Integer Index, Standard_Real& V) const Standard_Boolean ProjLib_CompProjectedCurve::IsVIso(const Standard_Integer Index, Standard_Real& V) const
{ {
if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise();
V = mySequence->Value(Index)->Value(1).Z(); V = mySequence->Value(Index)->Value(1).Z();
@ -1083,7 +1083,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
gp_Pnt2d ProjLib_CompProjectedCurve::Value(const Standard_Real t) const gp_Pnt2d ProjLib_CompProjectedCurve::Value(const Standard_Real t) const
{ {
gp_Pnt2d P; gp_Pnt2d P;
D0(t, P); D0(t, P);
@ -1094,7 +1094,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::D0(const Standard_Real U,gp_Pnt2d& P) const void ProjLib_CompProjectedCurve::D0(const Standard_Real U,gp_Pnt2d& P) const
{ {
Standard_Integer i, j; Standard_Integer i, j;
Standard_Real Udeb, Ufin; Standard_Real Udeb, Ufin;
@ -1117,10 +1117,10 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
for(j = 1; j < End; j++) for(j = 1; j < End; j++)
if ((U >= mySequence->Value(i)->Value(j).X()) && (U <= mySequence->Value(i)->Value(j + 1).X())) break; if ((U >= mySequence->Value(i)->Value(j).X()) && (U <= mySequence->Value(i)->Value(j + 1).X())) break;
// U0 = mySequence->Value(i)->Value(j).Y(); // U0 = mySequence->Value(i)->Value(j).Y();
// V0 = mySequence->Value(i)->Value(j).Z(); // V0 = mySequence->Value(i)->Value(j).Z();
// Cubic Interpolation // Cubic Interpolation
if(mySequence->Value(i)->Length() < 4 || if(mySequence->Value(i)->Length() < 4 ||
(Abs(U-mySequence->Value(i)->Value(j).X()) <= Precision::PConfusion()) ) (Abs(U-mySequence->Value(i)->Value(j).X()) <= Precision::PConfusion()) )
{ {
@ -1190,7 +1190,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::D1(const Standard_Real t, void ProjLib_CompProjectedCurve::D1(const Standard_Real t,
gp_Pnt2d& P, gp_Pnt2d& P,
gp_Vec2d& V) const gp_Vec2d& V) const
{ {
@ -1205,7 +1205,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::D2(const Standard_Real t, void ProjLib_CompProjectedCurve::D2(const Standard_Real t,
gp_Pnt2d& P, gp_Pnt2d& P,
gp_Vec2d& V1, gp_Vec2d& V1,
gp_Vec2d& V2) const gp_Vec2d& V2) const
@ -1249,7 +1249,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//purpose : //purpose :
//======================================================================= //=======================================================================
const Handle(ProjLib_HSequenceOfHSequenceOfPnt)& ProjLib_CompProjectedCurve::GetSequence() const const Handle(ProjLib_HSequenceOfHSequenceOfPnt)& ProjLib_CompProjectedCurve::GetSequence() const
{ {
return mySequence; return mySequence;
} }
@ -1258,7 +1258,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real ProjLib_CompProjectedCurve::FirstParameter() const Standard_Real ProjLib_CompProjectedCurve::FirstParameter() const
{ {
return myCurve->FirstParameter(); return myCurve->FirstParameter();
} }
@ -1268,7 +1268,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real ProjLib_CompProjectedCurve::LastParameter() const Standard_Real ProjLib_CompProjectedCurve::LastParameter() const
{ {
return myCurve->LastParameter(); return myCurve->LastParameter();
} }
@ -1278,7 +1278,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real ProjLib_CompProjectedCurve::MaxDistance(const Standard_Integer Index) const Standard_Real ProjLib_CompProjectedCurve::MaxDistance(const Standard_Integer Index) const
{ {
if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise();
return myMaxDistance->Value(Index); return myMaxDistance->Value(Index);
@ -1289,7 +1289,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer ProjLib_CompProjectedCurve::NbIntervals(const GeomAbs_Shape S) const Standard_Integer ProjLib_CompProjectedCurve::NbIntervals(const GeomAbs_Shape S) const
{ {
const_cast<ProjLib_CompProjectedCurve*>(this)->myTabInt.Nullify(); const_cast<ProjLib_CompProjectedCurve*>(this)->myTabInt.Nullify();
BuildIntervals(S); BuildIntervals(S);
@ -1301,7 +1301,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const void ProjLib_CompProjectedCurve::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
{ {
if (myTabInt.IsNull()) BuildIntervals (S); if (myTabInt.IsNull()) BuildIntervals (S);
T = myTabInt->Array1(); T = myTabInt->Array1();
@ -1312,7 +1312,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//purpose : //purpose :
//======================================================================= //=======================================================================
void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const
{ {
GeomAbs_Shape SforS = GeomAbs_CN; GeomAbs_Shape SforS = GeomAbs_CN;
switch(S) { switch(S) {
@ -1370,7 +1370,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
TColStd_SequenceOfReal TUdisc; TColStd_SequenceOfReal TUdisc;
for(k = 2; k <= NbIntSurU; k++) { for(k = 2; k <= NbIntSurU; k++) {
// cout<<"CutPntsU("<<k<<") = "<<CutPntsU(k)<<endl; // cout<<"CutPntsU("<<k<<") = "<<CutPntsU(k)<<endl;
for(i = 1; i <= myNbCurves; i++) for(i = 1; i <= myNbCurves; i++)
for(j = 1; j < mySequence->Value(i)->Length(); j++) { for(j = 1; j < mySequence->Value(i)->Length(); j++) {
Ul = mySequence->Value(i)->Value(j).Y(); Ul = mySequence->Value(i)->Value(j).Y();
@ -1404,10 +1404,14 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
gp_Pnt2d(Tol, myTolV), gp_Pnt2d(Tol, myTolV),
gp_Pnt2d(Tl, mySurface->FirstVParameter()), gp_Pnt2d(Tl, mySurface->FirstVParameter()),
gp_Pnt2d(Tr, mySurface->LastVParameter())); gp_Pnt2d(Tr, mySurface->LastVParameter()));
//
if(Solver.IsDone())
{
TUdisc.Append(Solver.Solution().X()); TUdisc.Append(Solver.Solution().X());
} }
} }
} }
}
for(i = 2; i <= TUdisc.Length(); i++) for(i = 2; i <= TUdisc.Length(); i++)
if(TUdisc(i) - TUdisc(i-1) < Precision::PConfusion()) if(TUdisc(i) - TUdisc(i-1) < Precision::PConfusion())
TUdisc.Remove(i--); TUdisc.Remove(i--);
@ -1424,7 +1428,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
for(k = 2; k <= NbIntSurV; k++) for(k = 2; k <= NbIntSurV; k++)
for(i = 1; i <= myNbCurves; i++) for(i = 1; i <= myNbCurves; i++)
{ {
// cout<<"CutPntsV("<<k<<") = "<<CutPntsV(k)<<endl; // cout<<"CutPntsV("<<k<<") = "<<CutPntsV(k)<<endl;
for(j = 1; j < mySequence->Value(i)->Length(); j++) { for(j = 1; j < mySequence->Value(i)->Length(); j++) {
Vl = mySequence->Value(i)->Value(j).Z(); Vl = mySequence->Value(i)->Value(j).Z();
@ -1458,10 +1462,14 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
gp_Pnt2d(Tol, myTolV), gp_Pnt2d(Tol, myTolV),
gp_Pnt2d(Tl, mySurface->FirstUParameter()), gp_Pnt2d(Tl, mySurface->FirstUParameter()),
gp_Pnt2d(Tr, mySurface->LastUParameter())); gp_Pnt2d(Tr, mySurface->LastUParameter()));
//
if(Solver.IsDone())
{
TVdisc.Append(Solver.Solution().X()); TVdisc.Append(Solver.Solution().X());
} }
} }
} }
}
for(i = 2; i <= TVdisc.Length(); i++) for(i = 2; i <= TVdisc.Length(); i++)
if(TVdisc(i) - TVdisc(i-1) < Precision::PConfusion()) if(TVdisc(i) - TVdisc(i-1) < Precision::PConfusion())
TVdisc.Remove(i--); TVdisc.Remove(i--);
@ -1519,7 +1527,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
//======================================================================= //=======================================================================
Handle(Adaptor2d_HCurve2d) ProjLib_CompProjectedCurve::Trim Handle(Adaptor2d_HCurve2d) ProjLib_CompProjectedCurve::Trim
(const Standard_Real First, (const Standard_Real First,
const Standard_Real Last, const Standard_Real Last,
const Standard_Real Tol) const const Standard_Real Tol) const
{ {

View File

@ -107,16 +107,12 @@ void TopOpeBRepDS_EdgeInterferenceTool::Add
} }
// V est un sommet de E ? // V est un sommet de E ?
#ifdef DEB
Standard_Boolean VofE = Standard_False; Standard_Boolean VofE = Standard_False;
#endif
TopoDS_Iterator it(E,Standard_False); TopoDS_Iterator it(E,Standard_False);
for ( ; it.More(); it.Next() ) { for ( ; it.More(); it.Next() ) {
const TopoDS_Shape& S = it.Value(); const TopoDS_Shape& S = it.Value();
if ( S.IsSame(V) ) { if ( S.IsSame(V) ) {
#ifdef DEB
VofE = Standard_True; VofE = Standard_True;
#endif
break; break;
} }
} }
@ -126,7 +122,10 @@ void TopOpeBRepDS_EdgeInterferenceTool::Add
cout<<"===================== VofE = False"<<endl; cout<<"===================== VofE = False"<<endl;
} }
#endif #endif
if(!VofE)
{
return;
}
// V est un sommet de E // V est un sommet de E
const TopoDS_Vertex& VV = TopoDS::Vertex(V); const TopoDS_Vertex& VV = TopoDS::Vertex(V);
const TopoDS_Edge& EE = TopoDS::Edge(E); const TopoDS_Edge& EE = TopoDS::Edge(E);

17
tests/bugs/moddata_3/bug24886 Executable file
View File

@ -0,0 +1,17 @@
puts "============"
puts "CR24886"
puts "============"
puts ""
###################################################################################
# BRepOffsetAPI_NormalProjection failure
###################################################################################
restore [locate_data_file bug24886_comp.brep] c
explode c
if [catch { nproject r c_1 c_2 } ] {
puts "Error : BRepOffsetAPI_NormalProjection failure"
} else {
puts "OK : BRepOffsetAPI_NormalProjection work good"
}