Archived issue #0023474
Changing material/color/transparency of a shaded AIS_Shape requires 'Redisplay'
Description
I've been testing the feature introduced in 23407 (Draw face outlines for XDE objects) and I spotted the following problem: When drawing face outlines of AIS_Shapes:
AIS_InteractiveContext::DefaultDrawer()->SetFaceBoundaryDraw(Standard_True)
The method AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat) did not update the presentation for shaded presentation (in other words the material was not updated after setting it). I needed to call AIS_InteractiveContext::Redisplay on the corresponding object for the change to take effect.
AIS_InteractiveContext::DefaultDrawer()->SetFaceBoundaryDraw(Standard_True)
The method AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat) did not update the presentation for shaded presentation (in other words the material was not updated after setting it). I needed to call AIS_InteractiveContext::Redisplay on the corresponding object for the change to take effect.
Steps to reproduce
Use MFC samples to reproduce.
- call AIS_InteractiveContext::DefaultDrawer()->SetFaceBoundaryDraw(Standard_True) after creating AIS_InteractiveContext
- Create a shape (e.g. sphere)
- Display it in shaded mode
- Change material
=======================
And a DRAW reproducer:
box b 10 20 30
vinit
vdisplay b
vfit
vsetdispmode b 1
vsetcolor b RED
vshowfaceboundary b 1
vsetcolor b BLUE
- call AIS_InteractiveContext::DefaultDrawer()->SetFaceBoundaryDraw(Standard_True) after creating AIS_InteractiveContext
- Create a shape (e.g. sphere)
- Display it in shaded mode
- Change material
=======================
And a DRAW reproducer:
box b 10 20 30
vinit
vdisplay b
vfit
vsetdispmode b 1
vsetcolor b RED
vshowfaceboundary b 1
vsetcolor b BLUE
Additional information
Further investigation revealed that within the body of AIS_Shape::SetMaterial the call (AIS_Shape.cxx, line 639)
if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
returned false and so
aGroup->SetGroupPrimitivesAspect(anAreaAsp);
was not called.
Further, I realized that StdPrs_ShadedShapes.cxx, in method
static void ComputeFaceBoundaries
a new group is created but not all the aspects are copied and so the group behaves as if there were no aspect for 'Graphic3d_ASPECT_FILL_AREA'.
if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
returned false and so
aGroup->SetGroupPrimitivesAspect(anAreaAsp);
was not called.
Further, I realized that StdPrs_ShadedShapes.cxx, in method
static void ComputeFaceBoundaries
a new group is created but not all the aspects are copied and so the group behaves as if there were no aspect for 'Graphic3d_ASPECT_FILL_AREA'.
Public activity
9 archived notes
Participants are labeled by their role within this record.
Branch [archived branch] has been pushed.
As a solution I have obtained a reference to the existing Graphic3d_Group instead of creating a new one. That solved the problem. However, maybe it is better/necessary (my understanding for the Visualization module is unfortunately limited) to create a new group. In that case all the aspect information (Graphic3d_AspectLine3d, Graphic3d_AspectFillArea3d, Graphic3d_AspectText3d etc.) should be copied to the new group, I guess.
Please review.
As a solution I have obtained a reference to the existing Graphic3d_Group instead of creating a new one. That solved the problem. However, maybe it is better/necessary (my understanding for the Visualization module is unfortunately limited) to create a new group. In that case all the aspect information (Graphic3d_AspectLine3d, Graphic3d_AspectFillArea3d, Graphic3d_AspectText3d etc.) should be copied to the new group, I guess.
Please review.
Dear Commenter 1, please add relation to the issue 0023407.
We need some time to analyze the proposed solution. The point is that AIS_Shape::Compute() creates several Graphic3d_Group instances while the patch modifies the aspect of one of the groups only, so some side effects are possible.
Dear Sergey,
can you please consider incorporating/verifying this patch for the upcoming 6.7.0 release? I've been using it for a year now and haven't been able to spot any resulting problems.
Thanks
can you please consider incorporating/verifying this patch for the upcoming 6.7.0 release? I've been using it for a year now and haven't been able to spot any resulting problems.
Thanks
Dear kgv,
Can you please review the patch and send it to testing if it is OK?
Can you please review the patch and send it to testing if it is OK?
I have no objections against the patch - re-using of the group looks reasonable in this case. Although I am unable to check original problem due to missing reference snapshots.
Patch has been re-based and pushed to branch CR23474_1.
Ready for testing.
Patch has been re-based and pushed to branch CR23474_1.
Ready for testing.
I have attached two snaphots illustrating how the test DRAW script works like with (Attachment 1 (PNG)) and without (Attachment 2 (PNG)) the proposed patch.
In the current implementation the line:
vsetcolor b BLUE
has no effect and the box remains red. After the patch is applied the box changes color (it's not really blue because of the material properties).
In the current implementation the line:
vsetcolor b BLUE
has no effect and the box remains red. After the patch is applied the box changes color (it's not really blue because of the material properties).
Dear Commenter 1,
Branch CR23474_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 320 (323 on master)
Windows: 0 (0 on master)
products component :
Linux: 188 (189 on master)
Windows: 287 (287 on master)
Regressions/Differences:
No regressions/differences
Testing cases:
http://occt-tests/CR23474-1-master-occt/Debian60-64/bugs/vis/bug23474.html
http://occt-tests/CR23474-1-master-occt/Windows-32-VC9/bugs/vis/bug23474.html
bugs vis(004) bug23474: OK
Testing on Linux:
Total MEMORY difference: 355397792 / 356295124
Total CPU difference: 42998.710000000625 / 40672.21000000072
Testing on Windows:
Total MEMORY difference: 410980760 / 406471844
Total CPU difference: 29134.109375 / 34772.53125
There are not differences in images found by testdiff.
Branch CR23474_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 320 (323 on master)
Windows: 0 (0 on master)
products component :
Linux: 188 (189 on master)
Windows: 287 (287 on master)
Regressions/Differences:
No regressions/differences
Testing cases:
http://occt-tests/CR23474-1-master-occt/Debian60-64/bugs/vis/bug23474.html
http://occt-tests/CR23474-1-master-occt/Windows-32-VC9/bugs/vis/bug23474.html
bugs vis(004) bug23474: OK
Testing on Linux:
Total MEMORY difference: 355397792 / 356295124
Total CPU difference: 42998.710000000625 / 40672.21000000072
Testing on Windows:
Total MEMORY difference: 410980760 / 406471844
Total CPU difference: 29134.109375 / 34772.53125
There are not differences in images found by testdiff.
Dear Commenter 1,
Branch CR23474_1 was rebased on current master. Branch CR23474_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 318 (318 on master)
Windows: 0 (0 on master)
products component :
Linux: 188 (188 on master)
Windows: 287 (287 on master)
Regressions/Differences:
No regressions/differences
Testing cases:
http://occt-tests/CR23474-01-master-occt/Debian60-64/bugs/vis/bug23474.html
http://occt-tests/CR23474-01-master-occt/Windows-32-VC9/bugs/vis/bug23474.html
bugs vis(004) bug23474: OK
Testing on Linux:
Total MEMORY difference: 356189692 / 356528316
Total CPU difference: 42744.18000000111 / 42450.47000000157
Testing on Windows:
There are not differences in images found by testdiff.
Branch CR23474_1 was rebased on current master. Branch CR23474_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 318 (318 on master)
Windows: 0 (0 on master)
products component :
Linux: 188 (188 on master)
Windows: 287 (287 on master)
Regressions/Differences:
No regressions/differences
Testing cases:
http://occt-tests/CR23474-01-master-occt/Debian60-64/bugs/vis/bug23474.html
http://occt-tests/CR23474-01-master-occt/Windows-32-VC9/bugs/vis/bug23474.html
bugs vis(004) bug23474: OK
Testing on Linux:
Total MEMORY difference: 356189692 / 356528316
Total CPU difference: 42744.18000000111 / 42450.47000000157
Testing on Windows:
There are not differences in images found by testdiff.
Related records