MantisBT - Open CASCADE
View Issue Details
0030484Open CASCADE[OCCT] OCCT:Visualizationpublic2019-02-07 12:032020-09-21 10:18
nds 
nds 
normalminor 
newopen 
[OCCT] 7.3.0 
[OCCT] 7.6.0* 
0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
SelectMgr_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.
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" 
}
No tags attached.
related to 0030686closed bugmaster Visualization, SelectMgr_ViewerSelector - sorting issues of transformation-persistent objects 
png 30484_wrong_highlight.png (11,792) 2019-02-07 13:55
https://tracker.dev.opencascade.org/
Issue History
2019-02-07 12:03ndsNew Issue
2019-02-07 12:03ndsAssigned To => kgv
2019-02-07 13:55ndsFile Added: 30484_wrong_highlight.png
2019-02-07 13:55ndsAssigned Tokgv => nds
2019-02-07 15:36gitNote Added: 0082063
2019-05-01 12:00kgvProduct Version => 7.3.0
2019-05-01 12:00kgvSummaryVisualization - 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:00kgvDescription Updatedbug_revision_view_page.php?rev_id=21131#r21131
2019-05-01 12:10kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=21133#r21133
2019-05-01 12:24kgvNote Added: 0084087
2019-05-01 12:29kgvRelationship addedrelated to 0030686
2019-05-01 12:36kgvNote Edited: 0084087bug_revision_view_page.php?bugnote_id=84087#r21135
2019-09-04 17:35kgvTarget Version7.4.0 => 7.5.0
2020-09-21 10:18ndsTarget Version7.5.0 => 7.6.0*

Notes
(0082063)
git   
2019-02-07 15:36   
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
(0084087)
kgv   
2019-05-01 12:24   
(edited on: 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).