diff --git a/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx b/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx index 81b51c859d..ae47f5298b 100644 --- a/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx +++ b/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx @@ -603,17 +603,20 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P, { gp_Vec Norm = aVecD1U.Crossed (aVecD1V); Standard_Real tt = Norm.Magnitude(); - tt = Abs (Norm.Dot (V)) / (tt * Par); - if (tt > maxscal) + if (tt > gp::Resolution()) { - maxscal = tt; - L = gp_Lin (P, V); - _Par = Par; - ptfound = Standard_True; - if (maxscal>0.2) + tt = Abs (Norm.Dot (V)) / (tt * Par); + if (tt > maxscal) { - myParamOnEdge=svmyparam; - return 0; + maxscal = tt; + L = gp_Lin (P, V); + _Par = Par; + ptfound = Standard_True; + if (maxscal>0.2) + { + myParamOnEdge=svmyparam; + return 0; + } } } } diff --git a/src/IntCurve/IntCurve_IntCurveCurveGen.gxx b/src/IntCurve/IntCurve_IntCurveCurveGen.gxx index bc00859aad..5aa472afa8 100644 --- a/src/IntCurve/IntCurve_IntCurveCurveGen.gxx +++ b/src/IntCurve/IntCurve_IntCurveCurveGen.gxx @@ -49,6 +49,11 @@ void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C, { Standard_Real paraminf = TheCurveTool::FirstParameter(C); Standard_Real paramsup = TheCurveTool::LastParameter(C); + if (Precision::IsInfinite(paraminf) && Precision::IsInfinite(paramsup)) { + done = Standard_False; + return; + } + // if(paraminf>-Precision::Infinite()) { if(paramsup #include #include #include @@ -305,7 +306,12 @@ Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle (const ThePSurfac gp_XYZ XYZ2=P3.XYZ()-P2.XYZ(); gp_XYZ XYZ3=P1.XYZ()-P3.XYZ(); gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1)); - NormalVector.Normalize(); + Standard_Real aNormLen = NormalVector.Magnitude(); + if (aNormLen < gp::Resolution()) { + return 0.; + } + // + NormalVector.Divide(aNormLen); //-- Standard_Real PolarDistance = NormalVector * P1.XYZ(); //-- Calcul du point u,v au centre du triangle Standard_Real u = (u1+u2+u3)/3.0; @@ -625,8 +631,14 @@ void IntCurveSurface_Polyhedron::PlaneEquation (const Standard_Integer Triang, if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; } NormalVector= (v1^v2)+(v2^v3)+(v3^v1); - NormalVector.Normalize(); - PolarDistance = NormalVector * Point(i1).XYZ(); + Standard_Real aNormLen = NormalVector.Modulus(); + if (aNormLen < gp::Resolution()) { + PolarDistance = 0.; + } + else { + NormalVector.Divide(aNormLen); + PolarDistance = NormalVector * Point(i1).XYZ(); + } } //======================================================================= //function : Contain diff --git a/src/IntPatch/IntPatch_Polyhedron.cxx b/src/IntPatch/IntPatch_Polyhedron.cxx index 5433adb36a..55fcae407b 100644 --- a/src/IntPatch/IntPatch_Polyhedron.cxx +++ b/src/IntPatch/IntPatch_Polyhedron.cxx @@ -207,7 +207,12 @@ Standard_Real IntPatch_Polyhedron::DeflectionOnTriangle gp_XYZ XYZ2=P3.XYZ()-P2.XYZ(); gp_XYZ XYZ3=P1.XYZ()-P3.XYZ(); gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1)); - NormalVector.Normalize(); + Standard_Real aNormLen = NormalVector.Magnitude(); + if (aNormLen < gp::Resolution()) { + return 0.; + } + // + NormalVector.Divide(aNormLen); //-- Calcul du point u,v au centre du triangle Standard_Real u = (u1+u2+u3)/3.0; Standard_Real v = (v1+v2+v3)/3.0; @@ -548,8 +553,14 @@ void IntPatch_Polyhedron::PlaneEquation (const Standard_Integer Triang, if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; } NormalVector= (v1^v2)+(v2^v3)+(v3^v1); - NormalVector.Normalize(); - PolarDistance = NormalVector * Point(i1).XYZ(); + Standard_Real aNormLen = NormalVector.Modulus(); + if (aNormLen < gp::Resolution()) { + PolarDistance = 0.; + } + else { + NormalVector.Divide(aNormLen); + PolarDistance = NormalVector * Point(i1).XYZ(); + } } //======================================================================= //function : Contain diff --git a/src/Intf/Intf.cxx b/src/Intf/Intf.cxx index d59b33517d..23c104e61c 100644 --- a/src/Intf/Intf.cxx +++ b/src/Intf/Intf.cxx @@ -33,8 +33,14 @@ void Intf::PlaneEquation (const gp_Pnt& P1, gp_XYZ v2=P3.XYZ()-P2.XYZ(); gp_XYZ v3=P1.XYZ()-P3.XYZ(); NormalVector= (v1^v2)+(v2^v3)+(v3^v1); - NormalVector.Normalize(); - PolarDistance = NormalVector * P1.XYZ(); + Standard_Real aNormLen = NormalVector.Modulus(); + if (aNormLen < gp::Resolution()) { + PolarDistance = 0.; + } + else { + NormalVector.Divide(aNormLen); + PolarDistance = NormalVector * P1.XYZ(); + } } diff --git a/tests/bugs/modalg_7/bug28844_1 b/tests/bugs/modalg_7/bug28844_1 new file mode 100644 index 0000000000..25a9a0c159 --- /dev/null +++ b/tests/bugs/modalg_7/bug28844_1 @@ -0,0 +1,25 @@ +puts "========" +puts "OCC28844" +puts "========" +puts "" +####################################################### +# Regression vs 7.1.0: Exception is raised by the solid classification algorithm +####################################################### + +restore [locate_data_file bug28844_Body.brep] b + +point p1 0 -10 0 + +if {![regexp "The point is" [bclassify b p1]]} { + puts "Error: The Solid classification algorithm fails to classify the point" +} + +point p2 10 10 10 +if {![regexp "The point is" [bclassify b p2]]} { + puts "Error: The Solid classification algorithm fails to classify the point" +} + +point p3 0 10 0 +if {![regexp "The point is" [bclassify b p3]]} { + puts "Error: The Solid classification algorithm fails to classify the point" +} diff --git a/tests/bugs/modalg_7/bug28844_2 b/tests/bugs/modalg_7/bug28844_2 new file mode 100644 index 0000000000..915030050f --- /dev/null +++ b/tests/bugs/modalg_7/bug28844_2 @@ -0,0 +1,13 @@ +puts "========" +puts "OCC28844" +puts "========" +puts "" +####################################################### +# Regression vs 7.1.0: Exception is raised by the solid classification algorithm +####################################################### + +restore [locate_data_file bug28844_Body.brep] b + +if {![regexp "Faulties" [bopargcheck b]]} { + puts "Error: bopargcheck fails to find faulty in the shape" +} \ No newline at end of file diff --git a/tests/bugs/modalg_7/bug28844_3 b/tests/bugs/modalg_7/bug28844_3 new file mode 100644 index 0000000000..c376c28c2f --- /dev/null +++ b/tests/bugs/modalg_7/bug28844_3 @@ -0,0 +1,14 @@ +puts "========" +puts "OCC28844" +puts "========" +puts "" +####################################################### +# Regression vs 7.1.0: Exception is raised by the solid classification algorithm +####################################################### + +restore [locate_data_file bug28844_Body.brep] b +restore [locate_data_file bug28844_Face.brep] f + +bcommon result b f +checknbshapes result -shape 1 +checkprops result -s empty \ No newline at end of file