Commit 63009aea by Ken Martin

### Try to gracefully handle degenrate cube axes

```When an axis is degenerate lots of div zero
and inf were happening. Try to handle it more
gracefully.```
parent 71c23834
 ... ... @@ -643,9 +643,12 @@ void vtkCubeAxesActor::AdjustAxes(double bounds[6], zRange[1] = range[5]; } const double xScale = (xRange[1] - xRange[0])/(bounds[1] - bounds[0]); const double yScale = (yRange[1] - yRange[0])/(bounds[3] - bounds[2]); const double zScale = (zRange[1] - zRange[0])/(bounds[5] - bounds[4]); const double xScale = (bounds[1] - bounds[0]) != 0.0 ? (xRange[1] - xRange[0])/(bounds[1] - bounds[0]) : 1.0; const double yScale = (bounds[3] - bounds[2]) != 0.0 ? (yRange[1] - yRange[0])/(bounds[3] - bounds[2]) : 1.0; const double zScale = (bounds[5] - bounds[4]) != 0.0 ? (zRange[1] - zRange[0])/(bounds[5] - bounds[4]) : 1.0; // Pull back the corners if specified if (this->CornerOffset > 0.0) ... ... @@ -1951,7 +1954,7 @@ inline int vtkCubeAxesActor::FRound(double value) inline int vtkCubeAxesActor::GetNumTicks(double range, double fxt) { // Find the number of integral points in the interval. double fnt = range/fxt; double fnt = fxt != 0.0 ? range/fxt : 0.0; fnt = this->FFix(fnt); return this->FRound(fnt); } ... ... @@ -1993,6 +1996,38 @@ void vtkCubeAxesActor::AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIG range = sortedRange[1] - sortedRange[0]; int axis = 0; switch(axes[0]->GetAxisType()) { case vtkAxisActor::VTK_AXIS_TYPE_X: axis = 0; break; case vtkAxisActor::VTK_AXIS_TYPE_Y: axis = 1; break; case vtkAxisActor::VTK_AXIS_TYPE_Z: axis = 2; break; } customizedLabels = this->AxisLabels[axis]; if (range == 0.0) { majorStart = sortedRange[0]; minorStart = sortedRange[0]; major = 1.0; minor = 1.0; for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) { axes[i]->SetMinorRangeStart(minorStart); axes[i]->SetMajorRangeStart(majorStart); axes[i]->SetDeltaRangeMinor(minor); axes[i]->SetDeltaRangeMajor(major); } } else { // Find the integral points. double pow10 = log10(range); ... ... @@ -2031,21 +2066,6 @@ void vtkCubeAxesActor::AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIG major /= div; } int axis = 0; switch(axes[0]->GetAxisType()) { case vtkAxisActor::VTK_AXIS_TYPE_X: axis = 0; break; case vtkAxisActor::VTK_AXIS_TYPE_Y: axis = 1; break; case vtkAxisActor::VTK_AXIS_TYPE_Z: axis = 2; break; } customizedLabels = this->AxisLabels[axis]; if (customizedLabels == nullptr) { // Figure out the first major tick locations, relative to the ... ... @@ -2100,6 +2120,7 @@ void vtkCubeAxesActor::AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIG const double scale = (boundsMax - boundsMin) / range; minor *= scale; major *= scale; } // Set major start and delta for the corresponding cube axis switch(axes[0]->GetAxisType()) ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!