]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchPlugin/SketchPlugin_Projection.cpp
Salome HOME
Issue #17347: B-Splines in Sketcher
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Projection.cpp
index e04031fee6db7cee731dd447ce225900018759b9..e041299b0c5b56a159e06529fa4b329b52a20264 100644 (file)
@@ -20,6 +20,7 @@
 #include <SketchPlugin_Projection.h>
 
 #include <SketchPlugin_Arc.h>
+#include <SketchPlugin_BSpline.h>
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_Ellipse.h>
 #include <SketchPlugin_EllipticArc.h>
@@ -31,6 +32,8 @@
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
@@ -39,6 +42,7 @@
 
 #include <Events_Loop.h>
 
+#include <GeomAPI_BSpline.h>
 #include <GeomAPI_Circ.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Ellipse.h>
@@ -49,6 +53,7 @@
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_Projection.h>
 #include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Point2DArray.h>
 
 #include <cmath>
 
@@ -145,6 +150,14 @@ static const std::set<std::string>& ARC_PROJECTION()
   return aProj;
 }
 
+static const std::set<std::string>& BSPLINE_PROJECTION()
+{
+  static std::set<std::string> aProj;
+  if (aProj.empty())
+    aProj.insert(SketchPlugin_BSpline::ID());
+  return aProj;
+}
+
 
 static const std::set<std::string>& possibleProjectionTypes(GeomEdgePtr theEdge,
                                                             GeomVertexPtr theVertex)
@@ -160,6 +173,8 @@ static const std::set<std::string>& possibleProjectionTypes(GeomEdgePtr theEdge,
       else
         return ARC_PROJECTION();
     }
+    else
+      return BSPLINE_PROJECTION();
   }
   static const std::set<std::string> DUMMY;
   return DUMMY;
@@ -196,8 +211,6 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
   // if the type of feature differs with already selected, remove it and create once again
   bool isRebuild = rebuildProjectedFeature(aProjection, aProjType);
 
-  std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
-
   ResultConstructionPtr aResult =
       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(lastResult());
   if (!isRebuild && aResult && aResult->shape() && theID == EXTERNAL_FEATURE_ID()) {
@@ -208,158 +221,14 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
 
   keepCurrentFeature();
 
-  if (aVertex) {
-    std::shared_ptr<GeomAPI_Pnt> aPrjPnt = aSketchPlane->project(aVertex->point());
-    std::shared_ptr<GeomAPI_Pnt2d> aPntInSketch = sketch()->to2D(aPrjPnt);
-
-    rebuildProjectedFeature(aProjection, POINT_PROJECTION(), SketchPlugin_Point::ID());
+  bool isProjected = false;
+  if (aVertex)
+    isProjected = projectPoint(aProjection, aVertex->point());
+  else
+    isProjected = projectEdge(aProjection, anEdge);
 
-    // update coordinates of projection
-    std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aProjection->attribute(SketchPlugin_Point::COORD_ID()))->setValue(aPntInSketch);
-  }
-  else if (anEdge->isLine()) {
-    std::shared_ptr<GeomAPI_Pnt> aFirst = aSketchPlane->project(anEdge->firstPoint());
-    std::shared_ptr<GeomAPI_Pnt> aLast = aSketchPlane->project(anEdge->lastPoint());
-
-    std::shared_ptr<GeomAPI_Pnt2d> aFirstInSketch = sketch()->to2D(aFirst);
-    std::shared_ptr<GeomAPI_Pnt2d> aLastInSketch = sketch()->to2D(aLast);
-    if (aFirstInSketch->distance(aLastInSketch) < tolerance)
-      return; // line is semi-orthogonal to the sketch plane
-
-    rebuildProjectedFeature(aProjection, LINE_PROJECTION(), SketchPlugin_Line::ID());
-
-    // update attributes of projection
-    std::shared_ptr<GeomDataAPI_Point2D> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aProjection->attribute(SketchPlugin_Line::START_ID()));
-    std::shared_ptr<GeomDataAPI_Point2D> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aProjection->attribute(SketchPlugin_Line::END_ID()));
-    aStartPnt->setValue(aFirstInSketch);
-    aEndPnt->setValue(aLastInSketch);
-  }
-  else if (anEdge->isCircle() || anEdge->isArc() || anEdge->isEllipse()) {
-    GeomAlgoAPI_Projection aProjAlgo(aSketchPlane);
-    GeomCurvePtr aProjectedCurve = aProjAlgo.project(anEdge);
-
-    if (aProjectedCurve->isCircle()) {
-      GeomAPI_Circ aCircle(aProjectedCurve);
-      GeomPointPtr aCenter = aSketchPlane->project(aCircle.center());
-      GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
-
-      if (aProjectedCurve->isTrimmed()) {
-        // ARC is a projection
-        rebuildProjectedFeature(aProjection, ARC_PROJECTION(), SketchPlugin_Arc::ID());
-
-        GeomPointPtr aFirst = aProjectedCurve->getPoint(aProjectedCurve->startParam());
-        GeomPointPtr aLast = aProjectedCurve->getPoint(aProjectedCurve->endParam());
-        GeomPnt2dPtr aFirstInSketch = sketch()->to2D(aSketchPlane->project(aFirst));
-        GeomPnt2dPtr aLastInSketch = sketch()->to2D(aSketchPlane->project(aLast));
-
-        double aNormalsDot = aCircle.normal()->dot(aSketchPlane->direction());
-        if (fabs(fabs(aNormalsDot) - 1.0) > tolerance)
-          return; // arc is not in the plane, parallel to the sketch plane
-
-        bool isInversed = aNormalsDot < 0.;
-
-        bool aWasBlocked = aProjection->data()->blockSendAttributeUpdated(true);
-
-        // update attributes of projection
-        std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_Arc::CENTER_ID()));
-        std::shared_ptr<GeomDataAPI_Point2D> aStartPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_Arc::START_ID()));
-        std::shared_ptr<GeomDataAPI_Point2D> aEndPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_Arc::END_ID()));
-        aStartPnt->setValue(aFirstInSketch);
-        aEndPnt->setValue(aLastInSketch);
-        aCenterPnt->setValue(aCenterInSketch);
-        aProjection->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(isInversed);
-
-        aProjection->data()->blockSendAttributeUpdated(aWasBlocked);
-      }
-      else {
-        // CIRCLE is a projection
-        rebuildProjectedFeature(aProjection, CIRCLE_ELLIPSE_PROJECTION(),
-                                SketchPlugin_Circle::ID());
-
-        // update attributes of projection
-        std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_Circle::CENTER_ID()));
-        aCenterPnt->setValue(aCenterInSketch);
-        aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aCircle.radius());
-      }
-    }
-    else if (aProjectedCurve->isEllipse()) {
-      GeomAPI_Ellipse anEllipse(aProjectedCurve);
-      GeomPointPtr aCenter = aSketchPlane->project(anEllipse.center());
-      GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
-      GeomPointPtr aFocus = aSketchPlane->project(anEllipse.firstFocus());
-      GeomPnt2dPtr aFocusInSketch = sketch()->to2D(aFocus);
-
-      if (aProjectedCurve->isTrimmed()) {
-        // ELLIPTIC ARC is a projection
-        rebuildProjectedFeature(aProjection, ARC_PROJECTION(), SketchPlugin_EllipticArc::ID());
-
-        GeomPointPtr aFirst = aProjectedCurve->getPoint(aProjectedCurve->startParam());
-        GeomPointPtr aLast = aProjectedCurve->getPoint(aProjectedCurve->endParam());
-        GeomPnt2dPtr aFirstInSketch = sketch()->to2D(aSketchPlane->project(aFirst));
-        GeomPnt2dPtr aLastInSketch = sketch()->to2D(aSketchPlane->project(aLast));
-
-        double aNormalsDot = anEllipse.normal()->dot(aSketchPlane->direction());
-        if (fabs(fabs(aNormalsDot) - 1.0) > tolerance)
-          return; // arc is not in the plane, parallel to the sketch plane
-
-        bool isInversed = aNormalsDot < 0.;
-
-        bool aWasBlocked = aProjection->data()->blockSendAttributeUpdated(true);
-
-        // update attributes of projection
-        std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_EllipticArc::CENTER_ID()));
-        std::shared_ptr<GeomDataAPI_Point2D> aFocusPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_EllipticArc::FIRST_FOCUS_ID()));
-        std::shared_ptr<GeomDataAPI_Point2D> aStartPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_EllipticArc::START_POINT_ID()));
-        std::shared_ptr<GeomDataAPI_Point2D> aEndPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_EllipticArc::END_POINT_ID()));
-        aStartPnt->setValue(aFirstInSketch);
-        aEndPnt->setValue(aLastInSketch);
-        aCenterPnt->setValue(aCenterInSketch);
-        aFocusPnt->setValue(aFocusInSketch);
-        aProjection->boolean(SketchPlugin_EllipticArc::REVERSED_ID())->setValue(isInversed);
-
-        aProjection->data()->blockSendAttributeUpdated(aWasBlocked);
-      }
-      else {
-        // ELLIPSE is a projection
-        rebuildProjectedFeature(aProjection, CIRCLE_ELLIPSE_PROJECTION(),
-                                SketchPlugin_Ellipse::ID());
-
-        // update attributes of projection
-        std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_Ellipse::CENTER_ID()));
-        aCenterPnt->setValue(aCenterInSketch);
-        std::shared_ptr<GeomDataAPI_Point2D> aFocusPnt =
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-            aProjection->attribute(SketchPlugin_Ellipse::FIRST_FOCUS_ID()));
-        aFocusPnt->setValue(aFocusInSketch);
-        aProjection->real(SketchPlugin_Ellipse::MINOR_RADIUS_ID())->setValue(
-            anEllipse.minorRadius());
-      }
-    }
-    else
-      return;
-  } else
-    return;
+  if (!isProjected)
+    return; // projection is not computed, stop processing
 
   aProjection->boolean(COPY_ID())->setValue(true);
   aProjection->execute();
@@ -407,3 +276,274 @@ bool SketchPlugin_Projection::rebuildProjectedFeature(
     theProjection = sketch()->addFeature(theRequestedFeature);
   return isRebuild;
 }
+
+bool SketchPlugin_Projection::projectPoint(FeaturePtr& theProjection, const GeomPointPtr& thePoint)
+{
+  std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
+
+  std::shared_ptr<GeomAPI_Pnt> aPrjPnt = aSketchPlane->project(thePoint);
+  std::shared_ptr<GeomAPI_Pnt2d> aPntInSketch = sketch()->to2D(aPrjPnt);
+
+  rebuildProjectedFeature(theProjection, POINT_PROJECTION(), SketchPlugin_Point::ID());
+
+  // update coordinates of projection
+  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_Point::COORD_ID()))->setValue(aPntInSketch);
+  return true;
+}
+
+bool SketchPlugin_Projection::projectSegment(FeaturePtr& theProjection, const GeomEdgePtr& theEdge)
+{
+  std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
+
+  std::shared_ptr<GeomAPI_Pnt> aFirst = aSketchPlane->project(theEdge->firstPoint());
+  std::shared_ptr<GeomAPI_Pnt> aLast = aSketchPlane->project(theEdge->lastPoint());
+
+  std::shared_ptr<GeomAPI_Pnt2d> aFirstInSketch = sketch()->to2D(aFirst);
+  std::shared_ptr<GeomAPI_Pnt2d> aLastInSketch = sketch()->to2D(aLast);
+  if (aFirstInSketch->distance(aLastInSketch) < tolerance)
+    return false; // line is semi-orthogonal to the sketch plane
+
+  rebuildProjectedFeature(theProjection, LINE_PROJECTION(), SketchPlugin_Line::ID());
+
+  // update attributes of projection
+  std::shared_ptr<GeomDataAPI_Point2D> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_Line::START_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_Line::END_ID()));
+  aStartPnt->setValue(aFirstInSketch);
+  aEndPnt->setValue(aLastInSketch);
+
+  return true;
+}
+
+bool SketchPlugin_Projection::projectEdge(FeaturePtr& theProjection, const GeomEdgePtr& theEdge)
+{
+  if (theEdge->isLine())
+    return projectSegment(theProjection, theEdge);
+
+  std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
+
+  GeomAlgoAPI_Projection aProjAlgo(aSketchPlane);
+  GeomCurvePtr aProjectedCurve = aProjAlgo.project(theEdge);
+
+  bool isOk = false;
+  if (aProjectedCurve->isCircle()) {
+    if (aProjectedCurve->isTrimmed()) {
+      // ARC is a projection
+      isOk = fillArc(theProjection, aProjectedCurve, aSketchPlane);
+    }
+    else {
+      // CIRCLE is a projection
+      isOk = fillCircle(theProjection, aProjectedCurve, aSketchPlane);
+    }
+  }
+  else if (aProjectedCurve->isEllipse()) {
+    if (aProjectedCurve->isTrimmed()) {
+      // ELLIPTIC ARC is a projection
+      isOk = fillEllipticArc(theProjection, aProjectedCurve, aSketchPlane);
+    }
+    else {
+      // ELLIPSE is a projection
+      isOk = fillEllipse(theProjection, aProjectedCurve, aSketchPlane);
+    }
+  }
+  else
+    isOk = fillBSpline(theProjection, aProjectedCurve, aSketchPlane);
+
+  return isOk;
+}
+
+bool SketchPlugin_Projection::fillArc(FeaturePtr& theProjection,
+                                      const GeomCurvePtr& theArc,
+                                      const GeomPlanePtr& thePlane)
+{
+  rebuildProjectedFeature(theProjection, ARC_PROJECTION(), SketchPlugin_Arc::ID());
+
+  GeomAPI_Circ aCircle(theArc);
+
+  double aNormalsDot = aCircle.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.;
+
+  GeomPointPtr aCenter = thePlane->project(aCircle.center());
+  GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
+
+  GeomPointPtr aFirst = theArc->getPoint(theArc->startParam());
+  GeomPnt2dPtr aFirstInSketch = sketch()->to2D(thePlane->project(aFirst));
+
+  GeomPointPtr aLast = theArc->getPoint(theArc->endParam());
+  GeomPnt2dPtr aLastInSketch = sketch()->to2D(thePlane->project(aLast));
+
+  bool aWasBlocked = theProjection->data()->blockSendAttributeUpdated(true);
+
+  // update attributes of projection
+  std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_Arc::CENTER_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aStartPnt =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_Arc::START_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aEndPnt =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_Arc::END_ID()));
+  aStartPnt->setValue(aFirstInSketch);
+  aEndPnt->setValue(aLastInSketch);
+  aCenterPnt->setValue(aCenterInSketch);
+  theProjection->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(isInversed);
+
+  theProjection->data()->blockSendAttributeUpdated(aWasBlocked);
+  return true;
+}
+
+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)
+{
+  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.;
+
+  GeomPointPtr aCenter = thePlane->project(anEllipse.center());
+  GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter);
+  GeomPointPtr aFocus = thePlane->project(anEllipse.firstFocus());
+  GeomPnt2dPtr aFocusInSketch = sketch()->to2D(aFocus);
+
+  GeomPointPtr aFirst = theEllipticArc->getPoint(theEllipticArc->startParam());
+  GeomPnt2dPtr aFirstInSketch = sketch()->to2D(thePlane->project(aFirst));
+  GeomPointPtr aLast = theEllipticArc->getPoint(theEllipticArc->endParam());
+  GeomPnt2dPtr aLastInSketch = sketch()->to2D(thePlane->project(aLast));
+
+  bool aWasBlocked = theProjection->data()->blockSendAttributeUpdated(true);
+
+  // update attributes of projection
+  std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_EllipticArc::CENTER_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aFocusPnt =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_EllipticArc::FIRST_FOCUS_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aStartPnt =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_EllipticArc::START_POINT_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aEndPnt =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theProjection->attribute(SketchPlugin_EllipticArc::END_POINT_ID()));
+  aStartPnt->setValue(aFirstInSketch);
+  aEndPnt->setValue(aLastInSketch);
+  aCenterPnt->setValue(aCenterInSketch);
+  aFocusPnt->setValue(aFocusInSketch);
+  theProjection->boolean(SketchPlugin_EllipticArc::REVERSED_ID())->setValue(isInversed);
+
+  theProjection->data()->blockSendAttributeUpdated(aWasBlocked);
+  return true;
+}
+
+bool SketchPlugin_Projection::fillBSpline(FeaturePtr& theProjection,
+                                          const GeomCurvePtr& theCurve,
+                                          const GeomPlanePtr& thePlane)
+{
+  rebuildProjectedFeature(theProjection, BSPLINE_PROJECTION(), SketchPlugin_BSpline::ID());
+
+  GeomAPI_BSpline aBSpline(theCurve);
+
+  theProjection->integer(SketchPlugin_BSpline::DEGREE_ID())->setValue(aBSpline.degree());
+
+  AttributePoint2DArrayPtr aPolesAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
+      theProjection->attribute(SketchPlugin_BSpline::POLES_ID()));
+  std::list<GeomPointPtr> aPoles = aBSpline.poles();
+  aPolesAttr->setSize((int)aPoles.size());
+  std::list<GeomPointPtr>::iterator anIt = aPoles.begin();
+  for (int anIndex = 0; anIt != aPoles.end(); ++anIt, ++anIndex) {
+    GeomPnt2dPtr aPoleInSketch = sketch()->to2D(*anIt);
+    aPolesAttr->setPnt(anIndex, aPoleInSketch);
+  }
+
+  AttributeDoubleArrayPtr aWeightsAttr =
+      theProjection->data()->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
+  std::list<double> aWeights = aBSpline.weights();
+  if (aWeights.empty()) { // rational B-spline
+    int aSize = (int)aPoles.size();
+    aWeightsAttr->setSize(aSize);
+    for (int anIndex = 0; anIndex < aSize; ++anIndex)
+      aWeightsAttr->setValue(anIndex, 1.0);
+  }
+  else { // non-rational B-spline
+    aWeightsAttr->setSize((int)aWeights.size());
+    std::list<double>::iterator anIt = aWeights.begin();
+    for (int anIndex = 0; anIt != aWeights.end(); ++anIt, ++anIndex)
+      aWeightsAttr->setValue(anIndex, *anIt);
+  }
+
+  AttributeDoubleArrayPtr aKnotsAttr =
+      theProjection->data()->realArray(SketchPlugin_BSpline::KNOTS_ID());
+  std::list<double> aKnots = aBSpline.knots();
+  int aSize = (int)aKnots.size();
+  aKnotsAttr->setSize(aSize);
+  std::list<double>::iterator aKIt = aKnots.begin();
+  for (int index = 0; index < aSize; ++index, ++aKIt)
+    aKnotsAttr->setValue(index, *aKIt);
+
+  AttributeIntArrayPtr aMultsAttr =
+      theProjection->data()->intArray(SketchPlugin_BSpline::MULTS_ID());
+  std::list<int> aMultiplicities = aBSpline.mults();
+  aSize = (int)aMultiplicities.size();
+  aMultsAttr->setSize(aSize);
+  std::list<int>::iterator aMIt = aMultiplicities.begin();
+  for (int index = 0; index < aSize; ++index, ++aMIt)
+    aMultsAttr->setValue(index, *aMIt);
+
+  return true;
+}