]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for bug 10356(9808): SIGFPE at cut lines edition
authorjfa <jfa@opencascade.com>
Wed, 26 Oct 2005 10:16:29 +0000 (10:16 +0000)
committerjfa <jfa@opencascade.com>
Wed, 26 Oct 2005 10:16:29 +0000 (10:16 +0000)
src/OBJECT/VISU_Actor.cxx
src/PIPELINE/VISU_CutPlanesPL.cxx
src/VISUGUI/VisuGUI.cxx
src/VISU_I/VISU_CutLines_i.cc
src/VISU_I/VISU_Prs3d_i.cc

index d26af3b9bae2171a4753b8f9e99bcec9a57cc806..0de904d9dc181b11bcfddb07753cf058f222c7df 100644 (file)
@@ -114,14 +114,17 @@ void VISU_Actor::SetPipeLine(VISU_PipeLine* thePipeLine) {
     this->Modified();
     vtkMapper *aMapper = myPipeLine->GetMapper();
     vtkDataSet *aDataSet = aMapper->GetInput();
-    if(!aDataSet)
-      throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no input data !!!");
-    aDataSet->Update();
-    static float eps = VTK_LARGE_FLOAT * 0.1 ;
-    if(aDataSet->GetLength() > eps)
-      throw std::runtime_error("VISU_Actor::SetPipeLine >> Diagonal of the actor is too large !!!");
-    if(!aDataSet->GetNumberOfCells())
-      throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no visible elements");
+
+    //This code has been moved into VISU::Prs3d_i::UpdateActor() for bug 9808
+    //if(!aDataSet)
+    //  throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no input data !!!");
+    //aDataSet->Update();
+    //static float eps = VTK_LARGE_FLOAT * 0.1 ;
+    //if(aDataSet->GetLength() > eps)
+    //  throw std::runtime_error("VISU_Actor::SetPipeLine >> Diagonal of the actor is too large !!!");
+    //if(!aDataSet->GetNumberOfCells())
+    //  throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no visible elements");
+
     //Bug SAL4221:  Mesh with less than 10 cells : shrink mode disable
     //SetShrinkable(aDataSet->GetNumberOfCells() > 10);
     SetShrinkable(true);
index be8925f440a151f47dfd23e2980cd5254935c1b6..0399a410c0cf561fdef3ce5494f06ff1e509322a 100644 (file)
@@ -296,7 +296,6 @@ void VISU_CutPlanesPL::CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDa
     float aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement;
     for (int i = 0; i < theNbPlanes; i++){
       aPosition = aStartPosition + i*aDBoundPrj;
-      float aDelta = (aBoundPrj[0] - aPosition) / aBoundPrj[2];
       if(thePlaneCondition[i]){
        aPosition = aStartPosition + i*aDBoundPrj;
       }else
index 531e792da260a1ecb8c6c9cf50aa5ece771ceb47..0fc01fbbc0c0feaa2c0491e15b6dd93674f88ba7 100644 (file)
@@ -1191,18 +1191,28 @@ void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
   try{
     thePrs->Update();
     //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
+    bool isPublished = false;
     for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
       if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
        QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
        if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
-         if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
-           thePrs->UpdateActor(anActor);
+         if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
+            isPublished = true;
+            thePrs->UpdateActor(anActor);
+          }
+      }
+
+    if (!isPublished) {
+      if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
+       if (VISU_Actor* anActor = thePrs->CreateActor())
+         vf->AddActor(anActor);
       }
+    }
   }catch(std::runtime_error& ex){
     INFOS(ex.what());
     QApplication::restoreOverrideCursor();
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
-                           tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()), 
+                           tr ("ERR_CANT_BUILD_PRESENTATION") + ": " + tr(ex.what()), 
                            tr ("VISU_BUT_OK") );
     for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
       if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
@@ -1467,7 +1477,7 @@ void VisuGUI::CreateMesh() {
     }catch(std::runtime_error& exc){
       INFOS(exc.what());
       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
-                             tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()), 
+                             tr ("ERR_CANT_CREATE_ACTOR") + ": " + tr(exc.what()), 
                              tr ("VISU_BUT_OK") ); 
     }
   }
@@ -4008,7 +4018,7 @@ VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
   } catch ( std::runtime_error& exc ){
     INFOS(exc.what());
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                          tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
+                          tr("ERR_CANT_VISUALIZE_OBJECT") + ": " + tr(exc.what()),
                           tr ("VISU_BUT_OK") );
     anVISUActor = NULL;
   }
index f2ee138e5dfb80343b319470b4d868ad123077c7..8adb5adb7beddcf31993cad0cd0231fa968c2c41 100644 (file)
@@ -36,6 +36,8 @@
 using namespace VISU;
 using namespace std;
 
+static float EPS_machine = 1.0E-7;
+
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 #else
@@ -298,10 +300,14 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){
       for(int i = 0; i < aNbPoints; i++){
        aDataSet->GetPoint(i,aPnt);
        Sub(aPnt,aBasePnt,aVect);
-       aDist = vtkMath::Dot(aVect,aDirLn) / aBoundPrjLn[2];
-       // the workaround
-       if(aDist < 0.0) aDist = 0.0; 
-       if(aDist > 1.0) aDist = 1.0;
+       if ( fabs(aBoundPrjLn[2]) < EPS_machine )
+         aDist = 0.5;
+       else {
+         aDist = vtkMath::Dot(aVect,aDirLn) / aBoundPrjLn[2];
+         // the workaround
+         if(aDist < 0.0) aDist = 0.0; 
+         if(aDist > 1.0) aDist = 1.0;
+       }
        aXYMap[aDist] = aScalars->GetTuple1(i);
       }
       if(aFilter){
index 5ae2f8ab245ca287d26c2c3837aa139b6b28eda1..6e96c31495346f3ff7b0d2e232c01657f19bfddd 100644 (file)
@@ -30,6 +30,7 @@
 #include "VISU_Actor.h"
 
 #include <vtkGeometryFilter.h>
+#include <vtkDataSet.h>
 #include <vtkDataSetMapper.h>
 
 using namespace VISU;
@@ -102,7 +103,22 @@ void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_Intera
 
 void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) {
   if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor() - this = "<<this);
-  theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
+
+  // fix for bug 9808 BEGIN
+  vtkMapper *aMapper = myPipeLine->GetMapper();
+  vtkDataSet *aDataSet = aMapper->GetInput();
+  if (!aDataSet)
+    throw std::runtime_error("There is no input data !!!");
+  aDataSet->Update();
+  static float eps = VTK_LARGE_FLOAT * 0.1 ;
+  if (!aDataSet->GetNumberOfCells())
+    throw std::runtime_error("There is no visible elements");
+  if (aDataSet->GetLength() > eps)
+    throw std::runtime_error("Diagonal of the actor is too large !!!");
+  // fix for bug 9808 END
+
+  //theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
+  theActor->GetMapper()->ShallowCopy(aMapper);
   theActor->Modified();
 }