From: asuraven Date: Wed, 28 Jul 2021 10:19:22 +0000 (+0300) Subject: 0032448: Modeling Algorithms - Provide exact validating (as option) using GeomLib_Che... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=a70c84226fe3237ee820d0eafd60de253fbfe386;p=occt-copy.git 0032448: Modeling Algorithms - Provide exact validating (as option) using GeomLib_CheckCurveOnSurface Add '-exact' option to checkshape command to use exact method to validate edges using BRepLib_ValidateEdge class. Default mode is calculating in finite number of points. --- diff --git a/src/BRepCheck/BRepCheck_Analyzer.cxx b/src/BRepCheck/BRepCheck_Analyzer.cxx index f478ef833f..eb6f549b59 100644 --- a/src/BRepCheck/BRepCheck_Analyzer.cxx +++ b/src/BRepCheck/BRepCheck_Analyzer.cxx @@ -345,7 +345,8 @@ private: //======================================================================= void BRepCheck_Analyzer::Init (const TopoDS_Shape& theShape, const Standard_Boolean B, - const Standard_Boolean theIsParallel) + const Standard_Boolean theIsParallel, + const Standard_Boolean theIsExact) { if (theShape.IsNull()) { @@ -354,7 +355,7 @@ void BRepCheck_Analyzer::Init (const TopoDS_Shape& theShape, myShape = theShape; myMap.Clear(); - Put (theShape, B, theIsParallel); + Put (theShape, B, theIsParallel, theIsExact); Perform (theIsParallel); } @@ -364,7 +365,8 @@ void BRepCheck_Analyzer::Init (const TopoDS_Shape& theShape, //======================================================================= void BRepCheck_Analyzer::Put (const TopoDS_Shape& theShape, const Standard_Boolean B, - const Standard_Boolean theIsParallel) + const Standard_Boolean theIsParallel, + const Standard_Boolean theIsExact) { if (myMap.Contains (theShape)) { @@ -380,6 +382,7 @@ void BRepCheck_Analyzer::Put (const TopoDS_Shape& theShape, case TopAbs_EDGE: HR = new BRepCheck_Edge (TopoDS::Edge (theShape)); Handle(BRepCheck_Edge)::DownCast(HR)->GeometricControls (B); + Handle(BRepCheck_Edge)::DownCast(HR)->SetExactMethod(theIsExact); break; case TopAbs_WIRE: HR = new BRepCheck_Wire (TopoDS::Wire (theShape)); @@ -410,7 +413,7 @@ void BRepCheck_Analyzer::Put (const TopoDS_Shape& theShape, for (TopoDS_Iterator theIterator (theShape); theIterator.More(); theIterator.Next()) { - Put (theIterator.Value(), B, theIsParallel); // performs minimum on each shape + Put (theIterator.Value(), B, theIsParallel, theIsExact); // performs minimum on each shape } } @@ -418,7 +421,7 @@ void BRepCheck_Analyzer::Put (const TopoDS_Shape& theShape, //function : Perform //purpose : //======================================================================= -void BRepCheck_Analyzer::Perform (Standard_Boolean theIsParallel) +void BRepCheck_Analyzer::Perform (const Standard_Boolean theIsParallel) { const Standard_Integer aMapSize = myMap.Size(); const Standard_Integer aMinTaskSize = 10; diff --git a/src/BRepCheck/BRepCheck_Analyzer.hxx b/src/BRepCheck/BRepCheck_Analyzer.hxx index d921efdc64..2e55832545 100644 --- a/src/BRepCheck/BRepCheck_Analyzer.hxx +++ b/src/BRepCheck/BRepCheck_Analyzer.hxx @@ -62,9 +62,10 @@ public: //! BRepCheck_SelfIntersectingWire BRepCheck_Analyzer (const TopoDS_Shape& S, const Standard_Boolean GeomControls = Standard_True, - const Standard_Boolean theIsParallel = Standard_False) + const Standard_Boolean theIsParallel = Standard_False, + const Standard_Boolean theIsExact = Standard_False) { - Init (S, GeomControls, theIsParallel); + Init (S, GeomControls, theIsParallel, theIsExact); } //! is the shape to control. If @@ -85,7 +86,8 @@ public: //! BRepCheck_SelfIntersectingWire Standard_EXPORT void Init (const TopoDS_Shape& S, const Standard_Boolean GeomControls = Standard_True, - const Standard_Boolean theIsParallel = Standard_False); + const Standard_Boolean theIsParallel = Standard_False, + const Standard_Boolean theIsExact = Standard_False); //! is a subshape of the original shape. Returns //! if no default has been detected on @@ -145,9 +147,10 @@ private: Standard_EXPORT void Put (const TopoDS_Shape& S, const Standard_Boolean Gctrl, - const Standard_Boolean theIsParallel); + const Standard_Boolean theIsParallel, + const Standard_Boolean theIsExact); - Standard_EXPORT void Perform (Standard_Boolean theIsParallel); + Standard_EXPORT void Perform (const Standard_Boolean theIsParallel); Standard_EXPORT Standard_Boolean ValidSub (const TopoDS_Shape& S, const TopAbs_ShapeEnum SubType) const; diff --git a/src/BRepCheck/BRepCheck_Edge.cxx b/src/BRepCheck/BRepCheck_Edge.cxx index 48c3b8c56e..c45a568bcb 100644 --- a/src/BRepCheck/BRepCheck_Edge.cxx +++ b/src/BRepCheck/BRepCheck_Edge.cxx @@ -385,6 +385,8 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S) BRepLib_ValidateEdge aValidateEdge(myHCurve, ACS, SameParameter); aValidateEdge.SetExitIfToleranceExceeded(Tol); + aValidateEdge.SetExactMethod(myIsExactMethod); + aValidateEdge.SetParallel(myIsParallel); aValidateEdge.Process(); if (!aValidateEdge.IsDone() || !aValidateEdge.CheckTolerance(Tol)) { @@ -407,6 +409,8 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S) BRepLib_ValidateEdge aValidateEdgeOnClosedSurf(myHCurve, ACS, SameParameter); aValidateEdgeOnClosedSurf.SetExitIfToleranceExceeded(Tol); + aValidateEdgeOnClosedSurf.SetExactMethod(myIsExactMethod); + aValidateEdgeOnClosedSurf.SetParallel(myIsParallel); aValidateEdgeOnClosedSurf.Process(); if (!aValidateEdgeOnClosedSurf.IsDone() || !aValidateEdgeOnClosedSurf.CheckTolerance(Tol)) { @@ -466,6 +470,8 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S) BRepLib_ValidateEdge aValidateEdgeProj(myHCurve, ACS, SameParameter); aValidateEdgeProj.SetExitIfToleranceExceeded(Tol); + aValidateEdgeProj.SetExactMethod(myIsExactMethod); + aValidateEdgeProj.SetParallel(myIsParallel); aValidateEdgeProj.Process(); if (!aValidateEdgeProj.IsDone() || !aValidateEdgeProj.CheckTolerance(Tol)) { diff --git a/src/BRepCheck/BRepCheck_Edge.hxx b/src/BRepCheck/BRepCheck_Edge.hxx index 3051c17673..002e17322f 100644 --- a/src/BRepCheck/BRepCheck_Edge.hxx +++ b/src/BRepCheck/BRepCheck_Edge.hxx @@ -51,6 +51,12 @@ public: //! Sets status of Edge; Standard_EXPORT void SetStatus (const BRepCheck_Status theStatus); + + //! Sets validate edge method + void SetExactMethod(Standard_Boolean theIsExact) + { + myIsExactMethod = theIsExact; + } //! Checks, if polygon on triangulation of heEdge //! is out of 3D-curve of this edge. @@ -64,7 +70,7 @@ private: Handle(BRep_CurveRepresentation) myCref; Handle(Adaptor3d_Curve) myHCurve; Standard_Boolean myGctrl; - + Standard_Boolean myIsExactMethod; }; #endif // _BRepCheck_Edge_HeaderFile diff --git a/src/BRepCheck/BRepCheck_Result.cxx b/src/BRepCheck/BRepCheck_Result.cxx index cb84fb41b8..ee19fd1951 100644 --- a/src/BRepCheck/BRepCheck_Result.cxx +++ b/src/BRepCheck/BRepCheck_Result.cxx @@ -28,7 +28,8 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepCheck_Result,Standard_Transient) //======================================================================= BRepCheck_Result::BRepCheck_Result() : myMin (Standard_False), - myBlind (Standard_False) + myBlind (Standard_False), + myIsParallel (Standard_False) { // } @@ -43,6 +44,7 @@ void BRepCheck_Result::Init(const TopoDS_Shape& S) myShape = S; myMin = Standard_False; myBlind = Standard_False; + myIsParallel = Standard_False; myMap.Clear(); Minimum(); } @@ -98,6 +100,7 @@ void BRepCheck_Result::NextShapeInContext() //======================================================================= void BRepCheck_Result::SetParallel(Standard_Boolean theIsParallel) { + myIsParallel = theIsParallel; if (theIsParallel && myMutex.IsNull()) { myMutex.reset(new Standard_HMutex()); diff --git a/src/BRepCheck/BRepCheck_Result.hxx b/src/BRepCheck/BRepCheck_Result.hxx index f731ef6051..a83fe81b7a 100644 --- a/src/BRepCheck/BRepCheck_Result.hxx +++ b/src/BRepCheck/BRepCheck_Result.hxx @@ -91,6 +91,7 @@ protected: Standard_Boolean myMin; Standard_Boolean myBlind; BRepCheck_DataMapOfShapeListOfStatus myMap; + Standard_Boolean myIsParallel; mutable Handle(Standard_HMutex) myMutex; private: diff --git a/src/BRepLib/BRepLib_ValidateEdge.cxx b/src/BRepLib/BRepLib_ValidateEdge.cxx index f97a13640e..fdae929961 100644 --- a/src/BRepLib/BRepLib_ValidateEdge.cxx +++ b/src/BRepLib/BRepLib_ValidateEdge.cxx @@ -17,6 +17,7 @@ #include #include #include +#include //============================================================================= //function : BRepLib_ValidateEdge @@ -32,7 +33,8 @@ BRepLib_ValidateEdge::BRepLib_ValidateEdge(Handle(Adaptor3d_Curve) theReferenceC myToleranceForChecking(0), myCalculatedDistance(0), myExitIfToleranceExceeded(Standard_False), - myIsDone(Standard_False) + myIsDone(Standard_False), + myIsExactMethod(Standard_False) { } //============================================================================= @@ -96,6 +98,22 @@ void BRepLib_ValidateEdge::SetExitIfToleranceExceeded(Standard_Real theTolerance //purpose : //============================================================================= void BRepLib_ValidateEdge::Process() +{ + if (myIsExactMethod && mySameParameter) + { + ProcessExact(); + } + else + { + ProcessApprox(); + } +} + +//============================================================================= +//function : ProcessApprox +//purpose : +//============================================================================= +void BRepLib_ValidateEdge::ProcessApprox() { myIsDone = Standard_True; Standard_Real aSquareToleranceForChecking = myToleranceForChecking * myToleranceForChecking; @@ -212,3 +230,19 @@ void BRepLib_ValidateEdge::Process() } myCalculatedDistance = Sqrt(aMaxSquareDistance); } + +//============================================================================= +//function : ProcessExact +//purpose : +//============================================================================= +void BRepLib_ValidateEdge::ProcessExact() +{ + GeomLib_CheckCurveOnSurface aCheckCurveOnSurface(myReferenceCurve); + aCheckCurveOnSurface.Perform(myOtherCurve, myIsParallel); + myIsDone = aCheckCurveOnSurface.IsDone(); + if (myIsDone) + { + myCalculatedDistance = aCheckCurveOnSurface.MaxDistance(); + } +} + diff --git a/src/BRepLib/BRepLib_ValidateEdge.hxx b/src/BRepLib/BRepLib_ValidateEdge.hxx index 48fc25c7f2..6c21610386 100644 --- a/src/BRepLib/BRepLib_ValidateEdge.hxx +++ b/src/BRepLib/BRepLib_ValidateEdge.hxx @@ -21,8 +21,9 @@ class Adaptor3d_Curve; class Adaptor3d_CurveOnSurface; -//! Computes the max distance between 3D-curve and curve on -//! surface in fixed points number +//! Computes the max distance between 3D-curve and curve on surface. +//! This class uses 2 methods: approximate using finite +//! number of points (default) and exact class BRepLib_ValidateEdge { public: @@ -37,23 +38,39 @@ public: myControlPointsNumber = theControlPointsNumber; } - //! Sets the maximal allowed distance in the Process() function. If the distance greater than - //! theToleranceForChecking the Process() function stops. Use this for best performance - //! in case of checking of tolerance. - Standard_EXPORT void SetExitIfToleranceExceeded(Standard_Real theToleranceForChecking); + //! Sets method to calculate distance: Calculating in finite number of points (if theIsExact + //! is false, faster, but possible not correct result) or exact calculating by using + //! BRepLib_CheckCurveOnSurface class (if theIsExact is true, slowly, but more correctly. + //! Default method is exact + void SetExactMethod(Standard_Boolean theIsExact) + { + myIsExactMethod = theIsExact; + } + + //! Sets limit to compute a distance in the Process() function. If the distance greater than + //! theToleranceForChecking the Process() function stopped. Use this in case checking of + //! tolerance for best performcnce. Has no effect in case using exact method. + void SetExitIfToleranceExceeded(Standard_Real theToleranceForChecking); //! Computes the max distance for the 3d curve //! and curve on surface . If the SetExitIfToleranceExceeded() //! function was called before contains first - //! greater than SetExitIfToleranceExceeded() parameter value + //! greater than SetExitIfToleranceExceeded() parameter value. In case + //! using exact method always computes real max distance. Standard_EXPORT void Process(); //! Returns true if the distance has been found for all points - Standard_Boolean IsDone() + Standard_Boolean IsDone() const { return myIsDone; } + //! Sets process validating in parallel + void SetParallel(const Standard_Boolean theIsParallel) + { + myIsParallel = theIsParallel; + } + //! Returns true if computed distance is less than Standard_EXPORT Standard_Boolean CheckTolerance(Standard_Real theToleranceToCheck); @@ -67,7 +84,12 @@ private: //! Adds some margin for distance checking Standard_Real correctTolerance(Standard_Real theTolerance); -private: + //! Calculating in finite number of points + void ProcessApprox(); + + //! Calculating by using BRepLib_CheckCurveOnSurface class + void ProcessExact(); + Handle(Adaptor3d_Curve) myReferenceCurve; Handle(Adaptor3d_CurveOnSurface) myOtherCurve; Standard_Boolean mySameParameter; @@ -76,6 +98,8 @@ private: Standard_Real myCalculatedDistance; Standard_Boolean myExitIfToleranceExceeded; Standard_Boolean myIsDone; + Standard_Boolean myIsExactMethod; + Standard_Boolean myIsParallel; }; -#endif // _BRepLib_ValidateEdge_HeaderFile \ No newline at end of file +#endif // _BRepLib_ValidateEdge_HeaderFile diff --git a/src/BRepTest/BRepTest_CheckCommands.cxx b/src/BRepTest/BRepTest_CheckCommands.cxx index 5f52c7a267..92d7a8c316 100644 --- a/src/BRepTest/BRepTest_CheckCommands.cxx +++ b/src/BRepTest/BRepTest_CheckCommands.cxx @@ -867,7 +867,7 @@ static Standard_Integer checkshape (Draw_Interpretor& theCommands, return 0; } - if (narg > 6) + if (narg > 7) { theCommands << "Invalid number of args!!!\n"; theCommands << "No args to have help.\n"; @@ -901,6 +901,7 @@ static Standard_Integer checkshape (Draw_Interpretor& theCommands, Standard_Boolean IsShortDump = Standard_False; Standard_Boolean IsContextDump = Standard_True; Standard_Boolean IsParallel = Standard_False; + Standard_Boolean IsExact = Standard_False; Standard_CString aPref(NULL); if (aCurInd < narg && strncmp(a[aCurInd], "-", 1)) { @@ -921,6 +922,10 @@ static Standard_Integer checkshape (Draw_Interpretor& theCommands, { IsParallel = Standard_True; } + else if (anArg == "-exact") + { + IsExact = Standard_True; + } else { theCommands << "Syntax error at '" << anArg << "'"; @@ -931,7 +936,7 @@ static Standard_Integer checkshape (Draw_Interpretor& theCommands, try { OCC_CATCH_SIGNALS - BRepCheck_Analyzer anAna (aShape, aGeomCtrl, IsParallel); + BRepCheck_Analyzer anAna (aShape, aGeomCtrl, IsParallel, IsExact); Standard_Boolean isValid = anAna.IsValid(); if (isValid) diff --git a/tests/heal/checkshape/bug27814_10 b/tests/heal/checkshape/bug27814_10 index c1862aa347..7137456311 100644 --- a/tests/heal/checkshape/bug27814_10 +++ b/tests/heal/checkshape/bug27814_10 @@ -1,7 +1,7 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_51" +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_31" puts "==========" puts "0027814: Parallelize BRepCheck_Analyzer" puts "==========" puts "" -CheckPerform [locate_data_file OCC394.brep] \ No newline at end of file +CheckPerform [locate_data_file OCC396.brep] \ No newline at end of file diff --git a/tests/heal/checkshape/bug27814_11 b/tests/heal/checkshape/bug27814_11 index 7137456311..09fdb8611f 100644 --- a/tests/heal/checkshape/bug27814_11 +++ b/tests/heal/checkshape/bug27814_11 @@ -1,7 +1,7 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_31" +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_287" puts "==========" puts "0027814: Parallelize BRepCheck_Analyzer" puts "==========" puts "" -CheckPerform [locate_data_file OCC396.brep] \ No newline at end of file +CheckPerform [locate_data_file OCC54.brep] \ No newline at end of file diff --git a/tests/heal/checkshape/bug32448_1 b/tests/heal/checkshape/bug32448_1 new file mode 100644 index 0000000000..a6f8cd3eef --- /dev/null +++ b/tests/heal/checkshape/bug32448_1 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_88" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file bug27814.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_10 b/tests/heal/checkshape/bug32448_10 new file mode 100644 index 0000000000..0984113b23 --- /dev/null +++ b/tests/heal/checkshape/bug32448_10 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_6101" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file OCC54.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_2 b/tests/heal/checkshape/bug32448_2 new file mode 100644 index 0000000000..6e59a840b7 --- /dev/null +++ b/tests/heal/checkshape/bug32448_2 @@ -0,0 +1,7 @@ +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file 5000-12.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_3 b/tests/heal/checkshape/bug32448_3 new file mode 100644 index 0000000000..713da3b007 --- /dev/null +++ b/tests/heal/checkshape/bug32448_3 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_3675" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file BPLSEITLI.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_4 b/tests/heal/checkshape/bug32448_4 new file mode 100644 index 0000000000..7308858430 --- /dev/null +++ b/tests/heal/checkshape/bug32448_4 @@ -0,0 +1,7 @@ +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file bug24525_License.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_5 b/tests/heal/checkshape/bug32448_5 new file mode 100644 index 0000000000..dc6652c617 --- /dev/null +++ b/tests/heal/checkshape/bug32448_5 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_8234" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file bug26278_E01754_000000_P00_01_0_VS3_1_20070102_sewed_fixed.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_6 b/tests/heal/checkshape/bug32448_6 new file mode 100644 index 0000000000..a1599c0531 --- /dev/null +++ b/tests/heal/checkshape/bug32448_6 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_7656" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file bug30360_GES-13500-000.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_7 b/tests/heal/checkshape/bug32448_7 new file mode 100644 index 0000000000..954d6bd252 --- /dev/null +++ b/tests/heal/checkshape/bug32448_7 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_1943" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file OCC187_from_bug_description.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_8 b/tests/heal/checkshape/bug32448_8 new file mode 100644 index 0000000000..b5befa2698 --- /dev/null +++ b/tests/heal/checkshape/bug32448_8 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_502" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file OCC394.brep] b +checkshape b -exact -parallel diff --git a/tests/heal/checkshape/bug32448_9 b/tests/heal/checkshape/bug32448_9 new file mode 100644 index 0000000000..a3b978bcb6 --- /dev/null +++ b/tests/heal/checkshape/bug32448_9 @@ -0,0 +1,8 @@ +puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_467" +puts "==========" +puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" +puts "==========" +puts "" + +restore [locate_data_file OCC396.brep] b +checkshape b -exact -parallel