diff --git a/src/IntWalk/IntWalk_PWalking.cxx b/src/IntWalk/IntWalk_PWalking.cxx index eed1c6334a..92298b01c3 100644 --- a/src/IntWalk/IntWalk_PWalking.cxx +++ b/src/IntWalk/IntWalk_PWalking.cxx @@ -729,7 +729,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, previousd = myIntersectionOn2S.Direction(); previousd1 = myIntersectionOn2S.DirectionOnS1(); previousd2 = myIntersectionOn2S.DirectionOnS2(); - indextg = 1; + myTangentIdx = 1; tgdir = previousd; firstd1 = previousd1; firstd2 = previousd2; @@ -748,7 +748,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, if(IsTangentExtCheck(Caro1, Caro2, Param(1), Param(2), Param(3), Param(4), myTolTang, pasuv)) return; - AddAPoint(line,previousPoint); + AddAPoint(previousPoint); // IntWalk_StatusDeflection aStatus = IntWalk_OK, aPrevStatus = IntWalk_OK; Standard_Boolean NoTestDeflection = Standard_False; @@ -1251,7 +1251,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, } } // - AddAPoint(line,previousPoint); + AddAPoint(previousPoint); RejectIndex++; if(RejectIndex >= RejectIndexMAX) @@ -1287,7 +1287,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, if(close) { //================= la ligne est fermee =============== - AddAPoint(line,line->Value(1)); //ligne fermee + AddAPoint(line->Value(1)); //ligne fermee LevelOfIterWithoutAppend=0; } else //$$$ @@ -1339,7 +1339,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, } } // - AddAPoint(line,previousPoint); + AddAPoint(previousPoint); RejectIndex++; if(RejectIndex >= RejectIndexMAX) @@ -1573,7 +1573,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, }//if (previoustg) cond. //////////////////////////////////////// - AddAPoint(line,previousPoint); + AddAPoint(previousPoint); RejectIndex++; if(RejectIndex >= RejectIndexMAX) @@ -2031,7 +2031,7 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop Standard_Integer i = 0; for(i = 1; i <= aSeqOfNewPoint.Length(); i++) { - AddAPoint(line, aSeqOfNewPoint.Value(i)); + AddAPoint(aSeqOfNewPoint.Value(i)); } return bOutOfTangentZone; @@ -2440,7 +2440,7 @@ Standard_Boolean IntWalk_PWalking:: break; } - line->RemovePoint(1); + RemoveAPoint(1); } line->InsertBefore(1, anIP); @@ -2481,7 +2481,7 @@ Standard_Boolean IntWalk_PWalking:: break; } - line->RemovePoint(aNbPnts); + RemoveAPoint(aNbPnts); } line->Add(anIP); @@ -2839,14 +2839,14 @@ RepartirOuDiviser(Standard_Boolean& DejaReparti, // Standard_Integer i; if (Arrive) { //restart in the other direction if (!DejaReparti ) { - Arrive = Standard_False; - DejaReparti = Standard_True; + Arrive = Standard_False; + DejaReparti = Standard_True; previousPoint = line->Value(1); - previoustg = Standard_False; - previousd1 = firstd1; - previousd2 = firstd2; - previousd = tgdir; - indextg = line->NbPoints(); + previoustg = Standard_False; + previousd1 = firstd1; + previousd2 = firstd2; + previousd = tgdir; + myTangentIdx = line->NbPoints(); tgdir.Reverse(); line->Reverse(); @@ -2886,14 +2886,15 @@ RepartirOuDiviser(Standard_Boolean& DejaReparti, tglast = Standard_True; // IS IT ENOUGH ???? } - if (!DejaReparti) { //restart in the other direction - DejaReparti = Standard_True; - previousPoint = line->Value(1); - previoustg = Standard_False; - previousd1 = firstd1; - previousd2 = firstd2; - previousd = tgdir; - indextg = line->NbPoints(); + if (!DejaReparti) + { //restart in the other direction + DejaReparti = Standard_True; + previousPoint = line->Value(1); + previoustg = Standard_False; + previousd1 = firstd1; + previousd2 = firstd2; + previousd = tgdir; + myTangentIdx = line->NbPoints(); tgdir.Reverse(); line->Reverse(); diff --git a/src/IntWalk/IntWalk_PWalking.hxx b/src/IntWalk/IntWalk_PWalking.hxx index e4dab8ed9a..9fe04b72be 100644 --- a/src/IntWalk/IntWalk_PWalking.hxx +++ b/src/IntWalk/IntWalk_PWalking.hxx @@ -132,7 +132,27 @@ public: Standard_EXPORT void RepartirOuDiviser (Standard_Boolean& DejaReparti, IntImp_ConstIsoparametric& ChoixIso, Standard_Boolean& Arrive); - void AddAPoint (Handle(IntSurf_LineOn2S)& line, const IntSurf_PntOn2S& POn2S); + //! Inserts thePOn2S in the end of line + void AddAPoint (const IntSurf_PntOn2S& thePOn2S); + + //! Removes point with index theIndex from line. + //! If theIndex is greater than the number of points in line + //! then the last point will be removed. + //! theIndex must be started with 1. + void RemoveAPoint(const Standard_Integer theIndex) + { + const Standard_Integer anIdx = Min(theIndex, line->NbPoints()); + + if (anIdx < 1) + return; + + if (anIdx <= myTangentIdx) + { + myTangentIdx--; + } + + line->RemovePoint(anIdx); + } Standard_EXPORT Standard_Boolean PutToBoundary (const Handle(Adaptor3d_HSurface)& theASurf1, const Handle(Adaptor3d_HSurface)& theASurf2); @@ -208,7 +228,7 @@ private: Standard_Boolean close; Standard_Boolean tgfirst; Standard_Boolean tglast; - Standard_Integer indextg; + Standard_Integer myTangentIdx; gp_Dir tgdir; Standard_Real fleche; Standard_Real pasMax; diff --git a/src/IntWalk/IntWalk_PWalking.lxx b/src/IntWalk/IntWalk_PWalking.lxx index de3bd591c2..b9216b56f8 100644 --- a/src/IntWalk/IntWalk_PWalking.lxx +++ b/src/IntWalk/IntWalk_PWalking.lxx @@ -54,18 +54,16 @@ inline Standard_Boolean IntWalk_PWalking::IsClosed() const{ return close; } -inline const gp_Dir& IntWalk_PWalking::TangentAtLine - (Standard_Integer& Index) const +inline const gp_Dir& IntWalk_PWalking::TangentAtLine(Standard_Integer& theIndex) const { if(!done) throw StdFail_NotDone(); - Index = indextg; + theIndex = myTangentIdx; return tgdir; } #define REGLAGE 0 -inline void IntWalk_PWalking::AddAPoint(Handle(IntSurf_LineOn2S)& theLine, - const IntSurf_PntOn2S& POn2S) { +inline void IntWalk_PWalking::AddAPoint(const IntSurf_PntOn2S& POn2S) { #if REGLAGE Standard_Integer n=theLine->NbPoints(); if(n) { @@ -79,7 +77,8 @@ inline void IntWalk_PWalking::AddAPoint(Handle(IntSurf_LineOn2S)& theLine, fflush(stdout); } #endif - theLine->Add(POn2S); + line->Add(POn2S); + myTangentIdx = Max(myTangentIdx, 1); } diff --git a/tests/bugs/modalg_7/bug28764 b/tests/bugs/modalg_7/bug28764 new file mode 100644 index 0000000000..2609c4de63 --- /dev/null +++ b/tests/bugs/modalg_7/bug28764 @@ -0,0 +1,24 @@ +puts "========" +puts "OCC28764" +puts "========" +puts "" +################################################# +# [Regression to 7.0] Intersection of faces gives exception in debug mode +################################################# + +restore [locate_data_file bug28764_ff.brep] f +explode f + +#### + +axo +don f +fit + +# Before the fix: Exception in Debug-mode only +set log [bopcurves f_1 f_2 -2d] +checkview -screenshot -2d -path ${imagedir}/${test_image}.png + +regexp {Tolerance Reached=+([-0-9.+eE]+)} ${log} full Toler +checkreal TolReached $Toler 4.60347250530349e-008 0.0 0.1 +