From: tma Date: Tue, 17 Nov 2020 12:51:19 +0000 (+0300) Subject: 0031942: Add possibility to break the BRepExtrema_DistShapeShape algorithm X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=ff696f24851fd77fe6f021c190ba40157d1972bc;p=occt-copy.git 0031942: Add possibility to break the BRepExtrema_DistShapeShape algorithm --- diff --git a/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx b/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx index f70215b670..e7c6c6b1eb 100644 --- a/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx +++ b/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx @@ -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 ( (nbv1UserBreak())) { 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 ( (nbv2UserBreak())) { 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; } diff --git a/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx b/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx index c3040472ec..7faf8e5cd6 100644 --- a/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx +++ b/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx @@ -26,6 +26,8 @@ #include #include #include +#include + //! This class provides tools to compute minimum distance
//! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex).
@@ -56,7 +58,7 @@ class BRepExtrema_DistShapeShape //! to specify a maximum deviation of extreme distances
//! from the minimum one.
//! Returns IsDone status.
- Standard_EXPORT Standard_Boolean Perform(); + Standard_EXPORT Standard_Boolean Perform(const Handle(Message_ProgressIndicator)& PR = nullptr); //! True if the minimum distance is found.
Standard_Boolean IsDone() const {