]> OCCT Git - occt-copy.git/commitdiff
BOPAlgo_PaveFiller::IsExistingPaveBlock - special treatment of linear edges coincidence.
authoremv <emv@opencascade.com>
Mon, 28 Mar 2016 08:39:59 +0000 (11:39 +0300)
committeremv <emv@opencascade.com>
Mon, 28 Mar 2016 11:45:10 +0000 (14:45 +0300)
src/BOPAlgo/BOPAlgo_PaveFiller.cdl
src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BOPDS/BOPDS_DS.cdl
src/BOPDS/BOPDS_DS.cxx
src/IntTools/IntTools_Context.cdl
src/IntTools/IntTools_Context.cxx

index 7dd03af03e4415c71d09f1b86a40c789cc9f132f..ba26476053c110d72b7e38b507424edef0c9ca98 100644 (file)
@@ -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 
index 18bf7ba3b4f3685af72e1d43329b20944c0a723e..c5d319e83cff830b48c55fb0d5b3a46e5b49a7e8 100644 (file)
@@ -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);
index 0fbd23127f6b09bde125f40117b1764252a06e21..7b047b46320d19c85a48f827d3f18605fd62d372 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <Geom_Curve.hxx>
 #include <Geom2d_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_TrimmedCurve.hxx>
 
 #include <GeomAPI_ProjectPointOnCurve.hxx>
 #include <GeomAPI_ProjectPointOnSurf.hxx>
@@ -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) {
index 4fc375f386de7f2d4029e62d673f0950cf470e8a..8a9ba1803a898049fca5c050b2a2f4c602c5aa37 100644 (file)
@@ -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 <theIndex>.
index c15d78e13b9ece23b66e18fdced902e93284591b..b2e7df84460b8bd6f4e9cb960f2635610b527923 100644 (file)
 #include <gp_Pnt.hxx>
 #include <Bnd_Box.hxx>
 //
+#include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 //
+#include <TopExp_Explorer.hxx>
+//
 #include <BRep_TVertex.hxx>
 #include <BRep_TEdge.hxx>
 #include <BRep_TFace.hxx>
@@ -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);
     }
index 4b17a9346cd0c9dbb3fec349177546656ebe5342..6c4eada1c8b7f4136ec36a0a97dbf80c5eea850d 100644 (file)
@@ -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
index 765444c6568aa9b3002c04d8d1cb1ac576c4ff2e..ee64258cb2aa3f17cdc15b48062867ea810d85fd 100644 (file)
@@ -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);