1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2017 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <BOPAlgo_Splitter.hxx>
17 #include <BOPAlgo_PaveFiller.hxx>
18 #include <BOPAlgo_Alerts.hxx>
20 #include <TopoDS_Iterator.hxx>
22 //=======================================================================
25 //=======================================================================
26 BOPAlgo_Splitter::BOPAlgo_Splitter()
27 : BOPAlgo_ToolsProvider()
30 //=======================================================================
33 //=======================================================================
34 BOPAlgo_Splitter::BOPAlgo_Splitter(const Handle(NCollection_BaseAllocator)& theAllocator)
35 : BOPAlgo_ToolsProvider(theAllocator)
38 //=======================================================================
41 //=======================================================================
42 BOPAlgo_Splitter::~BOPAlgo_Splitter()
45 //=======================================================================
46 // function: CheckData
48 //=======================================================================
49 void BOPAlgo_Splitter::CheckData()
51 if (myArguments.IsEmpty() ||
52 (myArguments.Extent() + myTools.Extent()) < 2) {
53 // too few arguments to process
54 AddError (new BOPAlgo_AlertTooFewArguments);
61 //=======================================================================
64 //=======================================================================
65 void BOPAlgo_Splitter::Perform()
69 if (myEntryPoint == 1) {
76 // prepare shapes for intersection
77 TopTools_ListOfShape aLS;
79 TopTools_ListIteratorOfListOfShape aItLS(myArguments);
80 for (; aItLS.More(); aItLS.Next()) {
81 aLS.Append(aItLS.Value());
84 aItLS.Initialize(myTools);
85 for (; aItLS.More(); aItLS.Next()) {
86 aLS.Append(aItLS.Value());
89 BOPAlgo_PaveFiller *pPF = new BOPAlgo_PaveFiller();
90 pPF->SetArguments(aLS);
91 pPF->SetRunParallel(myRunParallel);
92 pPF->SetProgressIndicator(myProgressIndicator);
93 pPF->SetFuzzyValue(myFuzzyValue);
94 pPF->SetNonDestructive(myNonDestructive);
96 pPF->SetUseOBB(myUseOBB);
101 PerformInternal(*pPF);
104 //=======================================================================
105 //function : BuildResult
107 //=======================================================================
108 void BOPAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType)
110 BOPAlgo_Builder::BuildResult(theType);
112 if (theType == TopAbs_COMPOUND)
114 // The method is called for the last time for this operation.
115 // If there is only one argument shape and it has been modified into
116 // a single shape, or has not been modified at all, the result shape
117 // has to be overwritten to avoid the unnecessary enclosure into compound.
118 if (myArguments.Extent() == 1)
120 TopoDS_Iterator it(myShape);
123 const TopoDS_Shape& aSFirst = it.Value();