]> OCCT Git - occt-copy.git/commitdiff
0031942: Add possibility to break the BRepExtrema_DistShapeShape algorithm CR0_DMUReviewer_IR-2019-08-30_obsolete
authortma <tatiana.retinskaya@opencascade.com>
Tue, 17 Nov 2020 12:51:19 +0000 (15:51 +0300)
committertma <tatiana.retinskaya@opencascade.com>
Tue, 17 Nov 2020 12:51:19 +0000 (15:51 +0300)
src/BRepExtrema/BRepExtrema_DistShapeShape.cxx
src/BRepExtrema/BRepExtrema_DistShapeShape.hxx

index f70215b67009d169bc625cd4a8e5b20ebf78c4ad..e7c6c6b1eb0fe83771e980b6c7b1ea1a622732e8 100644 (file)
@@ -276,13 +276,15 @@ void BRepExtrema_DistShapeShape::LoadS2 (const TopoDS_Shape& Shape2)
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean BRepExtrema_DistShapeShape::Perform()
+Standard_Boolean BRepExtrema_DistShapeShape::Perform(const Handle(Message_ProgressIndicator)& PR)
 {
   myIsDone=Standard_False;
   myInnerSol=Standard_False;
   mySolutionsShape1.Clear();
   mySolutionsShape2.Clear();
 
+  bool nullProgress = PR.IsNull();
+
   if ( myShape1.IsNull() || myShape2.IsNull() )
     return Standard_False;
 
@@ -296,7 +298,7 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
     BRepClass3d_SolidClassifier Classi(myShape1);
     const Standard_Integer nbv2 = myMapV2.Extent();
     Standard_Integer nbv1 = 0;
-    while ( (nbv1<nbv2) && (!myInnerSol) )
+    while ( (nbv1<nbv2) && (!myInnerSol) && (nullProgress || !PR->UserBreak()))
     {
       nbv1++;
       V = TopoDS::Vertex(myMapV2(nbv1));
@@ -313,14 +315,13 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
       }  
     }
   }
-  
   const TopAbs_ShapeEnum Type2 = myShape2.ShapeType();
-  if (((Type2==TopAbs_SOLID) || (Type2==TopAbs_COMPSOLID)) && (!myInnerSol))
+  if (((Type2 == TopAbs_SOLID) || (Type2 == TopAbs_COMPSOLID)) && (!myInnerSol) && (nullProgress || !PR->UserBreak()))
   {
     BRepClass3d_SolidClassifier Classi(myShape2);
     const Standard_Integer nbv1 = myMapV1.Extent();
     Standard_Integer nbv2 = 0;
-    while ( (nbv2<nbv1) && (!myInnerSol) )
+    while ((nbv2<nbv1) && (!myInnerSol) && (nullProgress || !PR->UserBreak()))
     {
       nbv2++;
       V = TopoDS::Vertex(myMapV1(nbv2));
@@ -337,7 +338,7 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
     }
   }
 
-  if (!myInnerSol)
+  if (!myInnerSol && (nullProgress || !PR->UserBreak()))
   {
     if (!myIsInitS1) // rebuild cached data for 1st shape
     {
@@ -352,7 +353,7 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
       myIsInitS1 = Standard_True;
     }
 
-    if (!myIsInitS2) // rebuild cached data for 2nd shape
+    if (!myIsInitS2 && (nullProgress || !PR->UserBreak())) // rebuild cached data for 2nd shape
     {
       myBV2.Clear();
       myBE2.Clear();
@@ -365,7 +366,7 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
       myIsInitS2 = Standard_True;
     }
 
-    if (myMapV1.Extent() && myMapV2.Extent())
+    if (myMapV1.Extent() && myMapV2.Extent() && (nullProgress || !PR->UserBreak()))
     {
       TopoDS_Vertex V1 = TopoDS::Vertex(myMapV1(1));
       TopoDS_Vertex V2 = TopoDS::Vertex(myMapV2(1));
@@ -374,15 +375,32 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
     else
       myDistRef= 1.e30; //szv:!!!
 
+    if (!nullProgress && !PR->UserBreak())
+    {
+      return false;
+    }
+
     DistanceMapMap (myMapV1, myMapV2, myBV1, myBV2);
     DistanceMapMap (myMapV1, myMapE2, myBV1, myBE2);
     DistanceMapMap (myMapE1, myMapV2, myBE1, myBV2);
     DistanceMapMap (myMapV1, myMapF2, myBV1, myBF2);
+
+    if (!nullProgress && !PR->UserBreak())
+    {
+      return false;
+    }
+
     DistanceMapMap (myMapF1, myMapV2, myBF1, myBV2);
     DistanceMapMap (myMapE1, myMapE2, myBE1, myBE2);
     DistanceMapMap (myMapE1, myMapF2, myBE1, myBF2);
     DistanceMapMap (myMapF1, myMapE2, myBF1, myBE2);
 
+    if (!nullProgress && !PR->UserBreak())
+    {
+      return false;
+    }
+
+
     if (fabs (myDistRef) > myEps)
     {
       DistanceMapMap (myMapF1, myMapF2, myBF1, myBF2);
@@ -390,14 +408,14 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
     
     //  Modified by Sergey KHROMOV - Tue Mar  6 11:55:03 2001 Begin
     Standard_Integer i = 1;
-    for (; i <= mySolutionsShape1.Length(); i++)
+    for (; i <= mySolutionsShape1.Length() && (nullProgress || !PR->UserBreak()); i++)
       if (mySolutionsShape1.Value(i).Dist() > myDistRef + myEps)
       {
         mySolutionsShape1.Remove(i);
         mySolutionsShape2.Remove(i);
       }
     //  Modified by Sergey KHROMOV - Tue Mar  6 11:55:04 2001 End
-    myIsDone = ( mySolutionsShape1.Length() > 0 );
+    myIsDone = (mySolutionsShape1.Length() > 0) && (nullProgress || !PR->UserBreak());
   }
   return myIsDone;
 }
index c3040472ecaec311ac83d4e0408233ec3a40c490..7faf8e5cd60347a4a08fcc41a737ed66a4f2f46e 100644 (file)
@@ -26,6 +26,8 @@
 #include <Standard_OStream.hxx>
 #include <Standard_DefineAlloc.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
+#include <Message_ProgressIndicator.hxx>
+
 
 //! This class  provides tools to compute minimum distance <br>
 //! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). <br>
@@ -56,7 +58,7 @@ class BRepExtrema_DistShapeShape
   //!          to specify a maximum deviation of extreme distances <br>
   //!          from the minimum one. <br>
   //!          Returns IsDone status. <br>
-  Standard_EXPORT Standard_Boolean Perform();
+  Standard_EXPORT Standard_Boolean Perform(const Handle(Message_ProgressIndicator)& PR = nullptr);
   //! True if the minimum distance is found. <br>
   Standard_Boolean IsDone() const
   {