]> OCCT Git - occt-copy.git/commitdiff
0032330: Modeling Algorithms - Extend Offset algorithm with Progress Indicator and... CR32330
authorakaftasev <akaftasev@opencascade.com>
Thu, 18 Mar 2021 16:44:11 +0000 (19:44 +0300)
committerakaftasev <akaftasev@opencascade.com>
Mon, 9 Aug 2021 12:52:09 +0000 (15:52 +0300)
Added progress indicator to BRepOffset_MakeOffset::BuildSplitsOfTrimmedFaces() and BRepOffset_MakeOffset::BuildSplitsOfExtendedFaces()

src/BRepOffset/BRepOffset_MakeOffset.cxx
src/BRepOffset/BRepOffset_MakeOffset.hxx
src/BRepOffset/BRepOffset_MakeOffset_1.cxx

index 2c5fe795f3f622145fa4562ce71ad4881c7b6c8e..9f31a62473f9da579c9ed4b6efaa599720edd266 100644 (file)
@@ -1281,7 +1281,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
   TopTools_MapOfShape aMFDone;
   //
   if ((myJoin == GeomAbs_Intersection) && myInter && myIsPlanar) {
-    BuildSplitsOfExtendedFaces(LFE, myAnalyse, AsDes, anEdgesOrigins, aFacesOrigins, aETrimEInf, IMOE);
+    BuildSplitsOfExtendedFaces(LFE, myAnalyse, AsDes, anEdgesOrigins, aFacesOrigins, aETrimEInf, IMOE, Message_ProgressRange());
     //
     TopTools_ListIteratorOfListOfShape aItLF(LFE);
     for (; aItLF.More(); aItLF.Next()) {
@@ -2570,7 +2570,7 @@ void BRepOffset_MakeOffset::MakeLoops(TopTools_IndexedMapOfShape& Modif)
   }
   //
   if ((myJoin == GeomAbs_Intersection) && myInter && myIsPlanar) {
-    BuildSplitsOfTrimmedFaces(LF, myAsDes, myImageOffset);
+    BuildSplitsOfTrimmedFaces(LF, myAsDes, myImageOffset, Message_ProgressRange());
   }
   else {
     myMakeLoops.Build(LF,myAsDes,myImageOffset,myImageVV);
@@ -2620,7 +2620,7 @@ void BRepOffset_MakeOffset::MakeFaces(TopTools_IndexedMapOfShape& /*Modif*/)
   }
   //
   if ((myJoin == GeomAbs_Intersection) && myInter && myIsPlanar) {
-    BuildSplitsOfTrimmedFaces(LOF, myAsDes, myImageOffset);
+    BuildSplitsOfTrimmedFaces(LOF, myAsDes, myImageOffset, Message_ProgressRange());
   }
   else {
     myMakeLoops.BuildFaces(LOF,myAsDes,myImageOffset);
index ea99f9c92bbd6c7017b528148fc9636451f4bd4a..bc297b530a59bc8ef3f558c56939ff302ee7ffca 100644 (file)
@@ -36,6 +36,8 @@
 #include <BRepOffset_MakeLoops.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <BRepOffset_DataMapOfShapeOffset.hxx>
+
+#include <Message_ProgressRange.hxx>
 class BRepAlgo_AsDes;
 class TopoDS_Shape;
 class TopoDS_Face;
@@ -221,13 +223,15 @@ private:
                                                   TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
                                                   TopTools_DataMapOfShapeShape& theFacesOrigins,
                                                   TopTools_DataMapOfShapeShape& theETrimEInf,
-                                                  BRepAlgo_Image& theImage);
+                                                  BRepAlgo_Image& theImage,
+                                                  const Message_ProgressRange& theRange);
 
   //! Building of the splits of the already trimmed offset faces for mode Complete
   //! and joint type Intersection.
   Standard_EXPORT void BuildSplitsOfTrimmedFaces(const TopTools_ListOfShape& theLF,
                                                  const Handle(BRepAlgo_AsDes)& theAsDes,
-                                                 BRepAlgo_Image& theImage);
+                                                 BRepAlgo_Image& theImage,
+                                                 const Message_ProgressRange& theRange);
 
   Standard_Real myOffset;
   Standard_Real myTol;
index 3adba98fcd45e40899b81630f1d39e1adad4d181..9766b65f7531338be97b3ac77a6914abeb3fba68 100644 (file)
@@ -396,14 +396,15 @@ namespace {
   //=======================================================================
   static void BuildSplitsOfTrimmedFace (const TopoDS_Face& theFace,
                                         const TopoDS_Shape& theEdges,
-                                        TopTools_ListOfShape& theLFImages)
+                                        TopTools_ListOfShape& theLFImages,
+                                        const Message_ProgressRange& theRange)
   {
     BOPAlgo_Splitter aSplitter;
     //
     aSplitter.AddArgument (theFace);
     aSplitter.AddArgument (theEdges);
     aSplitter.SetToFillHistory (Standard_False);
-    aSplitter.Perform();
+    aSplitter.Perform(theRange);
     if (aSplitter.HasErrors())
     {
       return;
@@ -545,18 +546,18 @@ public: //! @name Setting data
 public: //! @name Public methods to build the splits
 
   //! Build splits of already trimmed faces
-  void BuildSplitsOfTrimmedFaces();
+  void BuildSplitsOfTrimmedFaces(const Message_ProgressRange& theRange);
 
   //! Building splits of not-trimmed offset faces.
   //! For the cases in which invalidities will be found, these invalidities will be rebuilt.
-  void BuildSplitsOfExtendedFaces();
+  void BuildSplitsOfExtendedFaces(const Message_ProgressRange& theRange);
 
 private: //! @name private methods performing the job
 
 private: //! @name Intersection and post-treatment of edges
 
   //! Intersection of the trimmed edges among themselves
-  void IntersectTrimmedEdges();
+  void IntersectTrimmedEdges(const Message_ProgressRange& theRange);
 
   //! Saving connection from trimmed edges to not trimmed ones
   void UpdateIntersectedEdges (const TopTools_ListOfShape& theLA,
@@ -898,7 +899,7 @@ private:
 //function : BuildSplitsOfTrimmedFaces
 //purpose  : 
 //=======================================================================
-void BRepOffset_BuildOffsetFaces::BuildSplitsOfTrimmedFaces()
+void BRepOffset_BuildOffsetFaces::BuildSplitsOfTrimmedFaces(const Message_ProgressRange& theRange)
 {
   if (!hasData (myFaces))
   {
@@ -911,11 +912,18 @@ void BRepOffset_BuildOffsetFaces::BuildSplitsOfTrimmedFaces()
     myEdgesOrigins = &anEdgesOrigins;
   }
 
+  Message_ProgressScope aPS(theRange, NULL, 2);
+
   // Fuse all edges
-  IntersectTrimmedEdges();
+  IntersectTrimmedEdges(aPS.Next());
 
+  Message_ProgressScope aPSLoop(aPS.Next(), NULL, myFaces->Size());
   for (TopTools_ListOfShape::Iterator aItLF (*myFaces); aItLF.More(); aItLF.Next())
   {
+    if (!aPSLoop.More())
+    {
+      return;
+    }
     const TopoDS_Face& aF = *(TopoDS_Face*)&aItLF.Value();
 
     TopoDS_Shape aCE;
@@ -932,7 +940,7 @@ void BRepOffset_BuildOffsetFaces::BuildSplitsOfTrimmedFaces()
     }
 
     TopTools_ListOfShape aLFImages;
-    BuildSplitsOfTrimmedFace (aF, aCE, aLFImages);
+    BuildSplitsOfTrimmedFace (aF, aCE, aLFImages, aPSLoop.Next());
 
     myOFImages.Add (aF, aLFImages);
   }
@@ -944,7 +952,7 @@ void BRepOffset_BuildOffsetFaces::BuildSplitsOfTrimmedFaces()
 //function : BuildSplitsOfExtendedFaces
 //purpose  : 
 //=======================================================================
-void BRepOffset_BuildOffsetFaces::BuildSplitsOfExtendedFaces()
+void BRepOffset_BuildOffsetFaces::BuildSplitsOfExtendedFaces(const Message_ProgressRange& theRange)
 {
   // Check input data
   if (!hasData (myFaces) || !hasData (myEdgesOrigins) || !hasData (myFacesOrigins) || !hasData (myETrimEInf))
@@ -952,9 +960,14 @@ void BRepOffset_BuildOffsetFaces::BuildSplitsOfExtendedFaces()
     return;
   }
 
-  // Fusing all trimmed offset edges to avoid self-intersections in the splits
-  IntersectTrimmedEdges();
+  Message_ProgressScope aPS(theRange, NULL, 2);
 
+  // Fusing all trimmed offset edges to avoid self-intersections in the splits
+  IntersectTrimmedEdges(aPS.Next());
+  if (!aPS.More())
+  {
+    return;
+  }
   // vertices to avoid
   TopTools_MapOfShape aVertsToAvoid;
 
@@ -963,6 +976,10 @@ void BRepOffset_BuildOffsetFaces::BuildSplitsOfExtendedFaces()
   const Standard_Integer aNbMaxAttempts = 10;
   for (Standard_Integer iCount = 0; iCount < aNbMaxAttempts; ++iCount)
   {
+    if (!aPS.More())
+    {
+      return;
+    }
     // Clear the data before further faces construction
     myInvalidFaces.Clear();
     myArtInvalidFaces.Clear();
@@ -1038,14 +1055,19 @@ void BRepOffset_BuildOffsetFaces::UpdateIntersectedEdges (const TopTools_ListOfS
 //function : IntersectTrimmedEdges
 //purpose  :
 //=======================================================================
-void BRepOffset_BuildOffsetFaces::IntersectTrimmedEdges()
+void BRepOffset_BuildOffsetFaces::IntersectTrimmedEdges(const Message_ProgressRange& theRange)
 {
   // get edges to intersect from descendants of the offset faces
   TopTools_ListOfShape aLS;
   //
+  Message_ProgressScope aPS(theRange, NULL, 2);
   TopTools_ListIteratorOfListOfShape aItLF (*myFaces);
   for (; aItLF.More(); aItLF.Next())
   {
+    if (!aPS.More())
+    {
+      return;
+    }
     const TopoDS_Face& aF = *(TopoDS_Face*)&aItLF.Value();
     //
     const TopTools_ListOfShape& aLE = myAsDes->Descendant (aF);
@@ -1075,7 +1097,7 @@ void BRepOffset_BuildOffsetFaces::IntersectTrimmedEdges()
   // perform intersection of the edges
   BOPAlgo_Builder aGFE;
   aGFE.SetArguments (aLS);
-  aGFE.Perform();
+  aGFE.Perform(aPS.Next());
   if (aGFE.HasErrors())
   {
     return;
@@ -1083,8 +1105,13 @@ void BRepOffset_BuildOffsetFaces::IntersectTrimmedEdges()
   //
   TopTools_ListOfShape aLA;
   // fill map with edges images
-  for (TopTools_ListOfShape::Iterator aIt (aLS); aIt.More(); aIt.Next())
+  Message_ProgressScope aPSLoop(aPS.Next(), NULL, aLS.Size());
+  for (TopTools_ListOfShape::Iterator aIt (aLS); aIt.More(); aIt.Next(), aPSLoop.Next())
   {
+    if (!aPSLoop.More())
+    {
+      return;
+    }
     const TopoDS_Shape& aE = aIt.Value();
     const TopTools_ListOfShape& aLEIm = aGFE.Modified (aE);
     if (aLEIm.IsEmpty())
@@ -8225,12 +8252,13 @@ void BRepOffset_BuildOffsetFaces::FillHistory()
 //=======================================================================
 void BRepOffset_MakeOffset::BuildSplitsOfTrimmedFaces (const TopTools_ListOfShape& theLF,
                                                        const Handle (BRepAlgo_AsDes)& theAsDes,
-                                                       BRepAlgo_Image& theImage)
+                                                       BRepAlgo_Image& theImage,
+                                                       const Message_ProgressRange& theRange)
 {
   BRepOffset_BuildOffsetFaces aBFTool (theImage);
   aBFTool.SetFaces (theLF);
   aBFTool.SetAsDesInfo (theAsDes);
-  aBFTool.BuildSplitsOfTrimmedFaces();
+  aBFTool.BuildSplitsOfTrimmedFaces(theRange);
 }
 
 //=======================================================================
@@ -8245,7 +8273,8 @@ void BRepOffset_MakeOffset::BuildSplitsOfExtendedFaces (const TopTools_ListOfSha
                                                         TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
                                                         TopTools_DataMapOfShapeShape& theFacesOrigins,
                                                         TopTools_DataMapOfShapeShape& theETrimEInf,
-                                                        BRepAlgo_Image& theImage)
+                                                        BRepAlgo_Image& theImage,
+                                                        const Message_ProgressRange& theRange)
 {
   BRepOffset_BuildOffsetFaces aBFTool (theImage);
   aBFTool.SetFaces (theLF);
@@ -8254,5 +8283,5 @@ void BRepOffset_MakeOffset::BuildSplitsOfExtendedFaces (const TopTools_ListOfSha
   aBFTool.SetEdgesOrigins (theEdgesOrigins);
   aBFTool.SetFacesOrigins (theFacesOrigins);
   aBFTool.SetInfEdges (theETrimEInf);
-  aBFTool.BuildSplitsOfExtendedFaces();
+  aBFTool.BuildSplitsOfExtendedFaces(theRange);
 }