#include <GeomAlgoAPI_EdgeBuilder.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
// for sqrt on Linux
-#include <math.h>
+#include <cmath>
const double tolerance = 1e-7;
const double paramTolerance = 1.e-4;
aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
- GeomShapePtr anArcShape = boolean(REVERSED_ID())->value() ?
- GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal)
- : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal);
-
if (myParamBefore == 0) { // parameter has not been calculate yet
std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
aCircleForArc->parameter(anEndAttr->pnt(), paramTolerance, myParamBefore);
}
+ GeomShapePtr anArcShape;
+ if (fabs(myParamBefore - 2.0 * PI) < paramTolerance)
+ anArcShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aStart->distance(aCenter));
+ else {
+ anArcShape = boolean(REVERSED_ID())->value() ?
+ GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal)
+ : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal);
+ }
+
std::shared_ptr<ModelAPI_ResultConstruction> aResult = document()->createConstruction(data(), 1);
aResult->setShape(anArcShape);
aResult->setIsInHistory(false);
}
data()->blockSendAttributeUpdated(aWasBlocked, false);
}
+ if (fabs(aParameterNew) < paramTolerance ||
+ fabs(aParameterNew - 2.0 * PI) < paramTolerance)
+ aParameterNew = 2.0 * PI;
myParamBefore = aParameterNew;
}
}