Fix SIGSEGV

This commit is contained in:
kga 2013-12-03 07:19:46 +00:00
parent a045068b34
commit a6c6fefb15
3 changed files with 10 additions and 16 deletions

View File

@ -27,6 +27,7 @@
#include <GEOMImpl_ITransformOperations.hxx> #include <GEOMImpl_ITransformOperations.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <GEOMUtils.hxx>
#include <ShapeFix_Shape.hxx> #include <ShapeFix_Shape.hxx>
#include <ShapeFix_ShapeTolerance.hxx> #include <ShapeFix_ShapeTolerance.hxx>
@ -175,10 +176,7 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
Handle(GEOM_Function) aVector = TI.GetVector(); Handle(GEOM_Function) aVector = TI.GetVector();
gp_Vec Vec = gp::DX(); gp_Vec Vec = gp::DX();
if (!aVector.IsNull()) { if (!aVector.IsNull()) {
TopoDS_Shape aV = aVector->GetValue(); Vec = GEOMUtils::GetVector( aVector->GetValue(), Standard_False );
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.Normalize(); Vec.Normalize();
} }
@ -211,18 +209,12 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const
gp_Vec Vec2 = gp::DY(); gp_Vec Vec2 = gp::DY();
if (!aVector.IsNull()) { if (!aVector.IsNull()) {
TopoDS_Shape aV = aVector->GetValue(); Vec1 = GEOMUtils::GetVector( aVector->GetValue(), Standard_False );
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.Normalize(); Vec1.Normalize();
} }
if (!aVector2.IsNull()) { if (!aVector2.IsNull()) {
TopoDS_Shape aV = aVector2->GetValue(); Vec2 = GEOMUtils::GetVector( aVector2->GetValue(), Standard_False );
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.Normalize(); Vec2.Normalize();
} }

View File

@ -275,7 +275,8 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
// angular step // angular step
double diag = sqrt((Xmax-Xmin)*(Xmax-Xmin) + (Ymax-Ymin)*(Ymax-Ymin)); 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))); 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); GroupArgs->SpinBox_DX1->setValue(myAng);
// radial step // radial step

View File

@ -668,8 +668,8 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
createPathPreview(myVectorU.get()); createPathPreview(myVectorU.get());
createPathPreview(myVectorV.get()); createPathPreview(myVectorV.get());
anObj = anOper->MultiTranslate2D(myBase.get(), anObj = anOper->MultiTranslate2D(myBase.get(),
myVectorU.get(), myStepU, myNbTimesU, myVectorU.get(), myStepU, myNbTimesU,
myVectorV.get(), myStepV, myNbTimesV); myVectorV.get(), myStepV, myNbTimesV);
if (!IsPreview()) { if (!IsPreview()) {
aParameters << GroupDimensions->SpinBox_DX1->text(); aParameters << GroupDimensions->SpinBox_DX1->text();
aParameters << GroupDimensions->SpinBox_DY1->text(); aParameters << GroupDimensions->SpinBox_DY1->text();
@ -743,10 +743,11 @@ void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Objec
ShapeAnalysis_Edge aShapeAnal; ShapeAnalysis_Edge aShapeAnal;
TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge ); TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
TopoDS_Vertex aLast = aShapeAnal.LastVertex( 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(); TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
const char* aName = "tmpVector"; const char* aName = "tmpVector";
Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName ); Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
// add Prs to preview // add Prs to preview
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));