1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and / or modify it
7 // under the terms of the GNU Lesser General Public version 2.1 as published
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <BOPAlgo_BOP.ixx>
17 #include <BOPDS_DS.hxx>
18 #include <BOPDS_PaveBlock.hxx>
19 #include <BOPDS_CommonBlock.hxx>
20 #include <BOPDS_FaceInfo.hxx>
21 #include <BOPDS_ListOfPaveBlock.hxx>
22 #include <BOPDS_MapOfPaveBlock.hxx>
23 #include <BOPDS_VectorOfListOfPaveBlock.hxx>
24 #include <BOPDS_VectorOfFaceInfo.hxx>
26 #include <BOPTools.hxx>
27 #include <BOPTools_AlgoTools.hxx>
29 #include <BOPCol_MapOfShape.hxx>
31 #include <BRep_Builder.hxx>
32 #include <TopExp_Explorer.hxx>
35 //=======================================================================
36 //function : BuildSection
38 //=======================================================================
39 void BOPAlgo_BOP::BuildSection()
42 Standard_Integer i, j, k, nE, nF1, nF2, aNbPB, aNbFF;
43 Standard_Boolean bFlag;
46 BOPCol_MapOfShape aME;
47 BOPCol_IndexedMapOfShape aME1, aME2;
51 BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
52 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
55 for (i=0; i<aNbFF; ++i) {
56 BOPDS_InterfFF& aFF=aFFs(i);
57 aFF.Indices(nF1, nF2);
58 const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1);
59 const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2);
61 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
62 const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
63 const BOPDS_IndexedMapOfPaveBlock& aMPBSc1=aFI1.PaveBlocksSc();
65 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
66 const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
69 aNbPB = aMPBSc1.Extent();
70 for (j=1; j<=aNbPB; ++j) {
71 const Handle(BOPDS_PaveBlock)& aPB=aMPBSc1(j);
73 const TopoDS_Shape& aE=myDS->Shape(nE);
79 BOPDS_IndexedMapOfPaveBlock aMPB[4] = {aMPBOn2, aMPBIn1, aMPBIn2, aMPBOn1};
80 for (k = 0; k < 3; ++k) {
81 aNbPB = aMPB[k].Extent();
82 for (j=1; j<=aNbPB; ++j) {
83 const Handle(BOPDS_PaveBlock)& aPB=aMPB[k](j);
84 bFlag = (k==0) ? aMPB[3].Contains(aPB) :
85 (aMPB[k-1].Contains(aPB) || aMPB[k+1].Contains(aPB));
88 const TopoDS_Shape& aE=myDS->Shape(nE);
99 const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
100 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
102 BOPTools::MapShapes(aF1, TopAbs_EDGE, aME1);
103 BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);
105 aNbPB = aME1.Extent();
106 for (j=1; j<=aNbPB; ++j) {
107 const TopoDS_Shape& aE = aME1(j);
108 if (aME2.Contains(aE)) {
116 //case when arguments are the same
118 if (myArgs[0].IsSame(myArgs[1])) {
119 TopExp_Explorer anExpF, anExpE;
121 anExpF.Init(myArgs[0], TopAbs_FACE);
122 for(; anExpF.More(); anExpF.Next()) {
123 const TopoDS_Shape& aF = anExpF.Current();
125 anExpE.Init(aF, TopAbs_EDGE);
126 for (; anExpE.More(); anExpE.Next()) {
127 const TopoDS_Shape& aE = anExpE.Current();
140 //=======================================================================
141 //function : Generated
143 //=======================================================================
144 const TopTools_ListOfShape& BOPAlgo_BOP::Generated(const TopoDS_Shape& theS)
146 myHistShapes.Clear();
147 if (theS.IsNull() || (myOperation != BOPAlgo_SECTION)) {
151 TopAbs_ShapeEnum aType = theS.ShapeType();
152 if (aType != TopAbs_FACE) {
156 Standard_Integer nS = myDS->Index(theS);
161 if (!myDS->HasFaceInfo(nS)) {
165 //collect section edges of the face theS
166 Standard_Integer i, aNb, nSp;
168 const BOPDS_FaceInfo& aFI = myDS->FaceInfo(nS);
169 const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
170 aNb = aMPBSc.Extent();
171 for (i = 1; i <= aNb; ++i) {
172 const Handle(BOPDS_PaveBlock)& aPB = aMPBSc(i);
174 const TopoDS_Shape& aSp = myDS->Shape(nSp);
175 myHistShapes.Append(aSp);