0028187: Add possibility to avoid creation of Internal parts in the result of Volume...
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 2010-2014 OPEN CASCADE SAS
4e57c75e 3// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6//
973c2be1 7// This file is part of Open CASCADE Technology software library.
4e57c75e 8//
d5f74e42 9// This library is free software; you can redistribute it and/or modify it under
10// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 11// by the Free Software Foundation, with special exception defined in the file
12// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13// distribution for complete text of the license and disclaimer of any warranty.
4e57c75e 14//
973c2be1 15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
4e57c75e 17
4e57c75e 18
42cf5bc1 19#include <BOPAlgo_PaveFiller.hxx>
20#include <BOPAlgo_SectionAttribute.hxx>
21#include <BOPDS_Curve.hxx>
4e57c75e 22#include <BOPDS_DS.hxx>
23#include <BOPDS_Iterator.hxx>
42cf5bc1 24#include <BOPDS_PaveBlock.hxx>
25#include <gp_Pnt.hxx>
26#include <IntTools_Context.hxx>
27#include <NCollection_BaseAllocator.hxx>
28#include <Standard_ErrorHandler.hxx>
29#include <Standard_Failure.hxx>
30#include <TopoDS_Face.hxx>
31#include <TopoDS_Vertex.hxx>
49b0c452 32#include <TopTools_ListIteratorOfListOfShape.hxx>
4e57c75e 33
34//=======================================================================
35//function :
36//purpose :
37//=======================================================================
6f31882a 38BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
4e57c75e 39:
0d0481c7 40 BOPAlgo_Algo()
4e57c75e 41{
42 myDS=NULL;
43 myIterator=NULL;
3510db62 44 myNonDestructive=Standard_False;
45 myIsPrimary=Standard_True;
483ce1bd 46 myGlue=BOPAlgo_GlueOff;
4e57c75e 47}
48//=======================================================================
49//function :
50//purpose :
51//=======================================================================
6f31882a 52BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
53 (const Handle(NCollection_BaseAllocator)& theAllocator)
4e57c75e 54:
0d0481c7 55 BOPAlgo_Algo(theAllocator)
4e57c75e 56{
57 myDS=NULL;
58 myIterator=NULL;
3510db62 59 myNonDestructive=Standard_False;
60 myIsPrimary=Standard_True;
483ce1bd 61 myGlue=BOPAlgo_GlueOff;
4e57c75e 62}
63//=======================================================================
64//function : ~
65//purpose :
66//=======================================================================
6f31882a 67BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
4e57c75e 68{
69 Clear();
70}
71//=======================================================================
3510db62 72//function : SetNonDestructive
73//purpose :
74//=======================================================================
75void BOPAlgo_PaveFiller::SetNonDestructive(const Standard_Boolean bFlag)
76{
77 myNonDestructive=bFlag;
78}
79//=======================================================================
80//function : NonDestructive
81//purpose :
82//=======================================================================
83Standard_Boolean BOPAlgo_PaveFiller::NonDestructive()const
84{
85 return myNonDestructive;
86}
87//=======================================================================
483ce1bd 88//function : SetGlue
89//purpose :
90//=======================================================================
91void BOPAlgo_PaveFiller::SetGlue(const BOPAlgo_GlueEnum theGlue)
92{
93 myGlue=theGlue;
94}
95//=======================================================================
96//function : Glue
97//purpose :
98//=======================================================================
99BOPAlgo_GlueEnum BOPAlgo_PaveFiller::Glue() const
100{
101 return myGlue;
102}
103//=======================================================================
3510db62 104//function : SetIsPrimary
105//purpose :
106//=======================================================================
107void BOPAlgo_PaveFiller::SetIsPrimary(const Standard_Boolean bFlag)
108{
109 myIsPrimary=bFlag;
110}
111//=======================================================================
112//function : IsPrimary
113//purpose :
114//=======================================================================
115Standard_Boolean BOPAlgo_PaveFiller::IsPrimary()const
116{
117 return myIsPrimary;
118}
119//=======================================================================
4e57c75e 120//function : Clear
121//purpose :
122//=======================================================================
6f31882a 123void BOPAlgo_PaveFiller::Clear()
4e57c75e 124{
125 if (myIterator) {
126 delete myIterator;
127 myIterator=NULL;
128 }
129 if (myDS) {
130 delete myDS;
131 myDS=NULL;
132 }
4e57c75e 133}
134//=======================================================================
135//function : DS
136//purpose :
137//=======================================================================
6f31882a 138const BOPDS_DS& BOPAlgo_PaveFiller::DS()
4e57c75e 139{
140 return *myDS;
141}
142//=======================================================================
143//function : PDS
144//purpose :
145//=======================================================================
6f31882a 146BOPDS_PDS BOPAlgo_PaveFiller::PDS()
4e57c75e 147{
148 return myDS;
149}
150//=======================================================================
151//function : Context
152//purpose :
153//=======================================================================
51db0179 154const Handle(IntTools_Context)& BOPAlgo_PaveFiller::Context()
4e57c75e 155{
156 return myContext;
157}
158//=======================================================================
159//function : SectionAttribute
160//purpose :
161//=======================================================================
6f31882a 162void BOPAlgo_PaveFiller::SetSectionAttribute
163 (const BOPAlgo_SectionAttribute& theSecAttr)
4e57c75e 164{
165 mySectionAttribute = theSecAttr;
166}
167//=======================================================================
168//function : SetArguments
169//purpose :
170//=======================================================================
6f31882a 171void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS)
4e57c75e 172{
173 myArguments=theLS;
174}
175//=======================================================================
176//function : Arguments
177//purpose :
178//=======================================================================
6f31882a 179const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
4e57c75e 180{
181 return myArguments;
182}
183//=======================================================================
184// function: Init
185// purpose:
186//=======================================================================
6f31882a 187void BOPAlgo_PaveFiller::Init()
4e57c75e 188{
189 myErrorStatus=0;
190 //
191 if (!myArguments.Extent()) {
192 myErrorStatus=10;
193 return;
194 }
195 //
196 // 0 Clear
197 Clear();
198 //
199 // 1.myDS
200 myDS=new BOPDS_DS(myAllocator);
201 myDS->SetArguments(myArguments);
0d0481c7 202 myDS->Init(myFuzzyValue);
4e57c75e 203 //
204 // 2.myIterator
205 myIterator=new BOPDS_Iterator(myAllocator);
a2098360 206 myIterator->SetRunParallel(myRunParallel);
4e57c75e 207 myIterator->SetDS(myDS);
208 myIterator->Prepare();
209 //
210 // 3 myContext
1e143abb 211 myContext=new IntTools_Context;
4e57c75e 212 //
3510db62 213 // 4 NonDestructive flag
214 SetNonDestructive();
215 //
4e57c75e 216 myErrorStatus=0;
217}
218//=======================================================================
219// function: Perform
220// purpose:
221//=======================================================================
6f31882a 222void BOPAlgo_PaveFiller::Perform()
4e57c75e 223{
224 myErrorStatus=0;
6f31882a 225 try {
226 OCC_CATCH_SIGNALS
227 //
36f4947b 228 PerformInternal();
229 }
230 //
6f31882a 231 catch (Standard_Failure) {
232 myErrorStatus=11;
36f4947b 233 }
4e57c75e 234}
36f4947b 235//=======================================================================
236// function: PerformInternal
237// purpose:
238//=======================================================================
239void BOPAlgo_PaveFiller::PerformInternal()
240{
241 myErrorStatus=0;
242 //
243 Init();
244 if (myErrorStatus) {
245 return;
246 }
247 //
248 Prepare();
249 if (myErrorStatus) {
250 return;
251 }
252 // 00
253 PerformVV();
254 if (myErrorStatus) {
255 return;
256 }
257 // 01
258 PerformVE();
259 if (myErrorStatus) {
260 return;
261 }
262 //
3510db62 263 UpdatePaveBlocksWithSDVertices();
36f4947b 264 myDS->UpdatePaveBlocks();
265 // 11
266 PerformEE();
267 if (myErrorStatus) {
268 return;
269 }
3510db62 270 UpdatePaveBlocksWithSDVertices();
36f4947b 271 // 02
272 PerformVF();
273 if (myErrorStatus) {
274 return;
275 }
3510db62 276 UpdatePaveBlocksWithSDVertices();
36f4947b 277 // 12
278 PerformEF();
279 if (myErrorStatus) {
280 return;
281 }
3510db62 282 UpdatePaveBlocksWithSDVertices();
36f4947b 283 //
3510db62 284 // 22
285 PerformFF();
36f4947b 286 if (myErrorStatus) {
287 return;
288 }
289 //
3510db62 290 UpdateBlocksWithSharedVertices();
291 //
292 MakeSplitEdges();
36f4947b 293 if (myErrorStatus) {
294 return;
295 }
296 //
3510db62 297 UpdatePaveBlocksWithSDVertices();
298 //
36f4947b 299 MakeBlocks();
300 if (myErrorStatus) {
301 return;
302 }
303 //
304 RefineFaceInfoOn();
305 //
306 MakePCurves();
307 if (myErrorStatus) {
308 return;
309 }
310 //
311 ProcessDE();
312 if (myErrorStatus) {
313 return;
314 }
483ce1bd 315 //
316 if (myGlue != BOPAlgo_GlueOff) {
317 return;
318 }
955b3e71 319 // 03
320 PerformVZ();
321 if (myErrorStatus) {
322 return;
323 }
324 // 13
325 PerformEZ();
326 if (myErrorStatus) {
327 return;
328 }
329 // 23
330 PerformFZ();
331 if (myErrorStatus) {
332 return;
333 }
334 // 33
335 PerformZZ();
336 if (myErrorStatus) {
337 return;
338 }
36f4947b 339}