Salome HOME
Fix SIGSEGV
authorkga <kga@opencascade.com>
Tue, 3 Dec 2013 07:19:46 +0000 (07:19 +0000)
committerkga <kga@opencascade.com>
Tue, 3 Dec 2013 07:19:46 +0000 (07:19 +0000)
src/GEOMImpl/GEOMImpl_TranslateDriver.cxx
src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx
src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx

index 69311116399b70c5e2682b16125c203c84eb368f..a25a16004f5471f00ec893757605fe70f993a4ec 100644 (file)
@@ -27,6 +27,7 @@
 #include <GEOMImpl_ITransformOperations.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
 
 #include <ShapeFix_Shape.hxx>
 #include <ShapeFix_ShapeTolerance.hxx>
@@ -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();
     }
 
index 8c8e3cbe4fd3bf8f14343bd06e198c022e9e53ed..a7074e16d5328171109c35f6c1de1bf2c7233c95 100644 (file)
@@ -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
index 286e2dc00b9b51b8734c2c33ab755a86d98bedd3..b9862ae650001381e97cc17f48b12bc6a3983bab 100644 (file)
@@ -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_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));