0025734: GCC warnings in Android build
[occt.git] / src / BRepFeat / BRepFeat_Form.cxx
CommitLineData
b311480e 1// Created on: 1996-02-13
2// Created by: Olga KOULECHOVA
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <BRepFeat_Form.ixx>
18
19#include <LocOpe.hxx>
7fd59977 20#include <LocOpe_Gluer.hxx>
21#include <LocOpe_FindEdges.hxx>
22#include <LocOpe_CSIntersector.hxx>
23#include <LocOpe_SequenceOfCirc.hxx>
24#include <LocOpe_PntFace.hxx>
25#include <LocOpe_BuildShape.hxx>
26
27#include <TopExp_Explorer.hxx>
28#include <TopOpeBRepBuild_HBuilder.hxx>
29#include <TopTools_MapOfShape.hxx>
30#include <TopTools_ListIteratorOfListOfShape.hxx>
31#include <TopTools_MapIteratorOfMapOfShape.hxx>
32#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
33#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
34#include <TColgp_SequenceOfPnt.hxx>
35#include <Standard_NoSuchObject.hxx>
36#include <Precision.hxx>
37
38#include <BRep_Tool.hxx>
39#include <Geom_RectangularTrimmedSurface.hxx>
40#include <Geom_Plane.hxx>
41#include <Geom_CylindricalSurface.hxx>
42#include <Geom_ConicalSurface.hxx>
43
44#include <TopoDS_Solid.hxx>
45#include <TopoDS_Compound.hxx>
46#include <BRepTools_Modifier.hxx>
47#include <BRepTools_TrsfModification.hxx>
48#include <BRepFeat.hxx>
49#include <BRepCheck_Analyzer.hxx>
50#include <TopoDS.hxx>
51
52#include <Bnd_Box.hxx>
53#include <BRepBndLib.hxx>
54#include <BRepLib.hxx>
55
56#include <ElCLib.hxx>
57
58#include <BRepAlgo.hxx>
59//modified by NIZNHY-PKV Thu Mar 21 17:30:25 2002 f
60//#include <BRepAlgo_Cut.hxx>
61//#include <BRepAlgo_Fuse.hxx>
62
63#include <BRepAlgoAPI_Cut.hxx>
64#include <BRepAlgoAPI_Fuse.hxx>
4e57c75e 65#include <BRepFeat_Builder.hxx>
7fd59977 66//modified by NIZNHY-PKV Thu Mar 21 17:30:29 2002 t
67
0797d9d3 68#ifdef OCCT_DEBUG
1d0a9d4d 69extern Standard_Boolean BRepFeat_GettraceFEAT();
7fd59977 70#endif
71
72static void Descendants(const TopoDS_Shape&,
4e57c75e 73 BRepFeat_Builder&,
74 TopTools_MapOfShape&);
7fd59977 75
76//=======================================================================
77//function : Perform
0d969553 78//purpose : topological reconstruction of the result
7fd59977 79//=======================================================================
80 void BRepFeat_Form::GlobalPerform ()
81{
82
0797d9d3 83#ifdef OCCT_DEBUG
7fd59977 84 Standard_Boolean trc = BRepFeat_GettraceFEAT();
85 if (trc) cout << "BRepFeat_Form::GlobalPerform ()" << endl;
86#endif
87
88 if (!mySbOK || !myGSOK || !mySFOK || !mySUOK || !myGFOK ||
89 !mySkOK || !myPSOK) {
0797d9d3 90#ifdef OCCT_DEBUG
7fd59977 91 if (trc) cout << " Fields not initialized in BRepFeat_Form" << endl;
92#endif
93 myStatusError = BRepFeat_NotInitialized;
94 NotDone();
95 return;
96 }
97
7fd59977 98//--- Initialisation
7fd59977 99 TopExp_Explorer exp,exp2;
100 Standard_Integer theOpe = 2;
4e57c75e 101 TopTools_DataMapIteratorOfDataMapOfShapeShape itm;
7fd59977 102
103 if(myJustFeat && !myFuse) {
0797d9d3 104#ifdef OCCT_DEBUG
7fd59977 105 if (trc) cout << " Invalid option : myJustFeat + Cut" << endl;
106#endif
107 myStatusError = BRepFeat_InvOption;
108 NotDone();
109 return;
110 }
111 else if(myJustFeat) {
112 theOpe = 2;
113 }
114 else if (!myGluedF.IsEmpty()) {
115 theOpe = 1;
116 }
117 else {}
118 Standard_Boolean ChangeOpe = Standard_False;
119
7fd59977 120 Standard_Boolean FromInShape = Standard_False;
121 Standard_Boolean UntilInShape = Standard_False;
7fd59977 122
123 if (!mySFrom.IsNull()) {
124 FromInShape = Standard_True;
125 for (exp2.Init(mySFrom,TopAbs_FACE); exp2.More(); exp2.Next()) {
126 const TopoDS_Shape& ffrom = exp2.Current();
127 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
4e57c75e 128 if (exp.Current().IsSame(ffrom)) {
129 break;
130 }
7fd59977 131 }
132 if (!exp.More()) {
4e57c75e 133 FromInShape = Standard_False;
0797d9d3 134#ifdef OCCT_DEBUG
4e57c75e 135 if (trc) cout << " From not in Shape" << endl;
7fd59977 136#endif
4e57c75e 137 break;
7fd59977 138 }
139 }
140 }
141
142 if (!mySUntil.IsNull()) {
143 UntilInShape = Standard_True;
144 for (exp2.Init(mySUntil,TopAbs_FACE); exp2.More(); exp2.Next()) {
145 const TopoDS_Shape& funtil = exp2.Current();
146 for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) {
4e57c75e 147 if (exp.Current().IsSame(funtil)) {
148 break;
149 }
7fd59977 150 }
151 if (!exp.More()) {
4e57c75e 152 UntilInShape = Standard_False;
0797d9d3 153#ifdef OCCT_DEBUG
4e57c75e 154 if (trc) cout << " Until not in Shape" << endl;
7fd59977 155#endif
4e57c75e 156 break;
7fd59977 157 }
158 }
159 }
160
7fd59977 161 TopTools_ListIteratorOfListOfShape it,it2;
162 Standard_Integer sens = 0;
163
164 TColGeom_SequenceOfCurve scur;
165 Curves(scur);
166
7fd59977 167 Standard_Real mf, Mf, mu, Mu;
168
169 TopAbs_Orientation Orifuntil = TopAbs_INTERNAL;
170 TopAbs_Orientation Oriffrom = TopAbs_INTERNAL;
171 TopoDS_Face FFrom,FUntil;
172
173 LocOpe_CSIntersector ASI1;
174 LocOpe_CSIntersector ASI2;
175
7fd59977 176 TopTools_ListOfShape IntList;
177 IntList.Clear();
178
0d969553 179//--- 1) by intersection
7fd59977 180
0d969553 181// Intersection Tool Shape From
7fd59977 182 if (!mySFrom.IsNull()) {
183 ASI1.Init(mySFrom);
184 ASI1.Perform(scur);
185 }
186
0d969553 187// Intersection Tool Shape Until
7fd59977 188 if (!mySUntil.IsNull()) {
189 ASI2.Init(mySUntil);
190 ASI2.Perform(scur);
191 }
192
7fd59977 193 {
bcf50875 194// Find sens, FFrom, FUntil
7fd59977 195 for (Standard_Integer jj=1; jj<=scur.Length(); jj++) {
196 if (ASI1.IsDone() && ASI2.IsDone()) {
4e57c75e 197 if (ASI1.NbPoints(jj) <= 0) {
198 continue;
199 }
200 mf = ASI1.Point(jj,1).Parameter();
201 Mf = ASI1.Point(jj,ASI1.NbPoints(jj)).Parameter();
202 if (ASI2.NbPoints(jj) <= 0) {
203 continue;
204 }
205 mu = ASI2.Point(jj,1).Parameter();
206 Mu = ASI2.Point(jj,ASI2.NbPoints(jj)).Parameter();
bcf50875 207 if (!scur(jj)->IsPeriodic()) {
4e57c75e 208 Standard_Integer ku, kf;
209 if (! (mu > Mf || mf > Mu)) { //overlapping intervals
210 sens = 1;
211 kf = 1;
212 ku = ASI2.NbPoints(jj);
4e57c75e 213 }
214 else if (mu > Mf) {
215 if (sens == -1) {
216 myStatusError = BRepFeat_IntervalOverlap;
217 NotDone();
218 return;
219 }
220 sens = 1;
221 kf = 1;
222 ku = ASI2.NbPoints(jj);
4e57c75e 223 }
224 else {
225 if (sens == 1) {
226 myStatusError = BRepFeat_IntervalOverlap;
227 NotDone();
228 return;
229 }
230 sens = -1;
231 kf = ASI1.NbPoints(jj);
232 ku = 1;
4e57c75e 233 }
234 if (Oriffrom == TopAbs_INTERNAL) {
235 TopAbs_Orientation Oript = ASI1.Point(jj,kf).Orientation();
236 if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) {
237 if (sens == -1) {
238 Oript = TopAbs::Reverse(Oript);
239 }
240 Oriffrom = TopAbs::Reverse(Oript);
241 FFrom = ASI1.Point(jj,kf).Face();
242 }
243 }
244 if (Orifuntil == TopAbs_INTERNAL) {
245 TopAbs_Orientation Oript = ASI2.Point(jj,ku).Orientation();
246 if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) {
247 if (sens == -1) {
248 Oript = TopAbs::Reverse(Oript);
249 }
250 Orifuntil = Oript;
251 FUntil = ASI2.Point(jj,ku).Face();
252 }
253 }
254 }
7fd59977 255 }
256 else if (ASI2.IsDone()) {
4e57c75e 257 if (ASI2.NbPoints(jj) <= 0)
258 continue;
7fd59977 259
0d969553
Y
260// for base case prism on mySUntil -> ambivalent direction
261// -> preferrable direction = 1
4e57c75e 262 if(sens != 1) {
263 if (ASI2.Point(jj,1).Parameter()*
264 ASI2.Point(jj,ASI2.NbPoints(jj)).Parameter()<=0)
265 sens=1;
266 else if (ASI2.Point(jj,1).Parameter()<0.)
267 sens =-1;
268 else
269 sens =1;
270 }
271
272 Standard_Integer ku;
273 if (sens == -1) {
274 ku = 1;
4e57c75e 275 }
276 else {
277 ku = ASI2.NbPoints(jj);
4e57c75e 278 }
279 if (Orifuntil == TopAbs_INTERNAL && sens != 0) {
280 TopAbs_Orientation Oript = ASI2.Point(jj,ku).Orientation();
281 if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) {
282 if (sens == -1) {
283 Oript = TopAbs::Reverse(Oript);
284 }
285 Orifuntil = Oript;
286 FUntil = ASI2.Point(jj,ku).Face();
287 }
288 }
7fd59977 289 }
290 else {
4e57c75e 291 sens = 1;
292 break;
7fd59977 293 }
7fd59977 294 }
295 }
296
7fd59977 297 LocOpe_Gluer theGlue;
298
0d969553 299//--- case of gluing
7fd59977 300
301 if (theOpe == 1) {
0797d9d3 302#ifdef OCCT_DEBUG
7fd59977 303 if (trc) cout << " Gluer" << endl;
304#endif
305 Standard_Boolean Collage = Standard_True;
0d969553 306 // cut by FFrom && FUntil
7fd59977 307 TopoDS_Shape Comp;
308 BRep_Builder B;
309 B.MakeCompound(TopoDS::Compound(Comp));
310 if (!mySFrom.IsNull()) {
311 TopoDS_Solid S = BRepFeat::Tool(mySFrom,FFrom,Oriffrom);
312 if (!S.IsNull()) {
4e57c75e 313 B.Add(Comp,S);
7fd59977 314 }
315 }
316 if (!mySUntil.IsNull()) {
317 TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil);
318 if (!S.IsNull()) {
4e57c75e 319 B.Add(Comp,S);
7fd59977 320 }
321 }
322
323 LocOpe_FindEdges theFE;
324 TopTools_DataMapOfShapeListOfShape locmap;
325 TopExp_Explorer expp(Comp, TopAbs_SOLID);
326 if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) {
327 //modified by NIZNHY-PKV Thu Mar 21 17:15:36 2002 f
328 //BRepAlgo_Cut trP(myGShape,Comp);
329 BRepAlgoAPI_Cut trP(myGShape, Comp);
330 //modified by NIZNHY-PKV Thu Mar 21 17:15:58 2002 t
331 exp.Init(trP.Shape(), TopAbs_SOLID);
332 if (exp.Current().IsNull()) {
4e57c75e 333 theOpe = 2;
334 ChangeOpe = Standard_True;
335 Collage = Standard_False;
7fd59977 336 }
337 else {// else X0
4e57c75e 338 // Only solids are preserved
339 TopoDS_Shape theGShape;
340 BRep_Builder B;
341 B.MakeCompound(TopoDS::Compound(theGShape));
342 for (; exp.More(); exp.Next()) {
343 B.Add(theGShape,exp.Current());
344 }
345 if (!BRepAlgo::IsValid(theGShape)) {
346 theOpe = 2;
347 ChangeOpe = Standard_True;
348 Collage = Standard_False;
349 }
350 else {// else X1
351 if(!mySFrom.IsNull()) {
352 TopExp_Explorer ex;
353 ex.Init(mySFrom, TopAbs_FACE);
354 for(; ex.More(); ex.Next()) {
355 const TopoDS_Face& fac = TopoDS::Face(ex.Current());
356 if (!FromInShape) {
7fd59977 357 TopTools_ListOfShape thelist;
4e57c75e 358 myMap.Bind(fac, thelist);
359 }
360 else {
7fd59977 361 TopTools_ListOfShape thelist1;
4e57c75e 362 locmap.Bind(fac, thelist1);
363 }
364 if (trP.IsDeleted(fac)) {
365 }
366 else if (!FromInShape) {
367 myMap(fac) = trP.Modified(fac);
368 if (myMap(fac).IsEmpty()) myMap(fac).Append(fac);
369 }
370 else {
371 locmap(fac) =trP.Modified(fac) ;
372 if (locmap(fac).IsEmpty()) locmap(fac).Append(fac);
373 }
374 }
375 }// if(!mySFrom.IsNull())
376 //
377 if(!mySUntil.IsNull()) {
378 TopExp_Explorer ex;
379 ex.Init(mySUntil, TopAbs_FACE);
380 for(; ex.More(); ex.Next()) {
381 const TopoDS_Face& fac = TopoDS::Face(ex.Current());
382 if (!UntilInShape) {
383 TopTools_ListOfShape thelist2;
7fd59977 384 myMap.Bind(fac,thelist2);
4e57c75e 385 }
386 else {
7fd59977 387 TopTools_ListOfShape thelist3;
4e57c75e 388 locmap.Bind(fac,thelist3);
389 }
390 if (trP.IsDeleted(fac)) {
391 }
392 else if (!UntilInShape) {
393 myMap(fac) = trP.Modified(fac);
394 if (myMap(fac).IsEmpty()) myMap(fac).Append(fac);
395 }
396 else {
397 locmap(fac) = trP.Modified(fac);
398 if (locmap(fac).IsEmpty()) locmap(fac).Append(fac);
399 }
400 }
401 }// if(!mySUntil.IsNull())
402 //
403 //modified by NIZNHY-PKV Thu Mar 21 17:21:49 2002 f
404 //UpdateDescendants(trP.Builder(),theGShape,Standard_True); // skip faces
405 UpdateDescendants(trP,theGShape,Standard_True); // skip faces
406 //modified by NIZNHY-PKV Thu Mar 21 17:22:32 2002 t
407
408 theGlue.Init(mySbase,theGShape);
409 for (itm.Initialize(myGluedF);itm.More();itm.Next()) {
410 const TopoDS_Face& gl = TopoDS::Face(itm.Key());
411 TopTools_ListOfShape ldsc;
412 if (trP.IsDeleted(gl)) {
413 }
414 else {
415 ldsc = trP.Modified(gl);
416 if (ldsc.IsEmpty()) ldsc.Append(gl);
417 }
418 const TopoDS_Face& glface = TopoDS::Face(itm.Value());
419 for (it.Initialize(ldsc);it.More();it.Next()) {
420 const TopoDS_Face& fac = TopoDS::Face(it.Value());
421 Collage = BRepFeat::IsInside(fac, glface);
422 if(!Collage) {
423 theOpe = 2;
424 ChangeOpe = Standard_True;
425 break;
426 }
427 else {
428 theGlue.Bind(fac,glface);
429 theFE.Set(fac,glface);
430 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
431 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
432 }
433 }
434 }
435 }
436 }// else X1
7fd59977 437 }// else X0
438 }// if(expp.More() && !Comp.IsNull() && !myGShape.IsNull())
439 else {
440 theGlue.Init(mySbase,myGShape);
441 for (itm.Initialize(myGluedF); itm.More();itm.Next()) {
4e57c75e 442 const TopoDS_Face& glface = TopoDS::Face(itm.Key());
443 const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface));
444 for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) {
445 if (exp.Current().IsSame(glface)) {
446 break;
447 }
448 }
449 if (exp.More()) {
450 Collage = BRepFeat::IsInside(glface, fac);
451 if(!Collage) {
452 theOpe = 2;
453 ChangeOpe = Standard_True;
454 break;
455 }
456 else {
457 theGlue.Bind(glface, fac);
458 theFE.Set(glface, fac);
459 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
460 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
461 }
462 }
463 }
7fd59977 464 }
465 }
466
0d969553 467 // Add gluing on start and end face if necessary !!!
7fd59977 468 if (FromInShape && Collage) {
469 TopExp_Explorer ex(mySFrom,TopAbs_FACE);
470 for(; ex.More(); ex.Next()) {
4e57c75e 471 const TopoDS_Face& fac2 = TopoDS::Face(ex.Current());
472// for (it.Initialize(myMap(fac2)); it.More(); it.Next()) {
473 for (it.Initialize(locmap(fac2)); it.More(); it.Next()) {
474 const TopoDS_Face& fac1 = TopoDS::Face(it.Value());
475 theFE.Set(fac1, fac2);
476 theGlue.Bind(fac1, fac2);
477 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
478 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
479 }
480 }
481// myMap.UnBind(fac2);
7fd59977 482 }
483 }
484
485 if (UntilInShape && Collage) {
486 TopExp_Explorer ex(mySUntil, TopAbs_FACE);
487 for(; ex.More(); ex.Next()) {
4e57c75e 488 const TopoDS_Face& fac2 = TopoDS::Face(ex.Current());
489// for (it.Initialize(myMap(fac2)); it.More(); it.Next()) {
490 for (it.Initialize(locmap(fac2)); it.More(); it.Next()) {
491 const TopoDS_Face& fac1 = TopoDS::Face(it.Value());
492 theGlue.Bind(fac1, fac2);
493 theFE.Set(fac1, fac2);
494 for (theFE.InitIterator(); theFE.More();theFE.Next()) {
495 theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo());
496 }
497 }
498 //myMap.UnBind(fac2); // to avoid fac2 in Map when
499 // UpdateDescendants(theGlue) is called
7fd59977 500 }
501 }
502
503 LocOpe_Operation ope = theGlue.OpeType();
504 if (ope == LocOpe_INVALID ||
4e57c75e 505 (myFuse && ope != LocOpe_FUSE) ||
506 (!myFuse && ope != LocOpe_CUT) ||
507 (!Collage)) {
7fd59977 508 theOpe = 2;
509 ChangeOpe = Standard_True;
510 }
511 }
512
0d969553 513//--- if the gluing is always applicable
7fd59977 514
515 if (theOpe == 1) {
0797d9d3 516#ifdef OCCT_DEBUG
7fd59977 517 if (trc) cout << " still Gluer" << endl;
518#endif
519 theGlue.Perform();
520 if (theGlue.IsDone()) {
521 TopoDS_Shape shshs = theGlue.ResultingShape();
522// if (BRepOffsetAPI::IsTopologicallyValid(shshs)) {
523 if (BRepAlgo::IsValid(shshs)) {
4e57c75e 524 UpdateDescendants(theGlue);
525 myNewEdges = theGlue.Edges();
526 myTgtEdges = theGlue.TgtEdges();
0797d9d3 527#ifdef OCCT_DEBUG
4e57c75e 528 if (trc) cout << " Gluer result" << endl;
7fd59977 529#endif
4e57c75e 530 Done();
531 myShape = theGlue.ResultingShape();
7fd59977 532 }
533 else {
4e57c75e 534 theOpe = 2;
535 ChangeOpe = Standard_True;
7fd59977 536 }
537 }
538 else {
539 theOpe = 2;
540 ChangeOpe = Standard_True;
541 }
542 }
543
544
0d969553 545//--- case without gluing + Tool with proper dimensions
7fd59977 546
547 if (theOpe == 2 && ChangeOpe && myJustGluer) {
0797d9d3 548#ifdef OCCT_DEBUG
7fd59977 549 if (trc) cout << " Gluer failure" << endl;
550#endif
551 myJustGluer = Standard_False;
552 theOpe = 0;
553// Done();
554// return;
555 }
556
0d969553 557//--- case without gluing
7fd59977 558
559 if (theOpe == 2) {
0797d9d3 560#ifdef OCCT_DEBUG
7fd59977 561 if (trc) cout << " No Gluer" << endl;
562#endif
563 TopoDS_Shape theGShape = myGShape;
564 if (ChangeOpe) {
0797d9d3 565#ifdef OCCT_DEBUG
0d969553 566 if (trc) cout << " Passage to topological operations" << endl;
7fd59977 567#endif
7fd59977 568 }
569
570 TopoDS_Shape Comp;
571 BRep_Builder B;
572 B.MakeCompound(TopoDS::Compound(Comp));
573 if (!mySFrom.IsNull() || !mySUntil.IsNull()) {
574 if (!mySFrom.IsNull() && !FromInShape) {
4e57c75e 575 TopoDS_Solid S = BRepFeat::Tool(mySFrom,FFrom,Oriffrom);
576 if (!S.IsNull()) {
577 B.Add(Comp,S);
578 }
7fd59977 579 }
580 if (!mySUntil.IsNull() && !UntilInShape) {
4e57c75e 581 if (!mySFrom.IsNull()) {
582 if (!mySFrom.IsSame(mySUntil)) {
583 TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil);
584 if (!S.IsNull()) {
585 B.Add(Comp,S);
586 }
587 }
588 }
589 else {
590 TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil);
591 if (!S.IsNull()) {
592 B.Add(Comp,S);
593 }
594 }
7fd59977 595 }
596 }
597
0d969553 598// update type of selection
7fd59977 599 if(myPerfSelection == BRepFeat_SelectionU && !UntilInShape) {
600 myPerfSelection = BRepFeat_NoSelection;
601 }
602 else if(myPerfSelection == BRepFeat_SelectionFU &&
4e57c75e 603 !FromInShape && !UntilInShape) {
7fd59977 604 myPerfSelection = BRepFeat_NoSelection;
605 }
606 else if(myPerfSelection == BRepFeat_SelectionShU && !UntilInShape) {
607 myPerfSelection = BRepFeat_NoSelection;
608 }
609 else {}
610
611 TopExp_Explorer expp(Comp, TopAbs_SOLID);
612 if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) {
613 //modified by NIZNHY-PKV Thu Mar 21 17:24:52 2002 f
614 //BRepAlgo_Cut trP(myGShape,Comp);
615 BRepAlgoAPI_Cut trP(myGShape, Comp);
616 //modified by NIZNHY-PKV Thu Mar 21 17:24:56 2002 t
0d969553 617 // the result is necessarily a compound.
7fd59977 618 exp.Init(trP.Shape(),TopAbs_SOLID);
619 if (!exp.More()) {
4e57c75e 620 myStatusError = BRepFeat_EmptyCutResult;
621 NotDone();
622 return;
7fd59977 623 }
0d969553 624 // Only solids are preserved
7fd59977 625 theGShape.Nullify();
626 BRep_Builder B;
627 B.MakeCompound(TopoDS::Compound(theGShape));
628 for (; exp.More(); exp.Next()) {
4e57c75e 629 B.Add(theGShape,exp.Current());
7fd59977 630 }
631 if (!BRepAlgo::IsValid(theGShape)) {
4e57c75e 632 myStatusError = BRepFeat_InvShape;
633 NotDone();
634 return;
7fd59977 635 }
636 if(!mySFrom.IsNull()) {
4e57c75e 637 if(!FromInShape) {
638 TopExp_Explorer ex(mySFrom, TopAbs_FACE);
639 for(; ex.More(); ex.Next()) {
640 const TopoDS_Face& fac = TopoDS::Face(ex.Current());
7fd59977 641 TopTools_ListOfShape thelist4;
4e57c75e 642 myMap.Bind(fac,thelist4);
643 if (trP.IsDeleted(fac)) {
644 }
645 else {
646 myMap(fac) = trP.Modified(fac);
647 if (myMap(fac).IsEmpty()) myMap(fac).Append(fac);
648 }
649 }
650 }
7fd59977 651 }
652 if(!mySUntil.IsNull()) {
4e57c75e 653 if(!UntilInShape) {
654 TopExp_Explorer ex(mySUntil, TopAbs_FACE);
655 for(; ex.More(); ex.Next()) {
656 const TopoDS_Face& fac = TopoDS::Face(ex.Current());
7fd59977 657 TopTools_ListOfShape thelist5;
4e57c75e 658 myMap.Bind(fac,thelist5);
659 if (trP.IsDeleted(fac)) {
660 }
661 else {
662 myMap(fac) = trP.Modified(fac);
663 if (myMap.IsEmpty()) myMap(fac).Append(fac);
664 }
665 }
666 }
7fd59977 667 }
668 //modified by NIZNHY-PKV Thu Mar 21 17:27:23 2002 f
669 //UpdateDescendants(trP.Builder(),theGShape,Standard_True);
670 UpdateDescendants(trP,theGShape,Standard_True);
671 //modified by NIZNHY-PKV Thu Mar 21 17:27:31 2002 t
672 }//if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) {
673 //
7fd59977 674
0d969553 675//--- generation of "just feature" for assembly = Parts of tool
4e57c75e 676 Standard_Boolean bFlag = (myPerfSelection == BRepFeat_NoSelection) ? 0 : 1;
677 BRepFeat_Builder theBuilder;
678 theBuilder.Init(mySbase, theGShape);
679 theBuilder.SetOperation(myFuse, bFlag);
680 theBuilder.Perform();
681 //
682 TopTools_ListOfShape lshape;
683 theBuilder.PartsOfTool(lshape);
684 //
1d47d8d0 685 Standard_Real pbmin = RealLast(), pbmax = RealFirst();
686 Standard_Real prmin = RealLast() - 2*Precision::Confusion();
687 Standard_Real prmax = RealFirst() + 2*Precision::Confusion();
688 Standard_Boolean flag1 = Standard_False;
7fd59977 689 Handle(Geom_Curve) C;
7fd59977 690
0d969553 691//--- Selection of pieces of tool to be preserved
7fd59977 692 if(!lshape.IsEmpty() && myPerfSelection != BRepFeat_NoSelection) {
0d969553
Y
693// Find ParametricMinMax depending on the constraints of Shape From and Until
694// -> prmin, prmax, pbmin and pbmax
7fd59977 695 C = BarycCurve();
696 if (C.IsNull()) {
4e57c75e 697 myStatusError = BRepFeat_EmptyBaryCurve;
698 NotDone();
699 return;
7fd59977 700 }
701
702 if(myPerfSelection == BRepFeat_SelectionSh) {
4e57c75e 703 BRepFeat::ParametricMinMax(mySbase,C,
704 prmin, prmax, pbmin, pbmax, flag1);
7fd59977 705 }
706 else if(myPerfSelection == BRepFeat_SelectionFU) {
4e57c75e 707 Standard_Real prmin1, prmax1, prmin2, prmax2;
708 Standard_Real prbmin1, prbmax1, prbmin2, prbmax2;
7fd59977 709
4e57c75e 710 BRepFeat::ParametricMinMax(mySFrom,C,
711 prmin1, prmax1, prbmin1, prbmax1, flag1);
712 BRepFeat::ParametricMinMax(mySUntil,C,
713 prmin2, prmax2, prbmin2, prbmax2, flag1);
7fd59977 714
0d969553 715// case of revolutions
4e57c75e 716 if (C->IsPeriodic()) {
717 Standard_Real period = C->Period();
718 prmax = prmax2;
719 if (flag1) {
720 prmin = ElCLib::InPeriod(prmin1,prmax-period,prmax);
721 }
722 else {
723 prmin = Min(prmin1, prmin2);
724 }
725 pbmax = prbmax2;
726 pbmin = ElCLib::InPeriod(prbmin1,pbmax-period,pbmax);
727 }
728 else {
729 prmin = Min(prmin1, prmin2);
730 prmax = Max(prmax1, prmax2);
731 pbmin = Min(prbmin1, prbmin2);
732 pbmax = Max(prbmax1, prbmax2);
733 }
7fd59977 734 }
735 else if(myPerfSelection == BRepFeat_SelectionShU) {
4e57c75e 736 Standard_Real prmin1, prmax1, prmin2, prmax2;
737 Standard_Real prbmin1, prbmax1, prbmin2, prbmax2;
738
739 if(!myJustFeat && sens == 0) sens =1;
740 if (sens == 0) {
741 myStatusError = BRepFeat_IncDirection;
742 NotDone();
743 return;
744 }
745
746 BRepFeat::ParametricMinMax(mySUntil,C,
747 prmin1, prmax1, prbmin1, prbmax1, flag1);
748
749 BRepFeat::ParametricMinMax(mySbase,C,
750 prmin2, prmax2, prbmin2, prbmax2, flag1);
751 if (sens == 1) {
752 prmin = prmin2;
753 prmax = prmax1;
754 pbmin = prbmin2;
755 pbmax = prbmax1;
756 }
757 else if (sens == -1) {
758 prmin = prmin1;
759 prmax = prmax2;
760 pbmin = prbmin1;
761 pbmax = prbmax2;
762 }
7fd59977 763 }
764 else if (myPerfSelection == BRepFeat_SelectionU) {
4e57c75e 765 Standard_Real prmin1, prmax1, prbmin1, prbmax1;
766 if (sens == 0) {
767 myStatusError = BRepFeat_IncDirection;
768 NotDone();
769 return;
770 }
771
772 // Find parts of the tool containing descendants of Shape Until
773 BRepFeat::ParametricMinMax(mySUntil,C,
774 prmin1, prmax1, prbmin1, prbmax1, flag1);
775 if (sens == 1) {
776 prmin = RealFirst();
777 prmax = prmax1;
778 pbmin = RealFirst();
779 pbmax = prbmax1;
780 }
781 else if(sens == -1) {
782 prmin = prmin1;
783 prmax = RealLast();
784 pbmin = prbmin1;
785 pbmax = RealLast();
786 }
7fd59977 787 }
788
789
0d969553
Y
790// Finer choice of ParametricMinMax in case when the tool
791// intersects Shapes From and Until
792// case of several intersections (keep PartsOfTool according to the selection)
793// position of the face of intersection in PartsOfTool (before or after)
7fd59977 794 Standard_Real delta = Precision::Confusion();
795
796 if (myPerfSelection != BRepFeat_NoSelection) {
0d969553
Y
797// modif of the test for cts21181 : (prbmax2 and prnmin2) -> (prbmin1 and prbmax1)
798// correction take into account flag2 for pro15323 and flag3 for pro16060
4e57c75e 799 if (!mySUntil.IsNull()) {
800 TopTools_MapOfShape mapFuntil;
801 Descendants(mySUntil,theBuilder,mapFuntil);
802 if (!mapFuntil.IsEmpty()) {
803 for (it.Initialize(lshape); it.More(); it.Next()) {
804 TopExp_Explorer expf;
805 for (expf.Init(it.Value(),TopAbs_FACE);
806 expf.More(); expf.Next()) {
807 if (mapFuntil.Contains(expf.Current())) {
808 Standard_Boolean flag2,flag3;
809 Standard_Real prmin1, prmax1, prbmin1, prbmax1;
810 Standard_Real prmin2, prmax2, prbmin2, prbmax2;
811 BRepFeat::ParametricMinMax(expf.Current(),C, prmin1, prmax1,
812 prbmin1, prbmax1,flag3);
813 BRepFeat::ParametricMinMax(it.Value(),C, prmin2, prmax2,
814 prbmin2, prbmax2,flag2);
815 if (sens == 1) {
816 Standard_Boolean testOK = !flag2;
817 if (flag2) {
818 testOK = !flag1;
819 if (flag1 && prmax2 > prmin + delta) {
820 testOK = !flag3;
821 if (flag3 && prmax1 == prmax2) {
822 testOK = Standard_True;
823 }
824 }
825 }
826 if (prbmin1 < pbmax && testOK) {
827 if (flag2) {
828 flag1 = flag2;
829 prmax = prmax2;
830 }
831 pbmax = prbmin1;
832 }
833 }
834 else if (sens == -1){
835 Standard_Boolean testOK = !flag2;
836 if (flag2) {
837 testOK = !flag1;
838 if (flag1 && prmin2 < prmax - delta) {
839 testOK = !flag3;
840 if (flag3 && prmin1 == prmin2) {
841 testOK = Standard_True;
842 }
843 }
844 }
845 if (prbmax1 > pbmin && testOK) {
846 if (flag2) {
847 flag1 = flag2;
848 prmin = prmin2;
849 }
850 pbmin = prbmax1;
851 }
852 }
853 break;
854 }
855 }
856 }
857 it.Initialize(lshape);
858 }
859 }
860 if (!mySFrom.IsNull()) {
861 TopTools_MapOfShape mapFfrom;
862 Descendants(mySFrom, theBuilder, mapFfrom);
863 if (!mapFfrom.IsEmpty()) {
864 for (it.Initialize(lshape); it.More(); it.Next()) {
865 TopExp_Explorer expf;
866 for (expf.Init(it.Value(),TopAbs_FACE);
867 expf.More(); expf.Next()) {
868 if (mapFfrom.Contains(expf.Current())) {
869 Standard_Boolean flag2,flag3;
870 Standard_Real prmin1, prmax1, prbmin1, prbmax1;
871 Standard_Real prmin2, prmax2, prbmin2, prbmax2;
872 BRepFeat::ParametricMinMax(expf.Current(),C, prmin1, prmax1,
873 prbmin1, prbmax1,flag3);
874 BRepFeat::ParametricMinMax(it.Value(),C, prmin2, prmax2,
875 prbmin2, prbmax2,flag2);
876 if (sens == 1) {
877 Standard_Boolean testOK = !flag2;
878 if (flag2) {
879 testOK = !flag1;
880 if (flag1 && prmin2 < prmax - delta) {
881 testOK = !flag3;
882 if (flag3 && prmin1 == prmin2) {
883 testOK = Standard_True;
884 }
885 }
886 }
887 if (prbmax1 > pbmin && testOK) {
888 if (flag2) {
889 flag1 = flag2;
890 prmin = prmin2;
891 }
892 pbmin = prbmax1;
893 }
894 }
895 else if (sens == -1){
896 Standard_Boolean testOK = !flag2;
897 if (flag2) {
898 testOK = !flag1;
899 if (flag1 && prmax2 > prmin + delta) {
900 testOK = !flag3;
901 if (flag3 && prmax1 == prmax2) {
902 testOK = Standard_True;
903 }
904 }
905 }
906 if (prbmin1 < pbmax && testOK) {
907 if (flag2) {
908 flag1 = flag2;
909 prmax = prmax2;
910 }
911 pbmax = prbmin1;
912 }
913 }
914 break;
915 }
916 }
917 }
918 it.Initialize(lshape);
919 }
920 }
7fd59977 921 }
922
923
0d969553 924// Parse PartsOfTool to preserve or not depending on ParametricMinMax
7fd59977 925 if (!myJustFeat) {
4e57c75e 926 Standard_Boolean KeepParts = Standard_False;
927 Standard_Real prmin1, prmax1, prbmin1, prbmax1;
928 Standard_Real min, max, pmin, pmax;
929 Standard_Boolean flag2;
930 for (it.Initialize(lshape); it.More(); it.Next()) {
931 if (C->IsPeriodic()) {
932 Standard_Real period = C->Period();
933 Standard_Real pr, prb;
934 BRepFeat::ParametricMinMax(it.Value(),C, pr, prmax1,
935 prb, prbmax1,flag2,Standard_True);
936 if (flag2) {
937 prmin1 = ElCLib::InPeriod(pr,prmax1-period,prmax1);
938 }
939 else {
940 prmin1 = pr;
941 }
942 prbmin1 = ElCLib::InPeriod(prb,prbmax1-period,prbmax1);
943 }
944 else {
945 BRepFeat::ParametricMinMax(it.Value(),C,
946 prmin1, prmax1, prbmin1, prbmax1,flag2);
947 }
948 if(flag2 == Standard_False || flag1 == Standard_False) {
949 pmin = pbmin;
950 pmax = pbmax;
951 min = prbmin1;
952 max = prbmax1;
953 }
954 else {
955 pmin = prmin;
956 pmax = prmax;
957 min = prmin1;
958 max = prmax1;
959 }
960 if (!((min > pmax - delta) ||
961 (max < pmin + delta))) {
962 KeepParts = Standard_True;
963 const TopoDS_Shape& S = it.Value();
964 theBuilder.KeepPart(S);
965 }
966 }
7fd59977 967
0d969553 968// Case when no part of the tool is preserved
4e57c75e 969 if (!KeepParts) {
0797d9d3 970#ifdef OCCT_DEBUG
4e57c75e 971 if (trc) cout << " No parts of tool kept" << endl;
7fd59977 972#endif
4e57c75e 973 myStatusError = BRepFeat_NoParts;
974 NotDone();
975 return;
976 }
7fd59977 977 }
978 else {
0d969553 979// case JustFeature -> all PartsOfTool are preserved
4e57c75e 980 Standard_Real prmin1, prmax1, prbmin1, prbmax1;
981 Standard_Real min, max, pmin, pmax;
982 Standard_Boolean flag2;
983 TopoDS_Shape Compo;
984 BRep_Builder B;
985 B.MakeCompound(TopoDS::Compound(Compo));
986 for (it.Initialize(lshape); it.More(); it.Next()) {
987 BRepFeat::ParametricMinMax(it.Value(),C,
988 prmin1, prmax1, prbmin1, prbmax1,flag2);
989 if(flag2 == Standard_False || flag1 == Standard_False) {
990 pmin = pbmin;
991 pmax = pbmax;
992 min = prbmin1;
993 max = prbmax1;
994 }
995 else {
996 pmin = prmin;
997 pmax = prmax;
998 min = prmin1;
999 max = prmax1;
1000 }
1001 if ((min < pmax - delta) &&
1002 (max > pmin + delta)){
1003 if (!it.Value().IsNull()) {
1004 B.Add(Compo,it.Value());
1005 }
1006 }
1007 }
1008 myShape = Compo;
7fd59977 1009 }
1010 }
7fd59977 1011
0d969553 1012//--- Generation of result myShape
7fd59977 1013
1014 if (!myJustFeat) {
4e57c75e 1015 // removal of edges of section that have no common vertices
1016 // with PartsOfTool preserved
1017 //modified by NIZHNY-EMV Thu May 10 15:56:24 2012
1018 if (bFlag) {
1019 theBuilder.PerformResult();
1020 myShape = theBuilder.Shape();
1021 } else {
1022 myShape = theBuilder.Shape();
7fd59977 1023 }
4e57c75e 1024 //modified by NIZHNY-EMV Thu May 10 15:56:26 2012
1025 Done();
7fd59977 1026 }
1027 else {
0d969553 1028 // all is already done
7fd59977 1029 Done();
1030 }
1031 }
1032
1033 myStatusError = BRepFeat_OK;
1034}
1035
7fd59977 1036//=======================================================================
1037//function : IsDeleted
1038//purpose :
1039//=======================================================================
1040
1041Standard_Boolean BRepFeat_Form::IsDeleted(const TopoDS_Shape& F)
1042{
1043 return (myMap(F).IsEmpty());
1044}
1045
1046//=======================================================================
1047//function : Modified
1048//purpose :
1049//=======================================================================
1050
1051const TopTools_ListOfShape& BRepFeat_Form::Modified
1052 (const TopoDS_Shape& F)
1053{
1054 if (myMap.IsBound(F)) {
1055 static TopTools_ListOfShape list;
0d969553 1056 list.Clear(); // For the second passage DPF
7fd59977 1057 TopTools_ListIteratorOfListOfShape ite(myMap(F));
1058 for(; ite.More(); ite.Next()) {
1059 const TopoDS_Shape& sh = ite.Value();
1060 if(!sh.IsSame(F))
4e57c75e 1061 list.Append(sh);
7fd59977 1062 }
1063 return list;
1064 }
1065 return myGenerated; // empty list
1066}
1067
1068//=======================================================================
1069//function : Generated
1070//purpose :
1071//=======================================================================
1072
1073const TopTools_ListOfShape& BRepFeat_Form::Generated
1074 (const TopoDS_Shape& S)
1075{
1076 if (myMap.IsBound(S) &&
0d969553 1077 S.ShapeType() != TopAbs_FACE) { // check if filter on face or not
7fd59977 1078 static TopTools_ListOfShape list;
0d969553 1079 list.Clear(); // For the second passage DPF
7fd59977 1080 TopTools_ListIteratorOfListOfShape ite(myMap(S));
1081 for(; ite.More(); ite.Next()) {
1082 const TopoDS_Shape& sh = ite.Value();
1083 if(!sh.IsSame(S))
4e57c75e 1084 list.Append(sh);
7fd59977 1085 }
1086 return list;
1087 }
1088 else return myGenerated;
1089}
1090
1091
1092
1093//=======================================================================
1094//function : UpdateDescendants
1095//purpose :
1096//=======================================================================
1097
1098void BRepFeat_Form::UpdateDescendants(const LocOpe_Gluer& G)
1099{
1100 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
1101 TopTools_ListIteratorOfListOfShape it,it2;
1102 TopTools_MapIteratorOfMapOfShape itm;
1103
1104 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
1105 const TopoDS_Shape& orig = itdm.Key();
1106 TopTools_MapOfShape newdsc;
1107 for (it.Initialize(itdm.Value());it.More();it.Next()) {
1108 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
1109 for (it2.Initialize(G.DescendantFaces(fdsc));
4e57c75e 1110 it2.More();it2.Next()) {
1111 newdsc.Add(it2.Value());
7fd59977 1112 }
1113 }
1114 myMap.ChangeFind(orig).Clear();
1115 for (itm.Initialize(newdsc);itm.More();itm.Next()) {
1116 myMap.ChangeFind(orig).Append(itm.Key());
1117 }
1118 }
1119}
1120
1121
1122
1123
1124
1125//=======================================================================
1126//function : FirstShape
1127//purpose :
1128//=======================================================================
1129
1130const TopTools_ListOfShape& BRepFeat_Form::FirstShape() const
1131{
1132 if (!myFShape.IsNull()) {
1133 return myMap(myFShape);
1134 }
1135 return myGenerated; // empty list
1136}
1137
1138
1139//=======================================================================
1140//function : LastShape
1141//purpose :
1142//=======================================================================
1143
1144const TopTools_ListOfShape& BRepFeat_Form::LastShape() const
1145{
1146 if (!myLShape.IsNull()) {
1147 return myMap(myLShape);
1148 }
1149 return myGenerated; // empty list
1150}
1151
1152
1153//=======================================================================
1154//function : NewEdges
1155//purpose :
1156//=======================================================================
1157
1158const TopTools_ListOfShape& BRepFeat_Form::NewEdges() const
1159{
1160 return myNewEdges;
1161}
1162
1163
1164//=======================================================================
1165//function : NewEdges
1166//purpose :
1167//=======================================================================
1168
1169const TopTools_ListOfShape& BRepFeat_Form::TgtEdges() const
1170{
1171 return myTgtEdges;
1172}
1173
1174
1175//=======================================================================
1176//function : TransformSUntil
0d969553 1177//purpose : Limitation of the shape until the case of infinite faces
7fd59977 1178//=======================================================================
1179
1180Standard_Boolean BRepFeat_Form::TransformShapeFU(const Standard_Integer flag)
1181{
0797d9d3 1182#ifdef OCCT_DEBUG
7fd59977 1183 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1184#endif
1185 Standard_Boolean Trf = Standard_False;
1186
1187 TopoDS_Shape shapefu;
1188 if(flag == 0)
1189 shapefu = mySFrom;
1190 else if(flag == 1)
1191 shapefu = mySUntil;
1192 else
1193 return Trf;
1194
1195 TopExp_Explorer exp(shapefu, TopAbs_FACE);
0d969553 1196 if (!exp.More()) { // no faces... It is necessary to return an error
0797d9d3 1197#ifdef OCCT_DEBUG
7fd59977 1198 if (trc) cout << " BRepFeat_Form::TransformShapeFU : invalid Shape" << endl;
1199#endif
1200 return Trf;
1201 }
1202
1203 exp.Next();
0d969553 1204 if (!exp.More()) { // the only face. Is it infinite?
7fd59977 1205 exp.ReInit();
1206 TopoDS_Face fac = TopoDS::Face(exp.Current());
1207
1208 Handle(Geom_Surface) S = BRep_Tool::Surface(fac);
1209 Handle(Standard_Type) styp = S->DynamicType();
1210 if (styp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1211 S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
1212 styp = S->DynamicType();
1213 }
1214
1215 if (styp == STANDARD_TYPE(Geom_Plane) ||
4e57c75e 1216 styp == STANDARD_TYPE(Geom_CylindricalSurface) ||
1217 styp == STANDARD_TYPE(Geom_ConicalSurface)) {
7fd59977 1218 TopExp_Explorer exp1(fac, TopAbs_WIRE);
1219 if (!exp1.More()) {
4e57c75e 1220 Trf = Standard_True;
7fd59977 1221 }
1222 else {
4e57c75e 1223 Trf = BRep_Tool::NaturalRestriction(fac);
7fd59977 1224 }
1225
1226 }
1227 if (Trf) {
1228 BRepFeat::FaceUntil(mySbase, fac);
1229 }
1230
1231 if(flag == 0) {
1232 TopTools_ListOfShape thelist6;
1233 myMap.Bind(mySFrom,thelist6);
1234 myMap(mySFrom).Append(fac);
1235 mySFrom = fac;
1236 }
1237 else if(flag == 1) {
1238 TopTools_ListOfShape thelist7;
1239 myMap.Bind(mySUntil,thelist7);
1240 myMap(mySUntil).Append(fac);
1241 mySUntil = fac;
1242 }
1243 else {
1244 }
1245 }
1246 else {
1247 for (exp.ReInit(); exp.More(); exp.Next()) {
1248 const TopoDS_Shape& fac = exp.Current();
1249 TopTools_ListOfShape thelist8;
1250 myMap.Bind(fac,thelist8);
1251 myMap(fac).Append(fac);
1252 }
1253 }
0797d9d3 1254#ifdef OCCT_DEBUG
7fd59977 1255 if (trc) {
1256 if (Trf && (flag == 0)) cout << " TransformShapeFU From" << endl;
1257 if (Trf && (flag == 1)) cout << " TransformShapeFU Until" << endl;
1258 }
1259#endif
1260 return Trf;
1261}
1262
1263
1264//=======================================================================
1265//function : CurrentStatusError
1266//purpose :
1267//=======================================================================
1268
1269BRepFeat_StatusError BRepFeat_Form::CurrentStatusError() const
1270{
1271 return myStatusError;
1272}
1273
7fd59977 1274//=======================================================================
1275//function : Descendants
1276//purpose :
1277//=======================================================================
1278
1279static void Descendants(const TopoDS_Shape& S,
4e57c75e 1280 BRepFeat_Builder& theFB,
1281 TopTools_MapOfShape& mapF)
7fd59977 1282{
1283 mapF.Clear();
7fd59977 1284 TopTools_ListIteratorOfListOfShape it;
1285 TopExp_Explorer exp;
1286 for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) {
1287
1288 const TopoDS_Face& fdsc = TopoDS::Face(exp.Current());
4e57c75e 1289 const TopTools_ListOfShape& aLM=theFB.Modified(fdsc);
7fd59977 1290 it.Initialize(aLM);
1291 for (; it.More(); it.Next()) {
1292 mapF.Add(it.Value());
1293 }
1294
1295 }
1296}
1297
1298//=======================================================================
1299//function : UpdateDescendants
1300//purpose :
1301//=======================================================================
1302 void BRepFeat_Form::UpdateDescendants(const Handle(TopOpeBRepBuild_HBuilder)& B,
4e57c75e 1303 const TopoDS_Shape& S,
1304 const Standard_Boolean SkipFace)
7fd59977 1305{
1306 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
1307 TopTools_ListIteratorOfListOfShape it,it2;
1308 TopTools_MapIteratorOfMapOfShape itm;
1309 TopExp_Explorer exp;
1310
1311 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
1312 const TopoDS_Shape& orig = itdm.Key();
1313 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
1314 continue;
1315 }
1316 TopTools_MapOfShape newdsc;
1317
1318 if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);}
1319
1320 for (it.Initialize(itdm.Value());it.More();it.Next()) {
1321 const TopoDS_Shape& sh = it.Value();
1322 if(sh.ShapeType() != TopAbs_FACE) continue;
1323 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
1324 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
4e57c75e 1325 if (exp.Current().IsSame(fdsc)) { // preserved
1326 newdsc.Add(fdsc);
1327 break;
1328 }
7fd59977 1329 }
1330 if (!exp.More()) {
4e57c75e 1331 if (B->IsSplit(fdsc, TopAbs_OUT)) {
1332 for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT));
1333 it2.More();it2.Next()) {
1334 newdsc.Add(it2.Value());
1335 }
1336 }
1337 if (B->IsSplit(fdsc, TopAbs_IN)) {
1338 for (it2.Initialize(B->Splits(fdsc,TopAbs_IN));
1339 it2.More();it2.Next()) {
1340 newdsc.Add(it2.Value());
1341 }
1342 }
1343 if (B->IsSplit(fdsc, TopAbs_ON)) {
1344 for (it2.Initialize(B->Splits(fdsc,TopAbs_ON));
1345 it2.More();it2.Next()) {
1346 newdsc.Add(it2.Value());
1347 }
1348 }
1349 if (B->IsMerged(fdsc, TopAbs_OUT)) {
1350 for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT));
1351 it2.More();it2.Next()) {
1352 newdsc.Add(it2.Value());
1353 }
1354 }
1355 if (B->IsMerged(fdsc, TopAbs_IN)) {
1356 for (it2.Initialize(B->Merged(fdsc,TopAbs_IN));
1357 it2.More();it2.Next()) {
1358 newdsc.Add(it2.Value());
1359 }
1360 }
1361 if (B->IsMerged(fdsc, TopAbs_ON)) {
1362 for (it2.Initialize(B->Merged(fdsc,TopAbs_ON));
1363 it2.More();it2.Next()) {
1364 newdsc.Add(it2.Value());
1365 }
1366 }
7fd59977 1367 }
1368 }
1369 myMap.ChangeFind(orig).Clear();
1370 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
0d969553 1371 // check the appartenance to the shape...
7fd59977 1372 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
4e57c75e 1373 if (exp.Current().IsSame(itm.Key())) {
1374// const TopoDS_Shape& sh = itm.Key();
1375 myMap.ChangeFind(orig).Append(itm.Key());
1376 break;
1377 }
7fd59977 1378 }
1379 }
1380 }
1381}
1382//modified by NIZNHY-PKV Thu Mar 21 18:43:18 2002 f
1383//=======================================================================
1384//function : UpdateDescendants
1385//purpose :
1386//=======================================================================
1387 void BRepFeat_Form::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP,
4e57c75e 1388 const TopoDS_Shape& S,
1389 const Standard_Boolean SkipFace)
7fd59977 1390{
1391 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm;
1392 TopTools_ListIteratorOfListOfShape it,it2;
1393 TopTools_MapIteratorOfMapOfShape itm;
1394 TopExp_Explorer exp;
1395
1396 for (itdm.Initialize(myMap);itdm.More();itdm.Next()) {
1397 const TopoDS_Shape& orig = itdm.Key();
1398 if (SkipFace && orig.ShapeType() == TopAbs_FACE) {
1399 continue;
1400 }
1401 TopTools_MapOfShape newdsc;
1402
1403 if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);}
1404
1405 for (it.Initialize(itdm.Value());it.More();it.Next()) {
1406 const TopoDS_Shape& sh = it.Value();
1407 if(sh.ShapeType() != TopAbs_FACE) continue;
1408 const TopoDS_Face& fdsc = TopoDS::Face(it.Value());
1409 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
4e57c75e 1410 if (exp.Current().IsSame(fdsc)) { // preserved
1411 newdsc.Add(fdsc);
1412 break;
1413 }
7fd59977 1414 }
1415 if (!exp.More()) {
4e57c75e 1416 BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP;
1417 const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc);
1418 it2.Initialize(aLM);
1419 for (; it2.More(); it2.Next()) {
1420 const TopoDS_Shape& aS=it2.Value();
1421 newdsc.Add(aS);
1422 }
1423
7fd59977 1424 }
1425 }
1426 myMap.ChangeFind(orig).Clear();
1427 for (itm.Initialize(newdsc); itm.More(); itm.Next()) {
0d969553 1428 // check the appartenance to the shape...
7fd59977 1429 for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
4e57c75e 1430 if (exp.Current().IsSame(itm.Key())) {
1431// const TopoDS_Shape& sh = itm.Key();
1432 myMap.ChangeFind(orig).Append(itm.Key());
1433 break;
1434 }
7fd59977 1435 }
1436 }
1437 }
1438}
1439//modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t