X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_BooleanDriver.cxx;h=d311b0dcec72ca420b10ac2454487947cc151cc4;hb=3059f9d5521dd7c91c35c50afbd6beb18b8826fd;hp=c419cd6d5f93adbc78297384662cad6e3a0c762f;hpb=239f8109c64fa0c5a2e1d87a420bad5529b57f48;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx index c419cd6d5..d311b0dce 100644 --- a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx @@ -1,21 +1,23 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -38,6 +40,9 @@ #include #include #include +#include +#include +#include #include #include @@ -52,7 +57,6 @@ const Standard_GUID& GEOMImpl_BooleanDriver::GetID() return aBooleanDriver; } - //======================================================================= //function : GEOMImpl_BooleanDriver //purpose : @@ -405,9 +409,43 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const } if (aShape.IsNull()) return 0; - if (!BRepAlgo::IsValid(aShape)) { - Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result"); + + // as boolean operations always produce compound, lets simplify it + // for the case, if it contans only one sub-shape + TopTools_ListOfShape listShapeRes; + AddSimpleShapes(aShape, listShapeRes); + if (listShapeRes.Extent() == 1) { + aShape = listShapeRes.First(); + if (aShape.IsNull()) return 0; + } + + // 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 (!BRepAlgo::IsValid(aShape)) { + // Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result"); + //} + + //Alternative case to check shape result Mantis 0020604: EDF 1172 +/* TopoDS_Iterator It (aShape, Standard_True, Standard_True); + int nbSubshapes=0; + for (; It.More(); It.Next()) + nbSubshapes++; + if (!nbSubshapes) + Standard_ConstructionError::Raise("Boolean operation aborted : result object is empty compound");*/ + //end of 0020604: EDF 1172 + //! the changes temporary commented because of customer needs (see the same mantis bug) aFunction->SetValue(aShape); @@ -434,10 +472,10 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_BooleanDriver_Type_() static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_BooleanDriver", - sizeof(GEOMImpl_BooleanDriver), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); + sizeof(GEOMImpl_BooleanDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); return _aType; }