diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 389e6b8f58..7eeaf102e1 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -812,6 +812,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha //============================================================================== //function : VHLR //purpose : hidden lines removal algorithm +//draw args: vhlr is_enabled={on|off} [show_hidden={1|0}] //============================================================================== static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv) @@ -822,24 +823,62 @@ static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv) return 1; } - if (argc != 2) + if (argc < 2) { di << argv[0] << ": Wrong number of command arguments.\n" << "Type help " << argv[0] << " for more information.\n"; return 1; } + // Enable or disable HLR mode. Standard_Boolean isHLROn = (!strcasecmp (argv[1], "on")) ? Standard_True : Standard_False; - if (isHLROn == MyHLRIsOn) + if (isHLROn != MyHLRIsOn) { - return 0; + MyHLRIsOn = isHLROn; + ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn); } - MyHLRIsOn = isHLROn; - ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn); + // Show or hide hidden lines in HLR mode. + Standard_Boolean isCurrentShowHidden + = ViewerTest::GetAISContext()->DefaultDrawer()->DrawHiddenLine(); + Standard_Boolean isShowHidden = + (argc == 3) ? (atoi(argv[2]) == 1 ? Standard_True : Standard_False) + : isCurrentShowHidden; + + + if (isShowHidden != isCurrentShowHidden) + { + if (isShowHidden) + { + ViewerTest::GetAISContext()->DefaultDrawer()->EnableDrawHiddenLine(); + } + else + { + ViewerTest::GetAISContext()->DefaultDrawer()->DisableDrawHiddenLine(); + } + + // Redisplay shapes. + if (MyHLRIsOn) + { + AIS_ListOfInteractive aListOfShapes; + ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes); + + for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next()) + { + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (anIter.Value()); + if (aShape.IsNull()) + { + continue; + } + aShape->Redisplay(); + } + } + } + + ViewerTest::CurrentView()->Update(); return 0; } @@ -6183,9 +6222,10 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) " rot - texture rotation angle in degrees", __FILE__, VTextureEnv, group); theCommands.Add("vhlr" , - "is_enabled={on|off}" + "is_enabled={on|off} [show_hidden={1|0}]" " - Hidden line removal algorithm:" - " - is_enabled: if is on HLR algorithm is applied\n", + " - is_enabled: if is on HLR algorithm is applied\n" + " - show_hidden: if equals to 1, hidden lines are drawn as dotted ones.\n", __FILE__,VHLR,group); theCommands.Add("vhlrtype" , "algo_type={algo|polyalgo} [shape_1 ... shape_n]" diff --git a/tests/bugs/vis/bug24388_1 b/tests/bugs/vis/bug24388_1 new file mode 100644 index 0000000000..08553ada14 --- /dev/null +++ b/tests/bugs/vis/bug24388_1 @@ -0,0 +1,37 @@ +puts "===========" +puts "OCC24388" +puts "===========" +puts "" +################################################################## +# 0024388: Option to enable visualization of hidden lines in DRAW +# Checks if dotted hidden lines are highlighted properly. +################################################################## + +box b 15 0 0 10 10 10 +vinit +vdisplay b +vrotate 35 0 0 +vfit +vhlr on 1 +vhlrtype algo a + +vmoveto 76 304 + +set x_coord 115 +set y_coord 203 +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of dotted hidden lines in the box is wrong." +} + +set x_coord 122 +set y_coord 200 + +checkcolor $x_coord $y_coord 0 0 0 + +if { $stat != 1 } { + puts "Error : Highlighting of dotted hidden lines in the box is wrong." +} + +set only_screen 1 \ No newline at end of file diff --git a/tests/bugs/vis/bug24388_2 b/tests/bugs/vis/bug24388_2 new file mode 100644 index 0000000000..e7d0e7c7fe --- /dev/null +++ b/tests/bugs/vis/bug24388_2 @@ -0,0 +1,44 @@ +puts "===========" +puts "OCC24388" +puts "===========" +puts "" +################################################################## +# 0024388: Option to enable visualization of hidden lines in DRAW +# Checks if dotted hidden lines are displayed properly in HLR mode. +################################################################## + +set m_pi2 1,57 +pcone a 5 0 10 +vinit +vdisplay a +vrotate 35 0 0 +vfit +vhlr on 0 +vhlrtype algo a +vrotate -$m_pi2 -$m_pi2 0 +vfit + +set x_coord 131 +set y_coord 240 + +checkcolor $x_coord $y_coord 0 0 0 + +if { $stat != 1 } { + puts "Error : Drawing hidden lines as dotted lines produces wrong result." +} + +vdump $imagedir/${casename}_without_lines.png + +vhlr on 1 + +set x_coord 131 +set y_coord 240 + +# Check display of dotted hidden lines +checkcolor $x_coord $y_coord 0.2 0.2 0.2 + +if { $stat != 1 } { + puts "Error : Drawing hidden lines as dotted lines produces wrong result." +} + +vdump $imagedir/${casename}_with_lines.png \ No newline at end of file