]> OCCT Git - occt-copy.git/commitdiff
0028254: Xpress tessellation for specific STP file leads to strange results, while...
authoroan <oan@opencascade.com>
Fri, 7 Apr 2017 15:13:40 +0000 (18:13 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 27 Apr 2017 14:32:31 +0000 (17:32 +0300)
Add Standard_EXPORT to protected methods of BRepExtrema_SelfIntersection.
Allow self-intersection check for the elements belonging to the same face using CheckAll() flag

src/BRepExtrema/BRepExtrema_SelfIntersection.cxx
src/BRepExtrema/BRepExtrema_SelfIntersection.hxx
src/BRepTest/BRepTest_ExtremaCommands.cxx

index 1f99c205e68a7620bf6e2757aade41312917019e..b770ef960d2aa2ab30f3a311579a56faded2c861 100644 (file)
@@ -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
   }
index b1cd1d98f71de7f087d8b352164e9263d3e59bf1..8f2749f42d2c62ed565b003df4fd228d8c78be70 100644 (file)
@@ -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;
 
index 3fb1887f90f7a474df106e342754d863084c0905..7e6f6b6d5fdd898c14593548cbd32f75b634e349 100644 (file)
@@ -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 <value>] [-profile]" << std::endl;
+      " Shape [-tol <value>] [-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,