From 2111e967034186b00602c349ef367c7f369696f4 Mon Sep 17 00:00:00 2001 From: abv Date: Fri, 25 Aug 2017 16:23:05 +0300 Subject: [PATCH] 0028780: HLR with focus does not seem to work Method HLRBRep_Curve::D1() is corrected to apply transformation to a point according to current projection parameters --- src/HLRBRep/HLRBRep_Curve.cxx | 42 +++++++++++------------------------ tests/bugs/modalg_7/bug28780 | 17 ++++++++++++++ 2 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 tests/bugs/modalg_7/bug28780 diff --git a/src/HLRBRep/HLRBRep_Curve.cxx b/src/HLRBRep/HLRBRep_Curve.cxx index b4d827b5c3..34fdf31259 100644 --- a/src/HLRBRep/HLRBRep_Curve.cxx +++ b/src/HLRBRep/HLRBRep_Curve.cxx @@ -345,27 +345,15 @@ void HLRBRep_Curve::D1 (const Standard_Real U, // 1 - ---- f (1 - ----) // f f - /* gp_Pnt P3D; - gp_Vec V13D; - HLRBRep_BCurveTool::D1(myCurve,U,P3D,V13D); - P3D .Transform(((HLRAlgo_Projector*) myProj)->Transformation()); - V13D.Transform(((HLRAlgo_Projector*) myProj)->Transformation()); - if (((HLRAlgo_Projector*) myProj)->Perspective()) { - Standard_Real f = ((HLRAlgo_Projector*) myProj)->Focus(); - Standard_Real R = 1. - P3D.Z()/f; - Standard_Real e = V13D.Z()/(f*R*R); - P.SetCoord(P3D .X()/R , P3D .Y()/R ); - V.SetCoord(V13D.X()/R + P3D.X()*e, V13D.Y()/R + P3D.Y()*e); - } - else { - P.SetCoord(P3D .X(),P3D .Y()); - V.SetCoord(V13D.X(),V13D.Y()); - } */ gp_Pnt P3D; gp_Vec V13D; HLRBRep_BCurveTool::D1(myCurve,U,P3D,V13D); - if (((HLRAlgo_Projector*) myProj)->Perspective()) { - Standard_Real f = ((HLRAlgo_Projector*) myProj)->Focus(); + if (myProj->Perspective()) + { + P3D .Transform(myProj->Transformation()); + V13D.Transform(myProj->Transformation()); + + Standard_Real f = myProj->Focus(); Standard_Real R = 1. - P3D.Z()/f; Standard_Real e = V13D.Z()/(f*R*R); P.SetCoord(P3D .X()/R , P3D .Y()/R ); @@ -373,12 +361,7 @@ void HLRBRep_Curve::D1 (const Standard_Real U, } else { //OCC155 - ((HLRAlgo_Projector*) myProj)->Project(P3D,V13D,P,V); - /* ((HLRAlgo_Projector*) myProj)->Project(P3D,P); - gp_Pnt2d opop; - gp_Pnt uiui(V13D.X(),V13D.Y(),V13D.Z()); - ((HLRAlgo_Projector*) myProj)->Project(uiui,opop); - V.SetCoord(opop.X(),opop.Y()); */ + myProj->Project(P3D,V13D,P,V); } } @@ -402,11 +385,12 @@ void HLRBRep_Curve::D2 (const Standard_Real U, gp_Pnt P3D; gp_Vec V13D,V23D; HLRBRep_BCurveTool::D2(myCurve,U,P3D,V13D,V23D); - P3D .Transform(((HLRAlgo_Projector*) myProj)->Transformation()); - V13D.Transform(((HLRAlgo_Projector*) myProj)->Transformation()); - V23D.Transform(((HLRAlgo_Projector*) myProj)->Transformation()); - if (((HLRAlgo_Projector*) myProj)->Perspective()) { - Standard_Real f = ((HLRAlgo_Projector*) myProj)->Focus(); + P3D .Transform(myProj->Transformation()); + V13D.Transform(myProj->Transformation()); + V23D.Transform(myProj->Transformation()); + if (myProj->Perspective()) + { + Standard_Real f = myProj->Focus(); Standard_Real R = 1. - P3D.Z() / f; Standard_Real q = f*R*R; Standard_Real e = V13D.Z()/q; diff --git a/tests/bugs/modalg_7/bug28780 b/tests/bugs/modalg_7/bug28780 new file mode 100644 index 0000000000..ee89c9fc70 --- /dev/null +++ b/tests/bugs/modalg_7/bug28780 @@ -0,0 +1,17 @@ +puts "=======" +puts "0028780" +puts "=======" +puts "" +################################################## +# HLR with focus does not seem to work +################################################## + +box a 10 20 50 +vdisplay a +vtop +vfit +vcamera -persp +vhlrtype algo +vhlr on + +checkview -screenshot -3d -path ${imagedir}/${test_image}.png