]> OCCT Git - occt-copy.git/commitdiff
0032108: Modeling Algorithms - BRepAlgoAPI_Section is too slow [OCCT 7.2.0 backport] CR0_720_FixS
authoremv <emv@opencascade.com>
Mon, 1 Feb 2021 15:41:03 +0000 (18:41 +0300)
committeremv <emv@opencascade.com>
Tue, 2 Feb 2021 08:44:02 +0000 (11:44 +0300)
Porting parts of #0029711 - use ForceInterfEF() in PutSEInOtherFaces() to avoid duplication of the checks on the edge and face.

src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
tests/bugs/modalg_7/bug32108 [new file with mode: 0644]

index 159411df7f5415a9ee1338d84b5336bc2ab9c10c..a4e8f27699f819ea5b9c101a7e65d9646e87059f 100644 (file)
@@ -585,8 +585,14 @@ void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
   thePB->Indices(nV1, nV2);
   const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); 
   const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); 
-  // Original edge
-  Standard_Integer nE = thePB->OriginalEdge();
+  // Get the edge
+  Standard_Integer nE = -1;
+  if (!thePB->HasEdge(nE))
+  {
+    nE = thePB->OriginalEdge();
+    if (nE < 0)
+      return;
+  }
   const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); 
   // Range
   Standard_Real aT1, aT2;
index e1cbe33fe04cad4c060fbc3a5e55fc5d051f9433..1c2befe828232b7e595c61236fd79a2a924e2e4d 100644 (file)
@@ -3058,107 +3058,24 @@ void BOPAlgo_PaveFiller::PutSEInOtherFaces()
 {
   // Try to intersect each section edge with the faces
   // not participated in its creation
-  //
-  // 1. Get all section edges
+
+  // Get all section edges
   BOPDS_IndexedMapOfPaveBlock aMPBScAll;
-  //
+
   BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
-  Standard_Integer i, j, aNbFF = aFFs.Extent();
-  //
-  for (i = 0; i < aNbFF; ++i) {
+  const Standard_Integer aNbFF = aFFs.Length();
+  for (Standard_Integer i = 0; i < aNbFF; ++i)
+  {
     const BOPDS_VectorOfCurve& aVNC = aFFs(i).Curves();
-    Standard_Integer aNbC = aVNC.Extent();
-    for (j = 0; j < aNbC; ++j) {
+    const Standard_Integer aNbC = aVNC.Length();
+    for (Standard_Integer j = 0; j < aNbC; ++j)
+    {
       const BOPDS_ListOfPaveBlock& aLPBC = aVNC(j).PaveBlocks();
       BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPBC);
-      for (; aItPB.More(); aItPB.Next()) {
+      for (; aItPB.More(); aItPB.Next())
         aMPBScAll.Add(aItPB.Value());
-      }
-    }
-  }
-  //
-  Standard_Integer aNbPBSc = aMPBScAll.Extent();
-  //
-  // 2. Loop for all faces and check each section curve
-  Standard_Integer aNbS = myDS->NbSourceShapes();
-  for (i = 0; i < aNbS; ++i) {
-    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
-    if (aSI.ShapeType() != TopAbs_FACE) {
-      continue;
-    }
-    //
-    const TopoDS_Face& aF = (*(TopoDS_Face*)(&aSI.Shape()));
-    BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(i);
-    //
-    // IN edges to add new ones
-    BOPDS_IndexedMapOfPaveBlock& aMFPBIn = aFI.ChangePaveBlocksIn();
-    // Section edges to check the participation of the face
-    const BOPDS_IndexedMapOfPaveBlock& aMFPBSc = aFI.PaveBlocksSc();
-    //
-    // Get vertices of the face to check that vertices of the
-    // processed section edge belong to the face
-    BOPCol_MapOfInteger aMFVerts;
-    // Get vertices from ON, IN and Sc pave blocks of the face
-    for (j = 0; j < 3; ++j) {
-      const BOPDS_IndexedMapOfPaveBlock& aMPB =
-        !j ? aFI.PaveBlocksOn() : (j == 1 ? aMFPBIn : aMFPBSc);
-      Standard_Integer aNbPB = aMPB.Extent();
-      for (Standard_Integer k = 1; k <= aNbPB; ++k) {
-        const Handle(BOPDS_PaveBlock)& aPB = aMPB(k);
-        aMFVerts.Add(aPB->Pave1().Index());
-        aMFVerts.Add(aPB->Pave2().Index());
-      }
-    }
-    // Add ON, IN and Sc vertices of the face
-    for (j = 0; j < 3; ++j) {
-      const BOPCol_MapOfInteger& aMFV = !j ? aFI.VerticesOn() :
-        (j == 1 ? aFI.VerticesIn() : aFI.VerticesSc());
-      BOPCol_MapIteratorOfMapOfInteger aItMI(aMFV);
-      for (; aItMI.More(); aItMI.Next()) {
-        aMFVerts.Add(aItMI.Value());
-      }
-    }
-    //
-    // Check each section edge for possible belonging to the face
-    for (j = 1; j <= aNbPBSc; ++j) {
-      const Handle(BOPDS_PaveBlock)& aPB = aMPBScAll(j);
-      if (aMFPBSc.Contains(aPB)) {
-        continue;
-      }
-      //
-      // Both vertices of the section edge should belong to the face
-      if (!aMFVerts.Contains(aPB->Pave1().Index()) ||
-        !aMFVerts.Contains(aPB->Pave2().Index())) {
-        continue;
-      }
-      //
-      // Perform intersection
-      const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(aPB->Edge()));
-      //
-      IntTools_EdgeFace anEFInt;
-      anEFInt.SetEdge(aE);
-      anEFInt.SetFace(aF);
-      anEFInt.SetFuzzyValue(myFuzzyValue);
-      anEFInt.SetRange(aPB->Pave1().Parameter(), aPB->Pave2().Parameter());
-      anEFInt.SetContext(myContext);
-      anEFInt.UseQuickCoincidenceCheck(Standard_True);
-      anEFInt.Perform();
-      //
-      const IntTools_SequenceOfCommonPrts& aCPrts = anEFInt.CommonParts();
-      if ((aCPrts.Length() == 1) && (aCPrts(1).Type() == TopAbs_EDGE)) {
-        Handle(BOPDS_CommonBlock) aCB;
-        if (myDS->IsCommonBlock(aPB)) {
-          aCB = myDS->CommonBlock(aPB);
-        }
-        else {
-          aCB = new BOPDS_CommonBlock;
-          aCB->AddPaveBlock(aPB);
-        }
-        //
-        aCB->AddFace(i);
-        //
-        aMFPBIn.Add(aPB);
-      }
     }
   }
+  // Perform intersection of collected pave blocks
+  ForceInterfEF(aMPBScAll, Standard_False);
 }
diff --git a/tests/bugs/modalg_7/bug32108 b/tests/bugs/modalg_7/bug32108
new file mode 100644 (file)
index 0000000..abe67e0
--- /dev/null
@@ -0,0 +1,21 @@
+puts "============================================================================================="
+puts "0032108: Modeling Algorithms - BRepAlgoAPI_Section is too slow"
+puts "============================================================================================="
+puts ""
+
+restore [locate_data_file bug32108_H502.brep] s1
+restore [locate_data_file bug32108_z.brep] s2
+
+dchrono h restart
+bsection result s1 s2 -na
+dchrono h stop counter SECTION_NO_APPROX
+
+dchrono h restart
+bsection result1 s1 s2
+dchrono h stop counter SECTION_WITH_APPROX
+
+checksection result -r 0
+checkprops result -l 9.15304 
+checkprops result1 -l 9.15304
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png