]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix for Bug IPAL11794
authorapo <apo@opencascade.com>
Tue, 7 Mar 2006 12:47:09 +0000 (12:47 +0000)
committerapo <apo@opencascade.com>
Tue, 7 Mar 2006 12:47:09 +0000 (12:47 +0000)
"8 signal detected" appears and 3D view is broken after trying to create presentation in Post-Pro
(improve handling of the VTK presentations with null dimention bounding box)

src/VTKViewer/VTKViewer_Actor.cxx
src/VTKViewer/VTKViewer_Utilities.cxx

index da05fc98df4fa0c0a82b9c96066d6c83c94210c8..d2f72e2b8e8f40b980fdf32092b66e3fd456e6c0 100755 (executable)
@@ -408,7 +408,12 @@ bool
 VTKViewer_Actor
 ::IsInfinitive()
 { 
-  return myIsInfinite; 
+  static float MIN_DISTANCE = 1.0 / VTK_LARGE_FLOAT;
+
+  if(myIsInfinite || GetLength() < MIN_DISTANCE)
+    return true;
+  else
+    return false;
 }
 
 
index a05b0a36f5654b691ee82f7d34a13466088d18c6..723eea3fcc6cded3798b7ea3b5c3ce6b394c20b6 100755 (executable)
 /*!@see vtkRenderer::ResetCamera(float bounds[6]) method*/
 void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint)
 {  
-  if(!theRenderer) return;
-  float bounds[6];
-  int aCount = ComputeVisiblePropBounds(theRenderer,bounds);
+  if(!theRenderer)
+    return;
+
+  vtkCamera* aCamera = theRenderer->GetActiveCamera();
+  if(!aCamera) 
+    return;
+
+  float aBounds[6];
+  int aCount = ComputeVisiblePropBounds(theRenderer,aBounds);
+
   if(theUsingZeroFocalPoint || aCount){
-    float aLength = bounds[1]-bounds[0];
-    aLength = max((bounds[3]-bounds[2]),aLength);
-    aLength = max((bounds[5]-bounds[4]),aLength);
+    static float MIN_DISTANCE = 1.0 / VTK_LARGE_FLOAT;
+
+    float aLength = aBounds[1]-aBounds[0];
+    aLength = max((aBounds[3]-aBounds[2]),aLength);
+    aLength = max((aBounds[5]-aBounds[4]),aLength);
     
-    double vn[3];
-    if ( theRenderer->GetActiveCamera() != NULL )
-      theRenderer->GetActiveCamera()->GetViewPlaneNormal(vn);
-    else{
+    if(aLength < MIN_DISTANCE)
       return;
-    }
+
+    float aWidth = 
+      sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) +
+          (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) +
+          (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4]));
+    
+    if(aWidth < MIN_DISTANCE)
+      return;
+
+    double aViewPlaneNormal[3];
+    aCamera->GetViewPlaneNormal(aViewPlaneNormal);
     
-    float center[3] = {0.0, 0.0, 0.0};
+    float aCenter[3] = {0.0, 0.0, 0.0};
     if(!theUsingZeroFocalPoint){
-      center[0] = (bounds[0] + bounds[1])/2.0;
-      center[1] = (bounds[2] + bounds[3])/2.0;
-      center[2] = (bounds[4] + bounds[5])/2.0;
+      aCenter[0] = (aBounds[0] + aBounds[1])/2.0;
+      aCenter[1] = (aBounds[2] + aBounds[3])/2.0;
+      aCenter[2] = (aBounds[4] + aBounds[5])/2.0;
     }
-    theRenderer->GetActiveCamera()->SetFocalPoint(center[0],center[1],center[2]);
+    aCamera->SetFocalPoint(aCenter[0],aCenter[1],aCenter[2]);
     
-    float width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
-      (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
-      (bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
-    
-    double ang = theRenderer->GetActiveCamera()->GetViewAngle();
-    float distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0);
+    double aViewAngle = aCamera->GetViewAngle();
+    float aDistance = 2.0*aWidth/tan(aViewAngle*vtkMath::Pi()/360.0);
     
     // check view-up vector against view plane normal
-    double *vup = theRenderer->GetActiveCamera()->GetViewUp();
-    if ( fabs(vtkMath::Dot(vup,vn)) > 0.999 ){
-      theRenderer->GetActiveCamera()->SetViewUp(-vup[2], vup[0], vup[1]);
-    }
+    double aViewUp[3];
+    aCamera->GetViewUp(aViewUp);
+    if(fabs(vtkMath::Dot(aViewUp,aViewPlaneNormal)) > 0.999)
+      aCamera->SetViewUp(-aViewUp[2], aViewUp[0], aViewUp[1]);
     
     // update the camera
-    theRenderer->GetActiveCamera()->SetPosition(center[0]+distance*vn[0],
-                                                center[1]+distance*vn[1],
-                                                center[2]+distance*vn[2]);
+    aCamera->SetPosition(aCenter[0]+aDistance*aViewPlaneNormal[0],
+                        aCenter[1]+aDistance*aViewPlaneNormal[1],
+                        aCenter[2]+aDistance*aViewPlaneNormal[2]);
+
     // find size of the window
-    int* winsize = theRenderer->GetSize();
-    if(winsize[0] < winsize[1]) width *= float(winsize[1])/float(winsize[0]);
+    int* aWinSize = theRenderer->GetSize();
+    if(aWinSize[0] < aWinSize[1]) 
+      aWidth *= float(aWinSize[1])/float(aWinSize[0]);
     
-    if(theUsingZeroFocalPoint) width *= sqrt(2.0);
+    if(theUsingZeroFocalPoint) 
+      aWidth *= sqrt(2.0);
     
-    theRenderer->GetActiveCamera()->SetParallelScale(width/2.0);
+    aCamera->SetParallelScale(aWidth/2.0);
   }
-  //workaround on VTK
-  //theRenderer->ResetCameraClippingRange(bounds);
+
   ResetCameraClippingRange(theRenderer);
 }