c58055ad |
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 | |
33ba8565 |
17 | #include <BOPAlgo_Alerts.hxx> |
948fe6ca |
18 | #include <BOPAlgo_Splitter.hxx> |
c58055ad |
19 | |
20 | //======================================================================= |
21 | // function: Empty constructor |
22 | // purpose: |
23 | //======================================================================= |
24 | BRepAlgoAPI_Splitter::BRepAlgoAPI_Splitter() |
25 | : BRepAlgoAPI_BuilderAlgo() {} |
26 | |
27 | //======================================================================= |
948fe6ca |
28 | // function: Constructor with already prepared PaveFiller |
c58055ad |
29 | // purpose: |
30 | //======================================================================= |
31 | BRepAlgoAPI_Splitter::BRepAlgoAPI_Splitter(const BOPAlgo_PaveFiller& thePF) |
32 | : BRepAlgoAPI_BuilderAlgo(thePF) {} |
33 | |
c58055ad |
34 | //======================================================================= |
35 | // function: Build |
36 | // purpose: |
37 | //======================================================================= |
38 | void BRepAlgoAPI_Splitter::Build() |
39 | { |
948fe6ca |
40 | // Set Not Done status by default |
c58055ad |
41 | NotDone(); |
948fe6ca |
42 | // Clear the contents |
33ba8565 |
43 | Clear(); |
948fe6ca |
44 | // Check for availability of arguments and tools |
c58055ad |
45 | if (myArguments.IsEmpty() || |
948fe6ca |
46 | (myArguments.Extent() + myTools.Extent()) < 2) |
47 | { |
33ba8565 |
48 | AddError (new BOPAlgo_AlertTooFewArguments); |
c58055ad |
49 | return; |
50 | } |
948fe6ca |
51 | |
52 | // If necessary perform intersection of the argument shapes |
53 | if (myIsIntersectionNeeded) |
c58055ad |
54 | { |
948fe6ca |
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; |
c58055ad |
64 | } |
948fe6ca |
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(); |
c58055ad |
73 | } |