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 | |
16 | #include <BOPAlgo_Splitter.hxx> |
17 | #include <BOPAlgo_PaveFiller.hxx> |
33ba8565 |
18 | #include <BOPAlgo_Alerts.hxx> |
c58055ad |
19 | |
53a73fc1 |
20 | #include <TopoDS_Iterator.hxx> |
21 | |
c58055ad |
22 | //======================================================================= |
23 | //function : |
24 | //purpose : |
25 | //======================================================================= |
26 | BOPAlgo_Splitter::BOPAlgo_Splitter() |
5fbe3d01 |
27 | : BOPAlgo_ToolsProvider() |
c58055ad |
28 | { |
29 | } |
30 | //======================================================================= |
31 | //function : |
32 | //purpose : |
33 | //======================================================================= |
5fbe3d01 |
34 | BOPAlgo_Splitter::BOPAlgo_Splitter(const Handle(NCollection_BaseAllocator)& theAllocator) |
35 | : BOPAlgo_ToolsProvider(theAllocator) |
c58055ad |
36 | { |
37 | } |
38 | //======================================================================= |
39 | //function : ~ |
40 | //purpose : |
41 | //======================================================================= |
42 | BOPAlgo_Splitter::~BOPAlgo_Splitter() |
43 | { |
44 | } |
c58055ad |
45 | //======================================================================= |
46 | // function: CheckData |
47 | // purpose: |
48 | //======================================================================= |
49 | void BOPAlgo_Splitter::CheckData() |
50 | { |
c58055ad |
51 | if (myArguments.IsEmpty() || |
52 | (myArguments.Extent() + myTools.Extent()) < 2) { |
53 | // too few arguments to process |
33ba8565 |
54 | AddError (new BOPAlgo_AlertTooFewArguments); |
c58055ad |
55 | return; |
56 | } |
57 | // |
33ba8565 |
58 | CheckFiller(); |
c58055ad |
59 | } |
60 | |
61 | //======================================================================= |
62 | //function : Perform |
63 | //purpose : |
64 | //======================================================================= |
65 | void BOPAlgo_Splitter::Perform() |
66 | { |
33ba8565 |
67 | GetReport()->Clear(); |
c58055ad |
68 | // |
69 | if (myEntryPoint == 1) { |
70 | if (myPaveFiller) { |
71 | delete myPaveFiller; |
72 | myPaveFiller = NULL; |
73 | } |
74 | } |
75 | // |
76 | // prepare shapes for intersection |
1155d05a |
77 | TopTools_ListOfShape aLS; |
c58055ad |
78 | // |
1155d05a |
79 | TopTools_ListIteratorOfListOfShape aItLS(myArguments); |
c58055ad |
80 | for (; aItLS.More(); aItLS.Next()) { |
81 | aLS.Append(aItLS.Value()); |
82 | } |
83 | // |
84 | aItLS.Initialize(myTools); |
85 | for (; aItLS.More(); aItLS.Next()) { |
86 | aLS.Append(aItLS.Value()); |
87 | } |
88 | // |
89 | BOPAlgo_PaveFiller *pPF = new BOPAlgo_PaveFiller(); |
90 | pPF->SetArguments(aLS); |
91 | pPF->SetRunParallel(myRunParallel); |
7e785937 |
92 | pPF->SetProgressIndicator(*myProgressScope); |
c58055ad |
93 | pPF->SetFuzzyValue(myFuzzyValue); |
94 | pPF->SetNonDestructive(myNonDestructive); |
95 | pPF->SetGlue(myGlue); |
944768d2 |
96 | pPF->SetUseOBB(myUseOBB); |
c58055ad |
97 | // |
98 | pPF->Perform(); |
99 | // |
100 | myEntryPoint = 1; |
101 | PerformInternal(*pPF); |
102 | } |
53a73fc1 |
103 | |
104 | //======================================================================= |
105 | //function : BuildResult |
106 | //purpose : |
107 | //======================================================================= |
108 | void BOPAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType) |
109 | { |
110 | BOPAlgo_Builder::BuildResult(theType); |
111 | |
112 | if (theType == TopAbs_COMPOUND) |
113 | { |
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) |
119 | { |
120 | TopoDS_Iterator it(myShape); |
121 | if (it.More()) |
122 | { |
123 | const TopoDS_Shape& aSFirst = it.Value(); |
124 | it.Next(); |
125 | if (!it.More()) |
126 | myShape = aSFirst; |
127 | } |
128 | } |
129 | } |
130 | } |