X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Intersection.cpp;h=26f60e4b17682d30c7ee697f3f1ed432ae4a48c2;hb=50a8df0c6a66da8067b16155e5ae39f8f26a7ebc;hp=a1b29f5cbf4dc432e323cfc62ee0671651c1f62d;hpb=c9b9d4d4af3b96661c280a7e3ab829f26b5c7b95;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp index a1b29f5cb..26f60e4b1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp @@ -1,63 +1,88 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAlgoAPI_Intersection.cpp -// Created: 16 Feb 2016 -// Author: Dmitry Bobylev +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// +// 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, or (at your option) any later version. +// +// 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. +// +// 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 "GeomAlgoAPI_Intersection.h" #include -#include -#include -#include -#include +#include +#include -//================================================================================================= -GeomAlgoAPI_Intersection::GeomAlgoAPI_Intersection(const ListOfShape& theObjects, - const ListOfShape& theTools) +//================================================================================================== +GeomAlgoAPI_Intersection::GeomAlgoAPI_Intersection(const ListOfShape& theObjects) + : myFiller(0) { - build(theObjects, theTools); + build(theObjects); } -//================================================================================================= -void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects, - const ListOfShape& theTools) +GeomAlgoAPI_Intersection::~GeomAlgoAPI_Intersection() { + if (myFiller) + delete (BOPAlgo_PaveFiller*)myFiller; +} +//================================================================================================== +void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects) { - if (theObjects.empty() || theTools.empty()) { + if (theObjects.empty()) { return; } // Creating partition operation. - BRepAlgoAPI_Section* anOperation = new BRepAlgoAPI_Section; + BOPAlgo_Section* anOperation = new BOPAlgo_Section; this->setImpl(anOperation); - this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape); - - TopAbs_ShapeEnum aShapeType = TopAbs_COMPOUND; + this->setBuilderType(OCCT_BOPAlgo_Builder); // Getting objects. TopTools_ListOfShape anObjects; - for (ListOfShape::const_iterator anObjectsIt = theObjects.begin(); anObjectsIt != theObjects.end(); anObjectsIt++) { + for (ListOfShape::const_iterator + anObjectsIt = theObjects.begin(); anObjectsIt != theObjects.end(); anObjectsIt++) { const TopoDS_Shape& aShape = (*anObjectsIt)->impl(); if(!aShape.IsNull()) { anObjects.Append(aShape); } } - anOperation->SetArguments(anObjects); - // Getting tools. - TopTools_ListOfShape aTools; - for (ListOfShape::const_iterator aToolsIt = theTools.begin(); aToolsIt != theTools.end(); aToolsIt++) { - const TopoDS_Shape& aShape = (*aToolsIt)->impl(); - if(!aShape.IsNull()) { - aTools.Append(aShape); - } + BOPAlgo_PaveFiller* aDSFiller = new BOPAlgo_PaveFiller; + myFiller = aDSFiller; + aDSFiller->SetArguments(anObjects); + + aDSFiller->SetRunParallel(false); + aDSFiller->SetNonDestructive(false); + aDSFiller->SetGlue(BOPAlgo_GlueOff); + + // optimization for the issue #2399 + BOPAlgo_SectionAttribute theSecAttr(Standard_True, + Standard_True, + Standard_True); + aDSFiller->SetSectionAttribute(theSecAttr); + + aDSFiller->Perform(); + if (aDSFiller->HasErrors()) { + return; } - anOperation->SetTools(aTools); - // Building and getting result. - anOperation->Build(); - if(!anOperation->IsDone()) { + anOperation->SetArguments(anObjects); + anOperation->SetRunParallel(false); + anOperation->SetCheckInverted(true); + + anOperation->PerformWithFiller(*aDSFiller); // it references a filler fields, so keep the filler + myFiller = 0; + if(anOperation->HasErrors()) { return; } TopoDS_Shape aResult = anOperation->Shape();