View Issue Details

IDProjectCategoryView StatusLast Update
0030484Open CASCADEOCCT:Visualizationpublic2024-04-08 19:08
Reporternds Assigned Tobugmaster  
PriorityhighSeveritymajor 
Status resolvedResolutionopen 
Product Version7.3.0 
Target Version7.9.0 
Summary0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
DescriptionSelectMgr_ViewerSelector relies on the following SelectMgr_SortCriterion properties for sorting picking results, which might be invalid in case of 2D persistent (Graphic3d_TMF_2d) presentations:
- Distance to the geometry center (SelectBasics_PickResult::DistToGeomCenter()).
  This property has no much sense for 2D objects.
- Depth from eye with tolerance.
  The tolerance can have a negative sign for transformation-persistence objects
  leading to invalid comparison results for objects having equal depth.
Steps To Reproduce
pload MODELING VISUALIZATION
vclear
vinit View1
vselprops dynHighlight -dispMode 1 -color WHITE

box b1  75 -250 0 200 200 200
box b2 175 -300 0 200 200 200

vdisplay b1 -2d topLeft -top -dispmode 1
vsetmaterial b1  PLASTIC
vsetcolor    b1 DEEPPINK2

vdisplay b2 -2d topLeft -top -dispmode 1
vsetmaterial b2 PLASTIC
vsetcolor    b2 PALEGREEN2

vmoveto 205 170

if { [vreadpixel 205 170 rgb name] != "WHITE" } { puts "Error: common area should be highlighted" }
if { [vreadpixel 150 170 rgb name] == "WHITE" } { puts "Error: box b1 should NOT be highlighted" }
if { [vreadpixel 330 170 rgb name] != "WHITE" } { puts "Error: box b2 should be highlighted" }
TagsNo tags attached.
Test case number

Attached Files

  • 30484_wrong_highlight.png (11,792 bytes)

Relationships

related to 0030686 closedbugmaster Visualization, SelectMgr_ViewerSelector - sorting issues of transformation-persistent objects 

Activities

nds

2019-02-07 13:55

developer  

30484_wrong_highlight.png (11,792 bytes)

git

2019-02-07 15:36

administrator   ~0082063

Branch CR30484 has been created by nds.

SHA-1: d812a0899284f8dc807f087cd77d6f68768924d7


Detailed log of new commits:

Author: nds
Date: Thu Feb 7 15:31:50 2019 +0300

    0030484: Visualization - 2d persistent: order of detection doesn't coincide with order of objects creation

kgv

2019-05-01 12:24

developer   ~0084087

Last edited: 2019-05-01 12:36

Zeroing MinDist for 2D objects is not really helpful - it can provide desired effect only within limited usage scenarios, while in other cases result will become worse.

Consider extending your test case with removal/redisplay of first box:
pload MODELING VISUALIZATION
vclear
vinit View1
vselprops dynHighlight -dispMode 1 -color WHITE

box b1  75 -250 0 200 200 200
box b2 175 -300 0 200 200 200

vdisplay b1 -2d topLeft -top -dispmode 1
vsetmaterial b1  PLASTIC
vsetcolor    b1 DEEPPINK2

vdisplay b2 -2d topLeft -top -dispmode 1
vsetmaterial b2 PLASTIC
vsetcolor    b2 PALEGREEN2

vremove b1
vdisplay b1 -2d topLeft -top -dispmode 1
vsetmaterial b1  PLASTIC
vsetcolor    b1 DEEPPINK2

The result will be that b1 will now visually overlap b2, but highlighting (with patch applied) will tend to highlight b2 behind b1.

The root cause of the issue is an attempt to display two overlapping 2D objects with the same depth, which in general case produce undefined behavior for both - selection and visualization.

OCCT visualization does NOT guarantee rendering order for objects within a single ZLayer and having the same rendering priority - the actual rendering order following the order of displaying objects in AIS_InteractiveContext is a side effect of usage of collections with well-defined ordering in memory like to achieve reproducibility of visual results, and easily messed up after objects movements in context (like selecting/deselecting objects leading to movements from one Priority to another).

So that in this particular use case it is really desired displaying objects with extra information (different display Priority, different ZLayer, artificially different Z) for producing coherent visual and selection results. Note that since Selection currently ignores Display Priority, this property still wouldn't help (although selection itself has its own independent Selection Priorities actually used for sorting).

git

2024-01-17 13:47

administrator   ~0114915

Branch CR30484_1 has been created by drochalo.

SHA-1: a567fa39bcdec515a8baaa3914a8118ddbbb9c40


Detailed log of new commits:

Author: drochalo
Date: Wed Jan 17 10:36:42 2024 +0000

    0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
    
    Added property to SelectableObject for selection focused on display priority.
    Modified SelectMgr_ViewerSelector CompareResults based on the focus priority property.
    Added tests for multiple types of sensitive entities.

git

2024-01-17 17:19

administrator   ~0114919

Branch CR30484_1 has been updated by drochalo.

SHA-1: 4d804fe1429d7730706223abef5e1e62d05c56f9


Detailed log of new commits:

Author: drochalo
Date: Wed Jan 17 14:18:15 2024 +0000

    0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
    
    Logic fix on SelectMgr_ViewerSelector::checkOverlap.

git

2024-01-17 20:52

administrator   ~0114920

Branch CR30484_1 has been updated forcibly by drochalo.

SHA-1: 6cb504444d0d3c2f5f647a2760072cd9bc49b586

git

2024-01-18 13:55

administrator   ~0114922

Branch CR30484_1 has been updated forcibly by drochalo.

SHA-1: ac9c7c51682a34d61ed7796d3606e980121730a6

drochalo

2024-01-18 13:56

developer   ~0114923

Dear Marina,
please review.

Tests on Jenkins shows no major issues: http://jenkins-test-10.nnov.opencascade.com/view/CR30484_1-master-drochalo/view/COMPARE/

mzernova

2024-01-19 17:09

developer   ~0114935

I think we have enough information about transform persistence and object priorities and do not need additional flags (myPriorityFocus).
Please use the available information to solve the task.

git

2024-01-19 18:32

administrator   ~0114938

Branch CR30484_1 has been updated by drochalo.

SHA-1: 29132df19d5e1d15ba9eab882cd6020c34e4da29


Detailed log of new commits:

Author: drochalo
Date: Fri Jan 19 15:31:35 2024 +0000

    0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
    
    Removed variable myPriorityFocus.
    Modified logic to perform selection focused on display priority only for selectable objects with 2d transform persistence.

git

2024-01-19 20:42

administrator   ~0114940

Branch CR30484_1 has been updated forcibly by drochalo.

SHA-1: f0836b137f50ce7eb2e7655f2fa07bca91a37106

drochalo

2024-01-22 13:13

developer   ~0114948

Dear Marina,

changes were done to use 2d transform persistence in the logic instead of myPriorityFocus.
New tests on jenkins present no major issues http://jenkins-test-10.nnov.opencascade.com/view/CR30484_1-master-drochalo/view/COMPARE/
Please review.

iko

2024-01-24 03:15

developer   ~0114961

if (aSelectable->Presentations().Size() > 0 && !aSelectable->TransformPersistence().IsNull())
{
  if (!aSelectable->Presentations().First().IsNull() && aSelectable->TransformPersistence()->Mode() == Graphic3d_TMF_2d)
  {
    aCriterion.IsPreferPriority = Standard_True;
    aCriterion.Priority = aSelectable->Presentations().First()->DisplayPriority();
  }
}


It seems new selection logic works only for the first presentation ignoring anything else. What happens with other ones?
The relationship between selection priority and display priority is unclear and work only with Graphic3d_TMF_2d. Selection priority is preferrable in case of selection itself rather than display priority.

git

2024-01-25 13:53

administrator   ~0114970

Branch CR30484_1 has been updated by drochalo.

SHA-1: 8a79943812d8ed2a91938b99667c86c4b2e83514


Detailed log of new commits:

Author: drochalo
Date: Wed Jan 24 11:31:48 2024 +0000

    0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
    
    Added display priority to the sorting criterion
    Modified vpriority command to change an object's selection priority.
    Set display priority to presentation with same display mode.
    Modified tests.

git

2024-01-25 16:26

administrator   ~0114976

Branch CR30484_1 has been updated forcibly by drochalo.

SHA-1: 87fd13fb2e80de79f983e15323d9921c58d0c814

iko

2024-01-25 22:45

developer   ~0114981

Last edited: 2024-01-26 04:13

...
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_Integer   DisplayPriority;  //!< display priority
Standard_Boolean   IsPreferPriority; //!< flag to signal comparison to be done over priority
...

It would be nice to have all priorities close to each other. Also it would be nice to have 'SelectionPriority' instead of just 'Priority' in this case.

...
Graphic3d_DisplayPriority aDisplayPriority = Graphic3d_DisplayPriority_Bottom;
if (aSelectable->TransformPersistence()->Mode() == Graphic3d_TMF_2d)
{
...

Please move 'aDisplayPriority' into the scope where it is really used.

...
aSelectable->DisplayMode();
SelectMgr_SortCriterion aCriterion;
...

Empty unused call of function.

...
if (aSelectable->DisplayMode() == aPrs->Mode())
{
...

Presentable object can not to have its own mode. In that case global parameter is used. Please look at 'HasDisplayMode' method' s documentation.

...
//=======================================================================
//function : VPriority
//purpose  : Prints or sets the display priority for an object
//=======================================================================
...

Unchanged piece of documentation.

...
if (aToSetSelection)
{
  Handle(SelectMgr_EntityOwner) anOwner = anIObj->GlobalSelOwner();
  if (!anOwner.IsNull())
  {
    anOwner->SetPriority (aPriority);
  }
  return 0;
}
...

Seems like selection priority is processed in the same way as display priority (I meand limits checks etc.). Selection and display priorities should be separated and have different flags to print and set. Maybe it worth to have separate method or command for selection priority. Please loook where other selection option is set.

...
if (Abs (Depth - theOther.Depth) <= Precision::Confusion())
{
  return MinDist < theOther.MinDist;
}



return Depth < theOther.Depth;
...

Extra double lines.

git

2024-02-09 14:33

administrator   ~0115059

Branch CR30484_1 has been updated by drochalo.

SHA-1: 7776cf5ace184a938e8d12fde457486e7ee5e148


Detailed log of new commits:

Author: drochalo
Date: Tue Jan 30 09:56:04 2024 +0000

    0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
    
    Changed test logic in checkOverlap to use Interactive Object context to set display priority.
    Code cleanup.

git

2024-02-12 20:09

administrator   ~0115071

Branch CR30484_1 has been updated forcibly by drochalo.

SHA-1: 33cc83b2fe41bfe8049c3e1a30274a1c6c58e418

drochalo

2024-02-14 12:19

developer   ~0115075

Dear Ilya,

the requested changes were made.
New tests on Jenkins show no major issues: http://jenkins-test-10.nnov.opencascade.com/view/CR30484_1-master-drochalo/view/COMPARE/
Please review.

iko

2024-04-03 19:44

developer   ~0115567

if (SelectionPriority > theOther.SelectionPriority)
{
  return true;
}
else if (SelectionPriority != theOther.SelectionPriority)
{
  return false;
}

if (DisplayPriority > theOther.DisplayPriority)
{
  return true;
}
else if (DisplayPriority != theOther.DisplayPriority)
{
  return false;
}

It is more readable to write 'if(something != theOther.something) return something > theOtherSomething;'

Graphic3d_DisplayPriority aDisplayPriority = Graphic3d_DisplayPriority_INVALID;
if (!anObj.IsNull())
{
  Handle(Prs3d_Presentation) aPrs = anObj->Presentation();
  if (!aPrs.IsNull())
  {
    aDisplayPriority = aPrs->DisplayPriority();
  }
}
aCriterion.DisplayPriority = aDisplayPriority;

There is no needs to use 'aDisplayPriority' variable. Everything can be done directly in 'aCriterion.DisplayPriority'

Please get rid of changes in 'ViewerTest_ObjectCommands.cxx' because there are no any actual changes.

git

2024-04-04 19:01

administrator   ~0115591

Branch CR30484_1 has been updated by drochalo.

SHA-1: 4a4be629746a8c53bdb24d871501e4e4d0891f81


Detailed log of new commits:

Author: drochalo
Date: Thu Apr 4 17:00:43 2024 +0100

    0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
    
    Code cleanup.

git

2024-04-08 12:02

administrator   ~0115633

Branch CR30484_1 has been updated forcibly by drochalo.

SHA-1: 0a2c31fa6774cb081aa5b337075e5d3fc17edfbb

drochalo

2024-04-08 17:14

developer   ~0115637

Dear Ilya,

the requested changes were made. I also updated the branch due to some issues on a few of the tests.
http://jenkins-test-10.nnov.opencascade.com/view/CR30484_1-master-drochalo/view/COMPARE/
Please review.

dpasukhi

2024-04-08 19:01

administrator   ~0115642

Need to do something with branch

git

2024-04-08 19:07

administrator   ~0115646

Branch CR30484_1 has been updated forcibly by drochalo.

SHA-1: 0aa8eeaf5a3a647b3a41dedcbca949e93f46383e

drochalo

2024-04-08 19:08

developer   ~0115647

Dear bugmaster,
the commits were squashed and the branch was pushed.

Issue History

Date Modified Username Field Change
2019-02-07 12:03 nds New Issue
2019-02-07 12:03 nds Assigned To => kgv
2019-02-07 13:55 nds File Added: 30484_wrong_highlight.png
2019-02-07 13:55 nds Assigned To kgv => nds
2019-02-07 15:36 git Note Added: 0082063
2019-05-01 12:00 kgv Product Version => 7.3.0
2019-05-01 12:00 kgv Summary Visualization - 2d persistent: order of detection doesn't coincide with order of objects creation => Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
2019-05-01 12:00 kgv Description Updated
2019-05-01 12:10 kgv Steps to Reproduce Updated
2019-05-01 12:24 kgv Note Added: 0084087
2019-05-01 12:29 kgv Relationship added related to 0030686
2019-05-01 12:36 kgv Note Edited: 0084087
2019-09-04 17:35 kgv Target Version 7.4.0 => 7.5.0
2020-09-21 10:18 nds Target Version 7.5.0 => 7.6.0
2021-08-24 14:21 kgv Target Version 7.6.0 => 7.7.0
2022-08-17 11:57 kgv Target Version 7.7.0 => 7.8.0
2023-08-01 15:09 dpasukhi Target Version 7.8.0 => Unscheduled
2023-09-11 16:48 ebelouso Assigned To nds => mzernova
2023-09-11 16:49 ebelouso Priority normal => high
2023-09-11 16:49 ebelouso Severity minor => major
2023-09-11 16:49 ebelouso Target Version Unscheduled => 7.8.0
2024-01-15 12:09 drochalo Assigned To mzernova => drochalo
2024-01-17 13:47 git Note Added: 0114915
2024-01-17 17:19 git Note Added: 0114919
2024-01-17 20:52 git Note Added: 0114920
2024-01-18 13:55 git Note Added: 0114922
2024-01-18 13:56 drochalo Note Added: 0114923
2024-01-18 13:57 drochalo Assigned To drochalo => mzernova
2024-01-18 13:57 drochalo Status new => resolved
2024-01-19 17:09 mzernova Note Added: 0114935
2024-01-19 17:10 mzernova Assigned To mzernova => drochalo
2024-01-19 17:10 mzernova Status resolved => assigned
2024-01-19 18:32 git Note Added: 0114938
2024-01-19 20:42 git Note Added: 0114940
2024-01-22 13:13 drochalo Note Added: 0114948
2024-01-22 13:13 drochalo Assigned To drochalo => mzernova
2024-01-22 13:13 drochalo Status assigned => resolved
2024-01-24 03:15 iko Note Added: 0114961
2024-01-25 13:53 git Note Added: 0114970
2024-01-25 16:26 git Note Added: 0114976
2024-01-25 22:45 iko Note Added: 0114981
2024-01-26 04:13 iko Note Edited: 0114981
2024-02-09 14:33 git Note Added: 0115059
2024-02-12 20:09 git Note Added: 0115071
2024-02-14 12:19 drochalo Note Added: 0115075
2024-02-14 12:19 drochalo Assigned To mzernova => iko
2024-03-25 12:52 dpasukhi Target Version 7.8.0 => 7.9.0
2024-04-03 19:44 iko Note Added: 0115567
2024-04-03 19:46 iko Assigned To iko => drochalo
2024-04-04 19:01 git Note Added: 0115591
2024-04-08 12:02 git Note Added: 0115633
2024-04-08 17:14 drochalo Note Added: 0115637
2024-04-08 17:14 drochalo Assigned To drochalo => iko
2024-04-08 18:03 iko Assigned To iko => bugmaster
2024-04-08 18:03 iko Status resolved => reviewed
2024-04-08 19:01 dpasukhi Assigned To bugmaster => drochalo
2024-04-08 19:01 dpasukhi Status reviewed => assigned
2024-04-08 19:01 dpasukhi Note Added: 0115642
2024-04-08 19:07 git Note Added: 0115646
2024-04-08 19:08 drochalo Note Added: 0115647
2024-04-08 19:08 drochalo Assigned To drochalo => bugmaster
2024-04-08 19:08 drochalo Status assigned => resolved