From c8ee5bed039f671b205d61c124c96eb5d9bc91ce Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 3 Apr 2015 12:14:38 +0300 Subject: [PATCH] Issue #434: Fix crash on line-arc equivalence --- src/SketchSolver/SketchSolver_ConstraintEqual.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintEqual.cpp b/src/SketchSolver/SketchSolver_ConstraintEqual.cpp index 23ff40407..e91ca2cf0 100644 --- a/src/SketchSolver/SketchSolver_ConstraintEqual.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintEqual.cpp @@ -23,6 +23,7 @@ void SketchSolver_ConstraintEqual::process() int aNbLines = 0; int aNbArcs = 0; int aNbCircs = 0; + bool isArcFirst = false; // in line-arc equivalence, the line should be first std::vector::iterator anEntIter = anEntities.begin(); for (; anEntIter != anEntities.end(); anEntIter++) { Slvs_Entity anEnt = myStorage->getEntity(*anEntIter); @@ -30,8 +31,10 @@ void SketchSolver_ConstraintEqual::process() aNbLines++; else if (anEnt.type == SLVS_E_CIRCLE) aNbCircs++; - else if (anEnt.type == SLVS_E_ARC_OF_CIRCLE) + else if (anEnt.type == SLVS_E_ARC_OF_CIRCLE) { aNbArcs++; + isArcFirst = (aNbLines == 0); + } } if (aNbLines + aNbArcs + aNbCircs != 2 || @@ -46,6 +49,11 @@ void SketchSolver_ConstraintEqual::process() break; case 1: myType = SLVS_C_EQUAL_LINE_ARC_LEN; + if (isArcFirst) { // change the order of arc and line + Slvs_hEntity aTmp = anEntities[2]; + anEntities[2] = anEntities[3]; + anEntities[3] = aTmp; + } break; default: myType = SLVS_C_EQUAL_LENGTH_LINES; -- 2.30.2