0030611: Coding Rules - eliminate GCC compiler warnings -Wcatch-value
[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>
33ba8565 21#include <BOPAlgo_Alerts.hxx>
42cf5bc1 22#include <BOPDS_Curve.hxx>
4e57c75e 23#include <BOPDS_DS.hxx>
24#include <BOPDS_Iterator.hxx>
42cf5bc1 25#include <BOPDS_PaveBlock.hxx>
26#include <gp_Pnt.hxx>
27#include <IntTools_Context.hxx>
28#include <NCollection_BaseAllocator.hxx>
29#include <Standard_ErrorHandler.hxx>
30#include <Standard_Failure.hxx>
31#include <TopoDS_Face.hxx>
32#include <TopoDS_Vertex.hxx>
49b0c452 33#include <TopTools_ListIteratorOfListOfShape.hxx>
4e57c75e 34
35//=======================================================================
36//function :
37//purpose :
38//=======================================================================
6f31882a 39BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
4e57c75e 40:
0d0481c7 41 BOPAlgo_Algo()
4e57c75e 42{
0c5a6d47 43 myDS = NULL;
44 myIterator = NULL;
45 myNonDestructive = Standard_False;
46 myIsPrimary = Standard_True;
47 myAvoidBuildPCurve = Standard_False;
48 myGlue = BOPAlgo_GlueOff;
4e57c75e 49}
50//=======================================================================
51//function :
52//purpose :
53//=======================================================================
6f31882a 54BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
55 (const Handle(NCollection_BaseAllocator)& theAllocator)
4e57c75e 56:
d3578357 57 BOPAlgo_Algo(theAllocator),
58 myFPBDone(1, theAllocator),
59 myIncreasedSS(1, theAllocator),
60 myVertsToAvoidExtension(1, theAllocator)
4e57c75e 61{
0c5a6d47 62 myDS = NULL;
63 myIterator = NULL;
64 myNonDestructive = Standard_False;
65 myIsPrimary = Standard_True;
66 myAvoidBuildPCurve = Standard_False;
67 myGlue = BOPAlgo_GlueOff;
4e57c75e 68}
69//=======================================================================
70//function : ~
71//purpose :
72//=======================================================================
6f31882a 73BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
4e57c75e 74{
75 Clear();
76}
77//=======================================================================
3510db62 78//function : SetNonDestructive
79//purpose :
80//=======================================================================
81void BOPAlgo_PaveFiller::SetNonDestructive(const Standard_Boolean bFlag)
82{
83 myNonDestructive=bFlag;
84}
85//=======================================================================
86//function : NonDestructive
87//purpose :
88//=======================================================================
89Standard_Boolean BOPAlgo_PaveFiller::NonDestructive()const
90{
91 return myNonDestructive;
92}
93//=======================================================================
483ce1bd 94//function : SetGlue
95//purpose :
96//=======================================================================
97void BOPAlgo_PaveFiller::SetGlue(const BOPAlgo_GlueEnum theGlue)
98{
99 myGlue=theGlue;
100}
101//=======================================================================
102//function : Glue
103//purpose :
104//=======================================================================
105BOPAlgo_GlueEnum BOPAlgo_PaveFiller::Glue() const
106{
107 return myGlue;
108}
109//=======================================================================
3510db62 110//function : SetIsPrimary
111//purpose :
112//=======================================================================
113void BOPAlgo_PaveFiller::SetIsPrimary(const Standard_Boolean bFlag)
114{
115 myIsPrimary=bFlag;
116}
117//=======================================================================
118//function : IsPrimary
119//purpose :
120//=======================================================================
121Standard_Boolean BOPAlgo_PaveFiller::IsPrimary()const
122{
123 return myIsPrimary;
124}
125//=======================================================================
4e57c75e 126//function : Clear
127//purpose :
128//=======================================================================
6f31882a 129void BOPAlgo_PaveFiller::Clear()
4e57c75e 130{
33ba8565 131 BOPAlgo_Algo::Clear();
4e57c75e 132 if (myIterator) {
133 delete myIterator;
134 myIterator=NULL;
135 }
136 if (myDS) {
137 delete myDS;
138 myDS=NULL;
139 }
d3578357 140 myIncreasedSS.Clear();
4e57c75e 141}
142//=======================================================================
143//function : DS
144//purpose :
145//=======================================================================
6f31882a 146const BOPDS_DS& BOPAlgo_PaveFiller::DS()
4e57c75e 147{
148 return *myDS;
149}
150//=======================================================================
151//function : PDS
152//purpose :
153//=======================================================================
6f31882a 154BOPDS_PDS BOPAlgo_PaveFiller::PDS()
4e57c75e 155{
156 return myDS;
157}
158//=======================================================================
159//function : Context
160//purpose :
161//=======================================================================
51db0179 162const Handle(IntTools_Context)& BOPAlgo_PaveFiller::Context()
4e57c75e 163{
164 return myContext;
165}
166//=======================================================================
167//function : SectionAttribute
168//purpose :
169//=======================================================================
6f31882a 170void BOPAlgo_PaveFiller::SetSectionAttribute
171 (const BOPAlgo_SectionAttribute& theSecAttr)
4e57c75e 172{
173 mySectionAttribute = theSecAttr;
174}
175//=======================================================================
4e57c75e 176// function: Init
177// purpose:
178//=======================================================================
6f31882a 179void BOPAlgo_PaveFiller::Init()
4e57c75e 180{
4e57c75e 181 if (!myArguments.Extent()) {
33ba8565 182 AddError (new BOPAlgo_AlertTooFewArguments);
4e57c75e 183 return;
184 }
185 //
1155d05a 186 TopTools_ListIteratorOfListOfShape aIt(myArguments);
33ba8565 187 for (; aIt.More(); aIt.Next()) {
188 if (aIt.Value().IsNull()) {
189 AddError (new BOPAlgo_AlertNullInputShapes);
190 return;
191 }
192 }
193 //
4e57c75e 194 // 0 Clear
195 Clear();
196 //
197 // 1.myDS
198 myDS=new BOPDS_DS(myAllocator);
199 myDS->SetArguments(myArguments);
0d0481c7 200 myDS->Init(myFuzzyValue);
4e57c75e 201 //
944768d2 202 // 2 myContext
203 myContext=new IntTools_Context;
204 //
205 // 3.myIterator
4e57c75e 206 myIterator=new BOPDS_Iterator(myAllocator);
a2098360 207 myIterator->SetRunParallel(myRunParallel);
4e57c75e 208 myIterator->SetDS(myDS);
944768d2 209 myIterator->Prepare(myContext, myUseOBB, myFuzzyValue);
4e57c75e 210 //
3510db62 211 // 4 NonDestructive flag
212 SetNonDestructive();
4e57c75e 213}
214//=======================================================================
215// function: Perform
216// purpose:
217//=======================================================================
6f31882a 218void BOPAlgo_PaveFiller::Perform()
4e57c75e 219{
33ba8565 220 try {
6f31882a 221 OCC_CATCH_SIGNALS
222 //
36f4947b 223 PerformInternal();
224 }
225 //
a738b534 226 catch (Standard_Failure const&) {
33ba8565 227 AddError (new BOPAlgo_AlertIntersectionFailed);
36f4947b 228 }
4e57c75e 229}
36f4947b 230//=======================================================================
231// function: PerformInternal
232// purpose:
233//=======================================================================
234void BOPAlgo_PaveFiller::PerformInternal()
235{
36f4947b 236 Init();
33ba8565 237 if (HasErrors()) {
36f4947b 238 return;
239 }
240 //
241 Prepare();
33ba8565 242 if (HasErrors()) {
36f4947b 243 return;
244 }
245 // 00
246 PerformVV();
33ba8565 247 if (HasErrors()) {
36f4947b 248 return;
249 }
250 // 01
251 PerformVE();
33ba8565 252 if (HasErrors()) {
36f4947b 253 return;
254 }
255 //
3510db62 256 UpdatePaveBlocksWithSDVertices();
36f4947b 257 // 11
258 PerformEE();
33ba8565 259 if (HasErrors()) {
36f4947b 260 return;
261 }
3510db62 262 UpdatePaveBlocksWithSDVertices();
36f4947b 263 // 02
264 PerformVF();
33ba8565 265 if (HasErrors()) {
36f4947b 266 return;
267 }
3510db62 268 UpdatePaveBlocksWithSDVertices();
36f4947b 269 // 12
270 PerformEF();
33ba8565 271 if (HasErrors()) {
36f4947b 272 return;
273 }
3510db62 274 UpdatePaveBlocksWithSDVertices();
8ae442a8 275 UpdateInterfsWithSDVertices();
b7cd7c2b 276
d3578357 277 // Repeat Intersection with increased vertices
278 RepeatIntersection();
279 if (HasErrors())
280 return;
281
b7cd7c2b 282 // Force intersection of edges after increase
283 // of the tolerance values of their vertices
284 ForceInterfEE();
d3578357 285 // Force Edge/Face intersection after increase
286 // of the tolerance values of their vertices
287 ForceInterfEF();
36f4947b 288 //
3510db62 289 // 22
290 PerformFF();
33ba8565 291 if (HasErrors()) {
36f4947b 292 return;
293 }
294 //
3510db62 295 UpdateBlocksWithSharedVertices();
296 //
297 MakeSplitEdges();
33ba8565 298 if (HasErrors()) {
36f4947b 299 return;
300 }
301 //
3510db62 302 UpdatePaveBlocksWithSDVertices();
303 //
36f4947b 304 MakeBlocks();
33ba8565 305 if (HasErrors()) {
36f4947b 306 return;
307 }
308 //
33ba8565 309 CheckSelfInterference();
310 //
24542bc0 311 UpdateInterfsWithSDVertices();
6769ec6b 312 myDS->ReleasePaveBlocks();
313 myDS->RefineFaceInfoOn();
36f4947b 314 //
241a6133 315 RemoveMicroEdges();
316 //
36f4947b 317 MakePCurves();
33ba8565 318 if (HasErrors()) {
36f4947b 319 return;
320 }
321 //
322 ProcessDE();
33ba8565 323 if (HasErrors()) {
36f4947b 324 return;
325 }
25dfc507 326}
d3578357 327
328//=======================================================================
329// function: RepeatIntersection
330// purpose:
331//=======================================================================
332void BOPAlgo_PaveFiller::RepeatIntersection()
333{
334 // Find all vertices with increased tolerance
335 TColStd_MapOfInteger anExtraInterfMap;
336 const Standard_Integer aNbS = myDS->NbSourceShapes();
337 for (Standard_Integer i = 0; i < aNbS; ++i)
338 {
339 const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
340 if (aSI.ShapeType() != TopAbs_VERTEX)
341 continue;
342 // Check if the tolerance of the original vertex has been increased
343 if (myIncreasedSS.Contains(i))
344 {
345 anExtraInterfMap.Add(i);
346 continue;
347 }
348
349 // Check if the vertex created a new vertex with greater tolerance
350 Standard_Integer nVSD;
351 if (!myDS->HasShapeSD(i, nVSD))
352 continue;
353
354 if (myIncreasedSS.Contains(nVSD))
355 anExtraInterfMap.Add(i);
356 }
357
358 if (anExtraInterfMap.IsEmpty())
359 return;
360
361 // Update iterator of pairs of shapes with interfering boxes
362 myIterator->PrepareExt(anExtraInterfMap);
363
364 // Perform intersections with vertices
365 PerformVV();
366 if (HasErrors())
367 return;
368 UpdatePaveBlocksWithSDVertices();
369
370 PerformVE();
371 if (HasErrors())
372 return;
373 UpdatePaveBlocksWithSDVertices();
374
375 PerformVF();
376 if (HasErrors())
377 return;
378
379 UpdatePaveBlocksWithSDVertices();
380 UpdateInterfsWithSDVertices();
381}