diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx index 336ff024a9..c6dc7b6707 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx @@ -401,13 +401,21 @@ GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const { Standard_Real TolConf = Precision::Confusion(); Standard_Real TolAng = Precision::Angular(); + Standard_Real TolConeSemiAng = Precision::Confusion(); switch (myBasisCurve->GetType()) { case GeomAbs_Line: { gp_Ax1 Axe = myBasisCurve->Line().Position(); if (myAxis.IsParallel(Axe, TolAng)) - return GeomAbs_Cylinder; + { + gp_Pnt P = Value(0., 0.); + Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); + if (R > TolConf) + { + return GeomAbs_Cylinder; + } + } else if (myAxis.IsNormal(Axe, TolAng)) return GeomAbs_Plane; else @@ -425,16 +433,27 @@ GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const gp_Vec vlin(pf,pl); gp_Vec vaxe(myAxis.Direction()); Standard_Real projlen = Abs(vaxe.Dot(vlin)); - Standard_Real aTolConf = len*TolAng; - if ((len - projlen) <= aTolConf) - return GeomAbs_Cylinder; - else if (projlen <= aTolConf) + if ((len - projlen) <= TolConf) + { + gp_Pnt P = Value(0., 0.); + Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); + if (R > TolConf) + { + return GeomAbs_Cylinder; + } + } + else if (projlen <= TolConf) return GeomAbs_Plane; } gp_Vec V(myAxis.Location(), myBasisCurve->Line().Location()); gp_Vec W(Axe.Direction()); - if (Abs(V.DotCross(myAxis.Direction(), W)) <= TolConf) + gp_Vec AxisDir(myAxis.Direction()); + Standard_Real proj = Abs(W.Dot(AxisDir)); + if (Abs(V.DotCross(AxisDir, W)) <= TolConf && + (proj >= TolConeSemiAng && proj <= 1. - TolConeSemiAng)) + { return GeomAbs_Cone; + } } break; }//case GeomAbs_Line: diff --git a/tests/bugs/modalg_6/bug28261 b/tests/bugs/modalg_6/bug28261 new file mode 100644 index 0000000000..8a2a6d7c5d --- /dev/null +++ b/tests/bugs/modalg_6/bug28261 @@ -0,0 +1,29 @@ +puts "========" +puts "OCC28261" +puts "========" +puts "" +################################################# +# Chamfer fails on edges placed on quasi-planar cone +################################################# + +brestore [locate_data_file bug28261_face.brep] f +brestore [locate_data_file bug28261_hexaprism.brep] h + +explode f E +mkcurve c f_1 +cvalue c 0 x y z dx dy dz +revol rev f $x $y $z $dx $dy $dz 360 + +bcut r rev h + +explode r F +explode r_9 E +chamf r r r_9_1 r_9 0.1 0.1 r_9_2 r_9 0.1 0.1 r_9_3 r_9 0.1 0.1 r_9_4 r_9 0.1 0.1 r_9_5 r_9 0.1 0.1 r_9_6 r_9 0.1 0.1 + +explode r F +explode r_4 E +chamf result r r_4_1 r_4 0.1 0.1 r_4_2 r_4 0.1 0.1 r_4_3 r_4 0.1 0.1 r_4_4 r_4 0.1 0.1 r_4_5 r_4 0.1 0.1 r_4_6 r_4 0.1 0.1 r_4_8 r_4 0.1 0.1 + +checkshape result +checknbshapes result -solid 1 -face 18 -edge 36 -vertex 22 +checkprops result -v 17158.1 -s 4073.25 \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug28266 b/tests/bugs/modalg_6/bug28266 new file mode 100644 index 0000000000..49230e5232 --- /dev/null +++ b/tests/bugs/modalg_6/bug28266 @@ -0,0 +1,28 @@ +puts "========" +puts "OCC28266" +puts "========" +puts "" +################################################# +# Boolean CUT produces incorrect result with quasi-planar cone +################################################# + +brestore [locate_data_file bug28261_face.brep] f +brestore [locate_data_file bug28266_tool1.brep] t1 +brestore [locate_data_file bug28266_tool2.brep] t2 + +explode f E +mkcurve c f_1 +cvalue c 0 x y z dx dy dz +revol rev f $x $y $z $dx $dy $dz 360 + +bcut r rev t1 + +checkshape r +checknbshapes r -solid 1 -face 86 -edge 267 -vertex 184 +checkprops r -v 17215.5 -s 4033.34 + +bcut result r t2 + +checkshape result +checknbshapes result -solid 1 -face 90 -edge 278 -vertex 190 +checkprops result -v 17215.5 -s 4033.52 \ No newline at end of file