+bool SketchPlugin_Projection::fillCircle(FeaturePtr& theProjection,
+ const GeomCurvePtr& theCircle,
+ const GeomPlanePtr& thePlane)
+{
+ rebuildProjectedFeature(theProjection, CIRCLE_ELLIPSE_PROJECTION(), SketchPlugin_Circle::ID());
+
+ GeomAPI_Circ aCircle(theCircle);
+ GeomPointPtr aCenter = thePlane->project(aCircle.center());
+ GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
+
+ // update attributes of projection
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ theProjection->attribute(SketchPlugin_Circle::CENTER_ID()));
+ aCenterPnt->setValue(aCenterInSketch);
+ theProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aCircle.radius());
+ return true;
+}
+
+bool SketchPlugin_Projection::fillEllipse(FeaturePtr& theProjection,
+ const GeomCurvePtr& theEllipse,
+ const GeomPlanePtr& thePlane)
+{
+ rebuildProjectedFeature(theProjection, CIRCLE_ELLIPSE_PROJECTION(), SketchPlugin_Ellipse::ID());
+
+ GeomAPI_Ellipse anEllipse(theEllipse);
+ GeomPointPtr aCenter = thePlane->project(anEllipse.center());
+ GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
+ GeomPointPtr aFocus = thePlane->project(anEllipse.firstFocus());
+ GeomPnt2dPtr aFocusInSketch = sketch()->to2D(aFocus);
+
+ // update attributes of projection
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ theProjection->attribute(SketchPlugin_Ellipse::CENTER_ID()));
+ aCenterPnt->setValue(aCenterInSketch);
+ std::shared_ptr<GeomDataAPI_Point2D> aFocusPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ theProjection->attribute(SketchPlugin_Ellipse::FIRST_FOCUS_ID()));
+ aFocusPnt->setValue(aFocusInSketch);
+ theProjection->real(SketchPlugin_Ellipse::MINOR_RADIUS_ID())->setValue(anEllipse.minorRadius());
+ return true;
+}
+
+bool SketchPlugin_Projection::fillEllipticArc(FeaturePtr& theProjection,
+ const GeomCurvePtr& theEllipticArc,
+ const GeomPlanePtr& thePlane,
+ const GeomEdgePtr& theOriginalEdge)
+{
+ rebuildProjectedFeature(theProjection, ARC_PROJECTION(), SketchPlugin_EllipticArc::ID());
+
+ GeomAPI_Ellipse anEllipse(theEllipticArc);
+
+ double aNormalsDot = anEllipse.normal()->dot(thePlane->direction());
+ if (fabs(fabs(aNormalsDot) - 1.0) > tolerance)
+ return false; // arc is not in the plane, parallel to the sketch plane
+
+ bool isInversed = aNormalsDot < 0.;
+
+ GeomEllipsePtr anOriginalEllipse = theOriginalEdge->ellipse();
+ if (anOriginalEllipse) {
+ double anEllipsesDot = anOriginalEllipse->normal()->dot(anEllipse.normal());
+ if (anEllipsesDot < 0.)
+ isInversed = !isInversed;