From 135c2bd90858f779bb4557a909e18adf8422649e Mon Sep 17 00:00:00 2001 From: emv Date: Tue, 13 Oct 2020 14:31:27 +0300 Subject: [PATCH] 0031835: Modeling Algorithms - step by step Boolean common produces bad shape on given three cylinders Fix inconsistency between IntAna_QuadQuadGeo(gp_Cylinder,gp_Cylinder) and AxeOperator::Coplanar(). --- src/IntAna/IntAna_QuadQuadGeo.cxx | 31 +++++++++++-------- tests/bugs/modalg_7/bug31835_1 | 44 ++++++++++++++++++++++++++ tests/bugs/modalg_7/bug31835_2 | 51 +++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 tests/bugs/modalg_7/bug31835_1 create mode 100644 tests/bugs/modalg_7/bug31835_2 diff --git a/src/IntAna/IntAna_QuadQuadGeo.cxx b/src/IntAna/IntAna_QuadQuadGeo.cxx index 93e64b5283..4621f39d6e 100644 --- a/src/IntAna/IntAna_QuadQuadGeo.cxx +++ b/src/IntAna/IntAna_QuadQuadGeo.cxx @@ -63,7 +63,9 @@ static //======================================================================= class AxeOperator { public: - AxeOperator(const gp_Ax1& A1,const gp_Ax1& A2); + AxeOperator(const gp_Ax1& A1,const gp_Ax1& A2, + const Standard_Real theEpsDistance = 1.e-14, + const Standard_Real theEpsAxesPara = Precision::Angular()); void Distance(Standard_Real& dist, Standard_Real& Param1, @@ -123,12 +125,15 @@ class AxeOperator { //function : AxeOperator::AxeOperator //purpose : //======================================================================= -AxeOperator::AxeOperator(const gp_Ax1& A1,const gp_Ax1& A2) +AxeOperator::AxeOperator(const gp_Ax1& A1,const gp_Ax1& A2, + const Standard_Real theEpsDistance, + const Standard_Real theEpsAxesPara) +: + Axe1 (A1), + Axe2 (A2), + myEPSILON_DISTANCE (theEpsDistance), + myEPSILON_AXES_PARA (theEpsAxesPara) { - myEPSILON_DISTANCE=1.0e-14; - myEPSILON_AXES_PARA=Precision::Angular(); - Axe1=A1; - Axe2=A2; //--------------------------------------------------------------------- gp_Dir V1=Axe1.Direction(); gp_Dir V2=Axe2.Direction(); @@ -162,12 +167,11 @@ AxeOperator::AxeOperator(const gp_Ax1& A1,const gp_Ax1& A2) thecoplanar=Standard_True; } } - else { - thecoplanar=Standard_True; - thenormal=(V1.Dot(V2)==0.0)? Standard_True : Standard_False; - } + + thenormal = Abs (V1.Dot(V2)) < myEPSILON_AXES_PARA; + //--- check if the two axis are concurrent - if(thecoplanar && (!theparallel)) { + if (thecoplanar && !theparallel) { Standard_Real smx=P2.X() - P1.X(); Standard_Real smy=P2.Y() - P1.Y(); Standard_Real smz=P2.Z() - P1.Z(); @@ -949,7 +953,8 @@ void IntAna_QuadQuadGeo::Perform(const gp_Cylinder& Cyl1, { done=Standard_True; //---------------------------- Parallel axes ------------------------- - AxeOperator A1A2(Cyl1.Axis(),Cyl2.Axis()); + AxeOperator A1A2(Cyl1.Axis(),Cyl2.Axis(), + myEPSILON_CYLINDER_DELTA_DISTANCE, myEPSILON_AXES_PARA); Standard_Real R1=Cyl1.Radius(); Standard_Real R2=Cyl2.Radius(); Standard_Real RmR, RmR_Relative; @@ -1118,7 +1123,7 @@ void IntAna_QuadQuadGeo::Perform(const gp_Cylinder& Cyl1, } else { //-- No Parallel Axis ---------------------------------OK if((RmR_Relative<=myEPSILON_CYLINDER_DELTA_RADIUS) - && (DistA1A2 <= myEPSILON_CYLINDER_DELTA_DISTANCE)) + && A1A2.Intersect()) { //-- PI/2 between the two axis and Intersection //-- and identical radius diff --git a/tests/bugs/modalg_7/bug31835_1 b/tests/bugs/modalg_7/bug31835_1 new file mode 100644 index 0000000000..da0216b9e3 --- /dev/null +++ b/tests/bugs/modalg_7/bug31835_1 @@ -0,0 +1,44 @@ +puts "=============================================================================================" +puts "0031835: Modeling Algorithms - step by step Boolean common produces bad shape on given three cylinders" +puts "=============================================================================================" +puts "" + +plane p1 -200 2.22044604925033e-14 12.6935294289015 1 -1.11022302462516e-16 0 +pcylinder c1 p1 100 400 +plane p2 0 0 -187.306470571099 0 0 1 +pcylinder c2 p2 100 400 +plane p3 0 200 12.6935294289015 0 -1 1.11022302462516e-16 +pcylinder c3 p3 100 400 + +bcommon r c1 c2 +checkshape r +if {![regexp "OK" [bopcheck r]]} { + puts "Error: r is self-intersecting shape" +} +checkmaxtol r -ref 2.e-7 +checknbshapes r -wire 5 -face 5 -shell 1 -solid 1 +checkprops r -s 160000 -v 5.33333e+06 + +bcommon result r c3 +checkshape result +if {![regexp "OK" [bopcheck result]]} { + puts "Error: result is self-intersecting shape" +} +checkmaxtol result -ref 2.e-7 +checknbshapes result -wire 12 -face 12 -shell 1 -solid 1 +checkprops result -s 140589 -v 4.68629e+06 + +bclearobjects +bcleartools +baddobjects c1 c2 c3 +bfillds +bcbuild r + +bcremoveall +bcadd result1 c1 1 c2 1 c3 1 + +checkprops result1 -equal result +checknbshapes result1 -ref [nbshapes result] +checkmaxtol result1 -ref 2.e-7 + +checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_7/bug31835_2 b/tests/bugs/modalg_7/bug31835_2 new file mode 100644 index 0000000000..ba8a0e87a2 --- /dev/null +++ b/tests/bugs/modalg_7/bug31835_2 @@ -0,0 +1,51 @@ +puts "=============================================================================================" +puts "0031835: Modeling Algorithms - step by step Boolean common produces bad shape on given three cylinders" +puts "=============================================================================================" +puts "" + +plane p1 -200 2.22044604925033e-14 12.6935294289015 1 -1.11022302462516e-16 0 +pcylinder c1 p1 100 400 +plane p2 0 0 -187.306470571099 0 0 1 +pcylinder c2 p2 100 400 +plane p3 0 200 12.6935294289015 0 -1 1.11022302462516e-16 +pcylinder c3 p3 100 400 + +bfuzzyvalue 1.e-6 +bnondestructive 1 +brunparallel 1 +setfillhistory 0 + +bcommon r c1 c2 +checkshape r +if {![regexp "OK" [bopcheck r]]} { + puts "Error: r is self-intersecting shape" +} +checkmaxtol r -ref 2.e-7 +checknbshapes r -wire 5 -face 5 -shell 1 -solid 1 +checkprops r -s 160000 -v 5.33333e+06 + +bcommon result r c3 +checkshape result +if {![regexp "OK" [bopcheck result]]} { + puts "Error: result is self-intersecting shape" +} +checkmaxtol result -ref 2.e-7 +checknbshapes result -wire 12 -face 12 -shell 1 -solid 1 +checkprops result -s 140589 -v 4.68629e+06 + +bclearobjects +bcleartools +baddobjects c1 c2 c3 +bfillds +bcbuild r + +bcremoveall +bcadd result1 c1 1 c2 1 c3 1 + +boptions -default + +checkprops result1 -equal result +checknbshapes result1 -ref [nbshapes result] +checkmaxtol result1 -ref 2.e-7 + +checkview -display result -2d -path ${imagedir}/${test_image}.png