1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
20 #include <BOPAlgo_BOP.ixx>
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>
31 #include <BOPTools.hxx>
32 #include <BOPTools_AlgoTools.hxx>
34 #include <BOPCol_MapOfShape.hxx>
36 #include <BRep_Builder.hxx>
37 #include <TopExp_Explorer.hxx>
40 //=======================================================================
41 //function : BuildSection
43 //=======================================================================
44 void BOPAlgo_BOP::BuildSection()
47 Standard_Integer i, j, k, nE, nF1, nF2, aNbPB, aNbFF;
48 Standard_Boolean bFlag;
51 BOPCol_MapOfShape aME;
52 BOPCol_IndexedMapOfShape aME1, aME2;
56 BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
57 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
60 for (i=0; i<aNbFF; ++i) {
61 BOPDS_InterfFF& aFF=aFFs(i);
62 aFF.Indices(nF1, nF2);
63 const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1);
64 const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2);
66 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
67 const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
68 const BOPDS_IndexedMapOfPaveBlock& aMPBSc1=aFI1.PaveBlocksSc();
70 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
71 const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
74 aNbPB = aMPBSc1.Extent();
75 for (j=1; j<=aNbPB; ++j) {
76 const Handle(BOPDS_PaveBlock)& aPB=aMPBSc1(j);
78 const TopoDS_Shape& aE=myDS->Shape(nE);
84 BOPDS_IndexedMapOfPaveBlock aMPB[4] = {aMPBOn2, aMPBIn1, aMPBIn2, aMPBOn1};
85 for (k = 0; k < 3; ++k) {
86 aNbPB = aMPB[k].Extent();
87 for (j=1; j<=aNbPB; ++j) {
88 const Handle(BOPDS_PaveBlock)& aPB=aMPB[k](j);
89 bFlag = (k==0) ? aMPB[3].Contains(aPB) :
90 (aMPB[k-1].Contains(aPB) || aMPB[k+1].Contains(aPB));
93 const TopoDS_Shape& aE=myDS->Shape(nE);
104 const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
105 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
107 BOPTools::MapShapes(aF1, TopAbs_EDGE, aME1);
108 BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);
110 aNbPB = aME1.Extent();
111 for (j=1; j<=aNbPB; ++j) {
112 const TopoDS_Shape& aE = aME1(j);
113 if (aME2.Contains(aE)) {
121 //case when arguments are the same
123 if (myArgs[0].IsSame(myArgs[1])) {
124 TopExp_Explorer anExpF, anExpE;
126 anExpF.Init(myArgs[0], TopAbs_FACE);
127 for(; anExpF.More(); anExpF.Next()) {
128 const TopoDS_Shape& aF = anExpF.Current();
130 anExpE.Init(aF, TopAbs_EDGE);
131 for (; anExpE.More(); anExpE.Next()) {
132 const TopoDS_Shape& aE = anExpE.Current();