//==============================================================================
//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)
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;
}
" 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]"
--- /dev/null
+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
--- /dev/null
+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