[vtk-developers] [VTK 0013829]: vtkAssembly::GetBounds blindly adds bounds which are uninitialized

Mantis Bug Tracker mantis at public.kitware.com
Tue Jan 29 11:55:06 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.vtk.org/Bug/view.php?id=13829 
====================================================================== 
Reported By:                Joó Péter
Assigned To:                
====================================================================== 
Project:                    VTK
Issue ID:                   13829
Category:                   (No Category)
Reproducibility:            have not tried
Severity:                   minor
Priority:                   normal
Status:                     backlog
Project:                    TBD 
Type:                       incorrect functionality 
Resolution:                 open
Fixed in Version:           
====================================================================== 
Date Submitted:             2013-01-29 11:55 EST
Last Modified:              2013-01-29 11:55 EST
====================================================================== 
Summary:                    vtkAssembly::GetBounds blindly adds bounds which are
uninitialized
Description: 
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.

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-01-29 11:55 Joó Péter      New Issue                                    
2013-01-29 11:55 Joó Péter      File Added: badbounds.zip                    
======================================================================




More information about the vtk-developers mailing list