From: kga Date: Tue, 3 Dec 2013 07:19:46 +0000 (+0000) Subject: Fix SIGSEGV X-Git-Tag: V7_3_0b1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a6c6fefb151c65e8b752b1a3c94151c0ef801255;p=modules%2Fgeom.git Fix SIGSEGV --- diff --git a/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx index 693111163..a25a16004 100644 --- a/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -175,10 +176,7 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const Handle(GEOM_Function) aVector = TI.GetVector(); gp_Vec Vec = gp::DX(); if (!aVector.IsNull()) { - TopoDS_Shape aV = aVector->GetValue(); - if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; - TopoDS_Edge anEdge = TopoDS::Edge(aV); - Vec = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec = GEOMUtils::GetVector( aVector->GetValue(), Standard_False ); Vec.Normalize(); } @@ -211,18 +209,12 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const gp_Vec Vec2 = gp::DY(); if (!aVector.IsNull()) { - TopoDS_Shape aV = aVector->GetValue(); - if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; - TopoDS_Edge anEdge = TopoDS::Edge(aV); - Vec1 = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec1 = GEOMUtils::GetVector( aVector->GetValue(), Standard_False ); Vec1.Normalize(); } if (!aVector2.IsNull()) { - TopoDS_Shape aV = aVector2->GetValue(); - if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; - TopoDS_Edge anEdge = TopoDS::Edge(aV); - Vec2 = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec2 = GEOMUtils::GetVector( aVector2->GetValue(), Standard_False ); Vec2.Normalize(); } diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx index 8c8e3cbe4..a7074e16d 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -275,7 +275,8 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() // angular step double diag = sqrt((Xmax-Xmin)*(Xmax-Xmin) + (Ymax-Ymin)*(Ymax-Ymin)); double d = sqrt((0.5*(Xmax+Xmin))*(0.5*(Xmax+Xmin)) + (0.5*(Ymax+Ymin))*(0.5*(Ymax+Ymin))); - myAng = floor(2.0 * atan(diag/d) * 180.0 / M_PI); + if ( fabs(d) > 1.e-16 ) + myAng = floor(2.0 * atan(diag/d) * 180.0 / M_PI); GroupArgs->SpinBox_DX1->setValue(myAng); // radial step diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index 286e2dc00..b9862ae65 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -668,8 +668,8 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects) createPathPreview(myVectorU.get()); createPathPreview(myVectorV.get()); anObj = anOper->MultiTranslate2D(myBase.get(), - myVectorU.get(), myStepU, myNbTimesU, - myVectorV.get(), myStepV, myNbTimesV); + myVectorU.get(), myStepU, myNbTimesU, + myVectorV.get(), myStepV, myNbTimesV); if (!IsPreview()) { aParameters << GroupDimensions->SpinBox_DX1->text(); aParameters << GroupDimensions->SpinBox_DY1->text(); @@ -743,10 +743,11 @@ void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Objec ShapeAnalysis_Edge aShapeAnal; TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge ); TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge ); + if ( BRep_Tool::Pnt(aFirst).IsEqual( BRep_Tool::Pnt(aLast), Precision::Confusion() ) ) return; TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape(); const char* aName = "tmpVector"; Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName ); - + // add Prs to preview SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SOCC_Prs* aPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));