From 58940aef4e8476ff84e4682c65f24831a821943c Mon Sep 17 00:00:00 2001 From: oan Date: Fri, 7 Apr 2017 18:13:40 +0300 Subject: [PATCH] 0028254: Xpress tessellation for specific STP file leads to strange results, while BRep tessellation leads to expected results. Add Standard_EXPORT to protected methods of BRepExtrema_SelfIntersection. Allow self-intersection check for the elements belonging to the same face using CheckAll() flag --- .../BRepExtrema_SelfIntersection.cxx | 5 ++- .../BRepExtrema_SelfIntersection.hxx | 37 +++++++++++++------ src/BRepTest/BRepTest_ExtremaCommands.cxx | 13 +++++-- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/BRepExtrema/BRepExtrema_SelfIntersection.cxx b/src/BRepExtrema/BRepExtrema_SelfIntersection.cxx index 1f99c205e6..b770ef960d 100644 --- a/src/BRepExtrema/BRepExtrema_SelfIntersection.cxx +++ b/src/BRepExtrema/BRepExtrema_SelfIntersection.cxx @@ -24,6 +24,7 @@ //======================================================================= BRepExtrema_SelfIntersection::BRepExtrema_SelfIntersection (const Standard_Real theTolerance) : myTolerance (theTolerance) +, myCheckAll (Standard_False) { myIsInit = Standard_False; } @@ -34,6 +35,7 @@ BRepExtrema_SelfIntersection::BRepExtrema_SelfIntersection (const Standard_Real //======================================================================= BRepExtrema_SelfIntersection::BRepExtrema_SelfIntersection (const TopoDS_Shape& theShape, const Standard_Real theTolerance) : myTolerance (theTolerance) +, myCheckAll (Standard_False) { LoadShape (theShape); } @@ -240,7 +242,8 @@ BRepExtrema_ElementFilter::FilterResult BRepExtrema_SelfIntersection::isRegularS BRepExtrema_ElementFilter::FilterResult BRepExtrema_SelfIntersection::PreCheckElements (const Standard_Integer theIndex1, const Standard_Integer theIndex2) { - if (myElementSet->GetFaceID (theIndex1) == myElementSet->GetFaceID (theIndex2)) + const Standard_Boolean isSameFace = (myElementSet->GetFaceID(theIndex1) == myElementSet->GetFaceID(theIndex2)); + if (isSameFace && (!myCheckAll || theIndex1 == theIndex2)) { return BRepExtrema_ElementFilter::NoCheck; // triangles are from the same face } diff --git a/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx b/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx index b1cd1d98f7..8f2749f42d 100644 --- a/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx +++ b/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx @@ -55,6 +55,18 @@ public: myTolerance = theTolerance; } + //! Returns flag notifying that all triangles (including that belong to the same face) should be checked. + Standard_Boolean CheckAll() const + { + return myCheckAll; + } + + //! Sets flag notifying that all triangles (including that belong to the same face) should be checked. + void SetCheckAll(const Standard_Boolean isCheck) + { + myCheckAll = isCheck; + } + //! Loads shape for detection of self-intersections. Standard_EXPORT Standard_Boolean LoadShape (const TopoDS_Shape& theShape); @@ -96,27 +108,30 @@ public: protected: //! Filter out correct adjacent mesh elements. - virtual BRepExtrema_ElementFilter::FilterResult PreCheckElements (const Standard_Integer theIndex1, - const Standard_Integer theIndex2); + Standard_EXPORT virtual BRepExtrema_ElementFilter::FilterResult PreCheckElements (const Standard_Integer theIndex1, + const Standard_Integer theIndex2); //! Checks if the given triangles have only single common vertex. - BRepExtrema_ElementFilter::FilterResult isRegularSharedVertex (const BVH_Vec3d& theSharedVert, - const BVH_Vec3d& theTrng1Vtxs1, - const BVH_Vec3d& theTrng1Vtxs2, - const BVH_Vec3d& theTrng2Vtxs1, - const BVH_Vec3d& theTrng2Vtxs2); + Standard_EXPORT BRepExtrema_ElementFilter::FilterResult isRegularSharedVertex (const BVH_Vec3d& theSharedVert, + const BVH_Vec3d& theTrng1Vtxs1, + const BVH_Vec3d& theTrng1Vtxs2, + const BVH_Vec3d& theTrng2Vtxs1, + const BVH_Vec3d& theTrng2Vtxs2); //! Checks if the given triangles have only single common edge. - BRepExtrema_ElementFilter::FilterResult isRegularSharedEdge (const BVH_Vec3d& theTrng1Vtxs0, - const BVH_Vec3d& theTrng1Vtxs1, - const BVH_Vec3d& theTrng1Vtxs2, - const BVH_Vec3d& theTrng2Vtxs2); + Standard_EXPORT BRepExtrema_ElementFilter::FilterResult isRegularSharedEdge (const BVH_Vec3d& theTrng1Vtxs0, + const BVH_Vec3d& theTrng1Vtxs1, + const BVH_Vec3d& theTrng1Vtxs2, + const BVH_Vec3d& theTrng2Vtxs2); private: //! Self-intersection tolerance. Standard_Real myTolerance; + //! Check all elements even belonging to the same face. + Standard_Boolean myCheckAll; + //! Is the input shape inited? Standard_Boolean myIsInit; diff --git a/src/BRepTest/BRepTest_ExtremaCommands.cxx b/src/BRepTest/BRepTest_ExtremaCommands.cxx index 3fb1887f90..7e6f6b6d5f 100644 --- a/src/BRepTest/BRepTest_ExtremaCommands.cxx +++ b/src/BRepTest/BRepTest_ExtremaCommands.cxx @@ -288,7 +288,7 @@ static int ShapeSelfIntersection (Draw_Interpretor& theDI, Standard_Integer theN if (theNbArgs < 2 || theNbArgs > 5) { std::cout << "Usage: " << theArgs[0] << - " Shape [-tol ] [-profile]" << std::endl; + " Shape [-tol ] [-all] [-profile]" << std::endl; return 1; } @@ -303,6 +303,7 @@ static int ShapeSelfIntersection (Draw_Interpretor& theDI, Standard_Integer theN Standard_Real aTolerance = 0.0; Standard_Boolean aToProfile = Standard_False; + Standard_Boolean isCheckAll = Standard_False; for (Standard_Integer anArgIdx = 2; anArgIdx < theNbArgs; ++anArgIdx) { @@ -328,11 +329,14 @@ static int ShapeSelfIntersection (Draw_Interpretor& theDI, Standard_Integer theN aTolerance = aValue; } } - - if (aFlag == "-profile") + else if (aFlag == "-profile") { aToProfile = Standard_True; } + else if (aFlag == "-all") + { + isCheckAll = Standard_True; + } } OSD_Timer aTimer; @@ -346,6 +350,7 @@ static int ShapeSelfIntersection (Draw_Interpretor& theDI, Standard_Integer theN } BRepExtrema_SelfIntersection aTool (aShape, aTolerance); + aTool.SetCheckAll(isCheckAll); if (aToProfile) { @@ -443,6 +448,8 @@ void BRepTest::ExtremaCommands (Draw_Interpretor& theCommands) "\n\t\t: -tol : non-negative tolerance value used for overlapping" "\n\t\t: test (for zero tolerance, the strict intersection" "\n\t\t: test will be performed)" + "\n\t\t: -all : check all cases of self-intersection including" + "\n\t\t: self-intersections on the same face" "\n\t\t: -profile : outputs execution time for main algorithm stages", __FILE__, ShapeSelfIntersection, -- 2.39.5