MantisBT - VTK
View Issue Details
0013300VTK(No Category)public2012-07-10 17:302012-07-12 18:08
Lawrence 
Sebastien Jourdain 
normalminorhave not tried
closedfixed 
5.8.0 
 
ParaViewPro
incorrect functionality
0013300: VTKCubeAxesActor:ComputeTickSize ; does not always honor changes when custom range is set. (Fix included)
Issue found with a patched*(footnote) version Paraview 3.14.1 so I don't know which version of vtk I should file this under.

PROBLEM: When SetXRange is used to set a custom range, the tick and labels may not updated.

Cause: In vtkCubeAxesActor::ComputeTickSize(double bounds[6]) {
(identical code for Y and Z axes omitted)

   bool xRangeChanged = this->LastXRange[0] != bounds[0] || ...
   
   if (!(xRangeChanged || yRangeChanged || ...))
    {
    // no need to re-compute ticksize.
    return false; <<<<< **** RETURNS EARLY HERE WHEN IT SHOULD NOT. ****
    }

So... why is LastXRange's value incorrect? Later in the same function, we have the following logic.

   this->LastXRange[0] = (this->XAxisRange[0] == VTK_DOUBLE_MAX ?
                                  bounds[0] : this->XAxisRange[0]);

->The fix is to check for changes in both the range AND the bounds.

The attached cxx file includes a new field "LastBound" to catch these kinds of modifications that need to force an update to the tick marks.
The main changes are in ComputeTickSize and are highlighted below -


vtkCubeAxesActor::ComputeTickSize(double bounds[6])
{
...

  double xrange[2], yrange[2], zrange[2];

  xrange[0] = (this->XAxisRange[0] == VTK_DOUBLE_MAX ?
                                  bounds[0] : this->XAxisRange[0]);
 ...
  bool xRangeChanged = this->LastXRange[0] != xrange[0] || ...

Also do explicit bounds check -
  bool boundsChanged = this->LastBounds[0] != bounds[0] ||
                      ...
                       this->LastBounds[5] != bounds[5];

// A new boundsChange check -
  if (!(xRangeChanged || yRangeChanged || zRangeChanged || boundsChanged) &&



And at the end of the function, we cache the range AND bounds we used-
  this->LastXRange[0] = xrange[0];
  this->LastXRange[1] = xrange[1];
  this->LastYRange[0] = yrange[0];
  this->LastYRange[1] = yrange[1];
  this->LastZRange[0] = zrange[0];
  this->LastZRange[1] = zrange[1];
  for( int i =0; i < 6; i++)
    {
    this->LastBounds[0] = bounds[0];
    }

Footnote:
This will not affect the official Paraview until
http://vtk.org/Bug/view.php?id=13093 [^]
is included.
No tags attached.
cxx vtkCubeAxesActor.cxx (84,324) 2012-07-10 17:30
https://www.vtk.org/Bug/file/9225/vtkCubeAxesActor.cxx
cxx vtkCubeAxesActor-v2.cxx (84,320) 2012-07-12 16:44
https://www.vtk.org/Bug/file/9226/vtkCubeAxesActor-v2.cxx
Issue History
2012-07-10 17:30LawrenceNew Issue
2012-07-10 17:30LawrenceFile Added: vtkCubeAxesActor.cxx
2012-07-11 08:44Sebastien JourdainAssigned To => Sebastien Jourdain
2012-07-11 08:44Sebastien JourdainStatusbacklog => tabled
2012-07-11 08:50Sebastien JourdainNote Added: 0028762
2012-07-11 15:32LawrenceNote Added: 0028763
2012-07-11 15:38Sebastien JourdainNote Added: 0028764
2012-07-12 14:51Sebastien JourdainAssigned ToSebastien Jourdain =>
2012-07-12 14:51Sebastien JourdainAssigned To => Sebastien Jourdain
2012-07-12 16:37LawrenceNote Added: 0028768
2012-07-12 16:44LawrenceFile Added: vtkCubeAxesActor-v2.cxx
2012-07-12 16:47Sebastien JourdainNote Added: 0028770
2012-07-12 16:48Sebastien JourdainNote Added: 0028771
2012-07-12 18:08Sebastien JourdainStatustabled => closed
2012-07-12 18:08Sebastien JourdainResolutionopen => fixed

Notes
(0028762)
Sebastien Jourdain   
2012-07-11 08:50   
I'm currently working on this set of classes to support oriented bounding box, so in the same time I try to fix some other culprit.
(0028763)
Lawrence   
2012-07-11 15:32   
OBB would be useful.

By the way, my suggested bug fix has a bug at the end...
this->LastBounds[0] = bounds[0];
should be
this->LastBounds[i] = bounds[i];
(0028764)
Sebastien Jourdain   
2012-07-11 15:38   
I've noticed... Don't worry I've fixed it as well. ;-)
(0028768)
Lawrence   
2012-07-12 16:37   
("The bug that refuses to die...")
Yesterday's alleged fix is incomplete: There are still times when the ticks are not updated because the later 'ifs' do not fire...
 if (...)
    {
    this->AdjustTicksComputeRange(this->XAxes, bounds[0], bounds[1]);
    this->BuildLabels(this->XAxes);
    this->UpdateLabels(this->XAxes, 0);

An improved fix is to group detected changes by axis (range and/or bounds) and then use that in the subsequent ifs...
i.e.
// Ticks need updating if the Range and/or Bounds are changed
bool xChanged = this->LastXRange[0] != xrange[0] ||
this->LastXRange[1] != xrange[1] ||
this->LastBounds[0] != bounds[0] ||
this->LastBounds[1] != bounds[1];

and later...
  if (xChanged)
    { // Bounds and/or range change causes tick recalculation ...
    this->AdjustTicksComputeRange(this->XAxes, bounds[0], bounds[1]);

---
I'll attach a file with these changes. I'm currently working on Paraview bug 0013093: With the above changes, I'm starting to see sensible axes when the object is scaled.
Best,
Lawrence.
(0028770)
Sebastien Jourdain   
2012-07-12 16:47   
I've noticed that as well, and I've been more eager than you by simply doing ;-)

if (xRangeChanged || boundsChanged)
if (yRangeChanged || boundsChanged)
if (zRangeChanged || boundsChanged)
(0028771)
Sebastien Jourdain   
2012-07-12 16:48   
http://review.source.kitware.com/#/t/915/ [^]