From: emv Date: Mon, 28 Mar 2016 08:39:59 +0000 (+0300) Subject: BOPAlgo_PaveFiller::IsExistingPaveBlock - special treatment of linear edges coincidence. X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=528c3def7ebda15749d25a532c1b1a8263889e4d;p=occt-copy.git BOPAlgo_PaveFiller::IsExistingPaveBlock - special treatment of linear edges coincidence. --- diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cdl b/src/BOPAlgo/BOPAlgo_PaveFiller.cdl index 7dd03af03e..ba26476053 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.cdl +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cdl @@ -250,7 +250,7 @@ is IsExistingPaveBlock(me:out; thePB:PaveBlock from BOPDS; theNC:Curve from BOPDS; - theTolR3D:Real from Standard; + theTolR3D:out Real from Standard; theMPB:IndexedMapOfPaveBlock from BOPDS; thePBOut:out PaveBlock from BOPDS) returns Boolean from Standard diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx index 18bf7ba3b4..c5d319e83c 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx @@ -372,7 +372,7 @@ void BOPAlgo_PaveFiller::PerformEF() } //update tolerance of edge if needed if (aTolE < aTolF) { - myDS->UpdateEdgeTolerance(nE, aTolF); + myDS->UpdateEdgeTolerance(aPB, aTolF); aTolE = aTolF; } aEF.SetCommonPart(aCPart); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 0fbd23127f..7b047b4632 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include @@ -516,7 +518,8 @@ void BOPAlgo_PaveFiller::MakeBlocks() continue; } // - bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aMPBOnIn, aPBOut); + Standard_Real aTolR3DNew = aTolR3D; + bExist=IsExistingPaveBlock(aPB, aNC, aTolR3DNew, aMPBOnIn, aPBOut); if (bExist) { if (aMPBAdd.Add(aPBOut)) { Standard_Boolean bInBothFaces = Standard_True; @@ -527,8 +530,18 @@ void BOPAlgo_PaveFiller::MakeBlocks() nE = aPBOut->Edge(); const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE); aTolE = BRep_Tool::Tolerance(aE); - if (aTolR3D > aTolE) { - myDS->UpdateEdgeTolerance(nE, aTolR3D); + if (aTolR3DNew > aTolE) { + myDS->UpdateEdgeTolerance(aPBOut, aTolR3DNew); + // do not let tolerances of vertices to get + // less than the tolerance of this edge + Standard_Integer nVE[2]; + aPBOut->Indices(nVE[0], nVE[1]); + for (Standard_Integer iV = 0; iV < 2; ++iV) { + Standard_Real *aTolEV = aMVTol.ChangeSeek(nVE[iV]); + if (aTolEV && (*aTolEV < aTolR3DNew)) { + *aTolEV = aTolR3DNew; + } + } } bInBothFaces = Standard_False; } else { @@ -1091,7 +1104,7 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo return !bRet; } // - Standard_Real aT1, aT2, aTm, aTx, aTol; + Standard_Real aT1, aT2, aTm, aTx, aTol, aDist; Standard_Integer nE, iFlag; gp_Pnt aPm; Bnd_Box aBoxPm; @@ -1112,7 +1125,7 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); aTol = BRep_Tool::Tolerance(aE); aTol = aTol > theTolR3D ? aTol : theTolR3D; - iFlag=myContext->ComputePE(aPm, aTol, aE, aTx); + iFlag=myContext->ComputePE(aPm, aTol, aE, aTx, aDist); if (!iFlag) { return bRet; } @@ -1121,6 +1134,23 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo return !bRet; } +//======================================================================= +//function : IsLine +//purpose : +//======================================================================= +inline Standard_Boolean IsLine (const TopoDS_Edge& theEdge) +{ + TopLoc_Location aLoc; + Standard_Real f,l; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aLoc, f, l); + if (!aCurve->IsKind(STANDARD_TYPE(Geom_Line))) + { + const Handle(Geom_TrimmedCurve)& aTrimC = Handle(Geom_TrimmedCurve)::DownCast(aCurve); + return !aTrimC.IsNull() && aTrimC->BasisCurve()->IsKind(STANDARD_TYPE(Geom_Line)); + } + return Standard_True; +} + //======================================================================= //function : IsExistingPaveBlock //purpose : @@ -1128,11 +1158,11 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock (const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC, - const Standard_Real theTolR3D, + Standard_Real& theTolR3D, const BOPDS_IndexedMapOfPaveBlock& theMPBOnIn, Handle(BOPDS_PaveBlock&) aPBOut) { - Standard_Boolean bRet; + Standard_Boolean bRet, bLineLine; Standard_Real aT1, aT2, aTm, aTx; Standard_Integer nSp, iFlag1, iFlag2, nV11, nV12, nV21, nV22, i, aNbPB; gp_Pnt aP1, aPm, aP2; @@ -1171,19 +1201,30 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 : (!aBoxSp.IsOut(aBoxP2) ? 1 : 0); if (iFlag1 && iFlag2) { - if (aBoxSp.IsOut(aBoxPm) || myContext->ComputePE(aPm, - theTolR3D, - aSp, - aTx)) { + bLineLine = (iFlag1 == 2 && iFlag2 == 2 && aIC.Type() == GeomAbs_Line && IsLine(aSp)); + if (aBoxSp.IsOut(aBoxPm) && !bLineLine) { continue; } // - if (iFlag1 == 1) { - iFlag1 = !myContext->ComputePE(aP1, theTolR3D, aSp, aTx); + Standard_Real aDist; + Standard_Integer iErr = myContext->ComputePE + (aPm, theTolR3D, aSp, aTx, aDist); + if (bLineLine && (iErr == -4)) { + // update tolerance 3D + theTolR3D += aDist; + } + else if (iErr != 0) { + continue; } // - if (iFlag2 == 1) { - iFlag2 = !myContext->ComputePE(aP2, theTolR3D, aSp, aTx); + if (!bLineLine) { + if (iFlag1 == 1) { + iFlag1 = !myContext->ComputePE(aP1, theTolR3D, aSp, aTx, aDist); + } + // + if (iFlag2 == 1) { + iFlag2 = !myContext->ComputePE(aP2, theTolR3D, aSp, aTx, aDist); + } } // if (iFlag1 && iFlag2) { diff --git a/src/BOPDS/BOPDS_DS.cdl b/src/BOPDS/BOPDS_DS.cdl index 4fc375f386..8a9ba1803a 100644 --- a/src/BOPDS/BOPDS_DS.cdl +++ b/src/BOPDS/BOPDS_DS.cdl @@ -622,7 +622,7 @@ is -- of the shape with index theIndex UpdateEdgeTolerance(me:out; - theIndex:Integer from Standard; + thePB:PaveBlock from BOPDS; theTolerance:Real from Standard); ---Purpose: --- Updates tolerance of the sub-shapes of the shape with index . diff --git a/src/BOPDS/BOPDS_DS.cxx b/src/BOPDS/BOPDS_DS.cxx index c15d78e13b..b2e7df8446 100644 --- a/src/BOPDS/BOPDS_DS.cxx +++ b/src/BOPDS/BOPDS_DS.cxx @@ -21,12 +21,15 @@ #include #include // +#include #include #include #include #include #include // +#include +// #include #include #include @@ -1354,15 +1357,20 @@ void BOPDS_DS::FaceInfoIn(const Standard_Integer theF, TopoDS_Iterator aItS; BOPDS_ListIteratorOfListOfPaveBlock aItPB; // - // 1. Pure internal vertices on the face const TopoDS_Shape& aF=Shape(theF); + // get all vertices from pave blocks from edges of the face + BOPCol_MapOfInteger aMVI; + BOPDS_IndexedMapOfPaveBlock aMPBx; + FaceInfoOn(theF, aMPBx, aMVI); + // + // 1. Pure internal vertices on the face aItS.Initialize(aF); for (; aItS.More(); aItS.Next()) { const TopoDS_Shape& aSx=aItS.Value(); if (aSx.ShapeType()==TopAbs_VERTEX){ nV=Index(aSx); if (HasShapeSD(nV, nVSD)) { - nV=nVSD; + nV=nVSD; } theMI.Add(nV); } @@ -1386,7 +1394,9 @@ void BOPDS_DS::FaceInfoIn(const Standard_Integer theF, BOPDS_InterfEF& aEF=aEFs(i); if(aEF.Contains(theF)) { if(aEF.HasIndexNew(nV)) { - theMI.Add(nV); + if (!aMVI.Contains(nV)) { + theMI.Add(nV); + } } else { nE=aEF.OppositeIndex(theF); @@ -1860,29 +1870,31 @@ void BOPDS_DS::Paves(const Standard_Integer theEdge, // function: UpdateTolerance // purpose: //======================================================================= -void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE, +void BOPDS_DS::UpdateEdgeTolerance(const Handle(BOPDS_PaveBlock)& thePB, const Standard_Real aTol) { - Standard_Integer nV; + Standard_Integer i, nE, nV[2]; Standard_Real aTolV; BRep_Builder aBB; - BOPCol_ListIteratorOfListOfInteger aIt; // + // update edge + if (!thePB->HasEdge(nE)) { + nE = thePB->OriginalEdge(); + } const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE); aBB.UpdateEdge(aE, aTol); BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE); Bnd_Box& aBoxE=aSIE.ChangeBox(); BRepBndLib::Add(aE, aBoxE); // - const BOPCol_ListOfInteger& aLI = aSIE.SubShapes(); - aIt.Initialize(aLI); - for (; aIt.More(); aIt.Next()) { - nV = aIt.Value(); - const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&Shape(nV); + thePB->Indices(nV[0], nV[1]); + // update its vertices + for (i = 0; i < 2; ++i) { + const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&Shape(nV[i]); aTolV = BRep_Tool::Tolerance(aV); if (aTolV < aTol) { aBB.UpdateVertex(aV, aTol); - BOPDS_ShapeInfo& aSIV = ChangeShapeInfo(nV); + BOPDS_ShapeInfo& aSIV = ChangeShapeInfo(nV[i]); Bnd_Box& aBoxV = aSIV.ChangeBox(); BRepBndLib::Add(aV, aBoxV); } diff --git a/src/IntTools/IntTools_Context.cdl b/src/IntTools/IntTools_Context.cdl index 4b17a9346c..6c4eada1c8 100644 --- a/src/IntTools/IntTools_Context.cdl +++ b/src/IntTools/IntTools_Context.cdl @@ -124,7 +124,8 @@ is theP : Pnt from gp; theTolP: Real from Standard; theE : Edge from TopoDS; - theT :out Real from Standard) + theT :out Real from Standard; + theDist:out Real from Standard) returns Integer from Standard; ---Purpose: --- Computes parameter of the Point theP on diff --git a/src/IntTools/IntTools_Context.cxx b/src/IntTools/IntTools_Context.cxx index 765444c656..ee64258cb2 100644 --- a/src/IntTools/IntTools_Context.cxx +++ b/src/IntTools/IntTools_Context.cxx @@ -480,12 +480,13 @@ Standard_Integer IntTools_Context::ComputePE (const gp_Pnt& aP1, const Standard_Real aTolP1, const TopoDS_Edge& aE2, - Standard_Real& aT) + Standard_Real& aT, + Standard_Real& aDist) { if (!BRep_Tool::IsGeometric(aE2)) { return -2; } - Standard_Real aDist, aTolE2, aTolSum; + Standard_Real aTolE2, aTolSum; Standard_Integer aNbProj; // GeomAPI_ProjectPointOnCurve& aProjector=ProjPC(aE2);