MantisBT - Community
View Issue Details
0002618Community[OCCT] OCCT:Visualizationpublic2003-05-13 11:292019-08-27 18:53
bugmaster 
bugmaster 
normalfeature 
closedfixed 
All
 
[OCCT] 7.4.0[OCCT] 7.4.0 
Not needed
0002618: Visualization - choose better center of gravity for camera rotation operations
Bug from Open CASCADE community
Bug has been registered by Fran├žois Lauzon

http://www.opencascade.org/forumorg/bug.php?bug_id=125&f=8 [^]


There is a bug in the method Gravity (which is used by StartRotation when we
start a rotation). If you see the whole model, the Gravity is set ok and the
rotation work ok, but if you zoom a small part of the model, the Gravity returns
0,0,0 and then the rotation is done by this new center and we "lost" the model.
This will append when all Graphic3d_Structure Bounding Box are outside the view.
Maybe use another way to compute gravity to set the center of rotation...
Documentation remark, added by apl 2011-07-26 11:55:53:

Improvements:
Two new approaches has been developed for rotating the model in the view. In
addition to the older algorithm when the displayed model in the view was
rotated around its gravity point, the new algorithms take for rotation more
appropriate point that provides more convenient method, similar to turning the
camera. There are two new methods: first calculates rotation point depending on
the objects displayed inside of the view that are visible, and the second
calculates rotation point in the same manner with priority of the closest
object in center of the view providing the rotation of the model around this
object. These methods calculate rotation point not the same as the gravity
point, thus the model could go out of front and back view planes (ZSize), but
this solution provides an option that enables automated recalculation of the
view planes for such rotations.

The mathematical part of solution is developed as an utility tool, which could
be reused with any viewer that could provide information on displayed objects
such as bounding boxes and its viewing volume geometrical properties.

You might need to revise code of your application to enable use of these new
approaches. The gravity point will be selected by default as point of rotating
the model when porting your application.
Changes:
Gravity point calculation has been fixed, in the case when the zoomed object
inside of the view the gravity point is taken as the object's center. Two new
approaches to calculate model rotation point has been added: these approaches
project the model on the ray that goes from the center of the view in front
direction, and find average point on it. New enumeration
Aspect_ViewRotationType has been added to define the rotation point calculation
algorithms. The rotation type and option to automatically recompute front and
back view planes (ZSize) is specified for the V3d view in the method
StartRotation that calculates the point of model rotation.

There are changes in the following packages:
Aspect package:
1) New enumeration Aspect_ViewRotationType has been added

Bnd package:
Bnd_Box class:
1) New methods has been added to Bnd_Box class: project its bounding points on
the line (Bnd_Box::ProjectedPoints (const gp_Lin& theLine)), find intersection
points of the line with bounding box (Bnd_Box::IntersectionPoints (const
gp_Lin& theLine))

TColgp package:
1) TColgp_Array1OfPln class has been defined in cdl.

V3d package:
V3d_View class:
1) Gravity method has been corrected;
2) StartRotation method now has two new arguments: theViewRotationType and
FitZSize to provide services of new approaches for calculating the rotation
point and automatically ZSize calculation;
3) FrustumPlanes method has been added, this method calculates view volume
planes of the view, normals of planes are oriented outside the viewing volume;
4) PointOfRotation method has been added, this method uses utility tool to
compute the point of model rotation depending on the bounding boxes and view
volume.

Viewer package:
Viewer_ViewRotationTool class:
1) New class Viewer_ViewRotationTool has been added, this class provides
services for interactive rotation point calculation. This class could be reused
with other viewers.

ViewerTest package:
1) ViewerTest_ViewerCommands.cxx: new command vsetrotationtype has been added
to switch between rotation point calculation methods; this command manipulates
variables that are passed to the StartRotation command on mouse move and right
button click.
Modified entities:
Aspect.cdl - New enumeration Aspect_ViewRotationType has been added.
Bnd_Box.cdl - Two methods ProjectedPoints, IntersectionPoints has been added.
TColgp.cdl - New class TColgp_Array1OfPln has been added.
V3d_View.cdl - New methods FrustumPlanes and PointOfRotation has been added.
Viewer_ViewRotationTool.cxx - new class has been added.
ViewerTest_ViewerCommands.cxx - new method VSetRotationType has been added.
No tags attached.
related to 0022520closed atp Community Update Visualization Users Guide 
related to 0030507closed bugmaster Open CASCADE Visualization - introduce AIS_ViewController 
has duplicate 0006784closed bugmaster Open CASCADE Non predicted position of rotation center in View 3d 
related to 0024617closed bugmaster Open CASCADE Axial scale of view is ignored when computing rotation Gravity point 
related to 0025723closed bugmaster Open CASCADE Visualization, TKV3d - the center of rotation should be calculated taking into account structure visibility and selection flags 
txt OCC2618.txt (3,537) 2003-05-16 06:48
https://tracker.dev.opencascade.org/
gz apl-OCC2618-v1.tar.gz (103,381) 2011-07-08 12:57
https://tracker.dev.opencascade.org/
Issue History
2003-05-13 11:31bugmasterAssigned Tobugmaster => vtn
2003-05-13 11:31bugmasterStatusnew => assigned
2003-05-13 11:31bugmasterSummary => Bug in V3d_View::Gravity
2003-05-14 16:43vtnStatusassigned => closed
2003-05-14 16:43vtnResolution@0@ => unable to reproduce
2003-06-09 18:32bugmasterAssigned Tovtn => bugmaster
2003-06-09 18:32bugmasterStatusclosed => assigned
2003-06-09 18:32bugmasterResolutionunable to reproduce => @0@
2003-06-09 18:32bugmasterAssigned Tobugmaster => vtn
2004-12-15 14:12vtnAssigned Tovtn => khr
2004-12-30 11:29bugmasterCustomer =>
2006-07-27 10:07bugmasterAssigned Tokhr => san
2011-04-07 18:10bugmasterAssigned Tosan => apl
2011-07-26 13:56aplCC => kgv
2011-07-26 16:23aplAssigned Toapl => kgv
2011-08-02 11:24bugmasterCategoryOCCT:VIZ => OCCT:Visualization
2011-09-13 17:27sanNote Added: 0018140
2011-09-13 17:27sanAssigned Tokgv => apl
2011-09-13 17:27sanStatusassigned => reviewed
2011-09-13 17:27sanStatusreviewed => assigned
2011-09-13 17:35sanRelationship addedrelated to 0022520
2011-09-21 14:11szyFixed in VersionEMPTY =>
2011-09-21 14:11szyTarget Version => 6.5.3
2011-09-21 14:11szyDescription Updatedbug_revision_view_page.php?rev_id=618#r618
2011-09-21 14:11szyAdditional Information Updatedbug_revision_view_page.php?rev_id=620#r620
2011-11-23 16:47szyAdditional Information Updatedbug_revision_view_page.php?rev_id=905#r905
2011-11-23 16:48szyAdditional Information Updatedbug_revision_view_page.php?rev_id=906#r906
2012-01-18 06:14abvNote Added: 0019163
2012-01-18 06:14abvStatusassigned => feedback
2012-01-19 09:17aplNote Added: 0019176
2012-01-19 09:17aplStatusfeedback => assigned
2012-03-12 07:28abvTarget Version6.5.3 => 6.5.4
2012-10-23 19:34abvTarget Version6.5.4 => 6.6.0
2013-02-20 19:31kgvTarget Version6.6.0 => 6.7.0
2013-11-01 19:37sanTarget Version6.7.0 => 6.7.1
2014-02-05 14:28kgvNote Added: 0027765
2014-02-05 14:28kgvStatusassigned => feedback
2014-02-05 14:47kgvRelationship addedhas duplicate 0006784
2014-02-11 17:24aplRelationship addedrelated to 0024617
2014-02-17 13:23aplStatusfeedback => assigned
2014-02-17 13:24aplNote Added: 0027916
2014-02-17 13:24aplNote Edited: 0027916bug_revision_view_page.php?bugnote_id=27916#r6800
2014-04-04 18:09abvTarget Version6.7.1 => 6.8.0
2014-08-06 12:07kgvPrioritynormal => high
2014-08-06 12:07kgvSeveritytrivial => feature
2014-08-06 12:07kgvSummaryBug in V3d_View::Gravity => Visualization - choose better center of gravity for camera rotation operations
2014-09-26 14:24abvTarget Version6.8.0 => 7.1.0
2015-01-26 14:46kgvRelationship addedrelated to 0025723
2015-01-26 14:50kgvPriorityhigh => normal
2015-03-11 10:32gitNote Added: 0038238
2015-03-11 11:06gitNote Added: 0038243
2015-03-11 11:14duvNote Added: 0038244
2016-10-25 09:48kgvTarget Version7.1.0 => 7.2.0
2016-10-25 09:50kgvRelationship addedrelated to 0027994
2017-07-20 10:55kgvTarget Version7.2.0 => 7.4.0
2019-08-27 16:34kgvRelationship addedrelated to 0030507
2019-08-27 16:40kgvNote Added: 0086470
2019-08-27 16:40kgvAssigned Toapl => bugmaster
2019-08-27 16:40kgvStatusassigned => resolved
2019-08-27 16:40kgvStatusresolved => reviewed
2019-08-27 16:41gitNote Added: 0086471
2019-08-27 18:53apnTest case number => Not needed
2019-08-27 18:53apnStatusreviewed => verified
2019-08-27 18:53apnResolutionopen => fixed

Notes
(0018140)
san   
2011-09-13 17:27   
Hello,

Here are some remarks concerning the source code, all of "Code style" and "Comments" type.

1. V3d_View.cdl, StartRotation() method - documentation should be updated

2. V3d_View.cxx, line 3175 - here some explanations expected to mention why the code for orthographic projection only is implemented

3. V3d_View.cxx, all changed code fragments - opening braces "{" should be on the same line as corresponding statement(if, else, for), similarly to the rest of the file.

4. Viewer_ViewRotationTool class - it has static methods only, why those methods cannot be the package methods of Viewer package and are not declared in Viewer.cdl? Do we really need a new class for that?

5. Bnd_Box.cxx, lines 1161, 1189, 1192, 1195 - opening "{" should be on the same line as "if"/"for" statements.

6. Aspect.cdl, Aspect_ViewRotationType enumeration - for me, explanation of each rotation type's meaning is not clear ("gravity" most likely means "gravity center" here, right? it is better to use clear wording to avoid questions from the community), especially for VRT_OBJECTSINCENTER.
It would be great to have an example of situation when each rotation type is suitable. Ideally, Visualization User's Guide should be also updated with some illustrations explaining different rotation types.

Best regards,
Sergey
(0019163)
abv   
2012-01-18 06:14   
Dear Anton,
Could you please refresh the status of this fix?
(0019176)
apl   
2012-01-19 09:17   
This bug is still assigned and needs correction of remarks
(0027765)
kgv   
2014-02-05 14:28   
Dear apl,

please analyze workload required to re-done the progress on this issue to current master and finalize integration.
(0027916)
apl   
2014-02-17 13:24   
The development should be based on results of 0024413

(0038238)
git   
2015-03-11 10:32   
Branch CR2618_1 has been created by duv.

SHA-1: 458c2c58284045313bb94e094e23baac29754773


No new revisions were added by this update.
(0038243)
git   
2015-03-11 11:06   
Branch CR2618_1 has been updated by duv.

SHA-1: d451744c1bf07c93e9ab4116ca9a9860df84b1cd


Detailed log of new commits:

Author: duv
Date: Tue Mar 10 15:15:07 2015 +0300

    0002618: Visualization - choose better center of gravity for camera rotation operations
    
    Gravity point set to camera center.

(0038244)
duv   
2015-03-11 11:14   
Alternative solution was implemented in advanced visualization demo. New camera concept introduced in OCCT 6.8.0 allows us to use camera "Center" point as "Gravity" point for rotation operations. Center point of camera doesn't get affected by scene contents directly. Thus we may achieve stable and predictable camera behavior.

Implementation available at branch CR2618_1.
(0086470)
kgv   
2019-08-27 16:40   
Please switch into VERIFIED state.

Patch for 0030507 introduced AIS_RotationMode enumeration, including AIS_RotationMode_PickLast handy for rotating around picked point.

Applications may also override AIS_ViewController::GravityPoint() method to customize this behavior further in desired way, since there is no good answer to the question how to rotate camera in orbit mode within arbitrary geometry.
(0086471)
git   
2019-08-27 16:41   
Branch CR2618_1 has been deleted by kgv.

SHA-1: d451744c1bf07c93e9ab4116ca9a9860df84b1cd