From 8f458544236aa19846de32f6a1ad5c107f584047 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 26 Oct 2005 10:16:29 +0000 Subject: [PATCH] Fix for bug 10356(9808): SIGFPE at cut lines edition --- src/OBJECT/VISU_Actor.cxx | 19 +++++++++++-------- src/PIPELINE/VISU_CutPlanesPL.cxx | 1 - src/VISUGUI/VisuGUI.cxx | 20 +++++++++++++++----- src/VISU_I/VISU_CutLines_i.cc | 14 ++++++++++---- src/VISU_I/VISU_Prs3d_i.cc | 18 +++++++++++++++++- 5 files changed, 53 insertions(+), 19 deletions(-) diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index d26af3b9..0de904d9 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -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); diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index be8925f4..0399a410 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -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 diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 531e792d..0fc01fbb 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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(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; } diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index f2ee138e..8adb5adb 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -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){ diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 5ae2f8ab..6e96c314 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -30,6 +30,7 @@ #include "VISU_Actor.h" #include +#include #include 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 = "<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(); } -- 2.39.2