//=======================================================================
BRepExtrema_SelfIntersection::BRepExtrema_SelfIntersection (const Standard_Real theTolerance)
: myTolerance (theTolerance)
+, myCheckAll (Standard_False)
{
myIsInit = Standard_False;
}
//=======================================================================
BRepExtrema_SelfIntersection::BRepExtrema_SelfIntersection (const TopoDS_Shape& theShape, const Standard_Real theTolerance)
: myTolerance (theTolerance)
+, myCheckAll (Standard_False)
{
LoadShape (theShape);
}
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
}
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);
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;
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;
}
Standard_Real aTolerance = 0.0;
Standard_Boolean aToProfile = Standard_False;
+ Standard_Boolean isCheckAll = Standard_False;
for (Standard_Integer anArgIdx = 2; anArgIdx < theNbArgs; ++anArgIdx)
{
aTolerance = aValue;
}
}
-
- if (aFlag == "-profile")
+ else if (aFlag == "-profile")
{
aToProfile = Standard_True;
}
+ else if (aFlag == "-all")
+ {
+ isCheckAll = Standard_True;
+ }
}
OSD_Timer aTimer;
}
BRepExtrema_SelfIntersection aTool (aShape, aTolerance);
+ aTool.SetCheckAll(isCheckAll);
if (aToProfile)
{
"\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,