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