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