diff --git a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx index 9d4007a0eb..09d14ca624 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx +++ b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx @@ -713,34 +713,30 @@ Standard_Boolean IsInside(const TopoDS_Shape& theHole, Handle(IntTools_Context)& theContext) { Standard_Boolean bRet; - Standard_Real aT, aU, aV; - TopAbs_State aState; TopExp_Explorer aExp; TopTools_IndexedMapOfShape aME2; gp_Pnt2d aP2D; // bRet=Standard_False; - aState=TopAbs_UNKNOWN; const TopoDS_Face& aF2=(*(TopoDS_Face *)(&theF2)); // TopExp::MapShapes(aF2, TopAbs_EDGE, aME2);//AA // aExp.Init(theHole, TopAbs_EDGE); - if (aExp.More()) { - const TopoDS_Edge& aE =(*(TopoDS_Edge *)(&aExp.Current())); - if (aME2.Contains(aE)) { + if (aExp.More()) + { + const TopoDS_Edge& aE = (*(TopoDS_Edge *) (&aExp.Current())); + if (aME2.Contains(aE)) + { return bRet; } - if (!BRep_Tool::Degenerated(aE)) { + if (!BRep_Tool::Degenerated(aE)) + { // - aT=BOPTools_AlgoTools2D::IntermediatePoint(aE); - BOPTools_AlgoTools2D::PointOnSurface(aE, aF2, aT, aU, aV, theContext); - aP2D.SetCoord(aU, aV); - // - IntTools_FClass2d& aClsf=theContext->FClass2d(aF2); - aState=aClsf.Perform(aP2D); - bRet=(aState==TopAbs_IN); + gp_Pnt aP3D; + BOPTools_AlgoTools::PointOnEdge(aE, BOPTools_AlgoTools2D::IntermediatePoint(aE), aP3D); + bRet = theContext->IsPointInFace(aP3D, aF2, BRep_Tool::Tolerance(aE)); } } // diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 930e1a82d8..2fcf04c908 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -711,7 +711,10 @@ void BOPAlgo_PaveFiller::MakeBlocks() // Treat possible common zones by trying to put each section edge // into all faces, not participated in creation of that edge, as IN edge PutSEInOtherFaces(); - // + + // Filter the Common Blocks created on the Face/Face post treatment stage from duplicates + myDS->FilterCommonBlocks(); + //-----------------------------------------------------scope t aMVStick.Clear(); aMPBOnIn.Clear(); diff --git a/src/BOPDS/BOPDS_DS.cxx b/src/BOPDS/BOPDS_DS.cxx index d7d3aa31b2..23edc7d045 100644 --- a/src/BOPDS/BOPDS_DS.cxx +++ b/src/BOPDS/BOPDS_DS.cxx @@ -1144,13 +1144,7 @@ Handle(BOPDS_CommonBlock) BOPDS_DS::CommonBlock void BOPDS_DS::SetCommonBlock(const Handle(BOPDS_PaveBlock)& thePB, const Handle(BOPDS_CommonBlock)& theCB) { - if (IsCommonBlock(thePB)) { - Handle(BOPDS_CommonBlock)& aCB = myMapPBCB.ChangeFind(thePB); - aCB=theCB; - } - else { - myMapPBCB.Bind(thePB, theCB); - } + myMapPBCB.Bind(thePB, theCB); } // @@ -2106,4 +2100,50 @@ Standard_Boolean BOPDS_DS::IsValidShrunkData(const Handle(BOPDS_PaveBlock)& theP } } return Standard_True; -} \ No newline at end of file +} + +//======================================================================= +//function : FilterCommonBlocks +//purpose : +//======================================================================= +void BOPDS_DS::FilterCommonBlocks() +{ + // Connection map from edge to common block + NCollection_DataMap aMapEC; + + // Iterate on all Pave Blocks in the Data Structure and make + // the Pave Blocks with the same edges be lined to the same Common Block + BOPDS_VectorOfListOfPaveBlock& aPBP = ChangePaveBlocksPool(); + Standard_Integer aNbPBP = aPBP.Length(); + for (Standard_Integer i = 0; i < aNbPBP; ++i) + { + BOPDS_ListOfPaveBlock& aLPB = aPBP(i); + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) + { + const Handle(BOPDS_PaveBlock) &aPB = aItPB.Value(); + + if (!IsCommonBlock(aPB)) + // not a Common block - skip + continue; + + // Get index of the edge + const Standard_Integer anEIdx = aPB->Edge(); + + Handle(BOPDS_CommonBlock) *aCB = aMapEC.ChangeSeek(anEIdx); + if (!aCB) + { + // Firstly met edge. Make all other Pave Blocks with the same edge + // be linked to the same Common Block. + aCB = aMapEC.Bound(anEIdx, CommonBlock(aPB)); + } + else + { + // Update the information about Common Block + (*aCB)->AddPaveBlock(aPB); + SetCommonBlock(aPB, *aCB); + } + } + } +} diff --git a/src/BOPDS/BOPDS_DS.hxx b/src/BOPDS/BOPDS_DS.hxx index 2201d5f499..39aa33bc68 100644 --- a/src/BOPDS/BOPDS_DS.hxx +++ b/src/BOPDS/BOPDS_DS.hxx @@ -478,6 +478,10 @@ Standard_EXPORT virtual ~BOPDS_DS(); Bnd_Box& theBox, const Standard_Boolean theCheckInverted = Standard_True); + //! Filter the Common Blocks on edges so that all Pave Blocks with the same Edge + //! have the same Common Block linked to it. + Standard_EXPORT void FilterCommonBlocks(); + protected: diff --git a/src/BOPTools/BOPTools_AlgoTools.cxx b/src/BOPTools/BOPTools_AlgoTools.cxx index b971decf90..2d7ba53387 100644 --- a/src/BOPTools/BOPTools_AlgoTools.cxx +++ b/src/BOPTools/BOPTools_AlgoTools.cxx @@ -1757,6 +1757,10 @@ Standard_Boolean FindFacePairs (const TopoDS_Edge& theE, } } // + + if(aLCEFx.IsEmpty()) + return Standard_False; + // F2 BOPTools_AlgoTools::GetFaceOff(aE1, aF1, aLCEFx, aF2, theContext); // diff --git a/src/IntImpParGen/IntImpParGen_Intersector.gxx b/src/IntImpParGen/IntImpParGen_Intersector.gxx index cd02df9abb..f0cce694ec 100644 --- a/src/IntImpParGen/IntImpParGen_Intersector.gxx +++ b/src/IntImpParGen/IntImpParGen_Intersector.gxx @@ -32,6 +32,8 @@ #include #include +#include + //====================================================================== #define EPSDIST Tol #define EPSNUL TolConf @@ -164,8 +166,15 @@ void IntImpParGen_Intersector::And_Domaine_Objet1_Intersections(const ImpTool& T Resultat2.SetValue(NbResultats, Inter2_And_Domain2.Value(indice_2)); } else { //====== la borne2 et la borne1 sont hors domaine ===== - if (param1TheImpCurveDomain.LastParameter()) { + const Standard_Real aParF = TheImpCurveDomain.HasFirstPoint() ? + TheImpCurveDomain.FirstParameter() : + -Precision::Infinite(); + const Standard_Real aParL = TheImpCurveDomain.HasLastPoint() ? + TheImpCurveDomain.LastParameter() : + Precision::Infinite(); + + if (param1aParL) + { Standard_Real t; NbResultats++; t = TheImpCurveDomain.FirstParameter(); diff --git a/src/IntTools/IntTools_BeanFaceIntersector.cxx b/src/IntTools/IntTools_BeanFaceIntersector.cxx index 3839ac7b77..6f202cc76d 100644 --- a/src/IntTools/IntTools_BeanFaceIntersector.cxx +++ b/src/IntTools/IntTools_BeanFaceIntersector.cxx @@ -1337,14 +1337,19 @@ void IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(const Standard_Boo if(BoundaryCondition && (isboundaryindex || !isvalidindex)) break; } - else { + else + { aDeltaRestrictor = aDelta; } // if point found decide to increase aDelta using derivative of distance function // - aDelta = (pointfound) ? (aDelta * 2.) : (aDelta * 0.5); + // (aDelta*2) and (aDelta/(3/2)). + // Use of constants 2 and 0.5 leads to infinite loop + // connected with the sequence: pointfound == TRUE ==> + // aDelta *= 2.0 ==> pointfound == FALSE ==> aDelta *= 0.5 ... + aDelta *= (pointfound) ? 2.0 : 0.6667; aDelta = (aDelta < aDeltaRestrictor) ? aDelta : aDeltaRestrictor; aCurPar = (ToIncreaseParameter) ? (aPrevPar + aDelta) : (aPrevPar - aDelta); diff --git a/src/IntWalk/IntWalk_PWalking.cxx b/src/IntWalk/IntWalk_PWalking.cxx index 141e905865..5707b91c1b 100644 --- a/src/IntWalk/IntWalk_PWalking.cxx +++ b/src/IntWalk/IntWalk_PWalking.cxx @@ -1654,10 +1654,69 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric theChoixIso, const Standard_Boolean theDirectionFlag) { + // Caro1 and Caro2 + const Handle(Adaptor3d_HSurface)& Caro1 = myIntersectionOn2S.Function().AuxillarSurface1(); + const Handle(Adaptor3d_HSurface)& Caro2 = myIntersectionOn2S.Function().AuxillarSurface2(); + // + const Standard_Real UFirst1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1); + const Standard_Real VFirst1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1); + const Standard_Real ULast1 = Adaptor3d_HSurfaceTool::LastUParameter(Caro1); + const Standard_Real VLast1 = Adaptor3d_HSurfaceTool::LastVParameter(Caro1); + + const Standard_Real UFirst2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2); + const Standard_Real VFirst2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2); + const Standard_Real ULast2 = Adaptor3d_HSurfaceTool::LastUParameter(Caro2); + const Standard_Real VLast2 = Adaptor3d_HSurfaceTool::LastVParameter(Caro2); + Standard_Boolean bOutOfTangentZone = Standard_False; + TColStd_Array1OfReal Param(1,4); + + previousPoint.Parameters(Param(1), Param(2), Param(3), Param(4)); + + // If the point is already in the boundary + // we avoid extension (see bug #29093). + if (Param(1) - UFirst1 < ResoU1) + { + return bOutOfTangentZone; + } + + if (Param(2) - VFirst1 < ResoV1) + { + return bOutOfTangentZone; + } + + if (Param(3) - UFirst2 < ResoU2) + { + return bOutOfTangentZone; + } + + if (Param(4) - VFirst2 < ResoV2) + { + return bOutOfTangentZone; + } + + if (Param(1) - ULast1 > -ResoU1) + { + return bOutOfTangentZone; + } + + if (Param(2) - VLast1 > -ResoV1) + { + return bOutOfTangentZone; + } + + if (Param(3) - ULast2 > -ResoU2) + { + return bOutOfTangentZone; + } + + if (Param(4) - VLast2 > -ResoV2) + { + return bOutOfTangentZone; + } + Standard_Boolean bStop = !myIntersectionOn2S.IsTangent(); Standard_Integer dIncKey = 1; - TColStd_Array1OfReal Param(1,4); IntWalk_StatusDeflection aStatus = IntWalk_OK; Standard_Integer nbIterWithoutAppend = 0; Standard_Integer nbEqualPoints = 0; @@ -1665,7 +1724,8 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop Standard_Integer uvit = 0; IntSurf_SequenceOfPntOn2S aSeqOfNewPoint; - while (!bStop) { + while (!bStop) + { nbIterWithoutAppend++; if((nbIterWithoutAppend > 20) || (nbEqualPoints > 20)) { diff --git a/tests/perf/modalg/bug29093_1 b/tests/perf/modalg/bug29093_1 new file mode 100644 index 0000000000..3e4af838e5 --- /dev/null +++ b/tests/perf/modalg/bug29093_1 @@ -0,0 +1,42 @@ +puts "========" +puts "OCC29093" +puts "========" +puts "" +################################# +# BOP PaveFiller hungs and constantly consumes memory +################################# + +puts "TODO OCC28989 ALL : Error! Big tolerance value!" +puts "TODO OCC29145 ALL : Faulty shapes in variables faulty_1 to faulty_" + +bclearobjects; +bcleartools; + +restore [locate_data_file bug29093_hung.brep] a +explode a So +baddobjects a_1 +baddtools a_2 a_3 a_4 a_5 a_6 a_7 a_8 a_9 a_10 a_11 a_12 a_13 a_14 + +dchrono cr restart + +bfillds +bbuild result + +dchrono cr stop counter bbuild + +regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTol + +# Maximal tolerance value must be updated after the fix. +# Current tolerance value is 803.89403359886296. + +if {${MaxTol} > 1.0e-4} { + puts "Error! Big tolerance value!" +} + +checkshape result + +smallview +donly result +fit + +checkview -screenshot -2d -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/perf/modalg/bug29093_2 b/tests/perf/modalg/bug29093_2 new file mode 100644 index 0000000000..85296cc26b --- /dev/null +++ b/tests/perf/modalg/bug29093_2 @@ -0,0 +1,32 @@ +puts "========" +puts "OCC29093" +puts "========" +puts "" +################################# +# BOP PaveFiller hungs and constantly consumes memory +################################# + +puts "TODO OCC29145 ALL : Faulty shapes in variables faulty_1 to faulty_" + +bclearobjects; +bcleartools; + +restore [locate_data_file bug29093_hung2.brep] a +explode a So +baddobjects a_1 +baddtools a_2 a_3 a_4 a_5 a_6 a_7 a_8 a_9 a_10 a_11 a_12 a_13 a_14 + +dchrono cr restart + +bfillds +bbuild result + +dchrono cr stop counter bbuild + +checkshape result + +smallview +donly result +fit + +checkview -screenshot -2d -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/perf/modalg/bug29093_3 b/tests/perf/modalg/bug29093_3 new file mode 100644 index 0000000000..f6fb6532d2 --- /dev/null +++ b/tests/perf/modalg/bug29093_3 @@ -0,0 +1,32 @@ +puts "========" +puts "OCC29093" +puts "========" +puts "" +################################# +# BOP PaveFiller hungs and constantly consumes memory +################################# + +puts "TODO OCC29145 ALL : Faulty shapes in variables faulty_1 to faulty_" + +bclearobjects; +bcleartools; + +restore [locate_data_file bug29093_hung3.brep] a +explode a So +baddobjects a_1 +baddtools a_2 a_3 a_4 a_5 a_6 a_7 a_8 a_9 a_10 a_11 a_12 a_13 a_14 + +dchrono cr restart + +bfillds +bbuild result + +dchrono cr stop counter bbuild + +checkshape result + +smallview +donly result +fit + +checkview -screenshot -2d -path ${imagedir}/${test_image}.png \ No newline at end of file