1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
nbv
f2b2db7683 BndBox 2017-10-13 17:19:16 +03:00
nbv
6ce74431d8 0029144: BOP PaveFiller hangs in some case
1. Method IntWalk_PWalking::ExtendLineInCommonZone(...) now is not called if the already found intersection point is on surface boundary.
As result, the intersection line going along any boundary will never be extended. It is appropriate for high-level OCCT-algorithm because they will take the boundary (not computed line) as intersection result.

2. Method IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(...) has been corrected in order to avoid infinite loop described in the issue. The algorithm of obtaining the neighborhood of the intersection point has been improved.

3. Now, IsInside(...) static function (see BOPAlgo_BuilderFace.cxx file) does not need a 2D-curve for classified edge on the face. It allows avoiding exceptions in cases when the curve creation is impossible.

4. Post-processing has been added to join several common blocks to one. Method BOPDS_DS::RemoveCommonBlock(...) has been added in order to avoid duplication after joining.
2017-10-13 17:19:14 +03:00
16 changed files with 263 additions and 36 deletions

View File

@@ -593,7 +593,7 @@ void BOPAlgo_BuilderFace::PerformAreas()
// 5.2. Add unused holes to the original face
if (aNbHoles != aNbInOutMap) {
Bnd_Box aBoxF;
BRepBndLib::Add(myFace, aBoxF);
BRepBndLib::AddOptimal(myFace, aBoxF, Standard_True, Standard_True);
if (aBoxF.IsOpenXmin() || aBoxF.IsOpenXmax() ||
aBoxF.IsOpenYmin() || aBoxF.IsOpenYmax() ||
aBoxF.IsOpenZmin() || aBoxF.IsOpenZmax()) {
@@ -810,7 +810,6 @@ 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;
@@ -824,20 +823,19 @@ Standard_Boolean IsInside(const TopoDS_Shape& theHole,
BOPTools::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));
}
}
//

View File

@@ -600,7 +600,7 @@ void BOPAlgo_BuilderSolid::PerformAreas()
const TopoDS_Shape& aShell = aItLS.Value();
aSB.SetShape(aShell);
//
BRepBndLib::Add(aShell, aBox);
BRepBndLib::AddOptimal(aShell, aBox, Standard_True, Standard_True);
bIsHole=Standard_False;
//
bIsGrowth=IsGrowthShell(aShell, aMHF);
@@ -834,7 +834,7 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes()
const BOPAlgo_FacePnt& aFP=aVFP(k);
const TopoDS_Face& aF=aFP.Face();
//
BRepBndLib::Add(aF, aBox);
BRepBndLib::AddOptimal(aF, aBox, Standard_True, Standard_True);
aTreeFiller.Add(k, aBox);
}
//

View File

@@ -577,7 +577,7 @@ void BOPAlgo_Builder::FillIn3DParts
continue;
}
Bnd_Box aBox;
BRepBndLib::Add(aSx, aBox);
BRepBndLib::AddOptimal(aSx, aBox, Standard_True, Standard_True);
aBox.SetGap(aBox.GetGap() + Precision::Confusion());
//
BOPAlgo_ShapeBox& aSB=aVSB.Append1();

View File

@@ -97,7 +97,7 @@ void BOPAlgo_PaveFiller::UpdateEdgeTolerance (const Standard_Integer nE,
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
aBB.UpdateEdge(aE, aTol);
Bnd_Box& aBoxE=aSIE.ChangeBox();
BRepBndLib::Add(aE, aBoxE);
BRepBndLib::AddOptimal(aE, aBoxE, Standard_True, Standard_True);
aBoxE.SetGap(aBoxE.GetGap() + Precision::Confusion());
//
aIt.Initialize(aLI);
@@ -113,7 +113,7 @@ void BOPAlgo_PaveFiller::UpdateEdgeTolerance (const Standard_Integer nE,
aBB.UpdateVertex(aV, aTol);
BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nV);
Bnd_Box& aBoxV = aSIV.ChangeBox();
BRepBndLib::Add(aV, aBoxV);
BRepBndLib::AddOptimal(aV, aBoxV, Standard_True, Standard_True);
aBoxV.SetGap(aBoxV.GetGap() + Precision::Confusion());
}
}
@@ -141,7 +141,7 @@ Standard_Integer BOPAlgo_PaveFiller::UpdateVertex
aBB.UpdateVertex(aVSD, aTolNew);
BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVNew);
Bnd_Box& aBoxV = aSIV.ChangeBox();
BRepBndLib::Add(aVSD, aBoxV);
BRepBndLib::AddOptimal(aVSD, aBoxV, Standard_True, Standard_True);
aBoxV.SetGap(aBoxV.GetGap() + Precision::Confusion());
}
return nVNew;
@@ -165,7 +165,7 @@ Standard_Integer BOPAlgo_PaveFiller::UpdateVertex
// bounding box for the new vertex
BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nVNew);
Bnd_Box& aBoxDS = aSIDS.ChangeBox();
BRepBndLib::Add(aVNew, aBoxDS);
BRepBndLib::AddOptimal(aVNew, aBoxDS, Standard_True, Standard_True);
aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
//
// add vertex to SD map

View File

@@ -630,7 +630,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV1);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
aBoxDS = Bnd_Box();
BRepBndLib::Add(aV, aBoxDS);
BRepBndLib::AddOptimal(aV, aBoxDS, Standard_True, Standard_True);
aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
//
if (aDMVLV.IsBound(nV1))
@@ -680,6 +680,9 @@ void BOPAlgo_PaveFiller::MakeBlocks()
// into all faces, not participated in creation of that edge, as IN edge
PutSEInOtherFaces();
//
myDS->FilterOfCommonBlocks();
//-----------------------------------------------------scope t
aMVStick.Clear();
aMPBOnIn.Clear();
@@ -1533,7 +1536,7 @@ void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aVn, aBoxDS);
BRepBndLib::AddOptimal(aVn, aBoxDS, Standard_True, Standard_True);
aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
//
aLVB.Append(nVn);
@@ -2151,7 +2154,7 @@ void BOPAlgo_PaveFiller::PutPaveOnCurve
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
BRepBndLib::AddOptimal(aV, aBoxDS, Standard_True, Standard_True);
aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
}
}

View File

@@ -142,7 +142,7 @@ class BOPAlgo_SplitEdge : public BOPAlgo_Algo {
myV1, myT1,
myV2, myT2,
myESp);
BRepBndLib::Add(myESp, myBox);
BRepBndLib::AddOptimal(myESp, myBox, Standard_True, Standard_True);
myBox.SetGap(myBox.GetGap() + Precision::Confusion());
}
//
@@ -525,7 +525,7 @@ Standard_Integer BOPAlgo_PaveFiller::SplitEdge(const Standard_Integer nE,
aSI.SetShape(aSp);
//
Bnd_Box& aBox=aSI.ChangeBox();
BRepBndLib::Add(aSp, aBox);
BRepBndLib::AddOptimal(aSp, aBox, Standard_True, Standard_True);
aBox.SetGap(aBox.GetGap() + Precision::Confusion());
//
nSp=myDS->Append(aSI);

View File

@@ -463,7 +463,7 @@ void BOPDS_DS::Init(const Standard_Real theFuzz)
}
//
Bnd_Box& aBox=aSI.ChangeBox();
BRepBndLib::Add(aE, aBox);
BRepBndLib::AddOptimal(aE, aBox, Standard_True, Standard_True);
//
const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
aIt1.Initialize(aLV);
@@ -490,7 +490,7 @@ void BOPDS_DS::Init(const Standard_Real theFuzz)
const TopoDS_Shape& aS=aSI.Shape();
//
Bnd_Box& aBox=aSI.ChangeBox();
BRepBndLib::Add(aS, aBox);
BRepBndLib::AddOptimal(aS, aBox, Standard_True, Standard_True);
//
BOPCol_ListOfInteger& aLW=aSI.ChangeSubShapes();
aIt1.Initialize(aLW);
@@ -1786,7 +1786,7 @@ void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE,
aBB.UpdateEdge(aE, aTol);
BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
Bnd_Box& aBoxE=aSIE.ChangeBox();
BRepBndLib::Add(aE, aBoxE);
BRepBndLib::AddOptimal(aE, aBoxE, Standard_True, Standard_True);
aBoxE.SetGap(aBoxE.GetGap() + aTolAdd);
//
const BOPCol_ListOfInteger& aLI = aSIE.SubShapes();
@@ -2106,4 +2106,43 @@ Standard_Boolean BOPDS_DS::IsValidShrunkData(const Handle(BOPDS_PaveBlock)& theP
}
}
return Standard_True;
}
}
//=======================================================================
//function : FilterOfCommonBlocks
//purpose :
//=======================================================================
void BOPDS_DS::FilterOfCommonBlocks()
{
NCollection_DataMap<TopoDS_Edge, Handle(BOPDS_CommonBlock)> aMapEC;
BOPDS_VectorOfListOfPaveBlock& aPBP = ChangePaveBlocksPool();
Standard_Integer aNbPBP = aPBP.Extent();
//
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))
continue;
const Standard_Integer anEIdx = aPB->Edge();
const TopoDS_Edge &anE = TopoDS::Edge(Shape(anEIdx));
Handle(BOPDS_CommonBlock) *aCB = aMapEC.ChangeSeek(anE);
if (!aCB)
{
aCB = aMapEC.Bound(anE, CommonBlock(aPB));
continue;
}
myMapPBCB.UnBind(aPB);
(*aCB)->AddPaveBlock(aPB);
SetCommonBlock(aPB, *aCB);
}
}
}

View File

@@ -468,6 +468,9 @@ Standard_EXPORT virtual ~BOPDS_DS();
//! of the existing vertices have been increased.
Standard_EXPORT Standard_Boolean IsValidShrunkData(const Handle(BOPDS_PaveBlock)& thePB);
//! Combines the common-blocks and removes excess common-blocks
Standard_EXPORT void FilterOfCommonBlocks();
protected:

View File

@@ -1657,6 +1657,10 @@ Standard_Boolean FindFacePairs (const TopoDS_Edge& theE,
}
}
//
if(aLCEFx.IsEmpty())
return Standard_False;
// F2
BOPTools_AlgoTools::GetFaceOff(aE1, aF1, aLCEFx, aF2, theContext);
//

View File

@@ -32,6 +32,8 @@
#include <gp.hxx>
#include <gp_Vec2d.hxx>
#include <Precision.hxx>
//======================================================================
#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 (param1<TheImpCurveDomain.FirstParameter()
&& param2>TheImpCurveDomain.LastParameter()) {
const Standard_Real aParF = TheImpCurveDomain.HasFirstPoint() ?
TheImpCurveDomain.FirstParameter() :
-Precision::Infinite();
const Standard_Real aParL = TheImpCurveDomain.HasLastPoint() ?
TheImpCurveDomain.LastParameter() :
Precision::Infinite();
if (param1<aParF && param2>aParL)
{
Standard_Real t;
NbResultats++;
t = TheImpCurveDomain.FirstParameter();

View File

@@ -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);

View File

@@ -199,7 +199,7 @@ Bnd_Box& IntTools_Context::BndBox(const TopoDS_Shape& aS)
new (pBox) Bnd_Box();
//
Bnd_Box &aBox=*pBox;
BRepBndLib::Add(aS, aBox);
BRepBndLib::AddOptimal(aS, aBox, Standard_True, Standard_True);
//
anAdr=(Standard_Address)pBox;
myBndBoxDataMap.Bind(aS, anAdr);

View File

@@ -1653,10 +1653,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;
@@ -1664,7 +1723,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)) {

View File

@@ -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

View File

@@ -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

View File

@@ -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