1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-26 10:19:45 +03:00

0031913: Modeling Algorithms - Invalid result of cut operation [OCCT 7.2.0 backport]

Porting parts of #0029711 - reduce tolerance of increased vertices to the actual value of the distance to the section curve on which it will be kept.
This commit is contained in:
emv 2020-11-24 17:29:29 +03:00
parent 1abdd41c29
commit 599e010668
4 changed files with 53 additions and 8 deletions

View File

@ -262,7 +262,7 @@ protected:
BOPCol_DataMapOfIntegerReal& theMVTol, BOPCol_DataMapOfIntegerReal& theMVTol,
BOPCol_DataMapOfIntegerListOfInteger& aDMVLV); BOPCol_DataMapOfIntegerListOfInteger& aDMVLV);
Standard_EXPORT void FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC); Standard_EXPORT void FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,BOPCol_DataMapOfIntegerReal& theMVTol);
//! Depending on the parameter aType it checks whether //! Depending on the parameter aType it checks whether
//! the vertex nV was created in EE or EF intersections. //! the vertex nV was created in EE or EF intersections.

View File

@ -442,7 +442,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
// if some E-F vertex was put on a curve due to large E-F intersection range, // if some E-F vertex was put on a curve due to large E-F intersection range,
// and it also was put on another curve correctly then remove this vertex from // and it also was put on another curve correctly then remove this vertex from
// the first curve. Detect such case if the distance to curve exceeds aTolR3D. // the first curve. Detect such case if the distance to curve exceeds aTolR3D.
FilterPavesOnCurves(aVC); FilterPavesOnCurves(aVC, aMVTol);
for (j = 0; j<aNbC; ++j) { for (j = 0; j<aNbC; ++j) {
BOPDS_Curve& aNC=aVC.ChangeValue(j); BOPDS_Curve& aNC=aVC.ChangeValue(j);
@ -1565,13 +1565,14 @@ void BOPAlgo_PaveFiller::PutPavesOnCurve
namespace { namespace {
struct PaveBlockDist { struct PaveBlockDist {
Handle(BOPDS_PaveBlock) PB; Handle(BOPDS_PaveBlock) PB;
Standard_Real Dist; // square distance from vertex to the paveblock Standard_Real SquareDist; // square distance from vertex to the paveblock
Standard_Real SinAngle; // sinus of angle between projection vector Standard_Real SinAngle; // sinus of angle between projection vector
// and tangent at projection point // and tangent at projection point
Standard_Real Tolerance; // tolerance of the section curve Standard_Real Tolerance; // tolerance of the section curve
}; };
} }
void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC) void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,
BOPCol_DataMapOfIntegerReal& theMVTol)
{ {
// For each vertex found in ExtPaves of pave blocks of section curves // For each vertex found in ExtPaves of pave blocks of section curves
// collect list of pave blocks with distance to the curve // collect list of pave blocks with distance to the curve
@ -1625,9 +1626,9 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC)
for (; itL.More(); itL.Next()) for (; itL.More(); itL.Next())
{ {
const PaveBlockDist& aPBD = itL.Value(); const PaveBlockDist& aPBD = itL.Value();
if (aPBD.Dist < aMinDist) if (aPBD.SquareDist < aMinDist)
{ {
aMinDist = aPBD.Dist; aMinDist = aPBD.SquareDist;
aPBMinDist = aPBD.PB; aPBMinDist = aPBD.PB;
} }
} }
@ -1635,13 +1636,32 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC)
// and there are other pave blocks for which the distance is less than the current. // and there are other pave blocks for which the distance is less than the current.
// Do not remove a vertex if it is projected on the curve with quite large angle // Do not remove a vertex if it is projected on the curve with quite large angle
// (see test bugs modalg_6 bug27761). // (see test bugs modalg_6 bug27761).
// Reduce tolerance for the vertex to the value of maximal distance to
// to section curve on which it will be kept.
Standard_Real aMaxDistKept = -1;
Standard_Boolean isRemoved = Standard_False;
for (itL.Init(aList); itL.More(); itL.Next()) for (itL.Init(aList); itL.More(); itL.Next())
{ {
const PaveBlockDist& aPBD = itL.Value(); const PaveBlockDist& aPBD = itL.Value();
Standard_Real aCheckDist = 100. * Max(aPBD.Tolerance*aPBD.Tolerance, aMinDist); Standard_Real aCheckDist = 100. * Max(aPBD.Tolerance*aPBD.Tolerance, aMinDist);
if (aPBD.Dist > aCheckDist && aPBD.SinAngle < aSinAngleMin) if (aPBD.SquareDist > aCheckDist && aPBD.SinAngle < aSinAngleMin)
{ {
aPBD.PB->RemoveExtPave(nV); aPBD.PB->RemoveExtPave(nV);
isRemoved = Standard_True;
}
else if (aPBD.SquareDist > aMaxDistKept)
aMaxDistKept = aPBD.SquareDist;
}
if (isRemoved && aMaxDistKept > 0)
{
const Standard_Real* pTol = theMVTol.Seek(nV);
if (pTol)
{
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
const Standard_Real aRealTol = Max(*pTol, sqrt(aMaxDistKept) + Precision::Confusion());
(*(Handle(BRep_TVertex)*)&aV.TShape())->Tolerance(aRealTol);
} }
} }
} }

View File

@ -16,5 +16,5 @@ checkprops result -s 11.9246
checkshape result checkshape result
# Analysis of "nbshapes result" # Analysis of "nbshapes result"
checknbshapes result -vertex 23 -edge 34 -wire 13 -face 13 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 86 checknbshapes result -wire 13 -face 13 -shell 1 -solid 1
checkview -display result -2d -path ${imagedir}/${test_image}.png checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@ -0,0 +1,25 @@
puts "============================================================================================="
puts "0031913: Modeling Algorithms - Invalid result of cut operation"
puts "============================================================================================="
puts ""
restore [locate_data_file bug31913_shell_to_cut.brep] s1
restore [locate_data_file bug31913_cutting_solid.brep] s2
bclearobjects
bcleartools
baddobjects s1
baddtools s2
bfillds
bbop rcommon 0
bbop rcut 2
checkshape rcommon
checknbshapes rcommon -face 17 -wire 17
checkprops rcommon -s 0.0317669
checkshape rcut
checknbshapes rcut -face 73 -wire 73
checkprops rcut -s 39.1577
checkview -display rcommon -2d -path ${imagedir}/${test_image}.png