MantisBT - VTK
View Issue Details
0013829VTK(No Category)public2013-01-29 11:552016-07-22 14:18
Joó Péter 
Haocheng Liu 
normalminoralways
closedfixed 
5.10.1 
7.1.06.2.0 
TBD
incorrect functionality
0013829: vtkAssembly::GetBounds blindly adds bounds which are uninitialized
Assume you have two spheres in an assembly and a clipping plane which entirely clips one of the sphere out but it keeps the other intact.

If you query the bounding box of that assembly then it returns with absolutely wrong bounding box coordinates.

The reason behind is that the vtkAssembly::GetBounds accumulates bounds but never checks weather an internal part!s bound is initialized or not. initialized or not.

Details of the investigation:
In file VTK5.10.1\Rendering\vtkAssembly.cxx at line 393 the following bound is an uninitialized bound :

line 393: bounds = prop3D->GetBounds();

Debugger tells that this bound is:

bounds[0] 1.0000000000000000 double
bounds[1] -1.0000000000000000 double
bounds[2] 1.0000000000000000 double
bounds[3] -1.0000000000000000 double
bounds[4] 1.0000000000000000 double
bounds[5] -1.0000000000000000 double

I recommend the following change in VTK inside vtkAssembly::GetBounds method:

ORIGINAL CODE
      propVisible = 1;
      prop3D->PokeMatrix(path->GetLastNode()->GetMatrix());
      bounds = prop3D->GetBounds();
      prop3D->PokeMatrix(NULL);

PROPOSAL
      prop3D->PokeMatrix(path->GetLastNode()->GetMatrix());
      bounds = prop3D->GetBounds();
      prop3D->PokeMatrix(NULL);
      if (!vtkMath::AreBoundsInitialized(bounds))
            continue;
      propVisible = 1;

I added an optional project as an attachment to test it with a debugger just in case.
Used user supplied badbounds.cxx to reproduce
No tags attached.
zip badbounds.zip (1,628) 2013-01-29 11:55
https://www.vtk.org/Bug/file/9389/badbounds.zip
Issue History
2013-01-29 11:55Joó PéterNew Issue
2013-01-29 11:55Joó PéterFile Added: badbounds.zip
2013-06-25 13:29Dave DeMarleNote Added: 0031055
2013-06-26 03:24Joó PéterNote Added: 0031080
2013-07-22 21:05Dave DeMarleAssigned To => Dave DeMarle
2013-07-22 21:05Dave DeMarleStatusbacklog => todo
2013-08-12 17:44Dave DeMarleStatustodo => backlog
2014-01-07 14:20Serge LalondeNote Added: 0032136
2014-01-07 16:34Bill LorensenAssigned ToDave DeMarle => Bill Lorensen
2014-01-07 16:34Bill LorensenReproducibilityhave not tried => always
2014-01-07 16:34Bill LorensenStatusbacklog => gerrit review
2014-01-07 16:34Bill LorensenFixed in Version => 6.2.0
2014-01-07 16:34Bill LorensenTarget Version => 6.2.0
2014-01-07 16:34Bill LorensenSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=713#r713
2015-01-16 16:43Serge LalondeNote Added: 0034088
2016-07-06 16:50Berk GeveciStatusgerrit review => expired
2016-07-06 16:50Berk GeveciNote Added: 0036302
2016-07-22 13:14Haocheng LiuStatusexpired => backlog
2016-07-22 13:14Haocheng LiuStatusbacklog => active development
2016-07-22 13:14Haocheng LiuTarget Version6.2.0 => 7.1.0
2016-07-22 13:14Haocheng LiuAssigned ToBill Lorensen => Haocheng Liu
2016-07-22 14:18Haocheng LiuNote Added: 0036548
2016-07-22 14:18Haocheng LiuStatusactive development => closed
2016-07-22 14:18Haocheng LiuResolutionopen => fixed

Notes
(0031055)
Dave DeMarle   
2013-06-25 13:29   
Thanks. Would you mind submitting this in the form of a gerrit topic to facilitate automated testing and code review? For details on how to do so see http://www.vtk.org/Wiki/VTK/Git/Develop [^]
(0031080)
Joó Péter   
2013-06-26 03:24   
Unfortunately I don't have to required amount of time to do that.
Also I think I fairly detailed the problem and its resolution, so anyone can integrate it into VTK now :)
(0032136)
Serge Lalonde   
2014-01-07 14:20   
I suggest changing the "if" in the code modification to this instead:

      if (bounds == NULL || !vtkMath::AreBoundsInitialized(bounds))
            continue;

since most other code that checks the validity of bounds also check to ensure that the return value of GetBounds() isn't NULL (ex: vtkRenderer::ComputeVisiblePropBounds())
(0034088)
Serge Lalonde   
2015-01-16 16:43   
I'm updating to VTK 6.1 and I can validate that this bug is still present. It's fine for me because I know about this bug and I can apply the fix myself and rebuild, but others might waste time on it. Can't an experienced VTK contributor apply the 4 line change?
(0036302)
Berk Geveci   
2016-07-06 16:50   
Setting bugs that have not been touched in 1 year to expired. If important, please re-open.
(0036548)
Haocheng Liu   
2016-07-22 14:18   
Tested with VTK7.0.0. It seems that this bug has been fixed. All the output looks fine.