From 96d664dd8892bfe8e11e057f7b3b03c17ab0dffb Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 13 Nov 2016 10:54:44 +0100 Subject: [PATCH] Part::Geometry: ArcOfHyperbola CCW emulation support/fix =================================================== Correction of the emulation so that arcs of hyperbola are always CCW. This fixes mismatching of end points and edge in Sketcher. --- src/Mod/Part/App/Geometry.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index aacef996e..2217b13ca 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -2160,26 +2160,36 @@ bool GeomArcOfHyperbola::isReversedInXY() const void GeomArcOfHyperbola::getRange(double& u, double& v, bool emulateCCWXY) const { - u = myCurve->FirstParameter(); - v = myCurve->LastParameter(); - if(emulateCCWXY){ - if(isReversedInXY()){ - std::swap(u,v); - u = -u; v = -v; + try { + if(emulateCCWXY){ + if(isReversedInXY()){ + Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast( myCurve->BasisCurve() ); + assert(!c.IsNull()); + c->Reverse(); + } } } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + throw Base::Exception(e->GetMessageString()); + } + + u = myCurve->FirstParameter(); + v = myCurve->LastParameter(); } void GeomArcOfHyperbola::setRange(double u, double v, bool emulateCCWXY) { try { + myCurve->SetTrim(u, v); + if(emulateCCWXY){ if(isReversedInXY()){ - std::swap(u,v); - u = -u; v = -v; + Handle_Geom_Hyperbola c = Handle_Geom_Hyperbola::DownCast( myCurve->BasisCurve() ); + assert(!c.IsNull()); + c->Reverse(); } } - myCurve->SetTrim(u, v); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught();