- data()->addAttribute(POLES_ID(), GeomDataAPI_Point2DArray::typeId());
- data()->addAttribute(WEIGHTS_ID(), ModelAPI_AttributeDoubleArray::typeId());
- data()->addAttribute(KNOTS_ID(), ModelAPI_AttributeDoubleArray::typeId());
- data()->addAttribute(MULTS_ID(), ModelAPI_AttributeIntArray::typeId());
- data()->addAttribute(DEGREE_ID(), ModelAPI_AttributeInteger::typeId());
-
- data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
- ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
-}
-
-void SketchPlugin_BSpline::execute()
-{
- SketchPlugin_Sketch* aSketch = sketch();
- if(!aSketch) {
- return;
- }
-
- AttributePoint2DArrayPtr aPolesArray =
- std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(attribute(POLES_ID()));
- AttributeDoubleArrayPtr aWeightsArray = data()->realArray(WEIGHTS_ID());
- AttributeDoubleArrayPtr aKnotsArray = data()->realArray(KNOTS_ID());
- AttributeIntArrayPtr aMultsArray = data()->intArray(MULTS_ID());
- AttributeIntegerPtr aDegreeAttr = data()->integer(DEGREE_ID());
-
- // collect poles
- std::list<GeomPnt2dPtr> aPoles2D;
- for (int anIndex = 0; anIndex < aPolesArray->size(); ++anIndex) {
- GeomPnt2dPtr aPole = aPolesArray->pnt(anIndex);
- aPoles2D.push_back(aPole);
- }
- // collect weights
- std::list<double> aWeights;
- for (int anIndex = 0; anIndex < aWeightsArray->size(); ++anIndex)
- aWeights.push_back(aWeightsArray->value(anIndex));
- // collect knots
- std::list<double> aKnots;
- for (int anIndex = 0; anIndex < aKnotsArray->size(); ++anIndex)
- aKnots.push_back(aKnotsArray->value(anIndex));
- // collect multiplicities
- std::list<int> aMults;
- for (int anIndex = 0; anIndex < aMultsArray->size(); ++anIndex)
- aMults.push_back(aMultsArray->value(anIndex));
-
- // create result non-periodic B-spline curve
- GeomShapePtr anEdge = GeomAlgoAPI_EdgeBuilder::bsplineOnPlane(aSketch->coordinatePlane(),
- aPoles2D, aWeights, aKnots, aMults, aDegreeAttr->value(), false);
-
- ResultConstructionPtr aResult = document()->createConstruction(data(), 0);
- aResult->setShape(anEdge);
- aResult->setIsInHistory(false);
- setResult(aResult, 0);
-}
-
-bool SketchPlugin_BSpline::isFixed() {
- return data()->selection(EXTERNAL_ID())->context().get() != NULL;