#include <TNaming_CopyShape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
#include <BRep_Builder.hxx>
-#include <BRepAlgo.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
-#include <BRepCheck_Analyzer.hxx>
#include <BOPAlgo_CheckerSI.hxx>
#include <BOPDS_DS.hxx>
{
TopoDS_Shape aResult;
- if (theShape.IsNull() == Standard_False) {
+ if (!theShape.IsNull()) {
BlockFix_BlockFixAPI aTool;
aTool.OptimumNbFaces() = 0;
aTool.SetShape(theShape);
aTool.Perform();
- aResult = aTool.Shape();
-
- // Repair result
- BRepCheck_Analyzer anAna (aResult, false);
- Standard_Boolean isValid = anAna.IsValid();
+ TopoDS_Shape aShape = aTool.Shape();
- if (!isValid) {
+ if (GEOMUtils::CheckShape(aShape)) {
+ aResult = aShape;
+ }
+ else {
TopoDS_Shape aFixed;
ShHealOper_ShapeProcess aHealer;
-
aHealer.Perform(aResult, aFixed);
-
- if (aHealer.isDone()) {
+ if (aHealer.isDone() && GEOMUtils::CheckShape(aFixed))
aResult = aFixed;
- anAna.Init(aResult, false);
- isValid = anAna.IsValid();
- }
- }
-
- if (!isValid) {
- aResult.Nullify();
}
}
if (!aShape1.IsNull() && !aShape2.IsNull()) {
// check arguments for Mantis issue 0021019
- BRepCheck_Analyzer ana (aShape1, Standard_True);
- if (!ana.IsValid())
- StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- ana.Init(aShape2);
- if (!ana.IsValid())
+ if (!GEOMUtils::CheckShape(aShape1, true) || !GEOMUtils::CheckShape(aShape2, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
if (isCheckSelfInte) {
aShape = aRefShape->GetValue();
if (!aShape.IsNull()) {
- BRepCheck_Analyzer anAna (aShape, Standard_True);
- if (!anAna.IsValid()) {
+ // check arguments for Mantis issue 0021019
+ if (!GEOMUtils::CheckShape(aShape, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
BOPAlgo_CheckerSI aCSI; // checker of self-interferences
for (i = 2; i <= nbShapes; i++) {
aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(i));
aShape2 = aRefShape->GetValue();
- anAna.Init(aShape2);
-
- if (!anAna.IsValid()) {
+
+ if (!GEOMUtils::CheckShape(aShape2, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
if (isCheckSelfInte) {
BOPCol_ListOfShape aList2;
if (!aShape.IsNull()) {
// check arguments for Mantis issue 0021019
- BRepCheck_Analyzer anAna (aShape, Standard_True);
-
- if (!anAna.IsValid()) {
+ if (!GEOMUtils::CheckShape(aShape, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
BOPAlgo_CheckerSI aCSI; // checker of self-interferences
for (i = 1; i <= nbShapes; i++) {
aRefTool = Handle(GEOM_Function)::DownCast(aTools->Value(i));
aTool = aRefTool->GetValue();
- anAna.Init(aTool);
- if (!anAna.IsValid()) {
+ if (!GEOMUtils::CheckShape(aTool, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
if (isCheckSelfInte) {
BOPCol_ListOfShape aList2;
}
// 08.07.2008 skl for bug 19761 from Mantis
- BRepCheck_Analyzer ana (aShape, Standard_True);
- ana.Init(aShape);
- if (!ana.IsValid()) {
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape, Precision::Confusion(),
- Precision::Confusion(), TopAbs_SHAPE);
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->Perform();
- aShape = aSfs->Shape();
- ana.Init(aShape);
- if (!ana.IsValid())
- Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
- }
+ if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+ Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
// BEGIN: Mantis issue 0021060: always limit tolerance of BOP result
// 1. Get shape parameters for comparison
TopoDS_Shape aShapeCopy;
TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
TNaming_CopyShape::CopyTool(aShape, aMapTShapes, aShapeCopy);
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShapeCopy, Precision::Confusion(), Precision::Confusion(), TopAbs_SHAPE);
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
- aSfs->Perform();
- aShapeCopy = aSfs->Shape();
-
- // 3. Check parameters
- ana.Init(aShapeCopy);
- if (ana.IsValid()) {
+
+ if ( GEOMUtils::FixShapeTolerance(aShapeCopy, true) ) {
int iType, nbTypesCopy [TopAbs_SHAPE];
for (iType = 0; iType < TopAbs_SHAPE; ++iType)