1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "GeomAlgoAPI_Intersection.h"
22 #include <GeomAlgoAPI_DFLoader.h>
24 #include <BOPAlgo_PaveFiller.hxx>
25 #include <BOPAlgo_Section.hxx>
27 //==================================================================================================
28 GeomAlgoAPI_Intersection::GeomAlgoAPI_Intersection(const ListOfShape& theObjects)
34 GeomAlgoAPI_Intersection::~GeomAlgoAPI_Intersection() {
36 delete (BOPAlgo_PaveFiller*)myFiller;
38 //==================================================================================================
39 void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects)
41 if (theObjects.empty()) {
45 // Creating partition operation.
46 BOPAlgo_Section* anOperation = new BOPAlgo_Section;
47 this->setImpl(anOperation);
48 this->setBuilderType(OCCT_BOPAlgo_Builder);
51 TopTools_ListOfShape anObjects;
52 for (ListOfShape::const_iterator
53 anObjectsIt = theObjects.begin(); anObjectsIt != theObjects.end(); anObjectsIt++) {
54 const TopoDS_Shape& aShape = (*anObjectsIt)->impl<TopoDS_Shape>();
55 if(!aShape.IsNull()) {
56 anObjects.Append(aShape);
60 BOPAlgo_PaveFiller* aDSFiller = new BOPAlgo_PaveFiller;
62 aDSFiller->SetArguments(anObjects);
64 aDSFiller->SetRunParallel(false);
65 aDSFiller->SetNonDestructive(false);
66 aDSFiller->SetGlue(BOPAlgo_GlueOff);
68 // optimization for the issue #2399
69 BOPAlgo_SectionAttribute theSecAttr(Standard_True,
72 aDSFiller->SetSectionAttribute(theSecAttr);
75 if (aDSFiller->HasErrors()) {
79 anOperation->SetArguments(anObjects);
80 anOperation->SetRunParallel(false);
81 anOperation->SetCheckInverted(true);
83 anOperation->PerformWithFiller(*aDSFiller); // it references a filler fields, so keep the filler
84 if(anOperation->HasErrors()) {
87 TopoDS_Shape aResult = anOperation->Shape();
89 if(aResult.ShapeType() == TopAbs_COMPOUND) {
90 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
93 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
94 aShape->setImpl(new TopoDS_Shape(aResult));
95 this->setShape(aShape);