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

0025597: Invalid curve on surface in the result of General Fuse operation

1. The tool of computing the max distance between 3D curve and its 2d representation on the face
has been moved from static methods in BOPTools_AlgoTools class to BRepLib_CheckCurveOnSurface class.
2. The tools has been applied to 2d curves built during Boolean Operation
and to some intersection curves.
3. The functions
  Standard_Boolean BOPTools_AlgoTools::ComputeTolerance
    (const TopoDS_Face& theFace,
     const TopoDS_Edge& theEdge,
     Standard_Real& theMaxDist,
     Standard_Real& theMaxPar)
and
  Standard_Boolean IntTools_Tools::ComputeTolerance
    (const Handle(Geom_Curve)& theCurve3D,
     const Handle(Geom2d_Curve)& theCurve2D,
     const Handle(Geom_Surface)& theSurf,
     const Standard_Real theFirst,
     const Standard_Real theLast,
     Standard_Real& theMaxDist,
     Standard_Real& theMaxPar)
have been developed for easy access to BRepLib_CheckCurveOnSurface functionality.

class IntTools_FaceFace
method void IntTools_FaceFace::ComputeTolReached3d()
Case for Plane/BSpline intersection added for treatment.

Test case for issue CR25597

Fix for regression boolean bsection N7.

class BOPAlgo_PaveFiller
method
  void BOPAlgo_PaveFiller::UpdateFaceInfo
    (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME,
     const BOPCol_DataMapOfIntegerInteger& theDMV)
Updating Face Info information with new vertices created in PostTreatFF.

Correction boolean/bsection/N2

Updated test cases.
This commit is contained in:
emv
2015-01-22 16:54:54 +03:00
committed by bugmaster
parent e2da917a1c
commit 1b7ae95146
21 changed files with 1167 additions and 761 deletions

View File

@@ -418,7 +418,8 @@ is
-- state information
UpdateFaceInfo(me:out;
theDME:out DataMapOfPaveBlockListOfPaveBlock from BOPDS)
theDME:out DataMapOfPaveBlockListOfPaveBlock from BOPDS;
theDMV: DataMapOfIntegerInteger from BOPCol)
is protected;
---Purpose:
-- Updates the information about faces

View File

@@ -32,11 +32,14 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBndLib.hxx>
#include <BRepTools.hxx>
@@ -48,7 +51,10 @@
#include <IntTools_SequenceOfPntOn2Faces.hxx>
#include <IntTools_Curve.hxx>
#include <IntTools_PntOn2Faces.hxx>
#include <IntTools_ShrunkRange.hxx>
#include <IntTools_Context.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_EdgeFace.hxx>
#include <IntSurf_ListOfPntOn2S.hxx>
#include <IntSurf_PntOn2S.hxx>
@@ -65,9 +71,6 @@
#include <BOPCol_NCVector.hxx>
#include <BOPCol_TBB.hxx>
#include <IntTools_Context.hxx>
#include <IntTools_Tools.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPDS_Curve.hxx>
@@ -85,12 +88,9 @@
#include <BOPDS_CoupleOfPaveBlocks.hxx>
#include <BOPDS_FaceInfo.hxx>
#include <BOPDS_CommonBlock.hxx>
#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <TopExp.hxx>
#include <IntTools_ShrunkRange.hxx>
#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
static void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2,
@@ -597,7 +597,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
}
//
// update face info
UpdateFaceInfo(aDMExEdges);
UpdateFaceInfo(aDMExEdges, aDMI);
//Update all pave blocks
UpdatePaveBlocks(aDMI);
//-----------------------------------------------------scope t
@@ -754,7 +754,8 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
if (!bHasPaveBlocks) {
if (bOld) {
aDMExEdges.ChangeFind(aPB1).Append(aPB1);
} else {
}
else {
aSI.SetShapeType(aType);
aSI.SetShape(aSx);
iE=myDS->Append(aSI);
@@ -894,12 +895,13 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdateFaceInfo
(BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME)
(BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME,
const BOPCol_DataMapOfIntegerInteger& theDMV)
{
Standard_Integer i, j, nV1, nF1, nF2,
aNbFF, aNbC, aNbP, aNbS, aNbPBIn;
BOPDS_IndexedMapOfPaveBlock aMPBCopy;
aNbFF, aNbC, aNbP;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
BOPCol_MapOfInteger aMF;
//
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
aNbFF=aFFs.Extent();
@@ -912,6 +914,7 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo
BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
//
// 1.1. Section edges
BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
aNbC=aVNC.Extent();
for (j=0; j<aNbC; ++j) {
@@ -919,21 +922,24 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo
BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
aItLPB.Initialize(aLPBC);
//
// Treat existing pave blocks
if (aItLPB.More() && theDME.IsBound(aLPBC.First())) {
const Handle(BOPDS_PaveBlock)& aPB=aLPBC.First();
BOPDS_ListOfPaveBlock& aLPB = theDME.ChangeFind(aPB);
BOPDS_ListOfPaveBlock& aLPB=theDME.ChangeFind(aPB);
UpdateExistingPaveBlocks(aPB, aLPB, nF1, nF2);
aLPBC.Clear();
continue;
}
//
for(; aItLPB.More(); aItLPB.Next()) {
// Add section edges to face info
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
aFI1.ChangePaveBlocksSc().Add(aPB);
aFI2.ChangePaveBlocksSc().Add(aPB);
}
}
// VerticesSc
//
// 1.2. Section vertices
const BOPDS_VectorOfPoint& aVNP=aFF.Points();
aNbP=aVNP.Extent();
for (j=0; j<aNbP; ++j) {
@@ -945,43 +951,81 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo
aFI1.ChangeVerticesSc().Add(nV1);
aFI2.ChangeVerticesSc().Add(nV1);
}
//
aMF.Add(nF1);
aMF.Add(nF2);
}
//
//2. PaveBlocksIn
if (theDME.IsEmpty()) {
Standard_Boolean bVerts, bEdges;
//
bVerts = theDMV.Extent() > 0;
bEdges = theDME.Extent() > 0;
//
if (!bVerts && !bEdges) {
return;
}
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()!=TopAbs_FACE) {
continue;
}
if(!myDS->HasFaceInfo(i)) {
continue;
}
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(i);
// 2. Update Face Info information with new vertices and new
// pave blocks created in PostTreatFF from existing ones
Standard_Integer nV2, aNbPB;
BOPCol_MapIteratorOfMapOfInteger aItMF;
BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItMV;
//
aItMF.Initialize(aMF);
for (; aItMF.More(); aItMF.Next()) {
nF1 = aItMF.Value();
//
BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.ChangePaveBlocksIn();
aMPBCopy.Assign(aMPBIn);
aMPBIn.Clear();
BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(nF1);
//
aNbPBIn=aMPBCopy.Extent();
for (j=1; j<=aNbPBIn; ++j) {
const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j);
if (theDME.IsBound(aPB)) {
const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB);
aItLPB.Initialize(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value();
aMPBIn.Add(aPB1);
// 2.1. Update information about vertices
if (bVerts) {
BOPCol_MapOfInteger& aMVOn = aFI.ChangeVerticesOn();
BOPCol_MapOfInteger& aMVIn = aFI.ChangeVerticesIn();
//
aItMV.Initialize(theDMV);
for (; aItMV.More(); aItMV.Next()) {
nV1 = aItMV.Key();
nV2 = aItMV.Value();
//
if (aMVOn.Remove(nV1)) {
aMVOn.Add(nV2);
}
} else {
aMPBIn.Add(aPB);
}
}//for (j=1; j<=aNbPBIn; ++j) {
}//for (i=0; i<aNbS; ++i) {
//
if (aMVIn.Remove(nV1)) {
aMVIn.Add(nV2);
}
} // for (; aItMV.More(); aItMV.Next()) {
} // if (bVerts) {
//
// 2.2. Update information about pave blocks
if (bEdges) {
BOPDS_IndexedMapOfPaveBlock& aMPBOn = aFI.ChangePaveBlocksOn();
BOPDS_IndexedMapOfPaveBlock& aMPBIn = aFI.ChangePaveBlocksIn();
//
BOPDS_IndexedMapOfPaveBlock aMPBCopy;
for (i = 0; i < 2; ++i) {
BOPDS_IndexedMapOfPaveBlock& aMPBOnIn = !i ? aMPBOn : aMPBIn;
aMPBCopy = aMPBOnIn;
aMPBOnIn.Clear();
//
aNbPB = aMPBCopy.Extent();
for (j = 1; j <= aNbPB; ++j) {
const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j);
if (theDME.IsBound(aPB)) {
const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB);
aItLPB.Initialize(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value();
aMPBOnIn.Add(aPB1);
}
}
else {
aMPBOnIn.Add(aPB);
}
} // for (j = 1; j <= aNbPB; ++j) {
} // for (i = 0; i < 2; ++i) {
} // if (bEdges) {
}
}
//=======================================================================
//function : IsExistingVertex
@@ -1807,9 +1851,8 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
Handle(BOPDS_PaveBlock) aPB, aPB1, aPB2, aPB2n;
Handle(BOPDS_CommonBlock) aCB;
BOPDS_ListIteratorOfListOfPaveBlock aIt, aIt1, aIt2;
BOPDS_IndexedMapOfPaveBlock aMPB;
//
//remove micro edges from aLPB
// 1. Remove micro edges from aLPB
aIt.Initialize(aLPB);
for (; aIt.More();) {
aPB = aIt.Value();
@@ -1824,10 +1867,6 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
if (!aLPB.Extent()) {
return;
}
//update face info
myDS->UpdateFaceInfoOn(nF1);
//
myDS->UpdateFaceInfoOn(nF2);
//
BOPDS_FaceInfo& aFI1 = myDS->ChangeFaceInfo(nF1);
BOPDS_FaceInfo& aFI2 = myDS->ChangeFaceInfo(nF2);
@@ -1837,7 +1876,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
BOPDS_IndexedMapOfPaveBlock& aMPBOn2 = aFI2.ChangePaveBlocksOn();
BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.ChangePaveBlocksIn();
//
// remove old pave blocks
// 2. Remove old pave blocks
const Handle(BOPDS_CommonBlock)& aCB1 = myDS->CommonBlock(aPBf);
bCB = !aCB1.IsNull();
BOPDS_ListOfPaveBlock aLPB1;
@@ -1863,8 +1902,9 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
}
}
//
// 3. Update pave blocks
if (bCB) {
//create new pave blocks
//create new common blocks
const BOPCol_ListOfInteger& aFaces = aCB1->Faces();
aIt.Initialize(aLPB);
for (; aIt.More(); aIt.Next()) {
@@ -1891,55 +1931,66 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
aPB=aCB->PaveBlocks().First();
}
}
//
aIt.Initialize(aLPB);
for (; aIt.More(); aIt.Next()) {
Handle(BOPDS_PaveBlock)& aPB = aIt.ChangeValue();
nE = aPB->OriginalEdge();
//
Standard_Integer nF = (aMPBOn1.Contains(aPBf) ||
aMPBIn1.Contains(aPBf)) ? nF2 : nF1;
const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF);
IntTools_Range aShrR(aPB->Pave1().Parameter(),
aPB->Pave2().Parameter());
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
//
Standard_Boolean bCom =
BOPTools_AlgoTools::IsBlockInOnFace(aShrR, aF, aE, myContext);
if (bCom) {
if (bCB) {
aCB = myDS->CommonBlock(aPB);
aCB->AddFace(nF);
} else {
aCB = new BOPDS_CommonBlock;
aCB->AddPaveBlock(aPB);
aCB->AddFace(nF1);
aCB->AddFace(nF2);
//
myDS->SetCommonBlock(aPB, aCB);
}
aMPB.Add(aPB);
}
if (!bCB) {
myDS->ChangePaveBlocks(nE).Append(aPB);
else {
nE = aPBf->OriginalEdge();
BOPDS_ListOfPaveBlock& aLPBE = myDS->ChangePaveBlocks(nE);
aIt.Initialize(aLPB);
for (; aIt.More(); aIt.Next()) {
aPB = aIt.Value();
aLPBE.Append(aPB);
}
}
//
Standard_Integer i, aNbPB;
Standard_Boolean bIn1, bIn2;
//
bIn1 = aMPBOn1.Contains(aPBf) || aMPBIn1.Contains(aPBf);
bIn2 = aMPBOn2.Contains(aPBf) || aMPBIn2.Contains(aPBf);
//
aNbPB=aMPB.Extent();
for (i=1; i<=aNbPB; ++i) {
aPB = aMPB(i);
if (!bIn1) {
aMPBIn1.Add(aPB);
}
if (bIn1 && bIn2) {
return;
}
//
// 4. Check new pave blocks for coincidence
// with the opposite face.
// In case of coincidence create common blocks
Standard_Integer nF;
Standard_Real aTolE, aTolF;
//
nF = bIn1 ? nF2 : nF1;
const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF);
BOPDS_IndexedMapOfPaveBlock& aMPBIn = bIn1 ? aMPBIn2 : aMPBIn1;
aTolF = BRep_Tool::Tolerance(aF);
//
aIt.Initialize(aLPB);
for (; aIt.More(); aIt.Next()) {
Handle(BOPDS_PaveBlock)& aPB = aIt.ChangeValue();
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
aTolE = BRep_Tool::Tolerance(aE);
//
if (!bIn2) {
aMPBIn2.Add(aPB);
IntTools_EdgeFace anEF;
anEF.SetEdge(aE);
anEF.SetFace(aF);
anEF.SetTolE(aTolE);
anEF.SetTolF(aTolF);
anEF.SetRange(aPB->Pave1().Parameter(), aPB->Pave2().Parameter());
anEF.SetContext(myContext);
anEF.Perform();
//
const IntTools_SequenceOfCommonPrts& aCPrts=anEF.CommonParts();
if (aCPrts.Length() == 1) {
Standard_Boolean bCoinc = (aCPrts(1).Type() == TopAbs_EDGE);
if (bCoinc) {
if (bCB) {
aCB = myDS->CommonBlock(aPB);
} else {
aCB = new BOPDS_CommonBlock;
aCB->AddPaveBlock(aPB);
myDS->SetCommonBlock(aPB, aCB);
}
aCB->AddFace(nF);
//
aMPBIn.Add(aPB);
}
}
}
}