0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / BRepAlgoAPI / BRepAlgoAPI_Splitter.cxx
1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2017 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <BRepAlgoAPI_Splitter.hxx>
16
17 #include <BOPAlgo_Alerts.hxx>
18 #include <BOPAlgo_Splitter.hxx>
19
20 //=======================================================================
21 // function: Empty constructor
22 // purpose: 
23 //=======================================================================
24 BRepAlgoAPI_Splitter::BRepAlgoAPI_Splitter()
25   : BRepAlgoAPI_BuilderAlgo() {}
26
27 //=======================================================================
28 // function: Constructor with already prepared PaveFiller
29 // purpose: 
30 //=======================================================================
31 BRepAlgoAPI_Splitter::BRepAlgoAPI_Splitter(const BOPAlgo_PaveFiller& thePF)
32   : BRepAlgoAPI_BuilderAlgo(thePF) {}
33
34 //=======================================================================
35 // function: Build
36 // purpose: 
37 //=======================================================================
38 void BRepAlgoAPI_Splitter::Build()
39 {
40   // Set Not Done status by default
41   NotDone();
42   // Clear the contents
43   Clear();
44   // Check for availability of arguments and tools
45   if (myArguments.IsEmpty() ||
46      (myArguments.Extent() + myTools.Extent()) < 2)
47   {
48     AddError (new BOPAlgo_AlertTooFewArguments);
49     return;
50   }
51
52   // If necessary perform intersection of the argument shapes
53   if (myIsIntersectionNeeded)
54   {
55     // Combine Arguments and Tools for intersection into a single list
56     TopTools_ListOfShape aLArgs = myArguments;
57     for (TopTools_ListOfShape::Iterator it(myTools); it.More(); it.Next())
58       aLArgs.Append(it.Value());
59
60     // Perform intersection
61     IntersectShapes(aLArgs);
62     if (HasErrors())
63       return;
64   }
65
66   // Initialization of the building tool
67   myBuilder = new BOPAlgo_Splitter(myAllocator);
68   myBuilder->SetArguments(myArguments);
69   ((BOPAlgo_Splitter*)myBuilder)->SetTools(myTools);
70
71   // Build result shape basing on the intersection results
72   BuildResult();
73 }