From 0038de11f4bacfa362473f297d0f73379336d2fe Mon Sep 17 00:00:00 2001 From: osa Date: Tue, 25 May 2021 17:57:48 +0300 Subject: [PATCH] 0032388: Visualization - provide ray-picking interface with zero tolerance for rectangular frustum --- src/Select3D/Select3D_SensitiveEntity.hxx | 2 +- .../SelectMgr_RectangularFrustum.cxx | 4 +- src/SelectMgr/SelectMgr_SelectionManager.cxx | 2 +- src/SelectMgr/SelectMgr_ToleranceMap.cxx | 2 +- src/SelectMgr/SelectMgr_ToleranceMap.hxx | 2 +- src/ViewerTest/ViewerTest.cxx | 4 +- tests/vselect/axis/A3 | 55 +++++++++++++++++++ 7 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 tests/vselect/axis/A3 diff --git a/src/Select3D/Select3D_SensitiveEntity.hxx b/src/Select3D/Select3D_SensitiveEntity.hxx index 3015a14d5b..1d745239a1 100644 --- a/src/Select3D/Select3D_SensitiveEntity.hxx +++ b/src/Select3D/Select3D_SensitiveEntity.hxx @@ -50,7 +50,7 @@ public: //! Allows to manage sensitivity of a particular sensitive entity void SetSensitivityFactor (const Standard_Integer theNewSens) { - Standard_ASSERT_RAISE (theNewSens > 0, "Error! Selection sensitivity have positive value."); + Standard_ASSERT_RAISE (theNewSens >= 0, "Error! Selection sensitivity should not be negative value."); mySFactor = theNewSens; } diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index 1cd8dff2d4..071cf1b259 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -364,8 +364,8 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_RectangularFrustum::ScaleAndTransfor Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point || mySelectionType == SelectMgr_SelectionType_Box, "Error! SelectMgr_RectangularFrustum::ScaleAndTransform() should be called after selection frustum initialization"); - Standard_ASSERT_RAISE (theScaleFactor > 0, - "Error! Pixel tolerance for selection should be greater than zero"); + Standard_ASSERT_RAISE (theScaleFactor >= 0, + "Error! Pixel tolerance for selection should not be negative"); Handle(SelectMgr_RectangularFrustum) aRes = new SelectMgr_RectangularFrustum(); const Standard_Boolean isToScale = theScaleFactor != 1; diff --git a/src/SelectMgr/SelectMgr_SelectionManager.cxx b/src/SelectMgr/SelectMgr_SelectionManager.cxx index 5aaad68ab4..8ba04c4b15 100644 --- a/src/SelectMgr/SelectMgr_SelectionManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectionManager.cxx @@ -574,7 +574,7 @@ void SelectMgr_SelectionManager::SetSelectionSensitivity (const Handle(SelectMgr const Standard_Integer theMode, const Standard_Integer theNewSens) { - Standard_ASSERT_RAISE (theNewSens > 0, "Error! Selection sensitivity have positive value."); + Standard_ASSERT_RAISE (theNewSens >= 0, "Error! Selection sensitivity should not be negative value."); if (theObject.IsNull()) { return; diff --git a/src/SelectMgr/SelectMgr_ToleranceMap.cxx b/src/SelectMgr/SelectMgr_ToleranceMap.cxx index bdea8cc488..9246063ff1 100644 --- a/src/SelectMgr/SelectMgr_ToleranceMap.cxx +++ b/src/SelectMgr/SelectMgr_ToleranceMap.cxx @@ -78,7 +78,7 @@ void SelectMgr_ToleranceMap::Decrement (const Standard_Integer& theTolerance) if (theTolerance == myLargestKey && *aFreq == 0) { - myLargestKey = 0; + myLargestKey = -1; for (NCollection_DataMap::Iterator anIter (myTolerances); anIter.More(); anIter.Next()) { if (anIter.Value() != 0) diff --git a/src/SelectMgr/SelectMgr_ToleranceMap.hxx b/src/SelectMgr/SelectMgr_ToleranceMap.hxx index 098cef202e..1af12cc082 100644 --- a/src/SelectMgr/SelectMgr_ToleranceMap.hxx +++ b/src/SelectMgr/SelectMgr_ToleranceMap.hxx @@ -40,7 +40,7 @@ public: //! Returns a current tolerance that must be applied Standard_Integer Tolerance() const { - if (myLargestKey < Precision::Confusion()) + if (myLargestKey < 0) { return 2; // default tolerance value } diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 4393c5c3c3..34bdb9f079 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -1898,9 +1898,9 @@ struct ViewerTest_AspectsChangeSet Message::SendFail() << "Error: the max parameter value should be greater than zero (specified " << MaxParamValue << ")"; isOk = Standard_False; } - if (Sensitivity <= 0 && ToSetSensitivity) + if (Sensitivity < 0 && ToSetSensitivity) { - Message::SendFail() << "Error: sensitivity parameter value should be positive (specified " << Sensitivity << ")"; + Message::SendFail() << "Error: sensitivity parameter value should not be negative (specified " << Sensitivity << ")"; isOk = Standard_False; } if (ToSetHatch == 1 && StdHatchStyle < 0 && PathToHatchPattern == "") diff --git a/tests/vselect/axis/A3 b/tests/vselect/axis/A3 new file mode 100644 index 0000000000..88aa4215e3 --- /dev/null +++ b/tests/vselect/axis/A3 @@ -0,0 +1,55 @@ +puts "========" +puts "0032388: Visualization - provide ray-picking interface with zero tolerance for rectangular frustum" +puts "========" +puts "" + +pload MODELING VISUALIZATION +box b 100 200 300 +vinit View1 +puts "Display box" +vdisplay -dispMode 1 b +vfit +vselprops -pixtol 0 +vaspects b -sensitivity 0 4 +set box_sens4 [vmoveto 321 319] +vdump ${imagedir}/${casename}_box_sens4.png +regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${box_sens4} full p +checkpoint "box_sens4" $p {100 200 0} 0.001 +vaspects b -sensitivity 0 0 +set box_sens0_out [vmoveto 321 319] +vdump ${imagedir}/${casename}_box_sens0_out.png +if {[string first "e+308" $box_sens0_out] == -1} { + puts "Faulty : Selection of box with sensitivity 0" +} +set box_sens0_in [vmoveto 319 317] +vdump ${imagedir}/${casename}_box_sens0_in.png +regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${box_sens0_in} full p +checkpoint "box_sens0_in" $p {100.00000000000003 196.92152736525867 0.4127082000112523} 0.001 + +puts "" +puts "Display 2d point" +vpoint p 320 318 -2d +vaspects p -markerType . +set point_sens12_out [vmoveto 321 319] +vdump ${imagedir}/${casename}_point_sens12_out.png +regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${point_sens12_out} full p +checkpoint "point_sens12_out" $p {104.7974449617403 -102.98278630143884 -346.41016151377545} 0.001 +set point_sens12_in [vmoveto 319 317] +vdump ${imagedir}/${casename}_point_sens12_in.png +regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${point_sens12_in} full p +checkpoint "point_sens12_in" $p {104.7974449617403 -102.98278630143884 -346.41016151377545} 0.001 +vaspects p -sensitivity 0 0 +set point_sens0_out [vmoveto 321 319] +vdump ${imagedir}/${casename}_point_sens0_out.png +if {[string first "e+308" $point_sens0_out] == -1} { + puts "Faulty : Selection of point with sensitivity 0" +} +set point_sens0_eq [vmoveto 320 318] +vdump ${imagedir}/${casename}_point_sens0_eq.png +if {[string first "e+308" $point_sens0_eq] == -1} { + puts "Faulty : Selection of point with sensitivity 0" +} +set point_sens0_in [vmoveto 319 317] +vdump ${imagedir}/${casename}_point_sens0_in.png +regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${point_sens0_in} full p +checkpoint "point_sens0_in" $p {100.00000000000003 196.92152736525867 0.41270820001116704} 0.001