From 507dd6d5798795de8bc1b4d8b57c1ca8c9631cb3 Mon Sep 17 00:00:00 2001 From: nbv Date: Wed, 18 Nov 2015 11:01:12 +0300 Subject: [PATCH] 0026884: Cylinder/Cylinder intersection algorithm throws an exception Check, if cylinder axes are parallel is made more carefully. This check is brought to conformity with check if axes are parallel (see constructor AxeOperator::AxeOperator(...) in IntAna_QuadQuadGeo.cxx file) Test case for issue CR26884 (cherry picked from commit ce48b00930ae801233d44228e5e1f5a193a5de82) --- src/IntAna/IntAna_QuadQuadGeo.cxx | 16 ++++----- .../IntPatch_ImpImpIntersection_4.gxx | 8 ++++- tests/bugs/moddata_3/bug26884 | 34 +++++++++++++++++++ 3 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 tests/bugs/moddata_3/bug26884 diff --git a/src/IntAna/IntAna_QuadQuadGeo.cxx b/src/IntAna/IntAna_QuadQuadGeo.cxx index fb9a876959..bd4419cc87 100644 --- a/src/IntAna/IntAna_QuadQuadGeo.cxx +++ b/src/IntAna/IntAna_QuadQuadGeo.cxx @@ -118,8 +118,8 @@ class AxeOperator { //======================================================================= AxeOperator::AxeOperator(const gp_Ax1& A1,const gp_Ax1& A2) { - myEPSILON_DISTANCE=0.00000000000001; - myEPSILON_AXES_PARA=0.000000000001; + myEPSILON_DISTANCE=1.0e-14; + myEPSILON_AXES_PARA=Precision::Angular(); Axe1=A1; Axe2=A2; //--------------------------------------------------------------------- @@ -268,12 +268,12 @@ IntAna_QuadQuadGeo::IntAna_QuadQuadGeo(void) //======================================================================= void IntAna_QuadQuadGeo::InitTolerances() { - myEPSILON_DISTANCE = 0.00000000000001; - myEPSILON_ANGLE_CONE = 0.000000000001; - myEPSILON_MINI_CIRCLE_RADIUS = 0.000000001; - myEPSILON_CYLINDER_DELTA_RADIUS = 0.0000000000001; - myEPSILON_CYLINDER_DELTA_DISTANCE= 0.0000001; - myEPSILON_AXES_PARA = 0.000000000001; + myEPSILON_DISTANCE = 1.0e-14; + myEPSILON_ANGLE_CONE = Precision::Angular(); + myEPSILON_MINI_CIRCLE_RADIUS = 0.01*Precision::Confusion(); + myEPSILON_CYLINDER_DELTA_RADIUS = 1.0e-13; + myEPSILON_CYLINDER_DELTA_DISTANCE= Precision::Confusion(); + myEPSILON_AXES_PARA = Precision::Angular(); } //======================================================================= //function : IntAna_QuadQuadGeo diff --git a/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx b/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx index 377d8c2326..fed0712d74 100644 --- a/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx +++ b/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx @@ -1022,7 +1022,13 @@ stCoeffsValue::stCoeffsValue( const gp_Cylinder& theCyl1, } } - if(Abs(aDetV1V2) < aNulValue) + // In point of fact, every determinant (aDelta1, aDelta2 and aDelta3) is + // cross-product between directions (i.e. sine of angle). + // If sine is too small then sine is (approx.) equal to angle itself. + // Therefore, in this case we should compare sine with angular tolerance. + // This constant is used for check if axes are parallel (see constructor + // AxeOperator::AxeOperator(...) in IntAna_QuadQuadGeo.cxx file). + if(Abs(aDetV1V2) < Precision::Angular()) { Standard_Failure::Raise("Error. Exception in divide by zerro (IntCyCyTrim)!!!!"); } diff --git a/tests/bugs/moddata_3/bug26884 b/tests/bugs/moddata_3/bug26884 new file mode 100644 index 0000000000..6bb33bb3d9 --- /dev/null +++ b/tests/bugs/moddata_3/bug26884 @@ -0,0 +1,34 @@ +puts "================" +puts "OCC26884" +puts "================" +puts "" +############################################################## +# Cylinder/Cylinder intersection algorithm throws an exception +############################################################## + +set max_time 0.1 + +restore [locate_data_file bug26884-f1.brep] f1 +restore [locate_data_file bug26884-f2.brep] f2 + +dchrono cr reset +dchrono cr start + +set info [bopcurves f1 f2 -2d] + +dchrono cr stop + +if {![regexp {has no 3d curves} $info] || + ![regexp {has no 3d points} $info] } { + puts "Error: wrong output" +} + +set logTime [dchrono cr show] + +regexp {CPU user time: ([-0-9.+eE]+) seconds} $logTime full z + +if { $z > ${max_time} } { + puts "Elapsed time ($z) is more than ${max_time} seconds - Error" +} else { + puts "Elapsed time ($z) is less than ${max_time} seconds - OK" +} -- 2.39.5