0024023: Revamp the OCCT Handle -- ambiguity
[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{
92e24f9d 61 myFuzzyValue = (theFuzz < 0.) ? 0. : theFuzz;
b1d15f53 62}
63//=======================================================================
64//function : FuzzyValue
65//purpose :
66//=======================================================================
67Standard_Real BRepAlgoAPI_BuilderAlgo::FuzzyValue() const
68{
69 return myFuzzyValue;
70}
49b0c452 71//=======================================================================
72//function : Clear
73//purpose :
74//=======================================================================
75void BRepAlgoAPI_BuilderAlgo::Clear()
76{
77 if (myDSFiller && myEntryType) {
78 delete myDSFiller;
79 myDSFiller=NULL;
80 }
81 if (myBuilder) {
82 delete myBuilder;
83 myBuilder=NULL;
84 }
85}
86//=======================================================================
87//function : SetArguments
88//purpose :
89//=======================================================================
90void BRepAlgoAPI_BuilderAlgo::SetArguments
91 (const TopTools_ListOfShape& theLS)
92{
93 myArguments=theLS;
94}
95//=======================================================================
96//function : Arguments
97//purpose :
98//=======================================================================
99const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Arguments()const
100{
101 return myArguments;
102}
103//=======================================================================
104//function : Build
105//purpose :
106//=======================================================================
107void BRepAlgoAPI_BuilderAlgo::Build()
108{
109 Standard_Integer iErr;
110 //
111 NotDone();
112 myErrorStatus=0;
113 //
114 Clear();
115 //
116 if (myEntryType) {
117 if (myDSFiller) {
118 delete myDSFiller;
119 }
120 myDSFiller=new BOPAlgo_PaveFiller(myAllocator);
121 //
122 myDSFiller->SetArguments(myArguments);
123 //
124 myDSFiller->SetRunParallel(myRunParallel);
125 myDSFiller->SetProgressIndicator(myProgressIndicator);
126 myDSFiller->SetFuzzyValue(myFuzzyValue);
127 //
128 myDSFiller->Perform();
129 iErr=myDSFiller->ErrorStatus();
130 if (iErr) {
131 myErrorStatus=100+iErr;
132 }
133 }// if (myEntryType) {
134 //
135 if (myBuilder) {
136 delete myBuilder;
137 }
138 myBuilder=new BOPAlgo_Builder(myAllocator);
139 //
140 myBuilder->SetArguments(myArguments);
141 //
142 myBuilder->SetRunParallel(myRunParallel);
143 myBuilder->SetProgressIndicator(myProgressIndicator);
144 //
145 myBuilder->PerformWithFiller(*myDSFiller);
146 iErr=myBuilder->ErrorStatus();
147 if (iErr) {
148 myErrorStatus=200+iErr;
149 }
150 //
151 Done();
152 myShape=myBuilder->Shape();
153}
154//=======================================================================
155//function : Generated
156//purpose :
157//=======================================================================
158const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Generated
159 (const TopoDS_Shape& aS)
160{
161 if (myBuilder==NULL) {
162 myGenerated.Clear();
163 return myGenerated;
164 }
165 myGenerated = myBuilder->Generated(aS);
166 return myGenerated;
167}
168//=======================================================================
169//function : Modified
170//purpose :
171//=======================================================================
172const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Modified
173 (const TopoDS_Shape& aS)
174{
175 if (myBuilder==NULL) {
176 myGenerated.Clear();
177 return myGenerated;
178 }
179 myGenerated = myBuilder->Modified(aS);
180 return myGenerated;
181}
182//=======================================================================
183//function : IsDeleted
184//purpose :
185//=======================================================================
186Standard_Boolean BRepAlgoAPI_BuilderAlgo::IsDeleted
187 (const TopoDS_Shape& aS)
188{
189 Standard_Boolean bDeleted = Standard_True;
190 if (myBuilder != NULL) {
191 bDeleted=myBuilder->IsDeleted(aS);
192 }
193 return bDeleted;
194}
195//=======================================================================
196//function : HasModified
197//purpose :
198//=======================================================================
199Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasModified() const
200{
201 if (myBuilder==NULL) {
202 return Standard_False;
203 }
204 return myBuilder->HasModified();
205}
206//=======================================================================
207//function : HasGenerated
208//purpose :
209//=======================================================================
210Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasGenerated() const
211{
212 if (myBuilder==NULL) {
213 return Standard_False;
214 }
215 return myBuilder->HasGenerated();
216}
217//=======================================================================
218//function : HasDeleted
219//purpose :
220//=======================================================================
221Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasDeleted() const
222{
223 if (myBuilder==NULL) {
224 return Standard_False;
225 }
226 return myBuilder->HasDeleted();
227}