1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0023783: New Boolean Operation algorithm produces incorrect result of SECTION operation for the attached shapes.

Fix for the bug.
Modifications:
BOPAlgo_BOP::BuildSection():
Building a result of the SECTION operation has been based on the Face/Face intersections.
It prevents the building the result of the SECTION operation between shapes without faces.
This commit is contained in:
emv
2013-02-21 12:25:34 +04:00
parent 7cfb39680f
commit 0ed6989cfa

View File

@@ -34,6 +34,7 @@
#include <BOPCol_MapOfShape.hxx> #include <BOPCol_MapOfShape.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
//======================================================================= //=======================================================================
@@ -43,45 +44,51 @@
void BOPAlgo_BOP::BuildSection() void BOPAlgo_BOP::BuildSection()
{ {
Standard_Integer i, aNb, nE, aNbPB, j; Standard_Integer i, j, k, nE, nF1, nF2, aNbPB, aNbFF;
Standard_Boolean bFlag;
TopoDS_Shape aRC; TopoDS_Shape aRC;
BRep_Builder aBB; BRep_Builder aBB;
BOPCol_MapOfShape aME; BOPCol_MapOfShape aME;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB; BOPCol_IndexedMapOfShape aME1, aME2;
// //
myErrorStatus=0; myErrorStatus=0;
// //
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC); BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
//1. Common Blocks BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
const BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->PaveBlocksPool(); aNbFF=aFFs.Extent();
aNb=aPBP.Extent();
for (i=0; i<aNb; ++i) {
const BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
// //
aItLPB.Initialize(aLPB); for (i=0; i<aNbFF; ++i) {
for (; aItLPB.More(); aItLPB.Next()) { BOPDS_InterfFF& aFF=aFFs(i);
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value(); aFF.Indices(nF1, nF2);
if (aPB->IsCommonBlock()) { const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1);
const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock(); const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2);
const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1(); //
nE=aPB1->Edge(); const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
const BOPDS_IndexedMapOfPaveBlock& aMPBSc1=aFI1.PaveBlocksSc();
//
const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
//
//1. Section edges
aNbPB = aMPBSc1.Extent();
for (j=1; j<=aNbPB; ++j) {
const Handle(BOPDS_PaveBlock)& aPB=aMPBSc1(j);
nE=aPB->Edge();
const TopoDS_Shape& aE=myDS->Shape(nE); const TopoDS_Shape& aE=myDS->Shape(nE);
if (aME.Add(aE)) { if (aME.Add(aE)) {
aBB.Add(aRC, aE); aBB.Add(aRC, aE);
} }
} }
} //2. Common edges
} BOPDS_IndexedMapOfPaveBlock aMPB[4] = {aMPBOn2, aMPBIn1, aMPBIn2, aMPBOn1};
//2. Section Edges for (k = 0; k < 3; ++k) {
const BOPDS_VectorOfFaceInfo& aFIP=myDS->FaceInfoPool(); aNbPB = aMPB[k].Extent();
aNb=aFIP.Extent();
for (i=0; i<aNb; ++i) {
const BOPDS_FaceInfo& aFI=aFIP(i);
const BOPDS_IndexedMapOfPaveBlock& aMPB=aFI.PaveBlocksSc();
//
aNbPB=aMPB.Extent();
for (j=1; j<=aNbPB; ++j) { for (j=1; j<=aNbPB; ++j) {
const Handle(BOPDS_PaveBlock)& aPB=aMPB(j); const Handle(BOPDS_PaveBlock)& aPB=aMPB[k](j);
bFlag = (k==0) ? aMPB[3].Contains(aPB) :
(aMPB[k-1].Contains(aPB) || aMPB[k+1].Contains(aPB));
if (bFlag) {
nE=aPB->Edge(); nE=aPB->Edge();
const TopoDS_Shape& aE=myDS->Shape(nE); const TopoDS_Shape& aE=myDS->Shape(nE);
if (aME.Add(aE)) { if (aME.Add(aE)) {
@@ -89,22 +96,48 @@
} }
} }
} }
//3. Shared Edges }
BOPCol_IndexedMapOfShape aMEO, aMET; //3. Shared edges
BOPCol_MapIteratorOfMapOfShape aItME; aME1.Clear();
aME2.Clear();
// //
BOPTools::MapShapes(myArgs[0], TopAbs_EDGE, aMEO); const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
BOPTools::MapShapes(myArgs[1], TopAbs_EDGE, aMET); const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
// //
aItME.Initialize(aMEO); BOPTools::MapShapes(aF1, TopAbs_EDGE, aME1);
for (; aItME.More(); aItME.Next()) { BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);
const TopoDS_Shape& aE = aItME.Value(); //
if (aMET.Contains(aE)) { aNbPB = aME1.Extent();
for (j=1; j<=aNbPB; ++j) {
const TopoDS_Shape& aE = aME1(j);
if (aME2.Contains(aE)) {
if (aME.Add(aE)) { if (aME.Add(aE)) {
aBB.Add(aRC, aE); aBB.Add(aRC, aE);
} }
} }
} }
}
//
//case when arguments are the same
if (!aNbFF) {
if (myArgs[0].IsSame(myArgs[1])) {
TopExp_Explorer anExpF, anExpE;
//
anExpF.Init(myArgs[0], TopAbs_FACE);
for(; anExpF.More(); anExpF.Next()) {
const TopoDS_Shape& aF = anExpF.Current();
//
anExpE.Init(aF, TopAbs_EDGE);
for (; anExpE.More(); anExpE.Next()) {
const TopoDS_Shape& aE = anExpE.Current();
//
if (aME.Add(aE)) {
aBB.Add(aRC, aE);
}
}
}
}
}
//
myShape=aRC; myShape=aRC;
} }