0026619: Tolerances of operands are modified using bop
[occt.git] / src / BRepAlgoAPI / BRepAlgoAPI_BuilderAlgo.cxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 2014 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_Builder.hxx>
17 #include <BOPAlgo_PaveFiller.hxx>
18 #include <BRepAlgoAPI_BuilderAlgo.hxx>
19 #include <TopoDS_Shape.hxx>
20
21 //=======================================================================
22 // function: 
23 // purpose: 
24 //=======================================================================
25 BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo()
26 :
27   BRepAlgoAPI_Algo(),
28   myEntryType(1),
29   myDSFiller(NULL),
30   myBuilder(NULL),
31   myFuzzyValue(0.),
32   myNonDestructive(Standard_False)
33 {}
34 //=======================================================================
35 // function: 
36 // purpose: 
37 //=======================================================================
38 BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo
39   (const BOPAlgo_PaveFiller& aPF)
40 :
41   BRepAlgoAPI_Algo(),
42   myEntryType(0),
43   myBuilder(NULL),
44   myFuzzyValue(0.),
45   myNonDestructive(Standard_False)
46 {
47   BOPAlgo_PaveFiller* pPF=(BOPAlgo_PaveFiller*)&aPF;
48   myDSFiller=pPF;
49 }
50 //=======================================================================
51 // function: ~
52 // purpose: 
53 //=======================================================================
54 BRepAlgoAPI_BuilderAlgo::~BRepAlgoAPI_BuilderAlgo()
55 {
56   Clear();
57 }
58 //=======================================================================
59 //function : SetFuzzyValue
60 //purpose  : 
61 //=======================================================================
62 void BRepAlgoAPI_BuilderAlgo::SetFuzzyValue(const Standard_Real theFuzz)
63 {
64   myFuzzyValue = (theFuzz < 0.) ? 0. : theFuzz;
65 }
66 //=======================================================================
67 //function : FuzzyValue
68 //purpose  : 
69 //=======================================================================
70 Standard_Real BRepAlgoAPI_BuilderAlgo::FuzzyValue() const
71 {
72   return myFuzzyValue;
73 }
74 //=======================================================================
75 //function : SetNonDestructive
76 //purpose  : 
77 //=======================================================================
78 void BRepAlgoAPI_BuilderAlgo::SetNonDestructive(const Standard_Boolean theFlag)
79 {
80   myNonDestructive = theFlag;
81 }
82 //=======================================================================
83 //function : NonDestructive
84 //purpose  : 
85 //=======================================================================
86 Standard_Boolean BRepAlgoAPI_BuilderAlgo::NonDestructive() const
87 {
88   return myNonDestructive;
89 }
90 //=======================================================================
91 //function : Clear
92 //purpose  : 
93 //=======================================================================
94 void BRepAlgoAPI_BuilderAlgo::Clear()
95 {
96   if (myDSFiller && myEntryType) {
97     delete myDSFiller;
98     myDSFiller=NULL;
99   }
100   if (myBuilder) {
101     delete myBuilder;
102     myBuilder=NULL;
103   }
104 }
105 //=======================================================================
106 //function : SetArguments
107 //purpose  : 
108 //=======================================================================
109 void BRepAlgoAPI_BuilderAlgo::SetArguments
110   (const TopTools_ListOfShape& theLS)
111 {
112   myArguments=theLS;
113 }
114 //=======================================================================
115 //function : Arguments
116 //purpose  : 
117 //=======================================================================
118 const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Arguments()const
119 {
120   return myArguments;
121 }
122 //=======================================================================
123 //function : Build
124 //purpose  : 
125 //=======================================================================
126 void BRepAlgoAPI_BuilderAlgo::Build()
127 {
128   Standard_Integer iErr;
129   //
130   NotDone();
131   myErrorStatus=0;
132   //
133   Clear();
134   //
135   if (myEntryType) {
136     if (myDSFiller) {
137       delete myDSFiller;
138     }
139     myDSFiller=new BOPAlgo_PaveFiller(myAllocator);
140     //
141     myDSFiller->SetArguments(myArguments);
142     //
143     myDSFiller->SetRunParallel(myRunParallel);
144     myDSFiller->SetProgressIndicator(myProgressIndicator);
145     myDSFiller->SetFuzzyValue(myFuzzyValue);
146     myDSFiller->SetNonDestructive(myNonDestructive);
147     //
148     myDSFiller->Perform();
149     iErr=myDSFiller->ErrorStatus();
150     if (iErr) {
151       myErrorStatus=100+iErr;
152     }
153   }// if (myEntryType) {
154   // 
155   if (myBuilder) {
156     delete myBuilder;
157   }
158   myBuilder=new BOPAlgo_Builder(myAllocator);
159   //
160   myBuilder->SetArguments(myArguments);
161   //
162   myBuilder->SetRunParallel(myRunParallel);
163   myBuilder->SetProgressIndicator(myProgressIndicator);
164   //
165   myBuilder->PerformWithFiller(*myDSFiller);
166   iErr=myBuilder->ErrorStatus();
167   if (iErr) {
168     myErrorStatus=200+iErr;
169   }
170   //
171   Done();
172   myShape=myBuilder->Shape();
173 }
174 //=======================================================================
175 //function : Generated
176 //purpose  : 
177 //=======================================================================
178 const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Generated
179   (const TopoDS_Shape& aS) 
180 {
181   if (myBuilder==NULL) {
182     myGenerated.Clear();
183     return myGenerated;
184   }
185   myGenerated = myBuilder->Generated(aS);
186   return myGenerated;
187 }
188 //=======================================================================
189 //function : Modified
190 //purpose  : 
191 //=======================================================================
192 const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Modified
193   (const TopoDS_Shape& aS) 
194 {
195   if (myBuilder==NULL) {
196     myGenerated.Clear();
197     return myGenerated;
198   }
199   myGenerated = myBuilder->Modified(aS);
200   return myGenerated;
201 }
202 //=======================================================================
203 //function : IsDeleted
204 //purpose  : 
205 //=======================================================================
206 Standard_Boolean BRepAlgoAPI_BuilderAlgo::IsDeleted
207   (const TopoDS_Shape& aS) 
208 {
209   Standard_Boolean bDeleted = Standard_True; 
210   if (myBuilder != NULL) {
211     bDeleted=myBuilder->IsDeleted(aS);
212   }
213   return bDeleted; 
214 }
215 //=======================================================================
216 //function : HasModified
217 //purpose  : 
218 //=======================================================================
219 Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasModified() const
220 {
221   if (myBuilder==NULL) {
222     return Standard_False;
223   }
224   return myBuilder->HasModified();
225 }
226 //=======================================================================
227 //function : HasGenerated
228 //purpose  : 
229 //=======================================================================
230 Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasGenerated() const
231 {
232   if (myBuilder==NULL) {
233     return Standard_False;
234   }
235   return myBuilder->HasGenerated();
236 }
237 //=======================================================================
238 //function : HasDeleted
239 //purpose  : 
240 //=======================================================================
241 Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasDeleted() const
242 {
243   if (myBuilder==NULL) {
244     return Standard_False;
245   }
246   return myBuilder->HasDeleted();
247 }