Archived issue #0022683
Incorrect result of Select3D_Projector::Project() in the case of perspective projection
Description
We use OCC selection algorithms in VTK viewer. We have our implementation of
ViewerSelector which uses OCC Select3D_Projector. In the parallel projection
mode it's working correctly but in the case of perspective projection the
result is wrong. As well as we use VTK we don't set a view to the projector so
myView field of the projector is null and the difference between parallel and
perspective mode computations is the following:
if (myPersp) {
Standard_Real R = 1.-P2.Z()/myFocus;
Pout.SetCoord(P2.X()/R,P2.Y()/R);
}
The usage of the projector in our ViewerSelector is the same for both modes
except the focal distance in the case of perspective projection (see code
snippet in attached Attachment 1 (CXX) file).
See also:
ViewerSelector implementation in SVN:
http://svn.nnov.opencascade.com/svn/occt-products/trunk/samples/vtk/VIS/src/
IVtk/IVtk_ViewerSelector.cxx
Sample project for testing in SVN:
http://svn.nnov.opencascade.com/svn/occt-products/trunk/samples/vtk/importexport
VIS component project used by the sample project:
http://svn.nnov.opencascade.com/svn/occt-products/trunk/samples/vtk/VIS
ViewerSelector which uses OCC Select3D_Projector. In the parallel projection
mode it's working correctly but in the case of perspective projection the
result is wrong. As well as we use VTK we don't set a view to the projector so
myView field of the projector is null and the difference between parallel and
perspective mode computations is the following:
if (myPersp) {
Standard_Real R = 1.-P2.Z()/myFocus;
Pout.SetCoord(P2.X()/R,P2.Y()/R);
}
The usage of the projector in our ViewerSelector is the same for both modes
except the focal distance in the case of perspective projection (see code
snippet in attached Attachment 1 (CXX) file).
See also:
ViewerSelector implementation in SVN:
http://svn.nnov.opencascade.com/svn/occt-products/trunk/samples/vtk/VIS/src/
IVtk/IVtk_ViewerSelector.cxx
Sample project for testing in SVN:
http://svn.nnov.opencascade.com/svn/occt-products/trunk/samples/vtk/importexport
VIS component project used by the sample project:
http://svn.nnov.opencascade.com/svn/occt-products/trunk/samples/vtk/VIS
Additional information
Documentation remark by SAN:
Select3D_Projector class documentation and Visualization User's Guide were updated in order to make usage of the projector class easier. Few obsolete and unused methods were removed from this class in the frames of continuous code clean up activity.
Modified entities:
Select3D package
Select3D_Projector class
Removed methods:
- Directions()
- BoxAdd()
Select3D_Projector class documentation and Visualization User's Guide were updated in order to make usage of the projector class easier. Few obsolete and unused methods were removed from this class in the frames of continuous code clean up activity.
Modified entities:
Select3D package
Select3D_Projector class
Removed methods:
- Directions()
- BoxAdd()
Public activity
10 archived notes
Participants are labeled by their role within this record.
Dear APL,
Please consider this issue in connection with OCCT perspective view first of all, to simplify testing.
Try to debug the projection algo and provide detailed documentation about it in Select3D_Projector.cdl, paying special attention on the meaning of the projector's parameters and how to set them.
Note that the level of documentation should potentially allow us to migrate the projector initialization code in StdSelect_ViewerSelector3d::UpdateProj() method to different implementation of perspective view based on cameras.
As the test case, we could try to use StdSelect_ViewerSelector3d::DisplayAreas() - it displays 2D projections of sensitive areas converting them back to 3D with help of the projector's inverse transformation...But a more reliable way would be to check 2D projections without converting them back to 3D (simulating picking? this is something to think about...)
As soon as you have corrected the projector class, please provide the patch to RKV to test it in VTK environment.
[signature removed]
SAN
Please consider this issue in connection with OCCT perspective view first of all, to simplify testing.
Try to debug the projection algo and provide detailed documentation about it in Select3D_Projector.cdl, paying special attention on the meaning of the projector's parameters and how to set them.
Note that the level of documentation should potentially allow us to migrate the projector initialization code in StdSelect_ViewerSelector3d::UpdateProj() method to different implementation of perspective view based on cameras.
As the test case, we could try to use StdSelect_ViewerSelector3d::DisplayAreas() - it displays 2D projections of sensitive areas converting them back to 3D with help of the projector's inverse transformation...But a more reliable way would be to check 2D projections without converting them back to 3D (simulating picking? this is something to think about...)
As soon as you have corrected the projector class, please provide the patch to RKV to test it in VTK environment.
[signature removed]
SAN
Dear SAN,
After a detailed study of principles and algorithm of Select3D_Projector, it seems that it is fully suitable for Vtk component without any modifications.
The undesired behavior of it is a result of very complex algorithm of preparing matrix transformation component for projector. There were some mistakes in interpretation of input parameters for building this matrix. All of them were resolved successfully without great changes to Vtk component and with no changes to Select3D_Project at all.
I suggest that we can limit solution to this bug only with good documentation update, with pointing on all important aspects of using Select3D_Projector.
SAN, what do you think about this?
After a detailed study of principles and algorithm of Select3D_Projector, it seems that it is fully suitable for Vtk component without any modifications.
The undesired behavior of it is a result of very complex algorithm of preparing matrix transformation component for projector. There were some mistakes in interpretation of input parameters for building this matrix. All of them were resolved successfully without great changes to Vtk component and with no changes to Select3D_Project at all.
I suggest that we can limit solution to this bug only with good documentation update, with pointing on all important aspects of using Select3D_Projector.
SAN, what do you think about this?
Dear APL,
I fully support your idea to provide detailed instructions how Select3D_Projector matrix should be set up in case of orthographic and perspective projection to ensure correct operation of projection logic. This should be a part of the class documentation, and matrix calculations can be illustrated in the Visualization User's Guide.
[signature removed]
SAN
I fully support your idea to provide detailed instructions how Select3D_Projector matrix should be set up in case of orthographic and perspective projection to ensure correct operation of projection logic. This should be a part of the class documentation, and matrix calculations can be illustrated in the Visualization User's Guide.
[signature removed]
SAN
Dear SAN,
Could you please make a revision of updated .cdl documentation (in the branch)
and attached file "Attachment 2 (DOC)" and write all your remarks?
http://svn/svn/occt/branches/OCC22683
I think there might be too much information in updated visualization guide, so if you think that something can be thrown away, please comment.
[signature removed]
APL
Could you please make a revision of updated .cdl documentation (in the branch)
and attached file "Attachment 2 (DOC)" and write all your remarks?
http://svn/svn/occt/branches/OCC22683
I think there might be too much information in updated visualization guide, so if you think that something can be thrown away, please comment.
[signature removed]
APL
Dear Anton,
I have removed some unused methods from Select3D_Projector class: SetDirection(), Directions() and BoxAdd(). Also I have changed slightly CDL documentation. Could you please review the updated branch http://svn/svn/occt/branches/OCC22683?
I have removed some unused methods from Select3D_Projector class: SetDirection(), Directions() and BoxAdd(). Also I have changed slightly CDL documentation. Could you please review the updated branch http://svn/svn/occt/branches/OCC22683?
Dear Sergey,
The modifications passed review without any remarks.
The modifications passed review without any remarks.
Dear Commenter 1,
The branch
http://svn/svn/occt/branches/OCC22683 passed review without any remarks and ready to be tested
The branch
http://svn/svn/occt/branches/OCC22683 passed review without any remarks and ready to be tested
Dear Commenter 1,
Workbench KAS:dev:aan-OCC22683-occt from SVN branch http://svn/svn/occt/branches/OCC22683
(and aan-OCC22683-products from trunk) was successfully compiled on Linux and Windows platforms, and tested on Linux and Windows platforms.
There are not regressions in aan-OCC22683-products regarding to KAS:dev:products-20120127-opt
See results in /QADisk/occttests/results/KAS/dev/aan-OCC22683-products_02022012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120127-opt_28012012/lin
See test cases in /QADisk/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions
http://doc/doku.php?id=occt:certification
Workbench KAS:dev:aan-OCC22683-occt from SVN branch http://svn/svn/occt/branches/OCC22683
(and aan-OCC22683-products from trunk) was successfully compiled on Linux and Windows platforms, and tested on Linux and Windows platforms.
There are not regressions in aan-OCC22683-products regarding to KAS:dev:products-20120127-opt
See results in /QADisk/occttests/results/KAS/dev/aan-OCC22683-products_02022012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120127-opt_28012012/lin
See test cases in /QADisk/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions
http://doc/doku.php?id=occt:certification
Integrated into trunk of occt repository
Date: 2012-02-10 13:30:38 +0400 (Fri, 10 Feb 2012)
New Revision: 10403
Modified:
trunk/src/Select3D/Select3D_Projector.cdl
trunk/src/Select3D/Select3D_Projector.cxx
trunk/src/Select3D/Select3D_Projector.lxx
Date: 2012-02-10 13:30:38 +0400 (Fri, 10 Feb 2012)
New Revision: 10403
Modified:
trunk/src/Select3D/Select3D_Projector.cdl
trunk/src/Select3D/Select3D_Projector.cxx
trunk/src/Select3D/Select3D_Projector.lxx