0024933: Inconsistent results of self-interferences checker in SALOME and DRAW Applic...
[occt.git] / src / BOPAlgo / BOPAlgo_ArgumentAnalyzer.cxx
CommitLineData
4e57c75e 1// Created on: 2004-09-02
973c2be1 2// Copyright (c) 2004-2014 OPEN CASCADE SAS
4e57c75e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
4e57c75e 5//
d5f74e42 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
973c2be1 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.
4e57c75e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
4e57c75e 14
15#include <BOPAlgo_ArgumentAnalyzer.ixx>
16
17#include <Standard_ErrorHandler.hxx>
18#include <Standard_Failure.hxx>
63def8e6 19
20#include <TColStd_Array2OfBoolean.hxx>
21
4e57c75e 22#include <gp_Pnt.hxx>
63def8e6 23
24#include <Geom_Surface.hxx>
25
4e57c75e 26#include <TopoDS_Iterator.hxx>
27#include <TopoDS.hxx>
28#include <TopoDS_Vertex.hxx>
29#include <TopoDS_Edge.hxx>
30#include <TopoDS_Wire.hxx>
31#include <TopoDS_Shell.hxx>
32#include <TopoDS_Solid.hxx>
63def8e6 33
34#include <BRep_Builder.hxx>
35#include <BRep_Tool.hxx>
36
37#include <TopExp.hxx>
38#include <TopExp_Explorer.hxx>
39
40#include <BRepExtrema_DistShapeShape.hxx>
41//
4e57c75e 42#include <BOPCol_ListOfShape.hxx>
43#include <BOPCol_SequenceOfShape.hxx>
44#include <BOPCol_MapOfShape.hxx>
45
4e57c75e 46#include <IntTools_Range.hxx>
47#include <IntTools_EdgeEdge.hxx>
48#include <IntTools_CommonPrt.hxx>
49
4e57c75e 50#include <BOPInt_Context.hxx>
51
52#include <BOPTools_AlgoTools3D.hxx>
53#include <BOPTools_AlgoTools.hxx>
63def8e6 54
55#include <BOPDS_DS.hxx>
56#include <BOPDS_MapOfPassKey.hxx>
57
58#include <BOPAlgo_Operation.hxx>
59#include <BOPAlgo_CheckerSI.hxx>
60#include <BOPAlgo_BuilderFace.hxx>
4e57c75e 61
62// ================================================================================
63// function: Constructor
64// purpose:
65// ================================================================================
66BOPAlgo_ArgumentAnalyzer::BOPAlgo_ArgumentAnalyzer() :
67myStopOnFirst(Standard_False),
68myOperation(BOPAlgo_UNKNOWN),
69myArgumentTypeMode(Standard_False),
70mySelfInterMode(Standard_False),
71mySmallEdgeMode(Standard_False),
72myRebuildFaceMode(Standard_False),
73myTangentMode(Standard_False),
74myMergeVertexMode(Standard_False),
75myMergeEdgeMode(Standard_False),
0e09ee8e 76myContinuityMode(Standard_False),
4e57c75e 77myEmpty1(Standard_False),
78myEmpty2(Standard_False)
79// myMergeFaceMode(Standard_False)
80{
81}
82
83// ================================================================================
84// function: SetShape1
85// purpose:
86// ================================================================================
87void BOPAlgo_ArgumentAnalyzer::SetShape1(const TopoDS_Shape & TheShape)
88{
89 myShape1 = TheShape;
90}
91
92// ================================================================================
93// function: SetShape2
94// purpose:
95// ================================================================================
96void BOPAlgo_ArgumentAnalyzer::SetShape2(const TopoDS_Shape & TheShape)
97{
98 myShape2 = TheShape;
99}
100
101// ================================================================================
102// function: GetShape1
103// purpose:
104// ================================================================================
105const TopoDS_Shape & BOPAlgo_ArgumentAnalyzer::GetShape1() const
106{
107 return myShape1;
108}
109
110// ================================================================================
111// function: GetShape2
112// purpose:
113// ================================================================================
114const TopoDS_Shape & BOPAlgo_ArgumentAnalyzer::GetShape2() const
115{
116 return myShape2;
117}
118
119// ================================================================================
120// function: OperationType
121// purpose:
122// ================================================================================
123BOPAlgo_Operation& BOPAlgo_ArgumentAnalyzer::OperationType()
124{
125 return myOperation;
126}
127
128// ================================================================================
129// function: StopOnFirstFaulty
130// purpose:
131// ================================================================================
132Standard_Boolean & BOPAlgo_ArgumentAnalyzer::StopOnFirstFaulty()
133{
134 return myStopOnFirst;
135}
136
137// ================================================================================
138// function: Prepare
139// purpose:
140// ================================================================================
141void BOPAlgo_ArgumentAnalyzer::Prepare()
142{
143 Standard_Boolean isS1 = myShape1.IsNull(), isS2 = myShape2.IsNull();
144 if (!isS1) {
145 myEmpty1 = BOPTools_AlgoTools3D::IsEmptyShape(myShape1);
146 }
147 if (!isS2) {
148 myEmpty2 = BOPTools_AlgoTools3D::IsEmptyShape(myShape2);
149 }
150}
151// ================================================================================
152// function: Perform
153// purpose:
154// ================================================================================
155void BOPAlgo_ArgumentAnalyzer::Perform()
156{
157 try {
158 OCC_CATCH_SIGNALS
159 myResult.Clear();
160
161 Prepare();
162
163 if(myArgumentTypeMode) {
164 TestTypes();
165 }
166
167 if(mySelfInterMode) {
168 TestSelfInterferences();
169 }
170
171 if(mySmallEdgeMode) {
172 if(!(!myResult.IsEmpty() && myStopOnFirst))
173 TestSmallEdge();
174 }
175
176 if(myRebuildFaceMode) {
177 if(!(!myResult.IsEmpty() && myStopOnFirst))
178 TestRebuildFace();
179 }
180
181 if(myTangentMode) {
182 if(!(!myResult.IsEmpty() && myStopOnFirst))
183 TestTangent();
184 }
185
186 if(myMergeVertexMode) {
187 if(!(!myResult.IsEmpty() && myStopOnFirst))
188 TestMergeVertex();
189 }
190
191 if(myMergeEdgeMode) {
192 if(!(!myResult.IsEmpty() && myStopOnFirst))
193 TestMergeEdge();
194 }
0e09ee8e 195
196 if(myContinuityMode) {
197 if(!(!myResult.IsEmpty() && myStopOnFirst))
198 TestContinuity();
199 }
4e57c75e 200 }
201 catch(Standard_Failure) {
202 BOPAlgo_CheckResult aResult;
203 aResult.SetCheckStatus(BOPAlgo_CheckUnknown);
204 myResult.Append(aResult);
205 }
206}
207
208// ================================================================================
209// function: HasFaulty
210// purpose:
211// ================================================================================
212Standard_Boolean BOPAlgo_ArgumentAnalyzer::HasFaulty() const
213{
214 return ( !myResult.IsEmpty());
215}
216
217// ================================================================================
218// function: GetCheckResult
219// purpose:
220// ================================================================================
221const BOPAlgo_ListOfCheckResult& BOPAlgo_ArgumentAnalyzer::GetCheckResult() const
222{
223 return myResult;
224}
225
226// ================================================================================
227// function: TestTypes
228// purpose:
229// ================================================================================
230void BOPAlgo_ArgumentAnalyzer::TestTypes()
231{
232 Standard_Boolean isS1 = myShape1.IsNull(), isS2 = myShape2.IsNull();
233
234 if(isS1 && isS2) {
235 BOPAlgo_CheckResult aResult;
236 aResult.SetCheckStatus(BOPAlgo_BadType);
237 myResult.Append(aResult);
238 return;
239 }
240
241 //single shape check
242 if((isS1 && !isS2) || (!isS1 && isS2)) {
243 Standard_Boolean bIsEmpty = (isS1) ? myEmpty2 : myEmpty1;
244
245 if(bIsEmpty || myOperation!=BOPAlgo_UNKNOWN) {
246 const TopoDS_Shape & aS = (isS1) ? myShape2 : myShape1;
247 BOPAlgo_CheckResult aResult;
248 aResult.SetShape1(aS);
249 aResult.SetCheckStatus(BOPAlgo_BadType);
250 myResult.Append(aResult);
251 return;
252 }
253 }
254 // two shapes check (begin)
255 else {
256 if(myEmpty1 || myEmpty2) {
257 BOPAlgo_CheckResult aResult;
258 if(myEmpty1 && myEmpty2) {
259 aResult.SetShape1(myShape1);
260 aResult.SetShape2(myShape2);
261 }
262 else {
263 const TopoDS_Shape & aS = myEmpty1 ? myShape1 : myShape2;
264 if(myEmpty1)
265 aResult.SetShape1(aS);
266 else
267 aResult.SetShape2(aS);
268 }
269 aResult.SetCheckStatus(BOPAlgo_BadType);
270 myResult.Append(aResult);
271 return;
272 }
273 //
274 Standard_Integer aDim1, aDim2;
275 Standard_Boolean bBadTypes = Standard_False;
276 //
277 aDim1 = BOPTools_AlgoTools::Dimension(myShape1);
278 aDim2 = BOPTools_AlgoTools::Dimension(myShape2);
279 if (aDim1 < aDim2) {
280 if (myOperation == BOPAlgo_FUSE ||
281 myOperation == BOPAlgo_CUT21) {
282 bBadTypes = Standard_True;
283 }
284 }
285 else if (aDim1 > aDim2) {
286 if (myOperation == BOPAlgo_FUSE ||
287 myOperation == BOPAlgo_CUT) {
288 bBadTypes = Standard_True;
289 }
290 }
291 if (bBadTypes) {
292 BOPAlgo_CheckResult aResult;
293 aResult.SetShape1(myShape1);
294 aResult.SetShape2(myShape2);
295 aResult.SetCheckStatus(BOPAlgo_BadType);
296 myResult.Append(aResult);
297 }
298 }
299}
ceaa5e27 300//=======================================================================
301//function : TestSelfInterferences
302//purpose :
303//=======================================================================
4e57c75e 304void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
305{
63def8e6 306 Standard_Integer ii;
307 //
4e57c75e 308 for(ii = 0; ii < 2; ii++) {
9d1c5188 309 const TopoDS_Shape& aS = (ii == 0) ? myShape1 : myShape2;
ceaa5e27 310 if(aS.IsNull()) {
4e57c75e 311 continue;
ceaa5e27 312 }
63def8e6 313 //
4e57c75e 314 Standard_Boolean bIsEmpty = (ii == 0) ? myEmpty1 : myEmpty2;
315 if (bIsEmpty) {
316 continue;
317 }
63def8e6 318 //
319 Standard_Integer iErr, n1, n2;
320 BOPDS_MapIteratorMapOfPassKey aItMPK;
4e57c75e 321 BOPCol_ListOfShape anArgs;
63def8e6 322 BOPAlgo_CheckerSI aChecker;
ceaa5e27 323 //
4e57c75e 324 anArgs.Append(aS);
325 aChecker.SetArguments(anArgs);
326 //
327 aChecker.Perform();
63def8e6 328 iErr=aChecker.ErrorStatus();
4e57c75e 329 //
63def8e6 330 const BOPDS_DS& aDS=*(aChecker.PDS());
331 const BOPDS_MapOfPassKey& aMPK=aDS.Interferences();
80db5701 332 //
63def8e6 333 aItMPK.Initialize(aMPK);
334 for (; aItMPK.More(); aItMPK.Next()) {
335 const BOPDS_PassKey& aPK=aItMPK.Value();
336 aPK.Ids(n1, n2);
337 if(aDS.IsNewShape(n1) || aDS.IsNewShape(n2)) {
338 continue;
339 }
340 //
341 const TopoDS_Shape& aS1=aDS.Shape(n1);
342 const TopoDS_Shape& aS2=aDS.Shape(n2);
343 //
344 BOPAlgo_CheckResult aResult;
345 if(ii == 0) {
346 aResult.SetShape1(myShape1);
347 aResult.AddFaultyShape1(aS1);
348 aResult.AddFaultyShape1(aS2);
4e57c75e 349 }
63def8e6 350 else {
351 aResult.SetShape2(myShape2);
352 aResult.AddFaultyShape2(aS1);
353 aResult.AddFaultyShape2(aS2);
354 }
355 aResult.SetCheckStatus(BOPAlgo_SelfIntersect);
356 myResult.Append(aResult);
4e57c75e 357 }
ceaa5e27 358 //
4e57c75e 359 if (iErr) {
360 BOPAlgo_CheckResult aResult;
4e57c75e 361 if(ii == 0) {
0e09ee8e 362 aResult.SetShape1(myShape1);
4e57c75e 363 aResult.AddFaultyShape1(myShape1);
364 }
365 else {
0e09ee8e 366 aResult.SetShape2(myShape2);
4e57c75e 367 aResult.AddFaultyShape2(myShape2);
368 }
369 aResult.SetCheckStatus(BOPAlgo_OperationAborted);
370 myResult.Append(aResult);
371 }
63def8e6 372 }// for(ii = 0; ii < 2; ii++) {
4e57c75e 373}
4e57c75e 374// ================================================================================
375// function: TestSmallEdge
376// purpose:
377// ================================================================================
378void BOPAlgo_ArgumentAnalyzer::TestSmallEdge()
379{
380 Standard_Integer i = 0;
381 BRepExtrema_DistShapeShape aDist;
382 Handle(BOPInt_Context) aCtx;
383 //
384 aCtx = new BOPInt_Context;
385
386 for(i = 0; i < 2; i++) {
9d1c5188 387 const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2;
4e57c75e 388
389 if(aS.IsNull())
390 continue;
391
392 TopExp_Explorer anExp(aS, TopAbs_EDGE);
393
394 for(; anExp.More(); anExp.Next()) {
9d1c5188 395 const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&anExp.Current();
396 if (BRep_Tool::Degenerated(anEdge)) {
397 continue;
398 }
4e57c75e 399
400 if(BOPTools_AlgoTools::IsMicroEdge(anEdge, aCtx)) {
401 Standard_Boolean bKeepResult = Standard_True;
402
403 if(myOperation == BOPAlgo_SECTION) {
9d1c5188 404 const TopoDS_Shape& anOtherS = (i == 0) ? myShape2 : myShape1;
4e57c75e 405
406 if(!anOtherS.IsNull()) {
407 aDist.LoadS2(anOtherS);
408
409 Standard_Boolean bVertexIsOnShape = Standard_False;
410 Standard_Integer ii = 0;
411 TopExp_Explorer anExpV(anEdge, TopAbs_VERTEX);
412
413 for(; anExpV.More(); anExpV.Next()) {
9d1c5188 414 const TopoDS_Shape& aV = anExpV.Current();
4e57c75e 415
416 aDist.LoadS1(aV);
417 aDist.Perform();
418
419 if(aDist.IsDone()) {
420
421 for(ii = 1; ii <= aDist.NbSolution(); ii++) {
9d1c5188 422 Standard_Real aTolerance = BRep_Tool::Tolerance(*(TopoDS_Vertex*)&aV);
423 const TopoDS_Shape& aSupportShape = aDist.SupportOnShape2(ii);
4e57c75e 424
425 switch(aSupportShape.ShapeType()) {
426 case TopAbs_VERTEX: {
9d1c5188 427 aTolerance += BRep_Tool::Tolerance(*(TopoDS_Vertex*)&(aSupportShape));
4e57c75e 428 break;
429 }
430 case TopAbs_EDGE: {
9d1c5188 431 aTolerance += BRep_Tool::Tolerance(*(TopoDS_Edge*)&(aSupportShape));
4e57c75e 432 break;
433 }
434 case TopAbs_FACE: {
9d1c5188 435 aTolerance += BRep_Tool::Tolerance(*(TopoDS_Face*)&(aSupportShape));
4e57c75e 436 break;
437 }
438 default:
439 break;
440 }
441
442 if(aDist.Value() < aTolerance) {
443 bVertexIsOnShape = Standard_True;
444 break;
445 }
446 }
447 }
448 }
449
450 if(!bVertexIsOnShape) {
451 bKeepResult = Standard_False;
452 }
453 }
454 }
455
456 if(bKeepResult) {
457 BOPAlgo_CheckResult aResult;
458
459 if(i == 0) {
460 aResult.SetShape1(myShape1);
461 aResult.AddFaultyShape1(anEdge);
462 }
463 else {
464 aResult.SetShape2(myShape2);
465 aResult.AddFaultyShape2(anEdge);
466 }
467
468 aResult.SetCheckStatus(BOPAlgo_TooSmallEdge);
469 myResult.Append(aResult);
470
471 if(myStopOnFirst) {
472 return;
473 }
474 }
475 }
476 }
477 }
478}
4e57c75e 479// ================================================================================
480// function: TestRebuildFace
481// purpose:
482// ================================================================================
483void BOPAlgo_ArgumentAnalyzer::TestRebuildFace()
484{
485 if((myOperation == BOPAlgo_SECTION) ||
486 (myOperation == BOPAlgo_UNKNOWN))
487 return;
488 Standard_Integer i = 0;
489
490 for(i = 0; i < 2; i++) {
9d1c5188 491 const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2;
4e57c75e 492
493 if(aS.IsNull())
494 continue;
495
496 TopExp_Explorer anExp(aS, TopAbs_FACE);
497 BOPCol_ListOfShape aLS;
498
499 for(; anExp.More(); anExp.Next()) {
9d1c5188 500 const TopoDS_Face& aFace = *(TopoDS_Face*)&(anExp.Current());
4e57c75e 501
502 TopoDS_Face aFF = aFace;
503 aFF.Orientation(TopAbs_FORWARD);
504 TopExp_Explorer anExpE(aFF, TopAbs_EDGE);
505 Standard_Integer nbstartedges = 0;
506 aLS.Clear();
507 //
508 for(; anExpE.More(); anExpE.Next()) {
509 const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&anExpE.Current()));
510 TopAbs_Orientation anOriE=aE.Orientation();
511 //
512 if (anOriE==TopAbs_INTERNAL) {
513 TopoDS_Edge aEE=aE;
514 aEE.Orientation(TopAbs_FORWARD);
515 aLS.Append(aEE);
516 aEE.Orientation(TopAbs_REVERSED);
517 aLS.Append(aEE);
518 }
519 else {
520 aLS.Append(aE);
521 }
522 nbstartedges++;
523 }
524 BOPAlgo_BuilderFace aBF;
525 aBF.SetFace(aFace);
526 aBF.SetShapes(aLS);
527 aBF.Perform();
528 const BOPCol_ListOfShape& aLF = aBF.Areas();
529 Standard_Boolean bBadFace = Standard_False;
530
531 if(aLF.Extent() != 1) {
532 bBadFace = Standard_True;
533 }
534 else {
535 Standard_Integer nbedgeused = 0;
536 anExpE.Init(aLF.First(), TopAbs_EDGE);
537
538 for(; anExpE.More(); anExpE.Next(), nbedgeused++);
539
540 if(nbstartedges != nbedgeused) {
541 bBadFace = Standard_True;
542 }
543 }
544
545 if(bBadFace) {
546 BOPAlgo_CheckResult aResult;
547
548 if(i == 0) {
549 aResult.SetShape1(myShape1);
550 aResult.AddFaultyShape1(aFace);
551 }
552 else {
553 aResult.SetShape2(myShape2);
554 aResult.AddFaultyShape2(aFace);
555 }
556
557 aResult.SetCheckStatus(BOPAlgo_NonRecoverableFace);
558 myResult.Append(aResult);
559
560 if(myStopOnFirst) {
561 return;
562 }
563 }
564 }
565 }
566}
567
568// ================================================================================
569// function: TestTangent
570// purpose:
571// ================================================================================
572void BOPAlgo_ArgumentAnalyzer::TestTangent()
573{
574 // not implemented
575}
576
577// ================================================================================
578// function: TestMergeSubShapes
579// purpose:
580// ================================================================================
581 void BOPAlgo_ArgumentAnalyzer::TestMergeSubShapes(const TopAbs_ShapeEnum theType)
582{
583 if(myShape1.IsNull() || myShape2.IsNull())
584 return;
585
586 if (myEmpty1 || myEmpty2)
587 return;
588
589 BOPAlgo_CheckStatus aStatus = BOPAlgo_CheckUnknown;
590
591 switch(theType) {
592 case TopAbs_VERTEX: {
593 aStatus = BOPAlgo_IncompatibilityOfVertex;
594 break;
595 }
596 case TopAbs_EDGE: {
597 aStatus = BOPAlgo_IncompatibilityOfEdge;
598 break;
599 }
600 case TopAbs_FACE: {
601 aStatus = BOPAlgo_IncompatibilityOfFace;
602 break;
603 }
604 default:
605 return;
606 }
607 TopExp_Explorer anExp1(myShape1, theType);
608 TopExp_Explorer anExp2(myShape2, theType);
609 BOPCol_SequenceOfShape aSeq1, aSeq2;
610 BOPCol_MapOfShape aMap1, aMap2;
611
612 for(; anExp1.More(); anExp1.Next()) {
9d1c5188 613 const TopoDS_Shape& aS1 = anExp1.Current();
4e57c75e 614
615 if(aMap1.Contains(aS1))
616 continue;
617 aSeq1.Append(aS1);
618 aMap1.Add(aS1);
619 }
620
621 for(; anExp2.More(); anExp2.Next()) {
9d1c5188 622 const TopoDS_Shape& aS2 = anExp2.Current();
4e57c75e 623 if(aMap2.Contains(aS2))
624 continue;
625 aSeq2.Append(aS2);
626 aMap2.Add(aS2);
627 }
628
629 TColStd_Array2OfBoolean anArrayOfFlag(1, aSeq1.Length(), 1, aSeq2.Length());
630 Standard_Integer i = 0, j = 0;
631 for(i = 1; i <= aSeq1.Length(); i++)
632 for(j = 1; j <= aSeq2.Length(); j++)
633 anArrayOfFlag.SetValue(i, j, Standard_False);
634
635 for(i = 1; i <= aSeq1.Length(); i++) {
9d1c5188 636 const TopoDS_Shape& aS1 = aSeq1.Value(i);
4e57c75e 637 BOPCol_ListOfShape aListOfS2;
638 Standard_Integer nbs = 0;
639
640 for(j = 1; j <= aSeq2.Length(); j++) {
9d1c5188 641 const TopoDS_Shape& aS2 = aSeq2.Value(j);
4e57c75e 642 Standard_Boolean bIsEqual = Standard_False;
643
644 if(theType == TopAbs_VERTEX) {
645
9d1c5188 646 const TopoDS_Vertex& aV1 = *(TopoDS_Vertex*)&(aS1);
647 const TopoDS_Vertex& aV2 = *(TopoDS_Vertex*)&(aS2);
4e57c75e 648 gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
649 gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
650 Standard_Real aDist = aP1.Distance(aP2);
651
652 if(aDist <= (BRep_Tool::Tolerance(aV1) + BRep_Tool::Tolerance(aV2))) {
653 bIsEqual = Standard_True;
654 }
655 }
656 else if(theType == TopAbs_EDGE) {
9d1c5188 657 const TopoDS_Edge& aE1 = *(TopoDS_Edge*)&(aS1);
658 const TopoDS_Edge& aE2 = *(TopoDS_Edge*)&(aS2);
ec0cdc0e 659 //
660 IntTools_EdgeEdge aEE(aE1, aE2);
661 //
4e57c75e 662 aEE.Perform();
4e57c75e 663 if (aEE.IsDone()) {
664 const IntTools_SequenceOfCommonPrts& aCPrts = aEE.CommonParts();
665 Standard_Integer ii = 0;
666
667 for (ii = 1; ii <= aCPrts.Length(); ii++) {
668 const IntTools_CommonPrt& aCPart = aCPrts(ii);
669
670 if (aCPart.Type() == TopAbs_EDGE) {
671 bIsEqual = Standard_True;
672 }
673 }
674 }
675 }
676 else if(theType == TopAbs_FACE) {
677 // not yet implemented!
678 }
679
680 if(bIsEqual) {
681 anArrayOfFlag.SetValue(i, j, Standard_True );
682 aListOfS2.Append(aS2);
683 nbs++;
684 }
685 }
686
687 if(nbs > 1) {
688 BOPAlgo_CheckResult aResult;
689
690 aResult.SetShape1(myShape1);
691 aResult.SetShape2(myShape2);
692 aResult.AddFaultyShape1(aS1);
693 BOPCol_ListIteratorOfListOfShape anIt(aListOfS2);
694
695 for(; anIt.More(); anIt.Next()) {
696 aResult.AddFaultyShape2(anIt.Value());
697 }
698
699 aResult.SetCheckStatus(aStatus);
700 myResult.Append(aResult);
701
702 if(myStopOnFirst) {
703 return;
704 }
705 }
706 }
707
708 for(i = 1; i <= aSeq2.Length(); i++) {
9d1c5188 709 const TopoDS_Shape& aS2 = aSeq2.Value(i);
4e57c75e 710 BOPCol_ListOfShape aListOfS1;
711 Standard_Integer nbs = 0;
712
713 for(j = 1; j <= aSeq1.Length(); j++) {
9d1c5188 714 const TopoDS_Shape& aS1 = aSeq1.Value(j);
4e57c75e 715
716 if(anArrayOfFlag.Value(j, i)) {
717 aListOfS1.Append(aS1);
718 nbs++;
719 }
720 }
721
722 if(nbs > 1) {
723 BOPAlgo_CheckResult aResult;
724
725 aResult.SetShape1(myShape1);
726 aResult.SetShape2(myShape2);
727 BOPCol_ListIteratorOfListOfShape anIt(aListOfS1);
728
729 for(; anIt.More(); anIt.Next()) {
730 aResult.AddFaultyShape1(anIt.Value());
731 }
732 aResult.AddFaultyShape2(aS2);
733
734 aResult.SetCheckStatus(aStatus);
735 myResult.Append(aResult);
736
737 if(myStopOnFirst) {
738 return;
739 }
740 }
741 }
742}
743
744// ================================================================================
745// function: TestMergeVertex
746// purpose:
747// ================================================================================
748void BOPAlgo_ArgumentAnalyzer::TestMergeVertex()
749{
750 TestMergeSubShapes(TopAbs_VERTEX);
751}
752
753// ================================================================================
754// function: TestMergeEdge
755// purpose:
756// ================================================================================
757void BOPAlgo_ArgumentAnalyzer::TestMergeEdge()
758{
759 TestMergeSubShapes(TopAbs_EDGE);
760}
761
762// ================================================================================
0e09ee8e 763// function: TestContinuity
764// purpose:
765// ================================================================================
766void BOPAlgo_ArgumentAnalyzer::TestContinuity()
767{
768 Standard_Integer i;
769 Standard_Real f, l;
770 TopExp_Explorer aExp;
771 BOPCol_MapIteratorOfMapOfShape aIt;
772 //
773 for (i = 0; i < 2; ++i) {
774 const TopoDS_Shape& aS = !i ? myShape1 : myShape2;
775 if(aS.IsNull()) {
776 continue;
777 }
778 //
779 BOPCol_MapOfShape aMS;
780 //Edges
781 aExp.Init(aS, TopAbs_EDGE);
782 for (; aExp.More(); aExp.Next()) {
783 const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current();
784 if (BRep_Tool::Degenerated(aE)) {
785 continue;
786 }
787 const Handle(Geom_Curve)& aC = BRep_Tool::Curve(aE, f, l);
788 if (aC->Continuity() == GeomAbs_C0) {
789 aMS.Add(aE);
790 }
791 }
792 //Faces
793 aExp.Init(aS, TopAbs_FACE);
794 for (; aExp.More(); aExp.Next()) {
795 const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current();
796 const Handle(Geom_Surface)& aS = BRep_Tool::Surface(aF);
797 if (aS->Continuity() == GeomAbs_C0) {
798 aMS.Add(aF);
799 }
800 }
801 //
802 //add shapes with continuity C0 to result
803 aIt.Initialize(aMS);
804 for (; aIt.More(); aIt.Next()) {
805 const TopoDS_Shape& aFS = aIt.Value();
806 BOPAlgo_CheckResult aResult;
807 if(i == 0) {
808 aResult.SetShape1(myShape1);
809 aResult.AddFaultyShape1(aFS);
810 } else {
811 aResult.SetShape2(myShape2);
812 aResult.AddFaultyShape2(aFS);
813 }
814 aResult.SetCheckStatus(BOPAlgo_GeomAbs_C0);
815 myResult.Append(aResult);
816 }
817 }
818}
819
820// ================================================================================
4e57c75e 821// function: TestMergeFace
822// purpose:
823// ================================================================================
824// void BOPAlgo_ArgumentAnalyzer::TestMergeFace()
825// {
826 // not implemented
827// }