vtkAssembly::GetBounds blindly adds bounds which are uninitialized
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
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 1.0000000000000000 double bounds -1.0000000000000000 double bounds 1.0000000000000000 double bounds -1.0000000000000000 double bounds 1.0000000000000000 double bounds -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.