From be7fc29e2a85bd19294713d9ceccc2d041c74be7 Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 6 Sep 2017 22:04:25 +0300 Subject: [PATCH] 0029086: Visualization, SelectMgr_ViewerSelector - drop Owners detected only by part of Entities within Box selection --- src/QABugs/QABugs_16.cxx | 59 ------------------- .../SelectMgr_SensitiveEntitySet.hxx | 3 + src/SelectMgr/SelectMgr_SortCriterion.hxx | 2 + src/SelectMgr/SelectMgr_ViewerSelector.cxx | 46 ++++++++++++--- tests/bugs/vis/bug25723 | 35 +++-------- tests/bugs/vis/bug26344 | 10 +--- tests/bugs/vis/bug60 | 37 ------------ tests/bugs/vis/bug61 | 26 -------- 8 files changed, 54 insertions(+), 164 deletions(-) delete mode 100755 tests/bugs/vis/bug60 delete mode 100755 tests/bugs/vis/bug61 diff --git a/src/QABugs/QABugs_16.cxx b/src/QABugs/QABugs_16.cxx index c96f711cc4..52f145afcf 100644 --- a/src/QABugs/QABugs_16.cxx +++ b/src/QABugs/QABugs_16.cxx @@ -634,63 +634,6 @@ static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, con return 0; } -static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - if(aContext.IsNull()) { - di << "use 'vinit' command before " << argv[0] << "\n"; - return 1; - } - if(argc < 5) { - di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window\n"; - return 1; - } - - Standard_Integer xmin = Draw::Atoi(argv[1]); - Standard_Integer ymin = Draw::Atoi(argv[2]); - Standard_Integer xmax = Draw::Atoi(argv[3]); - Standard_Integer ymax = Draw::Atoi(argv[4]); - - Handle(V3d_View) V3dView = ViewerTest::CurrentView(); - - Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager(); - EM->Select(xmin,ymin,xmax,ymax); - - return 0; -} - -static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - if(aContext.IsNull()) { - di << "use 'vinit' command before " << argv[0] << "\n"; - return 1; - } - if(argc < 7) { - di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n"; - return 1; - } - if (((argc - 1) % 2) != 0) { - di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n"; - return 1; - } - - Standard_Integer i, j, np = (argc-1) / 2; - TColgp_Array1OfPnt2d Polyline(1,np); - j = 1; - for (i = 1; i <= np; i++) { - Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1])); - j += 2; - } - - Handle(V3d_View) V3dView = ViewerTest::CurrentView(); - - aContext->Select (Polyline, V3dView, Standard_False); - aContext->UpdateCurrentViewer(); - - return 0; -} - static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { if(argc != 2) { @@ -758,8 +701,6 @@ void QABugs::Commands_16(Draw_Interpretor& theCommands) { theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group); theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group); theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group); - theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group); - theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group); theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group); theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group); theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group); diff --git a/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx b/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx index 0b1ce16f14..3aa05a78e3 100644 --- a/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx +++ b/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx @@ -70,6 +70,9 @@ public: //! Returns the entity with index theIndex in the set Standard_EXPORT const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById (const Standard_Integer theIndex) const; + //! Returns map of entities. + const SelectMgr_IndexedMapOfHSensitive& Sensitives() const { return mySensitives; } + private: SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH diff --git a/src/SelectMgr/SelectMgr_SortCriterion.hxx b/src/SelectMgr/SelectMgr_SortCriterion.hxx index 81f731d304..3fb98b347b 100644 --- a/src/SelectMgr/SelectMgr_SortCriterion.hxx +++ b/src/SelectMgr/SelectMgr_SortCriterion.hxx @@ -34,6 +34,7 @@ public: Standard_Real Tolerance; //!< tolerance used for selecting candidates Standard_Integer Priority; //!< selection priority Standard_Integer ZLayerPosition; //!< ZLayer rendering order index, stronger than a depth + Standard_Integer NbOwnerMatches; //!< overall number of entities collected for the same owner Standard_Boolean ToPreferClosest; //!< whether closest object is preferred even if has less priority public: @@ -46,6 +47,7 @@ public: Tolerance(0.0), Priority (0), ZLayerPosition (0), + NbOwnerMatches (0), ToPreferClosest (Standard_True) {} //! Comparison operator. diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 3157a3b931..e29538c8d6 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -248,21 +248,22 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive aCriterion.Tolerance = theEntity->SensitivityFactor() / 33.0; aCriterion.ToPreferClosest = preferclosest; - const Standard_Integer aPrevStoredIndex = mystored.FindIndex (anOwner); - if (aPrevStoredIndex != 0) + if (SelectMgr_SortCriterion* aPrevCriterion = mystored.ChangeSeek (anOwner)) { + ++aPrevCriterion->NbOwnerMatches; + aCriterion.NbOwnerMatches = aPrevCriterion->NbOwnerMatches; if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Box) { - SelectMgr_SortCriterion& aPrevCriterion = mystored.ChangeFromIndex (aPrevStoredIndex); - if (aCriterion > aPrevCriterion) + if (aCriterion > *aPrevCriterion) { updatePoint3d (aCriterion, theInversedTrsf, theMgr); - aPrevCriterion = aCriterion; + *aPrevCriterion = aCriterion; } } } else { + aCriterion.NbOwnerMatches = 1; updatePoint3d (aCriterion, theInversedTrsf, theMgr); mystored.Add (anOwner, aCriterion); } @@ -362,6 +363,9 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable { return; } + + const Standard_Integer aFirstStored = mystored.Extent() + 1; + Standard_Integer aStack[BVH_Constants_MaxTreeDepth]; Standard_Integer aHead = -1; for (;;) @@ -403,8 +407,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode); for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx) { - const Handle(SelectMgr_SensitiveEntity)& aSensitive = - anEntitySet->GetSensitiveById (anIdx); + const Handle(SelectMgr_SensitiveEntity)& aSensitive = anEntitySet->GetSensitiveById (anIdx); if (aSensitive->IsActiveForSelection()) { const Handle(SelectBasics_SensitiveEntity)& anEnt = aSensitive->BaseSensitive(); @@ -422,6 +425,35 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable --aHead; } } + + // in case of Box/Polyline selection - keep only Owners having all Entities detected + if (mySelectingVolumeMgr.IsOverlapAllowed() + || (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Box + && theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Polyline)) + { + return; + } + + for (Standard_Integer aStoredIter = mystored.Extent(); aStoredIter >= aFirstStored; --aStoredIter) + { + const SelectMgr_SortCriterion& aCriterion = mystored.FindFromIndex (aStoredIter); + const Handle(SelectBasics_EntityOwner)& anOwner = aCriterion.Entity->OwnerId(); + Standard_Integer aNbOwnerEntities = 0; + for (SelectMgr_IndexedMapOfHSensitive::Iterator aSensIter (anEntitySet->Sensitives()); aSensIter.More(); aSensIter.Next()) + { + if (aSensIter.Value()->BaseSensitive()->OwnerId() == anOwner) + { + if (++aNbOwnerEntities > aCriterion.NbOwnerMatches) + { + // Remove from index map. + // Considering NCollection_IndexedDataMap implementation, the values for lower indexes will not be modified. + // Hence, just keep iterating in backward direction. + mystored.RemoveFromIndex (aStoredIter); + break; + } + } + } + } } //======================================================================= diff --git a/tests/bugs/vis/bug25723 b/tests/bugs/vis/bug25723 index c0d6f9338c..f3a09cd5c2 100644 --- a/tests/bugs/vis/bug25723 +++ b/tests/bugs/vis/bug25723 @@ -1,31 +1,15 @@ puts "============" -puts "OCC25723" -puts "Calculate the center of rotation taking into account structure visibility" +puts "OCC25723 Calculate the center of rotation taking into account structure visibility" puts "============" puts "" -set x_start_sel_coord 100 -set y_start_sel_coord 104 - -set x_end_sel_coord 400 -set y_end_sel_coord 400 - -set x_mouse_start_coord 100 -set y_mouse_start_coord 100 - -set x_mouse_move_coord 300 -set y_mouse_move_coord 300 - -set x_check_coord 220 -set y_check_coord 50 - box b1 0 0 0 10 10 10 box b2 0 0 20 10 10 10 box b3 0 0 -20 10 10 10 box b4 0 0 40 10 10 10 -vinit View1 vclear +vinit View1 vaxo vsetdispmode 1 @@ -34,17 +18,12 @@ vselmode 6 1 vdisplay b1 b2 b3 b4 vfit -# select solid -vselect ${x_start_sel_coord} ${y_start_sel_coord} ${x_end_sel_coord} ${y_end_sel_coord} - -# hide selected solids +# select and hide boxes b2 b3 b4 +vselect 100 100 400 410 verase # rotation -vrotate -mouseStart ${x_mouse_start_coord} ${y_mouse_start_coord} -mouseMove ${x_mouse_move_coord} ${y_mouse_move_coord} - -if {"[vreadpixel ${x_check_coord} ${y_check_coord} rgb name]" != "GOLDENROD2"} { - puts "Error: Rotation is not correct" -} +vrotate -mouseStart 100 100 -mouseMove 300 300 +if {"[vreadpixel 220 50 rgb name]" != "GOLDENROD2"} { puts "Error: Rotation is not correct" } -checkview -screenshot -3d -path ${imagedir}/${test_image}.png +vdump ${imagedir}/${casename}.png diff --git a/tests/bugs/vis/bug26344 b/tests/bugs/vis/bug26344 index c7a0949c63..98c221b404 100644 --- a/tests/bugs/vis/bug26344 +++ b/tests/bugs/vis/bug26344 @@ -1,12 +1,8 @@ puts "============" -puts "CR26344" +puts "0026344: Visualization - provide a support of zoom persistent selection" puts "============" puts "" -########################################################################################## -puts "Visualization - provide a support of zoom persistent selection" -########################################################################################## - vclear vclose ALL vinit View1 w=409 h=409 @@ -31,7 +27,7 @@ vselect 387 77 if { [vreadpixel 387 77 rgb name] != "GRAY66" } { puts "Error picking zoom persistence object(s)" } vselect 0 0 -vselect 330 120 400 50 +vselect 330 120 410 50 if { [vreadpixel 387 77 rgb name] != "GRAY66" || [vreadpixel 352 96 rgb name] != "GRAY66" } { puts "Error selecting zoom persistence object(s)" } # 2) Rotate persistence @@ -70,7 +66,7 @@ vselect 0 0 vselect 50 223 235 395 if { [vreadpixel 132 300 rgb name] != "GRAY66" } { puts "Error selecting trihedron persistence object" } -vselect 50 380 400 50 +vselect 50 410 410 50 vstate -entities checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/vis/bug60 b/tests/bugs/vis/bug60 deleted file mode 100755 index b9ee45bfec..0000000000 --- a/tests/bugs/vis/bug60 +++ /dev/null @@ -1,37 +0,0 @@ -puts "========" -puts "OCC60" -puts "SAM723" -puts "BUC60916" -puts "========" - -vinit -box b 10 10 10 -vdisplay b -vfit -vaspects -setwidth 5 - -set x_coord 83 -set y_coord 337 - -if { [vreadpixel ${x_coord} ${y_coord} rgb name] != "YELLOW" } { - puts "Error : color is not yellow" -} - -set xmin 1 -set ymin 1 -set xmax 409 -set ymax 300 - -# Select part of box -OCC60 ${xmin} ${ymin} ${xmax} ${ymax} -OCC60 ${xmin} ${ymin} ${xmax} ${ymax} - -set Selection_R 0.8 -set Selection_G 0.8 -set Selection_B 0.8 - -if { [vreadpixel ${x_coord} ${y_coord} rgb name] != "GRAY80" } { - puts "Error : color is not gray" -} - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/vis/bug61 b/tests/bugs/vis/bug61 deleted file mode 100755 index a785c1ebc1..0000000000 --- a/tests/bugs/vis/bug61 +++ /dev/null @@ -1,26 +0,0 @@ -puts "========" -puts "OCC61" -puts "SAM723" -puts "BUC60919" -puts "========" - -vinit -vtrihedron trihedron - -set x_coord 205 -set y_coord 205 - -checkcolor $x_coord $y_coord 0.43 0.48 0.54 - -set xmin 1 -set ymin 1 -set xmax 409 -set ymax 205 - -# Select part of trihedron -OCC60 ${xmin} ${ymin} ${xmax} ${ymax} -OCC60 ${xmin} ${ymin} ${xmax} ${ymax} - -checkcolor $x_coord $y_coord 0.8 0.8 0.8 - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png -- 2.20.1