1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0026619: Tolerances of operands are modified using bop

0026796: The result of General Fuse operation is self-intersecting shape

The fix forces creation of new sub-shapes (vertex, edge) when the tolerance of some sub-shape of an argument is to be increased.

This new behavior is turned off by default. It can be turned on using two ways:
1) Setting 'locking' flag of the arguments.
2) Calling the method SetNonDestructive(Standard_True) of the API classes.

Various bug fixes in the algorithm:
- Compute correct tolerance values for intersections of type Line/Line, Line/Plane, Plane/Plane.
- In case of Line/Plane intersection check if line's vertices lie on the plane.
- Do not allow decreasing of the tolerance value of the Line/Line intersection vertex.
- In IntTools_EdgeEdge, call the method FindParameters with proper 3D tolerance of the curve.
- Force making copy of a degenerated edge if its vertex is touched but no 2D intersection with other curves is found.
- Remove pave blocks both ends of which became referring to the same vertex after vertices substitution.
- Avoid exception in IntTools_Context::IsVertexOnLine if Extrema is not done.
- Reduce tolerance of vertex/edge using actual distances to interfered shapes if it was increased due to line/line, line/plane, or plane/plane small intersection angle.
- Update tolerance of edges to reach all representations in a common block.
- In V-E intersections, check if a vertex hits beyond shrunk range, in such case create V-V interference.
- Do not put a section edge to the result if it becomes to be a micro edge after updating its vertex.
- Correctly make vertices same-domain during the work of MakeBlocks.
- Decrease shrunk range at least on a Precision::Confusion() in addition to vertex tolerance.
- Add Confusion to bounding boxes of new shapes in DS
- Add tolerance Precision::Confusion() to compare distances of touching cases to fix regressions.

TODO marks have been removed from (or modified in) the following test cases (Improvements):
boolean bsection M3 N2 R2
boolean gdml_private B6 C2 C6 G7 I6 F6 J1 J4 M7 N1 N8 N9 O3 O4 O6 O8 O9 P1 P2 P5 Q1 Q3 Q5 S9 T2 U4 U5 U9 ZB5 ZB6 ZC1 ZC5 ZD3 ZD6 ZD7 ZH2 ZH5 ZI2 ZI5 ZI7 ZI9 ZJ3 ZJ4 ZJ7 F8 I6 G1
boolean volumemaker A5 A6 B3 B4 B7 B9 D3 D4 D7 F1
boolean bopcut_2d D5
bugs modalg_5 bug25043
bugs modalg_2 bug472_1 bug472_2 bug472_3

Test cases updated because they are still bad but can be accepted as non-regression:
boolean volumemaker C4 A3 A7 E6
bugs modalg_1 bug10232
boolean bsection N2

Put new TODO in the scripts:
bugs modalg_5 bug25232_9
bugs modalg_6 bug26619
bugs modalg_1 buc60462_2
bugs modalg_4 bug772

For the following tests the result in fix became better, so take fix result as the reference:
bugs modalg_5 bug24628
bugs modalg_6 bug26954_3
boolean volumemaker A4 B5 B6 C3 C8 D2 D5 F2
bugs modalg_2 bug472_2
bugs modalg_1 buc60776_1

- Add the method SetNonDestructive to API classes of user level
This commit is contained in:
msv
2015-10-21 12:36:03 +03:00
committed by bugmaster
parent 6435b9c7fa
commit 3510db6201
144 changed files with 2242 additions and 925 deletions

View File

@@ -92,11 +92,13 @@
//
static
void CheckEdge (const TopoDS_Edge& E,
const Standard_Real aMaxTol);
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
const Standard_Real aMaxTol);
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
const Adaptor3d_Curve& Other,
@@ -105,15 +107,23 @@ static
Standard_Real& aNewTolerance);
static
void CorrectVertexTolerance(const TopoDS_Edge& aE);
void CorrectVertexTolerance(const TopoDS_Edge& aE,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void CorrectWires(const TopoDS_Face& aF);
void CorrectWires(const TopoDS_Face& aF,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void UpdateEdges(const TopoDS_Face& aF);
void UpdateEdges(const TopoDS_Face& aF,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void UpdateShape(const TopoDS_Shape& aS,
const Standard_Real aTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
Standard_Real IntersectCurves2d(const gp_Pnt& aPV,
@@ -131,7 +141,7 @@ static
class BOPTools_CPC {
public:
BOPTools_CPC()
: myMaxTol(1.e-7) {
: myMaxTol(1.e-7), mypMapToAvoid(0L) {
}
//
~BOPTools_CPC() {
@@ -153,13 +163,19 @@ class BOPTools_CPC {
return myMaxTol;
}
//
void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
mypMapToAvoid = &aMapToAvoid;
}
//
void Perform() {
CheckEdge(myEdge, myMaxTol);
Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
CheckEdge(myEdge, myMaxTol, *mypMapToAvoid);
}
protected:
Standard_Real myMaxTol;
TopoDS_Edge myEdge;
const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//
//=======================================================================
@@ -179,7 +195,7 @@ typedef BOPCol_Cnt
//=======================================================================
class BOPTools_CWT {
public:
BOPTools_CWT() {
BOPTools_CWT() : mypMapToAvoid(0L) {
}
//
~BOPTools_CWT() {
@@ -189,12 +205,18 @@ class BOPTools_CWT {
myFace=aF;
}
//
void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
mypMapToAvoid = &aMapToAvoid;
}
//
void Perform() {
CorrectWires(myFace);
Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
CorrectWires(myFace, *mypMapToAvoid);
}
//
protected:
TopoDS_Face myFace;
const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//=======================================================================
typedef BOPCol_NCVector<BOPTools_CWT> BOPTools_VectorOfCWT;
@@ -214,7 +236,7 @@ typedef BOPCol_Cnt
class BOPTools_CDT {
public:
BOPTools_CDT()
: myMaxTol(1.e-7) {
: myMaxTol(1.e-7), mypMapToAvoid(0L) {
}
//
~BOPTools_CDT() {
@@ -232,14 +254,20 @@ class BOPTools_CDT {
myMaxTol=aMaxTol;
}
//
void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
mypMapToAvoid = &aMapToAvoid;
}
//
void Perform() {
CorrectEdgeTolerance (myEdge, myFace, myMaxTol);
Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
CorrectEdgeTolerance (myEdge, myFace, myMaxTol, *mypMapToAvoid);
}
//
protected:
Standard_Real myMaxTol;
TopoDS_Edge myEdge;
TopoDS_Face myFace;
const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//=======================================================================
typedef BOPCol_NCVector<BOPTools_CDT> BOPTools_VectorOfCDT;
@@ -258,7 +286,7 @@ typedef BOPCol_Cnt
//=======================================================================
class BOPTools_CVT {
public:
BOPTools_CVT() {
BOPTools_CVT() : mypMapToAvoid(0L) {
}
//
~BOPTools_CVT() {
@@ -268,12 +296,18 @@ class BOPTools_CVT {
myEdge=aE;
}
//
void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
mypMapToAvoid = &aMapToAvoid;
}
//
void Perform() {
CorrectVertexTolerance(myEdge);
Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
CorrectVertexTolerance(myEdge, *mypMapToAvoid);
}
//
protected:
TopoDS_Edge myEdge;
const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//
//=======================================================================
@@ -293,7 +327,7 @@ typedef BOPCol_Cnt
//=======================================================================
class BOPTools_CET {
public:
BOPTools_CET() {
BOPTools_CET() : mypMapToAvoid(0L) {
}
//
~BOPTools_CET() {
@@ -303,12 +337,18 @@ class BOPTools_CET {
myFace=aF;
}
//
void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
mypMapToAvoid = &aMapToAvoid;
}
//
void Perform() {
UpdateEdges(myFace);
Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
UpdateEdges(myFace, *mypMapToAvoid);
}
//
protected:
TopoDS_Face myFace;
const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//=======================================================================
typedef BOPCol_NCVector<BOPTools_CET> BOPTools_VectorOfCET;
@@ -330,11 +370,12 @@ typedef BOPCol_Cnt
//=======================================================================
void BOPTools_AlgoTools::CorrectTolerances
(const TopoDS_Shape& aShape,
const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol,
const Standard_Boolean bRunParallel)
{
BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMaxTol, bRunParallel);
BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMaxTol, bRunParallel);
BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMapToAvoid, aMaxTol, bRunParallel);
BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMapToAvoid, aMaxTol, bRunParallel);
}
//
//=======================================================================
@@ -343,6 +384,7 @@ void BOPTools_AlgoTools::CorrectTolerances
//=======================================================================
void BOPTools_AlgoTools::CorrectPointOnCurve
(const TopoDS_Shape& aS,
const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol,
const Standard_Boolean bRunParallel)
{
@@ -355,6 +397,7 @@ void BOPTools_AlgoTools::CorrectPointOnCurve
BOPTools_CPC& aCPC=aVCPC.Append1();
aCPC.SetEdge(aE);
aCPC.SetMaxTol(aMaxTol);
aCPC.SetMapToAvoid(aMapToAvoid);
}
//
//======================================================
@@ -367,6 +410,7 @@ void BOPTools_AlgoTools::CorrectPointOnCurve
//=======================================================================
void BOPTools_AlgoTools::CorrectCurveOnSurface
(const TopoDS_Shape& aS,
const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol,
const Standard_Boolean bRunParallel)
{
@@ -380,6 +424,7 @@ void BOPTools_AlgoTools::CorrectCurveOnSurface
//
BOPTools_CWT& aCWT=aVCWT.Append1();
aCWT.SetFace(aF);
aCWT.SetMapToAvoid(aMapToAvoid);
//
aExpE.Init(aF, TopAbs_EDGE);
for (; aExpE.More(); aExpE.Next()) {
@@ -389,6 +434,7 @@ void BOPTools_AlgoTools::CorrectCurveOnSurface
aCDT.SetEdge(aE);
aCDT.SetFace(aF);
aCDT.SetMaxTol(aMaxTol);
aCDT.SetMapToAvoid(aMapToAvoid);
}
}
//
@@ -404,6 +450,7 @@ void BOPTools_AlgoTools::CorrectCurveOnSurface
//=======================================================================
void BOPTools_AlgoTools::CorrectShapeTolerances
(const TopoDS_Shape& aShape,
const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Boolean bRunParallel)
{
TopExp_Explorer aExp;
@@ -415,6 +462,7 @@ void BOPTools_AlgoTools::CorrectShapeTolerances
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current();
BOPTools_CVT& aCVT=aVCVT.Append1();
aCVT.SetEdge(aE);
aCVT.SetMapToAvoid(aMapToAvoid);
}
//
//======================================================
@@ -426,6 +474,7 @@ void BOPTools_AlgoTools::CorrectShapeTolerances
const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current();
BOPTools_CET& aCET=aVCET.Append1();
aCET.SetFace(aF);
aCET.SetMapToAvoid(aMapToAvoid);
}
//
//======================================================
@@ -438,7 +487,8 @@ void BOPTools_AlgoTools::CorrectShapeTolerances
// purpose : Correct tolerances for Vertices on Edge
//=======================================================================
void CheckEdge (const TopoDS_Edge& Ed,
const Standard_Real aMaxTol)
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolE, aTol, aD2, aNewTolerance, dd;
gp_Pnt aPC;
@@ -490,7 +540,7 @@ void CheckEdge (const TopoDS_Edge& Ed,
if (aD2 > aTol) {
aNewTolerance=sqrt(aD2)+dd;
if (aNewTolerance<aMaxTol)
TV->UpdateTolerance(aNewTolerance);
UpdateShape(aV, aNewTolerance, aMapToAvoid);
}
}
aItPR.Next();
@@ -512,7 +562,7 @@ void CheckEdge (const TopoDS_Edge& Ed,
if (aD2 > aTol) {
aNewTolerance=sqrt(aD2)+dd;
if (aNewTolerance<aMaxTol)
TV->UpdateTolerance(aNewTolerance);
UpdateShape(aV, aNewTolerance, aMapToAvoid);
}
}
}
@@ -525,7 +575,8 @@ void CheckEdge (const TopoDS_Edge& Ed,
// Function : CorrectWires
// purpose :
//=======================================================================
void CorrectWires(const TopoDS_Face& aFx)
void CorrectWires(const TopoDS_Face& aFx,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Boolean bIsPeriodic;
Standard_Integer i, aNbV;
@@ -600,10 +651,8 @@ void CorrectWires(const TopoDS_Face& aFx)
}// for (; aIt1.More(); aIt1.Next()) {
}// for (; aIt.More(); aIt.Next()) {
if (aD2max>aTol2) {
BRep_Builder aBB;
//
aTol=sqrt(aD2max);
aBB.UpdateVertex(aV, aTol);
UpdateShape(aV, aTol, aMapToAvoid);
}
}// for (i=1; i<=aNbV; ++i) {
}
@@ -673,7 +722,8 @@ Standard_Real IntersectCurves2d(const gp_Pnt& aPV,
//=======================================================================
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
const Standard_Real aMaxTol)
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
//
// 1. Minimum of conditions to Perform
@@ -812,9 +862,8 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
Tol, SameParameter, aNewTol);
if (ok) {
if (aNewTol<aMaxTol) {
TE->UpdateTolerance(aNewTol+Delta);
//
CorrectVertexTolerance(myShape);
UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
@@ -825,8 +874,8 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter, aNewTol);
if (ok) {
if (aNewTol<aMaxTol) {
TE->UpdateTolerance(aNewTol+Delta);
CorrectVertexTolerance(myShape);
UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
}
@@ -881,8 +930,8 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
Tol,Standard_True, aNewTol);
if (okx) {
if (aNewTol<aMaxTol) {
TE->UpdateTolerance(aNewTol+Delta);
CorrectVertexTolerance(myShape);
UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
}
@@ -893,7 +942,8 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
//function : CorrectVertexTolerance
//purpose :
//=======================================================================
void CorrectVertexTolerance(const TopoDS_Edge& aE)
void CorrectVertexTolerance(const TopoDS_Edge& aE,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolE, aTolV;
TopoDS_Iterator aIt;
@@ -904,8 +954,7 @@ void CorrectVertexTolerance(const TopoDS_Edge& aE)
const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aIt.Value());
aTolV=BRep_Tool::Tolerance(aV);
if (aTolV<aTolE) {
Handle(BRep_TVertex)& aTV= *((Handle(BRep_TVertex)*)&aV.TShape());
aTV->UpdateTolerance(aTolE);
UpdateShape(aV, aTolE, aMapToAvoid);
}
}
}
@@ -1027,11 +1076,11 @@ Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
// Function : UpdateEdges
// purpose :
//=======================================================================
void UpdateEdges(const TopoDS_Face& aF)
void UpdateEdges(const TopoDS_Face& aF,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolF, aTolE, aTolV;
TopoDS_Iterator aItF, aItW, aItE;
BRep_Builder aBB;
//
aTolE=aTolF= BRep_Tool::Tolerance(aF);
aItF.Initialize(aF);
@@ -1043,22 +1092,46 @@ void UpdateEdges(const TopoDS_Face& aF)
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aItW.Value());
aTolE = BRep_Tool::Tolerance(aE);
if (aTolE < aTolF) {
aBB.UpdateEdge(aE, aTolF);
UpdateShape(aE, aTolF, aMapToAvoid);
aTolE = aTolF;
}
//UpdateVertices(aE);
}
}
else {
const TopoDS_Vertex& aV=*(TopoDS_Vertex*)&aItF.Value();
aTolV = BRep_Tool::Tolerance(aV);
if (aTolV < aTolE) {
aBB.UpdateVertex(aV, aTolF);
UpdateShape(aV, aTolF, aMapToAvoid);
}
}
}
}
//=======================================================================
//function : UpdateShape
//purpose :
//=======================================================================
void UpdateShape(const TopoDS_Shape& aS,
const Standard_Real aTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
if (aMapToAvoid.Contains(aS)) {
return;
}
//
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
//
aType=aS.ShapeType();
if (aType==TopAbs_EDGE) {
const TopoDS_Edge& aE = *((TopoDS_Edge*)&aS);
aBB.UpdateEdge(aE, aTol);
}
else if (aType==TopAbs_VERTEX) {
const TopoDS_Vertex& aV = *((TopoDS_Vertex*)&aS);
aBB.UpdateVertex(aV, aTol);
}
}
//=======================================================================
// Function : ComputeTolerance
// purpose :
//=======================================================================