PartDesign, Transformed features: Improved intersection check

This commit is contained in:
jrheinlaender
2012-10-22 16:02:01 +02:00
committed by logari81
parent 1c158ef924
commit 32628462c2
3 changed files with 54 additions and 21 deletions

View File

@@ -27,14 +27,16 @@
# include <gp_Trsf.hxx>
# include <gp_Ax1.hxx>
# include <BRepBuilderAPI_MakeShape.hxx>
# include <BRepAlgoAPI_Common.hxx>
# include <TopTools_ListIteratorOfListOfShape.hxx>
# include <TopExp.hxx>
# include <TopTools_IndexedMapOfShape.hxx>
# include <Standard_Failure.hxx>
// includes for findAllFacesCutBy()
# include <TopoDS_Face.hxx>
# include <gp_Dir.hxx>
# include <gp_Pln.hxx> // for Precision::Confusion()
# include <Bnd_Box.hxx>
# include <BRepBndLib.hxx>
#endif
@@ -333,3 +335,34 @@ std::vector<Part::cutFaces> Part::findAllFacesCutBy(
return result;
}
const bool Part::checkIntersection(const TopoDS_Shape& first, const TopoDS_Shape& second, const bool quick) {
Bnd_Box first_bb, second_bb;
BRepBndLib::Add(first, first_bb);
first_bb.SetGap(0);
BRepBndLib::Add(second, second_bb);
second_bb.SetGap(0);
// Note: Both tests fail if the objects are touching one another at zero distance!
if (first_bb.IsOut(second_bb))
return false; // no intersection
//if (first_bb.Distance(second_bb) > Precision::Confusion())
// return false;
if (quick)
return true; // assumed intersection
// Try harder
BRepAlgoAPI_Common mkCommon(first, second);
// FIXME: Error in boolean operation, return true by default
if (!mkCommon.IsDone())
return true;
if (mkCommon.Shape().IsNull())
return true;
TopExp_Explorer xp;
xp.Init(mkCommon.Shape(),TopAbs_SOLID);
if (xp.More())
return true;
return false;
}