From 1d920a8bc89948b8b6145bcedf5f65937b283aff Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 22 Jan 2014 12:05:05 +0000 Subject: [PATCH] Fix bug comming from HYDRO. --- src/VTKViewer/VTKViewer_Utilities.cxx | 17 +++++++++++++++++ src/VTKViewer/VTKViewer_Utilities.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/VTKViewer/VTKViewer_Utilities.cxx b/src/VTKViewer/VTKViewer_Utilities.cxx index 89ca6be89..6e1900572 100755 --- a/src/VTKViewer/VTKViewer_Utilities.cxx +++ b/src/VTKViewer/VTKViewer_Utilities.cxx @@ -264,6 +264,19 @@ bool IsBBEmpty(vtkRenderer* theRenderer) return !isAny; } +/*! + Check that the given bounding box is valid, i.e each min bound < each max bound +*/ + +bool isBoundValid(double* theBounds) { + if(theBounds[0] > theBounds[1] || + theBounds[2] > theBounds[3] || + theBounds[4] > theBounds[5]) + return false; + else + return true; +} + bool ComputeBBCenter(vtkRenderer* theRenderer, double theCenter[3]) { theCenter[0] = theCenter[1] = theCenter[2] = 0.0; @@ -288,6 +301,10 @@ bool ComputeBBCenter(vtkRenderer* theRenderer, double theCenter[3]) if(anActor->GetVisibility() && !anActor->IsInfinitive()) { double *aBounds = anActor->GetBounds(); + + //Ignore invalid bounds + if(!isBoundValid(aBounds)) continue; + if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT && aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT && aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT) diff --git a/src/VTKViewer/VTKViewer_Utilities.h b/src/VTKViewer/VTKViewer_Utilities.h index 29d0d103d..1212e8f11 100755 --- a/src/VTKViewer/VTKViewer_Utilities.h +++ b/src/VTKViewer/VTKViewer_Utilities.h @@ -58,4 +58,7 @@ VTKVIEWER_EXPORT extern bool ComputeBBCenter(vtkRenderer* theRenderer, double theCenter[3]); +VTKVIEWER_EXPORT +extern +bool isBoundValid(double* theBounds); #endif -- 2.39.2