0023778: New Boolean Operation algorithm does not work with same arguments.
[occt.git] / src / BOPAlgo / BOPAlgo_BOP_1.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
19
20#include <BOPAlgo_BOP.ixx>
21
22#include <BOPDS_DS.hxx>
23#include <BOPDS_PaveBlock.hxx>
24#include <BOPDS_CommonBlock.hxx>
25#include <BOPDS_FaceInfo.hxx>
26#include <BOPDS_ListOfPaveBlock.hxx>
27#include <BOPDS_MapOfPaveBlock.hxx>
28#include <BOPDS_VectorOfListOfPaveBlock.hxx>
29#include <BOPDS_VectorOfFaceInfo.hxx>
30
31#include <BOPTools.hxx>
32#include <BOPTools_AlgoTools.hxx>
33
34#include <BOPCol_MapOfShape.hxx>
35
36#include <BRep_Builder.hxx>
37
38
39//=======================================================================
40//function : BuildSection
41//purpose :
42//=======================================================================
43 void BOPAlgo_BOP::BuildSection()
44{
45
46 Standard_Integer i, aNb, nE, aNbPB, j;
47 TopoDS_Shape aRC;
48 BRep_Builder aBB;
49 BOPCol_MapOfShape aME;
50 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
51 //
52 myErrorStatus=0;
53 //
54 BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
55 //1. Common Blocks
56 const BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->PaveBlocksPool();
57 aNb=aPBP.Extent();
58 for (i=0; i<aNb; ++i) {
59 const BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
60 //
61 aItLPB.Initialize(aLPB);
62 for (; aItLPB.More(); aItLPB.Next()) {
63 const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
64 if (aPB->IsCommonBlock()) {
65 const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock();
66 const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1();
67 nE=aPB1->Edge();
68 const TopoDS_Shape& aE=myDS->Shape(nE);
69 if (aME.Add(aE)) {
70 aBB.Add(aRC, aE);
71 }
72 }
73 }
74 }
75 //2. Section Edges
76 const BOPDS_VectorOfFaceInfo& aFIP=myDS->FaceInfoPool();
77 aNb=aFIP.Extent();
78 for (i=0; i<aNb; ++i) {
79 const BOPDS_FaceInfo& aFI=aFIP(i);
80 const BOPDS_IndexedMapOfPaveBlock& aMPB=aFI.PaveBlocksSc();
81 //
82 aNbPB=aMPB.Extent();
83 for (j=1; j<=aNbPB; ++j) {
84 const Handle(BOPDS_PaveBlock)& aPB=aMPB(j);
85 nE=aPB->Edge();
86 const TopoDS_Shape& aE=myDS->Shape(nE);
87 if (aME.Add(aE)) {
88 aBB.Add(aRC, aE);
89 }
90 }
91 }
92 //3. Shared Edges
93 BOPCol_IndexedMapOfShape aMEO, aMET;
94 BOPCol_MapIteratorOfMapOfShape aItME;
95 //
96 BOPTools::MapShapes(myArgs[0], TopAbs_EDGE, aMEO);
97 BOPTools::MapShapes(myArgs[1], TopAbs_EDGE, aMET);
98 //
99 aItME.Initialize(aMEO);
100 for (; aItME.More(); aItME.Next()) {
101 const TopoDS_Shape& aE = aItME.Value();
102 if (aMET.Contains(aE)) {
103 if (aME.Add(aE)) {
104 aBB.Add(aRC, aE);
105 }
106 }
107 }
108
109 myShape=aRC;
110}