X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_BooleanDriver.cxx;h=abfc738eaa38435dfec6a0ef047022f51eaf918d;hb=2736f682fe0d63fbaf9dff49c46b4fa6c23d72ce;hp=f9a7d0a72568d379ee21b0e2204dd1c9f687bb5b;hpb=ec168c32f86cab8199030ec4e8e2b1cbd5e42670;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx index f9a7d0a72..abfc738ea 100644 --- a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx @@ -114,7 +114,7 @@ GEOMImpl_BooleanDriver::GEOMImpl_BooleanDriver() //function : Execute //purpose : //======================================================================= -Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const +Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); @@ -150,11 +150,11 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const aList2.Append(aShape2); aCSI.SetArguments(aList1); aCSI.Perform(); - if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); aCSI.SetArguments(aList2); aCSI.Perform(); - if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } @@ -191,7 +191,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const if (nbShapes > 0) { aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(1)); aShape = aRefShape->GetValue(); - + if (!aShape.IsNull()) { // check arguments for Mantis issue 0021019 if (!GEOMUtils::CheckShape(aShape, true)) @@ -205,7 +205,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const aList1.Append(aShape); aCSI.SetArguments(aList1); aCSI.Perform(); - if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) { + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } } @@ -218,18 +218,18 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const aShape = aShapeCopy; for (i = 2; i <= nbShapes; i++) { - aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(i)); - aShape2 = aRefShape->GetValue(); - + aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(i)); + aShape2 = aRefShape->GetValue(); + if (!GEOMUtils::CheckShape(aShape2, true)) - StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid"); - + StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid"); + if (isCheckSelfInte) { BOPCol_ListOfShape aList2; aList2.Append(aShape2); aCSI.SetArguments(aList2); aCSI.Perform(); - if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) { + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } } @@ -237,17 +237,17 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const // Copy shape aShapeCopy.Nullify(); TNaming_CopyShape::CopyTool(aShape2, aMapTShapes, aShapeCopy); - aShape = performOperation (aShape, aShapeCopy, aSimpleType); + aShape = performOperation (aShape, aShapeCopy, aSimpleType); if (isRmExtraEdges) { aShape = RemoveExtraEdges(aShape); } - - if (aShape.IsNull()) { - return 0; - } - } - } + + if (aShape.IsNull()) { + return 0; + } + } + } } } break; @@ -262,7 +262,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const 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 + BOPAlgo_CheckerSI aCSI; // checker of self-interferences if (isCheckSelfInte) { aCSI.SetLevelOfCheck(BOP_SELF_INTERSECTIONS_LEVEL); @@ -270,7 +270,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const aList1.Append(aShape); aCSI.SetArguments(aList1); aCSI.Perform(); - if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) { + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } } @@ -281,7 +281,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const TNaming_CopyShape::CopyTool(aShape, aMapTShapes, aShapeCopy); aShape = aShapeCopy; - + Handle(TColStd_HSequenceOfTransient) aTools = aCI.GetShapes(); const Standard_Integer nbShapes = aTools->Length(); Standard_Integer i; @@ -300,7 +300,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const aList2.Append(aTool); aCSI.SetArguments(aList2); aCSI.Perform(); - if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) { + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } } @@ -323,11 +323,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const aFunction->SetValue(aShape); -#if OCC_VERSION_MAJOR < 7 - log.SetTouched(Label()); -#else log->SetTouched(Label()); -#endif return 1; } @@ -342,16 +338,30 @@ TopoDS_Shape GEOMImpl_BooleanDriver::makeCompoundShellFromFaces if (theShape.ShapeType() != TopAbs_COMPOUND) return theShape; + BRep_Builder B; + TopoDS_Compound aFaces; + B.MakeCompound(aFaces); + + // simplify compound structure for + // Mantis issue 0023419 (note 0021712) + TopExp_Explorer aExp; + TopTools_MapOfShape aMapFaces; + aExp.Init(theShape, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aFace = aExp.Current(); + if (aMapFaces.Add(aFace)) { + B.Add(aFaces, aFace); + } + } + BOPCol_ListOfShape aListShapes; - BOPTools_AlgoTools::MakeConnexityBlocks(theShape, TopAbs_EDGE, TopAbs_FACE, aListShapes); + BOPTools_AlgoTools::MakeConnexityBlocks(aFaces, TopAbs_EDGE, TopAbs_FACE, aListShapes); if (aListShapes.IsEmpty()) return theShape; TopoDS_Compound aResult; - BRep_Builder B; B.MakeCompound(aResult); - TopExp_Explorer aExp; BOPCol_ListIteratorOfListOfShape anIter(aListShapes); for (; anIter.More(); anIter.Next()) { @@ -373,6 +383,7 @@ TopoDS_Shape GEOMImpl_BooleanDriver::makeCompoundShellFromFaces return aResult; } + //======================================================================= //function : performOperation //purpose : @@ -411,15 +422,14 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation TopoDS_Shape aStepResult = BO.Shape(); // check result of this step: if it is a compound (boolean operations - // allways return a compound), we add all sub-shapes of it. + // always return a compound), we add all sub-shapes of it. // This allows to avoid adding empty compounds, // resulting from COMMON on two non-intersecting shapes. if (aStepResult.ShapeType() == TopAbs_COMPOUND) { - #if OCC_VERSION_MAJOR >= 7 - if (aValue1.ShapeType() == TopAbs_FACE && aValue2.ShapeType() == TopAbs_FACE) { + if ((aValue1.ShapeType() == TopAbs_FACE || aValue1.ShapeType() == TopAbs_SHELL) && + (aValue2.ShapeType() == TopAbs_FACE || aValue2.ShapeType() == TopAbs_SHELL)) { aStepResult = makeCompoundShellFromFaces(aStepResult); } - #endif TopoDS_Iterator aCompIter (aStepResult); for (; aCompIter.More(); aCompIter.Next()) { // add shape in a result @@ -473,15 +483,14 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation } if (isCompound) { // check result of this step: if it is a compound (boolean operations - // allways return a compound), we add all sub-shapes of it. + // always return a compound), we add all sub-shapes of it. // This allows to avoid adding empty compounds, // resulting from CUT of parts if (aCut.ShapeType() == TopAbs_COMPOUND) { - #if OCC_VERSION_MAJOR >= 7 - if (itSub1.Value().ShapeType() == TopAbs_FACE) { + if (itSub1.Value().ShapeType() == TopAbs_FACE || + itSub1.Value().ShapeType() == TopAbs_SHELL) { aCut = makeCompoundShellFromFaces(aCut); } - #endif TopoDS_Iterator aCompIter (aCut); for (; aCompIter.More(); aCompIter.Next()) { // add shape in a result @@ -509,7 +518,6 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation // perform FUSE operation else if (theType == BOOLEAN_FUSE) { - #if OCC_VERSION_MAJOR >= 7 Standard_Boolean isFaces = Standard_False; TopTools_ListOfShape listShape1, listShape2; GEOMUtils::AddSimpleShapes(theShape1, listShape1); @@ -521,12 +529,12 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation TopTools_ListIteratorOfListOfShape itSub2 (listShape2); for (; itSub2.More(); itSub2.Next()) { TopoDS_Shape aValue2 = itSub2.Value(); - if (aValue1.ShapeType() == TopAbs_FACE && aValue2.ShapeType() == TopAbs_FACE) { + if ((aValue1.ShapeType() == TopAbs_FACE || aValue1.ShapeType() == TopAbs_SHELL) && + (aValue2.ShapeType() == TopAbs_FACE || aValue2.ShapeType() == TopAbs_SHELL)) { isFaces = Standard_True; } } } -#endif // Perform BRepAlgoAPI_Fuse BO (theShape1, theShape2); @@ -534,10 +542,8 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation StdFail_NotDone::Raise("Fuse operation can not be performed on the given shapes"); } aShape = BO.Shape(); - #if OCC_VERSION_MAJOR >= 7 if (isFaces) aShape = makeCompoundShellFromFaces(aShape); - #endif } // perform SECTION operation @@ -569,7 +575,7 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation BO.ComputePCurveOn1(Standard_True); BO.ComputePCurveOn2(Standard_True); //modified by NIZNHY-PKV Tue Oct 18 14:34:18 2011t - + BO.Build(); if (!BO.IsDone()) { StdFail_NotDone::Raise("Section operation can not be performed on the given shapes"); @@ -578,7 +584,7 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation TopoDS_Shape aStepResult = BO.Shape(); // check result of this step: if it is a compound (boolean operations - // allways return a compound), we add all sub-shapes of it. + // always return a compound), we add all sub-shapes of it. // This allows to avoid adding empty compounds, // resulting from SECTION on two non-intersecting shapes. if (aStepResult.ShapeType() == TopAbs_COMPOUND) { @@ -697,4 +703,4 @@ GetCreationInformation(std::string& theOperationName, return true; } -OCCT_IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_BooleanDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_BooleanDriver,GEOM_BaseDriver);